Module:PaperOfTheDay: Difference between revisions
From MaRDI portal
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..." |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local sparql = require('mw. | local sparql = require('SPARQL') | ||
local mwHtml = require('mw.html') | |||
function p.query(frame) | function p.query(frame) |
Revision as of 19:00, 18 November 2024
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