Module:PaperOfTheDay

From MaRDI portal
Revision as of 19:00, 18 November 2024 by Tconrad (talk | contribs)

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

local p = {}
local sparql = require('SPARQL')
local mwHtml = require('mw.html')


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