Module:SoftwareLicenseList: Difference between revisions
From MaRDI portal
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 8: | Line 8: | ||
-- Main table to hold all functions | -- Main table to hold all functions | ||
local p = {} | local p = {} | ||
-- Function to build the list | -- Function to build the list | ||
| Line 50: | Line 18: | ||
end | end | ||
local fakeFrame = { args = {[1] = target1, [2] = "P163" } } | |||
local | jsonResults = helper.getValuesForProperty( fakeFrame ) | ||
} | |||
if not jsonResults then | if not jsonResults then | ||
| Line 89: | Line 29: | ||
end | end | ||
local licenseList = | local licenseList = helper.convertJsonToCommaSeparatedList(jsonResults) | ||
-- mw.log(licenseList) | -- mw.log(licenseList) | ||
Latest revision as of 15:11, 15 April 2025
Documentation for this module may be created at Module:SoftwareLicenseList/doc
-- Required module containing helper methods
local helper = require('Module:HelperMethods')
-- Required modules for SPARQL queries and HTML table generation
local sparql = require('SPARQL')
local mwHtml = require('mw.html')
-- Main table to hold all functions
local p = {}
-- Function to build the list
function p.buildLicenseList(frame)
-- Retrieve target1 from frame arguments or return error message if not set
local target1 = frame.args[1]
if not target1 or target1 == '' then
return "No records found"
end
local fakeFrame = { args = {[1] = target1, [2] = "P163" } }
jsonResults = helper.getValuesForProperty( fakeFrame )
if not jsonResults then
return "Could not fetch data."
end
if helper.countElementsInBindings(jsonResults.results.bindings) == 0 then
return "No records found."
end
local licenseList = helper.convertJsonToCommaSeparatedList(jsonResults)
-- mw.log(licenseList)
return licenseList
end
-- Return the created html table
return p