Visuaalinen muokkain/Viittaustyökalu

From mediawiki.org
This page is a translated version of the page VisualEditor/Citation tool and the translation is 29% complete.
Outdated translations are marked like this.

Visuaalisen muokkaimen viittaustyökalu mahdollistaa käyttäjien käyttää wikin viitemallineita Visuaalisessa muokkaimessa. To enable the tool, you'll need the following: a working installation of VisualEditor and Parsoid , citation templates on your wiki that use TemplateData to specify how they are invoked, and a special .json message in order to hook VisualEditor and the templates together.

Viitemallineiden tuominen

Wikisi tietokannassa tulee olla viittausmallineita, jotta vittaustoimintoja voidaan käyttää. Jos wikissäsi ei ole vittausmallineita (esimerkiksi uuden asennuksen tapauksessa) täytyy ne saada jostakin. Niiden kopioiminen Wikipediasta on helpoin tapa tehdä se. Jos wikissäsi on jo viittausmallineet voit ohittaa nämä vaiheet.

  1. Asenna Extension:Scribunto, Extension:ParserFunctions, Extension:Cite, ja Extension:TemplateData. Useimmat Wikipedian viittausmallineet käyttävät Lua-ohjelmointikieltä, jonka Scribunto tekee mahdolliseksi, ja ne käyttävät myös laajennuksen jäsennintoimintoja. Cite-laajennuksen myötä voit käyttää Extension:Scribunto , Extension:ParserFunctions , Extension:Cite , Extension:TemplateData -tageja.

Most citation templates on Wikipedia use the programming language Lua which Scribunto makes available, and they also use the extension's parser functions. The Cite extension allows you to use the ‎<ref> tags. Kaikissa Wikipedioissa ja muissa WMF-wikeissä kaikki nämä ovat jo asennettuna.

  1. Vie viittausmallineet Wikipediasta: Manual:Using content from Wikipedia . Esim. mallineiden w:Template:Cite web, w:Template:Cite news, w:Template:Cite journal, w:Template:Cite book vienti on hyvä alku. Näiden mallineiden uudet versiot englanninkielisessä Wikipediassa ja joissain muissa Wikpedioissa vaativat myös Lua-tukimoduulit.
  2. Lataa mallineesi käyttämällä sivua Special:Import wikissäsi (esimerkiksi, http://localhost/index.php/Special:Import)

Template data

You'll need Extension:TemplateData for the citation tool to be able to load the template data into the fields in VisualEditor and each template must have template data defined. For more information on how to define template data for citations, and to see screenshots of how a citation window should look with and without template data defined, see: Wikipedia:VisualEditor/TemplateData

Citation tool definition

To enable the VisualEditor citation tool on your wiki, you need to create a special configuration message on your wiki: MediaWiki:Cite-tool-definition.json. This is because each wiki is different and so needs to customise which features it wants to use; for example, the names of the templates used on your wiki might be different from those of other wikis.

Asetusviestin tarkoitus

Asetusviesti:

  • Says which templates your wiki uses for standard citations (you can state up to 5).
    • Huomioi, että jokaisella mallineella tulee olla TemplateData defined or the system will be very difficult for users to understand. If your wiki does not currently use citation templates, it is common to copy the templates from the English Wikipedia as a good general set.
  • Says which label you wish to use for each type of citation.
    • There are a standard four, "web", "book", "news" and "journal", which correspond to MediaWiki:Visualeditor-cite-tool-name-web etc.
  • Says which icon you wish to use for each type of citation.
    • There are a standard four, "ref-cite-web", "ref-cite-book", "ref-cite-news" and "ref-cite-journal", which correspond to CSS classes with the icon as a background SVG image called oo-ui-icon-ref-cite-news etc.

Once the MediaWiki:Cite-tool-definition.json configuration message is created, the citation tool will be live for all VisualEditor users on your wiki within a few minutes.

Additional types

If you are considering adding an additional type, the development team would really like to talk with you first, to give advice, help create an appropriate icon, and so we can consider whether other wikis might also want this type defined for all wikis.

To add an additional type, you will need to:

  1. Decide what type you wish to create
    • In this example, say you wished to have a database reference, you could call the type "database".
  2. Create a label for it
    • For the example, you could make the label name "db" and add a label at MediaWiki:Visualeditor-cite-tool-name-db with the value "database". This should be in your wiki's content language. If your wiki uses multiple languages or scripts, you may need to create several of these labels.
  3. Luo sille kuvake
    • For the example, you could make the icon label "ref-cite-dbase", and create the icon as an SVG file uploaded to commons, create the icon class "oo-ui-icon-ref-cite-dbase" in MediaWiki:Common.css and add the icon you want with "background-image:url(//upload.wikimedia.org/wikipedia/commons/1/12/VisualEditor_-_Icon_-_Ref_db.svg)" or similar.

Esimerkkejä

Voit nähdä esimerkkimääritysviestejä englannin-, puolan-, ranskan- ja italiankielisissä Wikipedioissa. Kopioi koodi wikiisi ja mukauta nimet paikalliseen asiayhteyteen sopiviksi.

Template type mapping

In addition to MediaWiki:Cite-tool-definition.json, you also need to create MediaWiki:Citoid-template-type-map.json to specify which types of citations map to which templates. You can see an example on the English Wikipedia.

"Citation needed" tool

The "citation needed" tool.

"Citation needed" templates can be configured to show an "Add a citation" button in the editor by configuring MediaWiki:Visualeditor-template-tools-definition.json with a citationNeeded key.

The configuration value lists templates (which can contain multiple titles for redirects) and parameter mappings. Currently supported keys are:

  • reason - shows the reason a citation is needed in the context item
  • date - shows the date "citation needed" template was added in the context item
  • encapsulate - text which has been wrapped by the template, and which should be unwrapped when a citation is added

The value of these mappings is the name of the parameter(s) in the local template:

{
	"citationNeeded": [
		// This key is always "citationNeeded" in every language
		// Each item of this list represents a single template
		{
			"title": [
				// Title can be a string, or list of redirects
				"Citation needed",
				"Cn",
				...
			],
			"params": {
				"reason": "reason",
				"date": "date"
			}
		},
		// This template is defined separately as it supports the
		// "encapsulate" param. On some wikis this is the same
		// template as the one above.
		{
			"title": [
				"Citation needed span",
				"Cite needed span",
				...
			],
			"params": {
				// Parameters can be a string or list of aliases
				"encapsulate": [ "1", "text" ],
				"reason": "reason",
				"date": "date"
			}
		}
	]
}

See the example definition on English Wikipedia.

Tunnettuja ongelmia

Jos sivulla Special:Version ei näy kenttiä viittausdialogissa, mutta TemplateData on asennettuna, täytyy viittausmalline joskus avata muokattavaksi ja tallentaa uudestaan tekemättä muutoksia. This is due to a bug where TemplateData which is transcluded (i.e. present in Template:Cite_web/doc instead of directly on Template:Cite_web) is not loaded into the database until the parent template is edited; see task T52372.

Please note that the user experience will differ slightly when using your own templates other than the standard 4. For instance, a list of fields won't show up initially in the citation dialog, but you will be able to request a list of all possible fields by clicking a button.