Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Library citation: Difference between revisions

From ProleWiki, the proletarian encyclopedia
(Testing error messages)
 
m (Testing dpl)
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
function is_lib_work(s)
return mw.getCurrentFrame():callParserFunction('#ifexist',"Library:" .. s,true) == "1"
end
function listOfWorks(author)
local list = mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","titleregexp=" ..author .. "/[^/]+$","format=,%PAGE%\\n")
if list == "" then
list = mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","category=Library works by " .. author ,"format=,%PAGE%\\n")
end
return list
end


function p.cite(frame)
function p.cite(frame)
-- Parent frame to get parameters from template calls instead of from {{#invoke: ...
-- Parent frame to get parameters from template calls instead of from {{#invoke: ...
local parentFrame = frame:getParent()
local parentFrame = frame:getParent()
local link = pframe.args.link
-- get arguments from "args" table pre-defined by MediaWiki/Scribunto
local author = pframe.args.author
local link = parentFrame.args.link
local work = pframe.args.work
local author = parentFrame.args.author
error("error message")
-- error("error message") to send error messages
-- mw.log(mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","titleregexp=Vladimir Lenin/[^/]+$","format=,%PAGE%\\n"))
-- mw.log(mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","category=Library works by Vladimir Lenin","format=,%PAGE%\\n"))
return listOfWorks(author)
end
end
return p

Revision as of 00:33, 7 October 2024

local p = {}

function is_lib_work(s)
	return mw.getCurrentFrame():callParserFunction('#ifexist',"Library:" .. s,true) == "1"
end

function listOfWorks(author) 
	local list = mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","titleregexp=" ..author .. "/[^/]+$","format=,%PAGE%\\n")
	if list == "" then
		list = mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","category=Library works by " .. author ,"format=,%PAGE%\\n")
	end
	return list
end

function p.cite(frame)
	-- Parent frame to get parameters from template calls instead of from {{#invoke: ...
	local parentFrame = frame:getParent()
	-- get arguments from "args" table pre-defined by MediaWiki/Scribunto
	local link = parentFrame.args.link
	local author = parentFrame.args.author
	-- error("error message") to send error messages
	-- mw.log(mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","titleregexp=Vladimir Lenin/[^/]+$","format=,%PAGE%\\n"))
	-- mw.log(mw.getCurrentFrame():callParserFunction("#dpl","namespace=Library","category=Library works by Vladimir Lenin","format=,%PAGE%\\n"))
	return listOfWorks(author)
end
return p