Modul:Literatur Wikidata: Unterschied zwischen den Versionen

Aus Regiowiki
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „local p = {} function p.literatur(f) local linkedwiki = require 'linkedwiki' local frame = mw.getCurrentFrame() -- init the prefix local r…“)
 
Keine Bearbeitungszusammenfassung
Zeile 19: Zeile 19:
     local dateFormat = "Y"
     local dateFormat = "Y"


     local subject = f.args.iri or linkedwiki.getCurrentIRI();  --find the iri of the current page
     --local subject = f.args.iri or linkedwiki.getCurrentIRI();  --find the iri of the current page


     local object = linkedwiki.new(subject)
     local object = linkedwiki.new(subject)

Version vom 10. April 2024, 22:55 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Literatur Wikidata/Doku erstellt werden

local p = {}

function p.literatur(f)
    
    local linkedwiki = require 'linkedwiki'

	local frame = mw.getCurrentFrame()

    -- init the prefix
    local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
    local xsd = 'http://www.w3.org/2001/XMLSchema#'
    local wdt = 'http://www.wikidata.org/prop/direct/'
    local wd = 'http://www.wikidata.org/entity/'
    local p = 'http://www.wikidata.org/prop/'
    local pq = 'http://www.wikidata.org/prop/qualifier/'
    local ps = 'http://www.wikidata.org/prop/statement/'

    local dateFormat = "Y"

    --local subject = f.args.iri or linkedwiki.getCurrentIRI();  --find the iri of the current page

    local object = linkedwiki.new(subject)
    --object:setDebug(true)
    object:removeSubject() -- delete all triples of this subject

    --compare data with Wikidata
    local iriWikidata = ""
    local objWikidata = nil
    local objWikidataTitle = ""
    local objWikidataLieuDeces = nil
    local objPapeFonction = nil
    local linkWikidata = ""
	local propertyZDB = wdt..'P1042'
	local propertyTitel = wdt..'P1476'
	local propertyAuthor = wdt..'P2093'
	local propertyJournal = wdt..'P1433'
	local propertyIssue = wdt..'P433'
	local propertyPubDate = wdt..'P577'
	local propertyPage = wdt..'P304'
	
    if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
        local idConfigWikidata = 'http://www.wikidata.org'
        local taglang = 'de'
        local datums = nil
        citeq_args = {}
        iriWikidata = wd .. f.args['Wikidata ID']
        objWikidata = linkedwiki.new(iriWikidata, idConfigWikidata, taglang)

        linkWikidata = '[[d:' .. f.args['Wikidata ID'] .. '|' .. f.args['Wikidata ID'] ..']]'
        
        --zdb = 'ZDB: [http://ld.zdb-services.de/resource/'..objWikidata:getValue(propertyZDB)..' '..objWikidata:getValue(propertyZDB)..']'
        citeq_args["Titel"] = objWikidata:getString(propertyTitel,taglang)
        citeq_args["Autor"] = objWikidata:getValue(propertyAuthor)
        objWikidataJournal= linkedwiki.new(objWikidata:getValue(propertyJournal), idConfigWikidata, taglang)
        
        citeq_args["Sammelwerk"] = objWikidataJournal:getString(propertyTitel,taglang)
        citeq_args["Seiten"] = objWikidata:getValue(propertyPage)
        citeq_args["Nummer"] = objWikidata:getValue(propertyIssue)
        datums = objWikidata:getValue(propertyPubDate)
        citeq_args["Datum"] = string.sub(datums,1,4)
    end


	--return '{{Literatur|Titel=' .. title ..'|Autor=' .. autor .. '}}'
	template = 'Literatur'
	return frame:expandTemplate{title = template, args = citeq_args}
	--return  objWikidata:getValue(propertyAuthor)
	
end

return p