Module:PaperOfTheDay

From MaRDI portal
Revision as of 18:54, 18 November 2024 by Tconrad (talk | contribs) (Created page with "local p = {} local sparql = require('mw.sparql') -- Requires the SPARQL extension function p.query(frame) local query = [[ PREFIX wdt: <https://portal.mardi4nfdi.de/prop/direct/> PREFIX wd: <https://portal.mardi4nfdi.de/entity/> SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q57162 . ?item rdfs:label ?itemLabel . } LIMIT 1 ]] local result = sparql.query(query) if result and resul...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:PaperOfTheDay/doc

local p = {}
local sparql = require('mw.sparql') -- Requires the SPARQL extension

function p.query(frame)
    local query = [[
        PREFIX wdt: <https://portal.mardi4nfdi.de/prop/direct/>
        PREFIX wd: <https://portal.mardi4nfdi.de/entity/>
        SELECT ?item ?itemLabel
        WHERE {  
            ?item wdt:P31 wd:Q57162 .
            ?item rdfs:label ?itemLabel .
        }
        LIMIT 1
    ]]
    local result = sparql.query(query)
    if result and result[1] then
        return string.format(
            '<a href="%s">%s</a>',
            result[1].item.value,
            result[1].itemLabel.value
        )
    else
        return "No result found."
    end
end

return p