Neidio i'r cynnwys

Modiwl:Cite

Oddi ar Wicipedia

This cite module is still under development. Module that formats

Single Source String

[golygu cod]

The following code

{{#invoke:Cite
| cite
| item=Q14405740
}}

creates the reference string based on the item given withqid.ForQ14405740,this results in
Lua error in Modiwl:Complex_date at line 550: attempt to call method 'callParserFunction' (a nil value).

List of references

[golygu cod]

Books

[golygu cod]

See also:Wikidata:Books task force

A list of references which can be directly added to a references section can be created with {{#invoke:Cite | reflist | Q20124587 Q17355847 Q15220486 }} creates:

Lua error in Modiwl:Complex_date at line 550: attempt to call method 'callParserFunction' (a nil value).

Articles

[golygu cod]

See also:Wikidata:Periodicals task force

A list of references which can be directly added to a references section can be created with {{#invoke:Cite | reflist | Q14405740 Q13416617 Q20058533 }}, which results in:

Lua error in Modiwl:Complex_date at line 550: attempt to call method 'callParserFunction' (a nil value).

Supported properties

[golygu cod]

The Cite module should support:

  • -- still missing
  • -- still missing
  • -- still missing
  • -- still missing

Wish list:

    • as well as proper authoring of authors listed viaand,using the respectivestatements
    • "additional authors not shown" functionality (e.g. asat arXiv)
  • If ISBN is missing (books published before 1972):
  • If ISBN and SUDOC are missing:
[golygu cod]

Usage

[golygu cod]

-- Creates a timeline for an item based on various properties

localp={}
localwikidata=require('Modiwl:WikidataWD')
locallinguistic=require('Modiwl:Linguistic')
localfb=require('Modiwl:Fallback')

localfunctionformatpage(page,lang)
-- same text for singular and plural, most of the time, they can be distinguished by the presence of a "-" but that does not always work, see Q11927173
ifnotpagethen
returnnil
end
returnfb._langSwitch({-- singular
de='S. '..page,
en='p. '..page,
fr='p. '..page,
nb='s. '..page,
nn='s. '..page,
},lang)
end

localfunctiongetauthor(item,lang)
returnwikidata.formatStatements{entity=item,property='P50',lang=lang}
end

localfunctiongetISBN(item,lang)
localISBN=wikidata.formatStatements{entity=item,property='P212',lang=lang,numval=1}
ifISBNthen
return'ISBN '..ISBN
end
end

localfunctiongetLink(item,lang)
locallinks=wikidata.formatStatements{entity=item,property='P854',numval=1,lang=lang}
iflinksthen
returnfb._langSwitch({
de='['..links..' online]',
en='['..links..' read online]',
fr='['..links..' lire en ligne]',
nb='['..links..' les online]',
nn='['..links..' les online]',
},lang)
end
end

localfunctiongetVolume(item,lang)
localvolume=wikidata.formatStatements{entity=item,property='P478',numval=1,lang=lang}
ifvolumethen
returnfb._langSwitch({
de='Band '..volume,
en='vol. '..volume,
},lang)
end
end

localfunctiongetDoi(item,lang)
localdoi=wikidata.formatStatements({entity=item,property='P356',numval=1,lang=lang})-- what to do if several value
ifnotdoithen
returnnil
end
return'<small>'..'doi: [//dx.doi.org/'..doi..' '..doi..']'..'</small>'-- needs i18n?
end

localfunctiongetPmid(item,lang)
localpmid=wikidata.formatStatements({entity=item,property='P698',numval=1,lang=lang})-- what to do if several value
ifnotpmidthen
returnnil
end
return'<small> Pub Med ID: [// ncbi.nlm.nih.gov/pubmed/?term='..pmid..' '..pmid..'] </small>'-- needs i18n?
end

localfunctiongetEditor(item,lang)
localeditortable=wikidata.getClaims({entity=item,property='P98'})
ifnoteditortablethen
returnnil
end
localeditor=wikidata.formatStatements({entity=item,property='P98',lang=lang})-- should have a "formatClaims" function to avoid double work
if#editortable>1thenreturn
fb._langSwitch({--plural
de=editor..' (Hrsg.)',
en=editor..' (eds.)',
nb=editor..' (red.)',
nn=editor..' (red.)',
},lang)
else
returnfb._langSwitch({-- singular
de=editor..' (Hrsg.)',
en=editor..' (ed.)',
nb=editor..' (red.)',
nn=editor..' (red.)',
},lang)
end

end

localfunctiongetedition(item,lang)
localednumber=wikidata.formatStatements({entity=item,property='P393',lang=lang,numval=1})
ifnotednumberthen
returnnil
end
localord=require('Module:Ordinal')._ordinal
returnfb._langSwitch({
de=ednumber..'. Auflage',
en=ord{ednumber,lang='en'}..' edition',
fr=ord{ednumber,lang='fr'}..' édition',
nb=ord{ednumber,lang='nb'}..' utgave',
nn=ord{ednumber,lang='nn'}..' utgave',
},lang)
end

localfunctiongetarticletitle(item,lang)
localtitle=wikidata.formatStatements({entity=item,property='P1476',lang=lang})orwikidata.formatStatements({entity=item,property='P357',lang=lang})
ifnottitlethen
return'[['..item.id..']] (no title property provided!)'
end
returnfb._langSwitch({
de='„'..'[['..item.id..'|'..title..']]'..' “',
en=' "'..'[['..item.id..'|'..title..']]'..' "',
fr='«'..'[['..item.id..'|'..title..']]'..'»',
nb='«'..'[['..item.id..'|'..title..']]'..'»',
nn='«'..'[['..item.id..'|'..title..']]'..'»',
},lang)
end

localfunctiongetbooktitle(item,lang)-- needs i18n some languages do not use this format
localtitle=wikidata.formatStatements({entity=item,property='P1476',lang=lang})orwikidata.formatStatements({entity=item,property='P357',lang=lang})
ifnottitlethen
return'[['..item.id..']] (no title property provided!)'
end
return'<i>'..'[['..item.id..'|'..title..']]'..'</i>'
end

localfunctiongetissue(item,lang)
returnwikidata.formatStatements({entity=item,property='P433',lang=lang})
end

localfunctiongetpublisher(item,lang)
returnwikidata.formatStatements({entity=item,property='P123',lang=lang})
end

localfunctiongetpublishdate(item,lang)
returnwikidata.formatStatements({entity=item,property='P577',lang=lang})
end

localfunctiongeturl(item,lang)
returnwikidata.formatStatements({entity=item,property='P854',lang=lang})
end

localfunctiongetlicense(item,lang)
returnwikidata.formatStatements{entity=item,property='P275',lang=lang}
end

localfunctiongetjournal(item,lang)-- get the title property rather than the label
localjournal=wikidata.getClaims({entity=item,property='P1433',exlcudespecial=true})
ifnotjournalthen
returnnil
end
if#journal>1then
return"error, source has too much publishing info"
end
localjournalid='Q'..journal[1].mainsnak.datavalue.value["numeric-id"]
localjournaltitle=wikidata.formatStatements({item=journalid,property='P1433',lang=lang})
ifnotjournaltitlethen
journaltitle=wikidata._getLabel(journalid)
end
return'<i>[['..journalid..'|'..journaltitle..']]</i>'
end

localfunctioncitebook(item,lang,page)
localpublishdate=getpublishdate(item,lang)
localauthor=getauthor(item,lang)
localeditor=getEditor(item,lang)
localtitle=getbooktitle(item,lang)
localpublisher=getpublisher(item,lang)
localedition=getedition(item,lang)
localisbn=getISBN(item,lang)
localdoi=getDoi(item,lang)
localpmid=getPmid(item,lang)
locallink=getLink(item,lang)
localvolume=getVolume(item,lang)
localpagenumber=formatpage(page,lang)
locallicense=getlicense(item,lang)

localfields={}
table.insert(fields,author)
table.insert(fields,editor)
table.insert(fields,title)
table.insert(fields,edition)
table.insert(fields,volume)
table.insert(fields,publisher)
table.insert(fields,publishdate)
table.insert(fields,pagenumber)
table.insert(fields,isbn)
table.insert(fields,doi)
table.insert(fields,pmid)
table.insert(fields,link)
table.insert(fields,license)
returnlinguistic.conj(fields,lang,"comma")
end

localfunctioncitearticle(item,lang,page)
localauthor=getauthor(item,lang)
localtitle=getarticletitle(item,lang)
localpublisher=getpublisher(item,lang)
localpublishdate=getpublishdate(item,lang)
localpagenumber=formatpage(page,lang)
localjournal=getjournal(item,lang)
localissue=getissue(item,lang)
localpublishdate=getpublishdate(item,lang)
localdoi=getDoi(item,lang)
localpmid=getPmid(item,lang)
locallink=getLink(item,lang)
localvolume=getVolume(item,lang)
localpagenumber=formatpage(page,lang)
locallicense=getlicense(item,lang)

localfields={}
table.insert(fields,author)
table.insert(fields,title)
table.insert(fields,publisher)
table.insert(fields,journal)
table.insert(fields,volume)
table.insert(fields,issue)
table.insert(fields,publishdate)
table.insert(fields,pagenumber)
table.insert(fields,doi)
table.insert(fields,pmid)
table.insert(fields,link)
table.insert(fields,license)
returnlinguistic.conj(fields,lang,"comma")
end

functionp.citeitem(item,lang,page)
ifnotitemthenreturnnilend
iftype(item)=='string'then
item=mw.wikibase.getEntityObject(item)
end
ifnotitemthen
return"invalid item id"
end
ifwikidata.getClaims({entity=item,property='P1433'})then-- if item has "edition of" is a book, else an article, needs a better solution
returncitearticle(item,lang,page)
else
mw.log('Citing as book')
returncitebook(item,lang,page)
end
end

functionp.cite(frame)
locallang=frame.args.lang
ifnotlangorlang==''then
lang=frame:preprocess('{{int:lang}}')
end
localpage=frame.args.page
ifpage==''then
page=nil
end
returnp.citeitem(frame.args.item,lang,page)
end

functionp.reflist(frame)
locallist=mw.text.split(frame.args[1],' ')
locallang=frame.args.lang
ifnotlangorlang==''then
lang=frame:preprocess('{{int:lang}}')
end
localstr=''
fori,jinpairs(list)do
str=str..'<li> '..p.citeitem(mw.text.trim(j),lang)..'</li>'
end
returnstr
end

returnp