More languages
More actions
m (Fixed typo (used date instead of year)) |
m (Began to develop quote for citation) |
||
Line 4: | Line 4: | ||
return not (var == nil or var == ''); | return not (var == nil or var == ''); | ||
end | end | ||
local function italics (var) | |||
return "''" .. var .. "''" | |||
end | |||
function p.cite( frame ) | function p.cite( frame ) | ||
Line 24: | Line 29: | ||
local LG = pframe.args.lg | local LG = pframe.args.lg | ||
local MIA = pframe.args.mia | local MIA = pframe.args.mia | ||
local Quote = pframe.args.quote | |||
if is_set (Author) then | if is_set (Author) then | ||
Line 136: | Line 142: | ||
:wikitext('[' .. MIA .. " " .. mw.text.nowiki('[MIA]') .. ']') | :wikitext('[' .. MIA .. " " .. mw.text.nowiki('[MIA]') .. ']') | ||
x4 = x4 .." " .. tostring(span) | x4 = x4 .." " .. tostring(span) | ||
end | end | ||
if is_set (Quote) then | |||
local div = mw.html.create ('div') | |||
div | |||
:attr('width','80%') | |||
:attr('margin-left','10%') | |||
:wikitext("''" .. Quote .. "''") | |||
mw.html.create('br') | |||
end | |||
Revision as of 05:45, 10 November 2021
local p = {}
local function is_set (var)
return not (var == nil or var == '');
end
local function italics (var)
return "''" .. 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 Trans = pframe.args['trans-title']
local TransLang = pframe.args['trans-lang']
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
local MIA = pframe.args.mia
local Quote = pframe.args.quote
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 .. "''"
if not is_set (Author) then
if is_set (Year) then
x2 = x2 .. " (" .. Year .. ")"
end
end
end
if is_set (Trans) then
if is_set (TransLang) then
x2 = x2 .. " (" .. TransLang .. ": " .. Trans .. ")"
else
x2 = x2 .. " (" .. Trans .. ")"
end
end
if is_set (Page) then
if tonumber(Page) ~= nil then
Page = "p. " .. Page
else
Page = "pp. " .. Page
end
x2 = x2 .. " (" .. Page .. ")."
else
x2 = x2 .. "."
end
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
if is_set (City) then
if is_set (Publisher) then
x3 = City .. ": " .. Publisher .. "."
else
x3 = City .. "."
end
elseif is_set(Publisher) then
x3 = Publisher .. "."
else
x3 = ""
end
x4 = ""
if is_set (ISBN) then
local span = mw.html.create ( 'span' )
span
:attr( 'title', 'WorldCat')
:addClass('plainlinks')
:tag( 'small' )
:wikitext('[' .. "https://www.worldcat.org/search?qt=worldcat_org_all&q=" .. ISBN .. " " .. "ISBN " .. ISBN .. ']')
x4 = x4 .. tostring(span)
end
if is_set (DOI) then
x4 = x4 .. " doi:" .. DOI
local span = mw.html.create ( 'span' )
span
:attr( 'title', 'Sci-Hub link')
:addClass('plainlinks')
:tag( 'small' )
:wikitext('[' .. "https://sci-hub.se/" .. DOI .. " " .. mw.text.nowiki('[HUB]') .. ']')
x4 = x4 .." " .. tostring(span)
end
if is_set (LG) then
local span = mw.html.create ( 'span' )
span
:attr( 'title', 'Library Genesis link')
:addClass('plainlinks')
:tag( 'small' )
:wikitext('[' .. LG .. " " .. mw.text.nowiki('[LG]') .. ']')
x4 = x4 .." " .. tostring(span)
end
if is_set (MIA) then
local span = mw.html.create ( 'span' )
span
:attr( 'title', 'Marxists Internet Archive link')
:addClass('plainlinks')
:tag( 'small' )
:wikitext('[' .. MIA .. " " .. mw.text.nowiki('[MIA]') .. ']')
x4 = x4 .." " .. tostring(span)
end
if is_set (Quote) then
local div = mw.html.create ('div')
div
:attr('width','80%')
:attr('margin-left','10%')
:wikitext("''" .. Quote .. "''")
mw.html.create('br')
end
if is_set (x1) then
x1 = x1 .. " "
end
if is_set (x2) then
x2 = x2 .. " "
end
if is_set (x3) then
x3 = x3 .. " "
end
return x1 .. x2 .. x3 .. x4
end
return p