Module:Citation/CS1/COinS: Difference between revisions

en>Trappist the monk
sync from sandbox;
 
m Reverted 3 edits by 174.230.149.159 (talk) to last revision by Hairy Dude
Line 1: Line 1:
--[[--------------------------< F O R W A R D  D E C L A R A T I O N S >--------------------------------------
{{hatnote|'''Note:''' Most conversation about Citation Style 1 (CS1) templates happens at [[Help talk:Citation Style 1]].}}
]]
==Keys==
{| class="wikitable"
|+ Used keys
! rowspan="2"|Key !! colspan="6"|Object !! rowspan="2"|Description !! rowspan="2"|cs1{{pipe}}2 meta-parameters{{efn|See [[Module:Citation/CS1/Configuration]], citation_config.aliases.}}
|-
! Book !! Journal !! Dissertation !! Patent{{efn|name="patent"|Supported by {{tlx|cite patent}} but not by cs1{{pipe}}2; listed here for completeness. Other schemes are sch_svc and ctx.}} !! [[Dublin Core|DC]]<ref name="KEV_DC">http://eprints.rclis.org/12151/1/KEV_Guidelines-200706.html#sect5_4_7</ref>{{efn|name="DC"|Supported by the COinS standard but not by cs1{{pipe}}2; listed here for completeness.}} || SVC<ref>http://alcme.oclc.org/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:sch_svc</ref>
|-
| rft.appldate || || || || {{MaybeCheck}} || || || || FilingDate
|-
| rft.applnumber || || || || {{MaybeCheck}} || || || || PublicationNumber
|-
| rft.artnum || || {{ya}} || || || || || Article number assigned by the publisher. Article numbers are often generated for publications that do not have usable pagination, in particular electronic journal articles, i.e. "unifi000000090". A URL may be the only usable identifier for an online article, in which case the URL can be treated as an identifier for the article (i.e. "rft_id=http://www.firstmonday.org/ issues/issue6_2/odlyzko/ index.html"). || ArticleNumber
|-
| rft.assignee || || || || {{MaybeCheck}} || || || || Assignee1
|-
| rft.atitle || {{ya}} || {{ya}} || || || || || [[Article title (work)|Article]] or [[chapter title]] || Chapter (book cites), Title (periodical and encyclopedia cites)
|-
| rft.au || {{ya}} || {{ya}} || {{ya}} || || || || Full name of a single author; repeatable || AuthorList-First, AuthorList-Last; ContributorList-First, ContributorList-Last (alternatively)
|-
| rft.aufirst || {{ya}} || {{ya}} || {{ya}} || || || || First author's given name or names and/or initials || AuthorList-First (not duplicated in rft.au); ContributorList-First (alternatively)
|-
| rft.aulast || {{ya}} || {{ya}} || {{ya}} || || || || First author's family name || AuthorList-Last (not duplicated in rft.au); ContributorList-Last (alternatively)
|-
| rft.btitle || {{ya}} || || || || || || [[Book title]] || Title, BookTitle (see also: rft.title)
|-
| rft.cc || || || || {{MaybeCheck}} || || || || CountryCode
|-
| rft.chron || || {{ya}} || || || || || Enumeration or chronology in not-normalized form, i.e. "1st quarter". Where numeric dates are also available, place the numeric portion in the "date" Key. So a recorded date of publication of "1st quarter 1992" becomes date=1992&chron=1st quarter. Normalized indications of chronology can be provided in the ssn and quarter Keys. || Date
|-
| rft.date || {{ya}} || {{ya}} || {{ya}} || {{MaybeCheck}} || {{na}}<!-- apparently not by Zotero --> || || Date of publication || Date, Year; IssueDate{{efn|name="patent"}}
|-
| rft.degree || || || {{ya}} || || || || Degree || Degree
|-
| rft.edition || {{ya}} || || || || || || [[Edition (book)|Edition]] || Edition
|-
| rft.eissn || || {{ya}} || || || || || ISSN for electronic version of the journal. Although there is no distinction by format in the assignment of ISSNs, some bibliographic services now carry both the ISSN for the paper version and a separate ISSN for the electronic version. This data element is included here to allow the [[OpenURL]] to carry both ISSNs and distinguish them. || [[EISSN]]
|-
| rowspan="14"|rft.genre || {{ya|rowspan=7}} || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || keyword: <code>book</code>; a publication that is complete in one part or a designated finite number of parts, often identified with an ISBN || cite book, encyclopedia; citation when <code>Periodical</code> not set
|-
| keyword: <code>bookitem</code>; a defined section of a book, usually with a separate title or number || cite book; encyclopedia when Chapter set; citation when {{pipe}}encyclopedia= set
|-
| keyword: <code>proceeding</code>; a conference paper or proceeding published in a conference publication || {{small|not currently supported}}
|-
| keyword: <code>conference</code>; a publication bundling the proceedings of a conference. || cite conference when <code>Periodical</code> not set
|-
| keyword: <code>report</code>; report or technical report is a published document that is issued by an organization, agency or government body || cite report, techreport
|-
| keyword: <code>document</code>; general document type to be used when available data elements do not allow determination of a more specific document type, i.e. when one has only author and title but no publication information. || {{small|not currently supported}}
|-
| keyword: <code>unknown</code>; used when the genre of the document is unknown || {{plainlist|style=padding-left: .8em; text-indent: -.8em|
* cite AV media, AV media notes, DVD notes, episode, mailinglist, map, newsgroup, podcast, serial, sign, speech
* cite web when <code>Periodical</code> not set}}
|-
| rowspan="7"|&nbsp; || {{ya|rowspan=7}} || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || keyword: <code>journal</code>; a serial publication issued in successive parts || {{small|1=not currently supported; periodical templates require {{pipe}}title=}}
|-
| keyword: <code>issue</code>; one instance of the serial publication || Issue
|-
| keyword: <code>article</code>; a document published in a journal || {{plainlist|style=padding-left: .8em; text-indent: -.8em|
* citation, cite conference, interview, press release when <code>Periodical</code> is set
* journal, magazine, news}}
|-
| keyword: <code>proceeding</code> a single conference presentation published in a journal or serial publication || {{small|not currently supported}}
|-
| keyword: <code>conference</code>; a record of a conference that includes one or more conference papers and that is published as an issue of a journal or serial publication || cite conference when <code>Periodical</code> set
|-
| keyword: <code>preprint</code>; an individual paper or report published in paper or electronically prior to its publication in a journal or serial || cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
|-
| keyword: <code>unknown</code>; used when the genre of the document is unknown || cite web
|-
| rft.inst || || || {{ya}} || || || || Institution that issued the dissertation, e.g. "University of California, Berkeley". || Publisher
|-
| rft.inventor || || || || {{MaybeCheck}} || || || || Surname1
|-
| rft.isbn || {{ya}} || {{ya}} || {{ya}} || || || || [[ISBN]] || ISBN
|-
| rft.issn || {{ya}} || {{ya}} || || || || || [[ISSN]] || ISSN
|-
| rft.issue || || {{ya}} || || || || || [[issue (periodicals)|issue]] or [[number (periodicals)|number]] (compare: rft.number) || Issue
|-
| rft.jtitle || || {{ya}} || || || || || [[Journal title]] (see also: rft.title and rft.stitle) || Periodical
|-
| rft.number || || || || {{MaybeCheck}} || || || (compare: rft.issue) || PublicationNumber
|-
| rft.pages || {{ya}} || {{ya}} || || || || || [[Page number]](s) || Page, Pages, At; Sheet, Sheets (only by cite map); QuotePage, QuotePages (only if none of the others)
|-
| rft.place || {{ya}} || || || || || || Place of publication || Place
|-
| rft.prioritydate || || || || {{MaybeCheck}} || || || || PriorityDate
|-
| rft.pub || {{ya}} || || || || || || [[Publisher]] (compare: rft.publisher) || Publisher
|-
| rft.pubdate || || || || {{MaybeCheck}} || || || || PublicationDate
|-
| rft.quarter || || {{ya}} || || || || || Quarter (chronology). Legitimate values are 1, 2, 3, 4. || Date
|-
| rft.series || {{ya}} || || || || || || [[Book series|Series]] || Series
|-
| rft.ssn || || {{ya}} || || || || || Season (chronology). Legitimate values are spring, summer, fall, winter || Date
|-
| rft.title || {{na}} || {{na}} || {{ya}} || {{MaybeCheck}} || {{na}} || || Title || Title (Provided for compatibility with version 0.1. Prefer rft.btitle or rft.jtitle.)
|-
| rft.volume || || {{ya}} || || || || || [[Volume (bibliography)|Volume]] || Volume
|-
| rowspan="12"|rft_id<!-- repeatable --> || {{ya|rowspan=2}} || {{ya|rowspan=2}} || rowspan="2"|&nbsp; || rowspan="2"|&nbsp; || rowspan="2"|&nbsp; || rowspan="2"|&nbsp; || <code>rft_id=&lt;{{var|encoded-url}}></code> || ChapterURL, [[URL]]
|-
| <code>rft_id=&lt;{{var|encoded-identifier-url}}>#id-name=&lt;{{var|identifier-name}}></code>{{efn|name="ID-Name"|The appendage of a #fragment indicating the name of the identifier is a [[Help_talk:Citation_Style_1/Archive_73#Improving_COinS_metadata_output|Wikipedia extension]] to allow receiving parties not knowing the name of the provided identifier to translate the URL back into a non-URL form. It is ignored by parties not being aware of this extension.}} || [[bioRxiv|BIORXIV]], [[CiteSeerX|CITESEERX]], [[Jahrbuch über die Fortschritte der Mathematik|JFM]], [[JSTOR]], [[Mathematical Reviews|MR]], [[Office of Scientific and Technical Information|OSTI]], [[PubMed Central|PMC]], [[Request for Comments|RFC]], [[SSRN]], [[S2CID]], [[Usenet|USENETID]], [[Zentralblatt MATH|ZBL]]
|-
| {{ya|rowspan=7}} || {{ya|rowspan=7}} || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || rowspan="7"|&nbsp; || <code>rft_id=info:arxiv/&lt;{{var|encoded-arxiv}}></code><ref>https://web.archive.org/web/20110721211657/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:arxiv/</ref> || [[arXiv|ARXIV]]
|-
| <code>rft_id=info:bibcode/&lt;{{var|encoded-bibcode}}></code><ref>https://web.archive.org/web/20110721211001/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:bibcode/</ref><ref>https://web.archive.org/web/20110719204105/http://adsdoc.harvard.edu/abs_doc/help_pages/bibcodes.html</ref> || [[Bibcode|BIBCODE]]
|-
| <code>rft_id=info:doi/&lt;{{var|encoded-doi}}></code><ref>https://web.archive.org/web/20110721210935/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:doi/</ref><ref>https://web.archive.org/web/20060206183037/http://www.niso.org/standards/resources/Z39-84-2000.pdf</ref> || [[digital object identifier|DOI]]
|-
| <code>rft_id=info:hdl/&lt;{{var|encoded-hdl}}></code><ref>https://web.archive.org/web/20110721210901/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:hdl/</ref><ref>https://www.ietf.org/rfc/rfc3650.txt</ref> || [[Handle System|HDL]]
|-
| <code>rft_id=info:lccn/&lt;{{var|encoded-lccn}}></code><ref>https://web.archive.org/web/20110721211650/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/</ref><ref>https://web.archive.org/web/20070603204459/http://www.loc.gov/marc/lccn-namespace.html#syntax</ref> || [[LCCN]]
|-
| <code>rft_id=info:oclcnum/&lt;{{var|encoded-oclcnum}}></code><ref>https://web.archive.org/web/20110721210543/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:oclcnum/</ref><ref>https://web.archive.org/web/20110720034202/http://www.loc.gov/z3950/agency/defns/bib1.html</ref><ref>https://web.archive.org/web/20110807042316/http://www.oclc.org/bibformats/en/fixedfield/oclc.shtm</ref> || [[OCLC]]
|-
| <code>rft_id=info:pmid/&lt;{{var|encoded-pmid}}></code><ref>https://web.archive.org/web/20110721211610/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:pmid/</ref> || [[PMID]]
|-
| {{na|rowspan=3}} || {{na|rowspan=3}} || rowspan="3"|&nbsp; || rowspan="3"|&nbsp; || rowspan="3"|&nbsp; || rowspan="3"|&nbsp; || <code>rft_id=info:sici/&lt;{{var|encoded-sici}}></code> (use rft.sici) ||
|-
| <code>rft_id=urn:isbn:&lt;{{var|encoded-isbn}}></code> (use rft.isbn) ||
|-
| <code>rft_id=urn:issn:&lt;{{var|encoded-issn}}></code> (use rft.issn) ||
|-
| rowspan="6"|rft_val_fmt || {{ya}} || || || || || || rft_val_fmt=info:ofi/fmt:kev:mtx:book<ref>https://web.archive.org/web/20110721210848/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:ofi/</ref> ||
|-
| || {{ya}} || || || || || rft_val_fmt=info:ofi/fmt:kev:mtx:journal ||
|-
| || || {{ya}} || || || || rft_val_fmt=info:ofi/fmt:kev:mtx:dissertation ||
|-
| || || || {{MaybeCheck}} || || || rft_val_fmt=info:ofi/fmt:kev:mtx:patent ||
|-
| || || || || {{na}} || || rft_val_fmt=info:ofi/fmt:kev:mtx:dc ||
|-
| || || || || || {{na}} || rft_val_fmt=info:ofi/fmt:kev:mtx:sch_svc ||
|-
| rfr_id || colspan="3" {{ya}} || {{MaybeCheck}} || {{na}} || {{na}} || rfr_id=info:sid/en.wikipedia.org:&lt;{{var|project-name}}><ref>https://web.archive.org/web/20170318224717/http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:sid/</ref><ref>https://web.archive.org/web/20170715103104/http://alcme.oclc.org/openurl/docs/pdf/info-sid.pdf</ref>{{efn|At present Wikipedia still appends the &lt;{{var|wikipedia-page}}> but this is incorrect and too granular. This will likely change to &lt;{{var|project-name}}> in the future.}} ||
|-
| ctx_ver || colspan="3" {{ya}} || {{MaybeCheck}} || {{na}} || {{na}} || ctx_ver=Z39.88-2004 ||
|}
{{notelist}}


local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup; -- functions in Module:Citation/CS1/Utilities
In this table, items that are marked are supported by the standard but not supported by cs1|2.
{| class="wikitable"
|+ Unused keys
! rowspan="2"|Key !! colspan="6"|Object !! rowspan="2"|Description !! rowspan="2"|cs1{{pipe}}2 meta-parameters{{efn|See [[Module:Citation/CS1/Configuration]], citation_config.aliases.}}
|-
! Book !! Journal !! Dissertation !! Patent{{efn|Supported by {{tlx|cite patent}}}} !! [[Dublin Core|DC]] !! SVC
|-
| rft.abstract || || || || || || {{na}} || Abstract of the referent ||
|-
| rft.advisor || || || {{na}} || || || || Dissertation advisor, e.g. "Prof. John H. James". ||
|-
| rft.any || || || || || || {{na}} || Any service type ||
|-
| rft.applcc || || || || {{na}} || || || Application country code; the country in which the patent application was made (mainly used for patents pending). ||
|-
| rft.applyear || || || || {{na}} || || || Year the application was made. ||
|-
| rft.aucorp || {{na}} || || || || || || Organization or corporation that is the author or creator of the book, i.e. "Mellon Foundation" ||
|-
| rft.auinit || {{na}} || {{na}} || {{na}} || || || || First author's first and middle initials. ||
|-
| rft.auinit1 || {{na}} || {{na}} || {{na}} || || || || First author's first initial. ||
|-
| rft.auinitm || {{na}} || {{na}} || {{na}} || || || || First author's middle initial. ||
|-
| rft.ausuffix || {{na}} || {{na}} || {{na}} || || || || First author's name suffix. Qualifiers on an author's name such as "Jr.", "III" are entered here. i.e. Smith, Fred Jr. is recorded as "ausuffux=jr" ||
|-
| rft.bici || {{na}} || || || || || || [[Book Item and Component Identifier]] (BICI). BICI is a draft [[NISO]] standard. ||
|-
| rft.cc || || || {{na}} || || || || Country of publication code, in ISO 2-character format, e.g. "US". ||
|-
| rft.citation || || || || || || {{na}} || Bibliographic citation of the referent ||
|-
| rft.co || || || {{na}} || {{na}} || || || Country of publication, e.g. "United States". ||
|-
| rft.coden || || {{MaybeCheck}}{{efn|name="coden"|Supported by {{tlx|infobox journal}} but not yet by cs1{{pipe}}2}} || || || || || [[CODEN]] ||
|-
| rft.contributor || || || || || {{na}}<!-- apparently not by Zotero --> || || Contributor ||
|-
| rft.coverage || || || || || {{na}}<!-- apparently not by Zotero --> || || Coverage ||
|-
| rft.creator || || || || || {{na}} || || Author ||
|-
| rft.description || || || || || {{na}} || || Text quote ||
|-
| rft.epage || {{na}} || {{na}} || || || || || Second (ending) page number of a start/end (spage-epage) pair. ||
|-
| rft.format || || || || || {{na}}<!-- apparently not by Zotero --> || || Format ||
|-
| rft.fulltext || || || || || || {{na}} || Full text of the referent ||
|-
| rft.holdings || || || || || || {{na}} || Holdings information related to the referent ||
|-
| rft.identifier || || || || || {{na}}<!-- apparently not by Zotero --> || || Identifier ||
|-
| rft.ill || || || || || || {{na}} || Inter-library loan request for the referent ||
|-
| rft.invfirst || || || || {{na}} || || || First or given name or names of the first inventor listed on the patent, e.g. "John J." ||
|-
| rft.invlast || || || || {{na}} || || || Family name of the first inventor listed on the patent, e.g. "Smith". ||
|-
| rft.kind || || || || {{na}} || || || The patent kind code indicates the stage of the patent. Kind codes are meaningful within a country code, ie.e. "AU A1". ||
|-
| rft.language || || || || || {{na}} || || Language code ||
|-
| rft.part || || {{na}} || || || || || [[Part (bibliography)|Part]] can be a special subdivision of a volume or it can be the highest level division of the journal. Parts are often designated with letters or names, i.e. "B", "Supplement". ||
|-
| rft.publisher || || || || || {{na}} || || Publisher (compare: rft.pub) ||
|-
| rft.relation || || || || || {{na}}<!-- apparently not by Zotero --> || || Relation ||
|-
| rft.rights || || || || || {{na}} || || Rights / License ||
|-
| rft.sici || || {{na}} || || || || || [[Serial Item and Contribution Identifier]] (SICI) ||
|-
| rft.source || || || || || {{na}}<!-- apparently not by Zotero --> || || Source ||
|-
| rft.spage || {{na}} || {{na}} || || || || || First page number of a start/end (spage-epage) pair. Note that pages are not always numeric. ||
|-
| rft.stitle || || {{MaybeCheck}}{{efn|name="coden"}} || || || || || Abbreviated or short journal title (see also: rft.jtitle and rft.title) ||
|-
| rft.subject || || || || || {{na}} || || Subject keys for topic ||
|-
| rft.tpages || {{na}} || || {{na}} || || || || Total pages. Total pages is the largest recorded number of pages, if this can be determined. I.e., "ix, 392 p." would be recorded as "392" in tpages. This data element is usually available only for monographs (books and printed reports). In some cases, tpages may not be numeric, i.e. "F36" ||
|-
| rft.type || || || || || {{na}} || || Controlled type<ref>https://www.dublincore.org/specifications/dublin-core/dcmi-type-vocabulary/</ref> ||
|-
| rfe_id || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || ||
|-
| rft_id || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || ||
|-
| rfe_dat || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || f.e. rfe_dat=ncid/<ncid-id>, naid/<naid-id> (Private data of referring entity)<ref>https://support.nii.ac.jp/en/cia/api/a_link_receive</ref><ref>https://zetoc.jisc.ac.uk/technical/mappings/ourljnl.html</ref> ||
|-
| rfr_dat || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || f.e. Generator and version (Private referrer data)<ref name="Passing_Parameters_1">https://web.archive.org/web/20201112210851/https://support.crossref.org/hc/en-us/articles/214507546-Passing-parameters</ref><ref name="Passing_Parameters_2">https://web.archive.org/web/20160617074523/http://www.crossref.org/08downloads/ParameterPassing.pdf</ref> ||
|-
| rft_dat || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || (Private referent data)<ref name="Passing_Parameters_1"/> ||
|-
| ctx_id || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || ctx_id=<source-domain>:<wikipedia-page>#<ref-id> (Context object data identifier) ||
|-
| ctx_tim || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || ctx_tim=yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd (Timestamp of context object data) ||
|-
| ctx_enc || colspan="3" {{na}} || {{na}} || {{na}} || {{na}} || ctx_enc=info:ofi/enc:UTF-8 (Encoding of context object data) ||
|-
|}
{{notelist}}


local cfg; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
== References ==
 
{{refbegin}}
 
; Wikipedia articles
--[[--------------------------< M A K E _ C O I N S _ T I T L E >----------------------------------------------
: [[COinS]]
 
: [[Wikipedia:COinS]]
Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)
; external sources
 
: {{cite web |title=OpenURL COinS: A Convention to Embed Bibliographic Metadata in HTML |url=http://ocoins.info/ |archive-url=https://web.archive.org/web/20170424223448/http://ocoins.info/ |archive-date=2017-04-24}}
Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
:: {{cite web |title=Brief guide to Implementing OpenURL 1.0 Context Object for Journal Articles |editor-first=Eric |editor-last=Hellman |publisher=[[OCLC]] |location=New Jersey, USA |work=OpenURL COinS: A Convention to Embed Bibliographic Metadata in HTML |version=1.0 |edition=stable |date=2009-06-16 |orig-date=2005-03-22 |url=http://ocoins.info/cobg.html |access-date=2016-11-30 |url-status=dead |archive-url=https://web.archive.org/web/20161130184729/http://ocoins.info/cobg.html |archive-date=2016-11-30}}
of %27%27...
:: {{cite web |title=Brief guide to Implementing OpenURL 1.0 Context Object for Books |editor-first=Eric |editor-last=Hellman |publisher=[[OCLC]] |location=New Jersey, USA |work=OpenURL COinS: A Convention to Embed Bibliographic Metadata in HTML |version=1.0 |edition=stable |date=2009-06-16 |orig-date=2005-03-22 |url=http://ocoins.info/cobgbook.html |access-date=2016-11-30 |url-status=dead |archive-url=https://web.archive.org/web/20161130183817/http://ocoins.info/cobgbook.html |archive-date=2016-11-30}}
 
: {{cite web |url=http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc&set=Core:Metadata+Formats |title=Registry for the OpenURL Framework - ANSI/NISO Z39.88-2004 |website=[[OCLC]] |accessdate=2015-09-27 |archive-url=https://web.archive.org/web/20160304100430/http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc&set=Core:Metadata+Formats |archive-date=2016-03-04}}
]]
:: {{cite web |title=OpenURL Syntax Description |url=http://alcme.oclc.org/openurl/docs/pdf/openurl-01.pdf |website=[[OCLC]] |accessdate=2015-11-06 |archive-url=https://web.archive.org/web/20180410225713/http://alcme.oclc.org/openurl/docs/pdf/openurl-01.pdf |archive-date=2018-04-10}}
 
:: {{cite web |title=Matrix defining the KEV Format to represent a journal publication |url=http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:journal |archive-url=https://web.archive.org/web/20070211105427/http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:journal |archive-date=2007-02-11}}
local function make_coins_title (title, script)
:: {{cite web |title=Matrix defining the KEV Format to represent a book |url=http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:book |archive-url=https://web.archive.org/web/20070211105427/http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:book |archive-date=2007-02-11}}
title = has_accept_as_written (title);
:: {{cite web |title=Matrix defining the KEV Format to represent a patent |url=http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:patent |archive-url=https://web.archive.org/web/20080317071414/http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:patent |archive-date=2008-03-17}}
if is_set (title) then
:: {{cite web |title=Matrix defining the KEV Format to represent a dissertation |url=http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:dissertation |archive-url=https://web.archive.org/web/20080317071409/http://alcme.oclc.org:80/openurl/servlet/OAIHandler/extension?verb=GetMetadata&metadataPrefix=mtx&identifier=info:ofi/fmt:kev:mtx:dissertation |archive-date=2008-03-17}}
title = strip_apostrophe_markup (title); -- strip any apostrophe markup
: {{cite web |url=http://info-uri.info/registry/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc |title="info" URI Scheme |website=info-uri.info |access-date=2015-10-31 |archive-url=https://web.archive.org/web/20171227063519/http://info-uri.info/registry/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc |archive-date=2017-12-27}} – info: scheme registry is closed
else
: {{cite web |url=http://epub.mimas.ac.uk/openurl/KEV_Guidelines-200706.html |title=Z39.88-2004: The OpenURL Framework for Context-Sensitive Services The Key/Encoded-Value (KEV) Format Implementation Guidelines}}
title = ''; -- if not set, make sure title is an empty string
:: {{cite web |url=http://epub.mimas.ac.uk/openurl/KEV_Guidelines_Ap-200706.html |title=Z39.88-2004: The OpenURL Framework for Context-Sensitive Services The Key/Encoded-Value (KEV) Format Implementation Guidelines, Appendices}}
end
:: {{cite web |url=http://epub.mimas.ac.uk/openurl/KEV_Guidelines_Egs-200706.html |title=Z39.88-2004: The OpenURL Framework for Context-Sensitive Services The Key/Encoded-Value (KEV) Format Implementation Guidelines, Examples}}
if is_set (script) then
: {{cite web |url=http://epub.mimas.ac.uk/openurl/KEV_Guidelines-200706.pdf |title=Z39.88-2004: The OpenURL Framework for Context-Sensitive Services The Key/Encoded-Value (KEV) Format Implementation Guidelines}}
script = script:gsub ('^%l%l%s*:%s*', ''); -- remove language prefix if present (script value may now be empty string)
{{refend}}
script = strip_apostrophe_markup (script); -- strip any apostrophe markup
else
script = ''; -- if not set, make sure script is an empty string
end
if is_set (title) and is_set (script) then
script = ' ' .. script; -- add a space before we concatenate
end
return title .. script; -- return the concatenation
end
 
 
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
 
Returns a string where all of Lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
 
local function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other Lua magic pattern characters
return argument;
end
 
 
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
 
Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
 
]]
 
local function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the URL and following space(s): "[url "
if nil == pattern then break; end -- no more URLs
pattern = escape_lua_magic_chars (pattern); -- pattern is not a literal string; escape Lua's magic pattern characters
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace HTML entities (&ndash; etc.) with hyphens; do we need to replace numerical entities like &#32; and the like?
return pages;
end
 
 
--[=[-------------------------< C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R >------------------
 
There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
PNG images
TeX source
MathML with SVG or PNG fallback
 
All three are heavy with HTML and CSS which doesn't belong in the metadata.
 
Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.
 
This function gets the rendered form of an equation according to the editor's preference before the page is saved. It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.
 
When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value. To replace multipe equations it is necessary to call this function from within a loop.
 
]=]
 
local function coins_replace_math_stripmarker (value)
local stripmarker = cfg.stripmarkers['math'];
local rendering = value:match (stripmarker); -- is there a math stripmarker
 
if not rendering then -- when value doesn't have a math stripmarker, abandon this test
return false, value;
end
rendering = mw.text.unstripNoWiki (rendering); -- convert stripmarker into rendered value (or nil? ''? when math render error)
if rendering:match ('alt="[^"]+"') then -- if PNG math option
rendering = rendering:match ('alt="([^"]+)"'); -- extract just the math text
elseif rendering:match ('$%s+.+%s+%$') then -- if TeX math option; $ is legit character that is escapes as \$
rendering = rendering:match ('$%s+(.+)%s+%$') -- extract just the math text
elseif rendering:match ('<annotation[^>]+>.+</annotation>') then -- if MathML math option
rendering = rendering:match ('<annotation[^>]+>(.+)</annotation>') -- extract just the math text
else
return false, value; -- had math stripmarker but not one of the three defined forms
end
return true, value:gsub (stripmarker, rendering, 1);
end
 
 
--[[--------------------------< C O I N S _ C L E A N U P >----------------------------------------------------
 
Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.
 
2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29
 
TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
 
]]
 
local function coins_cleanup (value)
local replaced = true; -- default state to get the do loop running
 
while replaced do -- loop until all math stripmarkers replaced
replaced, value = coins_replace_math_stripmarker (value); -- replace math stripmarker with text representation of the equation
end
 
value = value:gsub (cfg.stripmarkers['math'], "MATH RENDER ERROR"); -- one or more couldn't be replaced; insert vague error message
value = mw.text.unstripNoWiki (value); -- replace nowiki stripmarkers with their content
value = value:gsub ('<span class="nowrap" style="padding%-left:0%.1em;">&#39;(s?)</span>', "'%1"); -- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
value = value:gsub ('&nbsp;', ' '); -- replace &nbsp; entity with plain space
value = value:gsub ('\226\128\138', ' '); -- replace hair space with plain space
if not mw.ustring.find (value, cfg.indic_script) then -- don't remove zero-width joiner characters from indic script
value = value:gsub ('&zwj;', ''); -- remove &zwj; entities
value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', ''); -- remove zero-width joiner, zero-width space, soft hyphen
end
value = value:gsub ('[\009\010\013 ]+', ' '); -- replace horizontal tab, line feed, carriage return with plain space
return value;
end
 
 
--[[--------------------------< C O I N S >--------------------------------------------------------------------
 
COinS metadata (see <http://ocoins.info/>) allows automated tools to parse the citation information.
 
]]
 
local function COinS(data, class)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
 
for k, v in pairs (data) do -- spin through all of the metadata parameter values
if 'ID_list' ~= k and 'Authors' ~= k then -- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
data[k] = coins_cleanup (v);
end
end
 
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
end
end
});
if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn', 'journal', 'news', 'magazine'}) or
(in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or
('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal"; -- journal metadata identifier
if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) then -- set genre according to the type of citation template we are rendering
OCinSoutput["rft.genre"] = "preprint"; -- cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, cite ssrn
elseif 'conference' == class then
OCinSoutput["rft.genre"] = "conference"; -- cite conference (when Periodical set)
elseif 'web' == class then
OCinSoutput["rft.genre"] = "unknown"; -- cite web (when Periodical set)
else
OCinSoutput["rft.genre"] = "article"; -- journal and other 'periodical' articles
end
OCinSoutput["rft.jtitle"] = data.Periodical; -- journal only
OCinSoutput["rft.atitle"] = data.Title; -- 'periodical' article titles
 
-- these used only for periodicals
OCinSoutput["rft.ssn"] = data.Season; -- keywords: winter, spring, summer, fall
OCinSoutput["rft.quarter"] = data.Quarter; -- single digits 1->first quarter, etc.
OCinSoutput["rft.chron"] = data.Chron; -- free-form date components
OCinSoutput["rft.volume"] = data.Volume; -- does not apply to books
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput['rft.artnum'] = data.ArticleNumber; -- {{cite journal}} only
OCinSoutput["rft.pages"] = data.Pages; -- also used in book metadata
 
elseif 'thesis' ~= class then -- all others except cite thesis are treated as 'book' metadata; genre distinguishes
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book"; -- book metadata identifier
if 'report' == class or 'techreport' == class then -- cite report and cite techreport
OCinSoutput["rft.genre"] = "report";
elseif 'conference' == class then -- cite conference when Periodical not set
OCinSoutput["rft.genre"] = "conference";
OCinSoutput["rft.atitle"] = data.Chapter; -- conference paper as chapter in proceedings (book)
elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
if is_set (data.Chapter) then
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.atitle"] = data.Chapter; -- book chapter, encyclopedia article, interview in a book, or map title
else
if 'map' == class or 'interview' == class then
OCinSoutput["rft.genre"] = 'unknown'; -- standalone map or interview
else
OCinSoutput["rft.genre"] = 'book'; -- book and encyclopedia
end
end
else -- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
OCinSoutput["rft.genre"] = "unknown";
end
OCinSoutput["rft.btitle"] = data.Title; -- book only
OCinSoutput["rft.place"] = data.PublicationPlace; -- book only
OCinSoutput["rft.series"] = data.Series; -- book only
OCinSoutput["rft.pages"] = data.Pages; -- book, journal
OCinSoutput["rft.edition"] = data.Edition; -- book only
OCinSoutput["rft.pub"] = data.PublisherName; -- book and dissertation
else -- cite thesis
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:dissertation"; -- dissertation metadata identifier
OCinSoutput["rft.title"] = data.Title; -- dissertation (also patent but that is not yet supported)
OCinSoutput["rft.degree"] = data.Degree; -- dissertation only
OCinSoutput['rft.inst'] = data.PublisherName; -- book and dissertation
end
-- NB. Not currently supported are "info:ofi/fmt:kev:mtx:patent", "info:ofi/fmt:kev:mtx:dc", "info:ofi/fmt:kev:mtx:sch_svc", "info:ofi/fmt:kev:mtx:ctx"
-- and now common parameters (as much as possible)
OCinSoutput["rft.date"] = data.Date; -- book, journal, dissertation
 
for k, v in pairs( data.ID_list ) do -- what to do about these? For now assume that they are common to all?
if k == 'ISBN' then v = v:gsub( "[^-0-9X]", "" ); end
local id = cfg.id_handlers[k].COinS;
if string.sub( id or "", 1, 4 ) == 'info' then -- for ids that are in the info:registry
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
elseif string.sub (id or "", 1, 3 ) == 'rft' then -- for isbn, issn, eissn, etc. that have defined COinS keywords
OCinSoutput[ id ] = v;
elseif 'url' == id then -- for urls that are assembled in ~/Identifiers; |asin= and |ol=
OCinSoutput["rft_id"] = table.concat ({data.ID_list[k], "#id-name=", cfg.id_handlers[k].label});
elseif id then -- when cfg.id_handlers[k].COinS is not nil so urls created here
OCinSoutput["rft_id"] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', "#id-name=", cfg.id_handlers[k].label }; -- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
end
end
 
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = coins_cleanup (v.last), coins_cleanup (v.first or ''); -- replace any nowiki stripmarkers, non-printing or invisible characters
if k == 1 then -- for the first author name only
if is_set(last) and is_set(first) then -- set these COinS values if |first= and |last= specify the first author name
OCinSoutput["rft.aulast"] = last; -- book, journal, dissertation
OCinSoutput["rft.aufirst"] = first; -- book, journal, dissertation
elseif is_set(last) then
OCinSoutput["rft.au"] = last; -- book, journal, dissertation -- otherwise use this form for the first name
end
else -- for all other authors
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first }; -- book, journal, dissertation
elseif is_set(last) then
OCinSoutput["rft.au"] = last; -- book, journal, dissertation
end
-- TODO: At present we do not report "et al.". Add anything special if this condition applies?
end
end
 
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
 
-- TODO: Add optional extra info:
-- rfr_dat=#REVISION<version> (referrer private data)
-- ctx_id=<data.RawPage>#<ref> (identifier for the context object)
-- ctx_tim=<ts> (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
OCinSoutput = setmetatable( OCinSoutput, nil );
 
-- sort with version string always first, and combine.
-- table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
 
 
--[[--------------------------< S E T _ S E L E C T E D _ M O D U L E S >--------------------------------------
 
Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.
 
]]
 
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
cfg = cfg_table_ptr;
 
has_accept_as_written = utilities_page_ptr.has_accept_as_written; -- import functions from selected Module:Citation/CS1/Utilities module
is_set = utilities_page_ptr.is_set;
in_array = utilities_page_ptr.in_array;
remove_wiki_link = utilities_page_ptr.remove_wiki_link;
strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end
 
 
--[[--------------------------< E X P O R T E D  F U N C T I O N S >------------------------------------------
]]
 
return {
make_coins_title = make_coins_title,
get_coins_pages = get_coins_pages,
COinS = COinS,
set_selected_modules = set_selected_modules,
}