More languages
More actions
No edit summary |
mNo edit summary |
||
Line 11: | Line 11: | ||
local Year = pframe.args.year | local Year = pframe.args.year | ||
local Chapter = pframe.args.chapter | local Chapter = pframe.args.chapter | ||
local ChapterURL = pframe.args.chapter-url | |||
local Title = pframe.args.title | local Title = pframe.args.title | ||
local TitleURL = pframe.args.title-url | |||
local Page = pframe.args.page | local Page = pframe.args.page | ||
local PDF = pframe.args.pdf | local PDF = pframe.args.pdf | ||
Line 29: | Line 31: | ||
x1 = "" | x1 = "" | ||
end | end | ||
if is_set (Title) then | |||
if is_set (TitleURL) then | |||
Title = "[" .. TitleURL .. " " .. Title .. "]" | |||
end | |||
if is_set (Chapter) then | |||
if is_set (ChapterURL) then | |||
Chapter = "[" .. ChapterURL .. " " .. Chapter .. "]" | |||
end | |||
x2 = "'" .. Chapter .. "'" .. " in " .. "''" .. Title .. "''" | |||
else | |||
x2 = "''" .. Title .. "''" | |||
end | |||
end | end | ||
if is_set (Page) then | if is_set (Page) then | ||
if tonumber(Page) ~= nil then | if tonumber(Page) ~= nil then |
Revision as of 21:10, 27 October 2021
local p = {}
local function is_set (var)
return not (var == nil or var == '');
end
function p.cite( frame )
local pframe = frame:getParent()
local Author = pframe.args.author
local Year = pframe.args.year
local Chapter = pframe.args.chapter
local ChapterURL = pframe.args.chapter-url
local Title = pframe.args.title
local TitleURL = pframe.args.title-url
local Page = pframe.args.page
local PDF = pframe.args.pdf
local City = pframe.args.city
local Publisher = pframe.args.publisher
local ISBN = pframe.args.isbn
local DOI = pframe.args.doi
local LG = pframe.args.lg
if is_set (Author) then
if is_set (Year) then
x1 = Author .. " (" .. Year .. ")" .. ". "
else
x1 = Author .. ". "
end
else
x1 = ""
end
if is_set (Title) then
if is_set (TitleURL) then
Title = "[" .. TitleURL .. " " .. Title .. "]"
end
if is_set (Chapter) then
if is_set (ChapterURL) then
Chapter = "[" .. ChapterURL .. " " .. Chapter .. "]"
end
x2 = "'" .. Chapter .. "'" .. " in " .. "''" .. Title .. "''"
else
x2 = "''" .. Title .. "''"
end
end
if is_set (Page) then
if tonumber(Page) ~= nil then
Page = "p. " .. Page
else
Page = "pp. " .. Page
end
x2 = x2 .. " (" .. Page .. ")"
end
if is_set (PDF) then
local span = mw.html.create ( 'span' )
span
:attr( 'title', 'PDF download')
:addClass('plainlinks')
:tag( 'small' )
:wikitext('[' .. PDF .. " " .. mw.text.nowiki('[PDF]') .. ']')
x2 = x2 .. " " .. tostring(span)
end
return x1 .. x2
end
return p