Module:PublicationShowAbstract: Difference between revisions

From MaRDI portal
Created page with "-- 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 convert JSON results into a space-separated string function p.queryAbstractDB(QID) local resultsString = "" local safeList = helper.urlencode ( binding.value.value ) local r..."
 
No edit summary
Line 6: Line 6:
local mwHtml = require('mw.html')
local mwHtml = require('mw.html')


-- Main table to hold all functions
local p = {}
local p = {}


-- Function to convert JSON results into a space-separated string
function p.queryAbstractDB(QID)
function p.queryAbstractDB(QID)
local resultsString = ""
local abstract = ""
     local safeList = helper.urlencode ( binding.value.value )
     local safeList = helper.urlencode ( binding.value.value )
Line 20: Line 18:
                  
                  
if row then
if row then
abstract = row.abstract
        local link = baseUrl .. "/w/index.php?title=+Special%3ASearch&search=%22" .. helper.urlencode(msc_result.msc_label) .. "%22&go=Go"
if resultsString ~= "" then
        resultsString = resultsString .. "\n"
    end
local nameAndLink = "[" .. link .. " " .. msc_result.msc_label .. " (" .. name  .. ")]"
resultsString = resultsString .. nameAndLink
end
end


     return resultsString
     return abstract
end
end




-- Function to build the list
function p.getAbstractForPaperQID(frame)
function p.getAbstractForPaperQID(frame)

Revision as of 13:51, 8 April 2025

Documentation for this module may be created at Module:PublicationShowAbstract/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')

local p = {}

function p.queryAbstractDB(QID)
	local abstract = ""
	
    local safeList = helper.urlencode ( binding.value.value )
    local row = mw.ext.externaldata.getDbData {
	    db = "AbstractDB",
	    parameters = safeID
	}
                
	if row then
		abstract = row.abstract
	end

    return abstract
end


function p.getAbstractForPaperQID(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 abstract = p.queryAbstractDB(target1)
	
	-- mw.log(abstract) 
	
    return abstract
end

return p