Citoid/Maps TemplateData

From MediaWiki.org
Jump to: navigation, search

Example of TemplateData skeleton with empty maps value[edit]

Below, a barebone example of templateData that shows you how the 'maps' key fits in with the rest of the templateData. 'maps' values correspond to the name of the service being used, in this case 'citoid.'. The values in the citoid object must be valid 'params' (i.e. in this case, 'foo' - aliases are not allowed); 'maps' keys, i.e. 'bar' here, correspond to keys coming from the citoid service.

"description": null,
"params": {
    "foo": {
        "label": null,
        "description": null,
        "default": null,
        "example": null,
        "required": false,
        "suggested": false,
        "deprecated": false,
        "aliases": [],
        "type": "unknown",
        "autovalue": null
    }
},
"paramOrder": [
    "foo"
],
"sets": [],
"maps": {
    "citoid": {
        "bar": "foo"
    }
}

A citation with the field "bar"[edit]

[{
bar: 'Bar value'
}]

Resulting template[edit]

{{mytemplate|foo = Bar value}}

Real example[edit]

This is an example of a partial 'maps' value from the Cite web template on en wiki. The full templateData can be viewed on the page source.

"maps": {
    "citoid": {
        "title": "title",
        "url": "url",
        "publisher": "publisher",
        "publicationTitle": "journal",
        "proceedingsTitle": "journal",
        "bookTitle": "journal",
        "date": "date",
        "place": "location",
        "ISSN": ["issn"],
        "ISBN": ["isbn"],
        "PMCID": "pmc",
        "PMID": "pmid",
        "pages": "pages",
        "volume": "volume",
        "series": "series",
        "seriesNumber": "volume",
        "issue": "issue",
        "DOI": "doi",
        "language": "language",
        "author": [
            [ "first", "last" ],
            [ "first2", "last2" ],
            [ "first3", "last3" ]
        ],
        "editor": [
            ["editor-first", "editor-last"],
            ["editor2-first", "editor2-last"],
            ["editor3-first", "editor3-last"],
        ]
    }
}

Available fields and field structure[edit]

A complete list of fields for each zotero type is available from the Zotero type map.[1] These largely match the citoid fields. However, there are some exceptions.

In 'zotero' format, the field "creators" is a structured object that contains a list of creators with the creator type. In the 'mediawiki' format, the creatorType is transformed into a key. So instead of the creators key, there will be an 'editor' key as well as 'author', 'contributor', and 'translator' keys. These correspond to a two dimensional array, or matrix, which map onto the first and last names of the creators. If there is only one name for the contributor, the second value will be an empty string.

The other way mediawiki fields differ is that the values for ISSN and ISBN are lists, not strings.

On the type map, sometimes there is a base field in parentheses, i.e. websiteTitle (publicationTitle). Where this is the case, you will get the specific field type, i.e. websiteTitle, unless you request the basefield by appending the argument basefield=true to the request string. Currently citoid extension gets both fields back, but in the future it will only get the specific type i.e. the field not in parens, and specific fields should be used in template data. If your template handles multiple itemTypes, you should include all of the synonyms in the map.

Simple Arrays (lists)[edit]

ISSN and ISBN fields are simple lists. If you want to ensure that exactly one ISBN or ISSN goes in the field, (for example, if your template validates the ISBN or ISSN) your template data should look like so:

"maps": {
    "citoid": {
        "ISBN": ["isbn"]
    }
}

This will result in the template:

{{Cite journal|isbn = 978-3-16-148410-0}}

If you want to include all available ISBNs in your template, your template should look like so:

"maps": {
    "citoid": {
        "ISBN": "isbn"
    }
}

The resulting template will include all available ISBNs as a comma-separated string:

{{Cite journal|isbn = 978-3-16-148410-0, 978-8175257665}}

If you have multiple isbn fields that can allow a single ISBN:

"maps": {
    "citoid": {
        "ISBN": ["isbn", "isbn2"]
    }
}

The resulting template will be:

{{Cite journal|isbn = 978-3-16-148410-0|isbn2 = 978-8175257665}}

Two-dimensional Arrays (list of lists)[edit]

The following fields are available as a list of lists: artist, author, contributor, composer, performer, wordsBy, cosponsor, sponsor, commenter, editor, seriesEditor, translator, bookAuthor, counsel, programmer.

For templates that have separate fields for the first and last names, the template data should be as follows:

"maps": {
    "citoid": {
        "author": [
            [ "first", "last" ],
            [ "first2", "last2" ]
        ]
    }
}

The resulting template will be:

{{Cite journal|first = Anne E.|last = Pusey|first2 = Craig|last2 = Packer}}

However, not all templates have separate fields for first and last names. For templates with separate fields for each author only, the template data should be as follows:

"maps": {
    "citoid": {
        "author": ["last", "last2"]
    }
}

The resulting template will be:

{{Cite journal|last = Anne E. Pusey|last2 = Craig Packer}}

For templates with only one field for the entire list of authors, the template data should be as follows:

"maps": {
    "citoid": {
        "author": "last"
    }
}

The resulting template will be: {{Cite journal|last = Anne E. Pusey, Craig Packer}}

  1. http://aurimasv.github.io/z2csl/typeMap.xml