Modul:Citace: Porovnání verzí
Smazaný obsah Přidaný obsah
2 opravy |
2 opravy |
||
Řádek 376: | Řádek 376: | ||
function p.lastChar(s) |
function p.lastChar(s) |
||
if p.frame then |
|||
⚫ | |||
local len = mw.ustring.len(s) |
|||
return mw.ustring.sub(len, len) |
|||
else |
|||
⚫ | |||
end |
|||
end |
end |
||
Řádek 391: | Řádek 396: | ||
function p.upperFirst(s) |
function p.upperFirst(s) |
||
if p.frame then |
|||
⚫ | |||
return p.upper(mw.ustring.sub(s, 1, 1)) .. mw.ustring.sub(s, 2) |
|||
else |
|||
⚫ | |||
end |
|||
end |
end |
||
Řádek 1 003: | Řádek 1 012: | ||
if not p.empty(c.args["url2"]) then |
if not p.empty(c.args["url2"]) then |
||
table.insert(c.r, " " |
table.insert(c.r, " " |
||
.. p.coalesce(c.args["dostupnost2"], "Dostupné také na: |
.. p.coalesce(c.args["dostupnost2"], "Dostupné také na:") |
||
.. " " |
|||
.. p.wikiextlink(c.args["url2"]) |
.. p.wikiextlink(c.args["url2"]) |
||
.. "." |
.. "." |
||
Řádek 1 010: | Řádek 1 020: | ||
if not p.empty(c.args["url3"]) then |
if not p.empty(c.args["url3"]) then |
||
table.insert(c.r, " " |
table.insert(c.r, " " |
||
.. p.coalesce(c.args["dostupnost3"], "Dále dostupné na: |
.. p.coalesce(c.args["dostupnost3"], "Dále dostupné na:") |
||
.. " " |
|||
.. p.wikiextlink(c.args["url3"]) |
.. p.wikiextlink(c.args["url3"]) |
||
.. "." |
.. "." |
Verze z 6. 1. 2018, 17:32
Prozatímní dokumentace
V květnu 2020 importováno z Wikipedie včetně nových verzí citačních šablon.
Po každém dalším importu nutno změnit jména chybových kategorií.
local p = {
}
function p.trace(c, dbgInfo)
table.insert(c.r, "{p." .. dbgInfo.name .. "}")
end
function p.citaceInit(c)
c.r = {} -- result
c.flags = {}
if type(c.frame.callParserFunction) == 'function' then
-- running as wiki module
local aModule = require('Modul:Arguments')
c.args = aModule.getArgs(c.frame)
p.frame = c.frame -- zmena reseni, 30.12.2017 12:30:06
else
-- running in console
c.localTest = 1
c.args = c.frame
-- makety vybranych fci pro lokalni testovani
mw = {
uri = {
encode = p.identity
}
}
-- debugging options
-- c.noCoins = 1
-- c.trace = 1
-- c.dbg = 1
end
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
-- zpětná kompatibilita
p.convertUnderscoreArgs(c.args)
p.provideArgs(c.args, {
-- ["SRC"] = "DEST",
["příjmení"] = "příjmení1",
["jméno"] = "jméno1",
["autor"] = "autor1",
["odkaz na autora"] = "odkaz na autora1",
["příjmení sestavitele"] = "příjmení sestavitele1",
["jméno sestavitele"] = "jméno sestavitele1",
["sestavitel"] = "sestavitel1",
["odkaz na sestavitele"] = "odkaz na sestavitele1",
["noviny"] = "periodikum",
["časopis"] = "periodikum",
["odkaz na noviny"] = "odkaz na periodikum",
["odkaz na časopis"] = "odkaz na periodikum",
["datum vydání"] = "datum",
["den vydání"] = "den",
["měsíc vydání"] = "měsíc",
["rok vydání"] = "rok",
["stránky"] = "strany",
["poznámka"] = "poznámky",
["titulorig"] = "titul původní",
})
c.printAnchor = not p.empty(c.args.ref)
-- NOTE: Mozna dodat dalsi parametr pro vypnuti, tj. abychom mohli mit printAnchor, ale ne useHarvardFormat
c.useHarvardFormat = c.printAnchor
if c.dbg then
table.insert(c.r, "((DBG: ")
for k, v in pairs(c.args) do
table.insert(c.r, k .. ' = ' .. v .. ';')
end
table.insert(c.r, " DBG_END))\n")
end
end
function p.citaceMonografie(frame)
local c = {
frame = frame
}
p.citaceInit(c)
c.type = 'citaceMonografie'
local t = {} -- temp
local i
table.insert(c.r, '<cite class="book" style="font-style:normal"')
p.citAnchorId(c)
table.insert(c.r, '>')
p.citAuthors(c, { maxAuthors = 7, honorCorporation = true })
p.citTitle(c)
p.citOtherPersons(c)
p.citEdition(c)
p.citVolume(c)
p.citPlacePublisher(c)
p.citDate(c)
p.citNumberOfVolumesPagesAppendices(c)
p.citEdition(c)
p.citUrl(c)
p.citIsbn(c)
p.citDoi(c)
p.citOclc(c)
p.citId(c)
p.citChapterPage(c)
p.citLanguage(c)
p.citNotes(c)
table.insert(c.r, '</cite>')
p.citCoinsMonografie(c)
return table.concat(c.r)
end
function p.citaceElMonografie(frame)
local c = {
frame = frame
}
p.citaceInit(c)
c.type = 'citaceElMonografie'
local t = {} -- temp
local i
table.insert(c.r, '<cite class="book" style="font-style:normal"')
p.citAnchorId(c)
table.insert(c.r, '>')
p.citAuthors(c, { maxAuthors = 7, honorCorporation = true })
p.citTitle(c)
p.citOtherPersons(c)
p.citEdition(c)
-- p.citVolume(c)
p.citPlacePublisher(c)
p.citDate(c)
-- p.citNumberOfVolumesPagesAppendices(c)
p.citEdition(c)
p.citChapterPage(c)
p.citNotes(c)
p.citUrl(c)
p.citIsbn(c)
p.citDoi(c)
-- p.citOclc(c)
p.citId(c)
p.citLanguage(c)
table.insert(c.r, '</cite>')
p.citCoinsMonografie(c)
return table.concat(c.r)
end
function p.citacePeriodika(frame)
local c = {
frame = frame
}
p.citaceInit(c)
c.type = 'citacePeriodika'
local t = {} -- temp
local i
table.insert(c.r, '<cite style="font-style:normal"')
p.citAnchorId(c)
table.insert(c.r, '>')
p.citAuthors(c, { maxAuthors = 7, honorCorporation = false })
p.citTitle(c)
p.citOtherPersons(c)
table.insert(c.r, " ")
p.citPeriodical(c)
table.insert(c.r, " ")
p.citPlacePublisher(c)
p.citDate(c)
p.citYearNumber(c)
p.citPage(c)
table.insert(c.r, ".") -- může se stát, že po periodiku už žádné další údaje nebudou uvedeny, ale pak je ta citace stejně k ničemu
p.citNotes(c)
p.citUrl(c)
p.citIssn(c)
p.citIsbn(c)
p.citDoi(c)
p.citPmid(c)
p.citBibcode(c)
p.citArxiv(c)
p.citId(c)
p.citLanguage(c)
if p.empty(c.args["periodikum"]) then
if c.localTest then
t.chyba = '{{chyba|Chybí povinný parametr: V šabloně {{šablona|Citace periodika}} je nutno určit zdrojové "<code>periodikum</code>" odkazu!|kategorie=Údržba:Chybná volání citačních šablon|skrytý=skrytý}}'
else
t.chyba = c.frame:expandTemplate{title = 'chyba', args = {
'Chybí povinný parametr: V šabloně '
.. c.frame:expandTemplate{title = 'šablona', args = {'Citace periodika'}}
.. ' je nutno určit zdrojové "<code>periodikum</code>" odkazu!',
['kategorie'] = 'Údržba:Chybná volání citačních šablon',
['skrytý'] = 'skrytý'
}}
end
table.insert(c.r, t.chyba)
end;
table.insert(c.r, '</cite>')
p.citCoinsPeriodikum(c)
return table.concat(c.r)
end
function p.citaceElPeriodika(frame)
local c = {
frame = frame
}
p.citaceInit(c)
c.type = 'citaceElPeriodika'
local t = {} -- temp
local i
table.insert(c.r, '<cite style="font-style:normal"')
p.citAnchorId(c)
table.insert(c.r, '>')
p.citAuthors(c, { maxAuthors = 7, honorCorporation = false })
p.citTitle(c)
p.citOtherPersons(c)
table.insert(c.r, " ")
p.citPeriodical(c)
table.insert(c.r, " ")
p.citPlacePublisher(c)
p.citDate(c)
p.citYearNumber(c)
p.citPage(c)
-- table.insert(c.r, ".")
p.citNotes(c)
p.citUrl(c)
p.citIssn(c)
p.citIsbn(c)
p.citDoi(c)
p.citPmid(c)
p.citId(c)
p.citLanguage(c)
if p.empty(c.args["periodikum"]) then
if c.localTest then
t.chyba = '{{chyba|Chybí povinný parametr: V šabloně {{šablona|Citace periodika}} je nutno určit zdrojové "<code>periodikum</code>" odkazu!|kategorie=Údržba:Chybná volání citačních šablon|skrytý=skrytý}}'
else
t.chyba = c.frame:expandTemplate{title = 'chyba', args = {
'Chybí povinný parametr: V šabloně '
.. c.frame:expandTemplate{title = 'šablona', args = {'Citace periodika'}}
.. ' je nutno určit zdrojové "<code>periodikum</code>" odkazu!',
['kategorie'] = 'Údržba:Chybná volání citačních šablon',
['skrytý'] = 'skrytý'
}}
end
table.insert(c.r, t.chyba)
end;
table.insert(c.r, '</cite>')
p.citCoinsPeriodikum(c)
return table.concat(c.r)
end
function p.citaceSborniku(frame)
local c = {
frame = frame
}
p.citaceInit(c)
c.type = 'citaceSborniku'
local t = {}
local i
table.insert(c.r, '<cite style="font-style:normal"')
p.citAnchorId(c)
table.insert(c.r, '>')
p.citAuthors(c, { maxAuthors = 3, honorCorporation = true })
p.citTitle(c)
table.insert(c.r, ' In: ')
p.citCompilers(c, { maxAuthors = 3, honorCorporation = true })
p.citCompilation(c)
p.citEdition(c)
p.citPlacePublisher(c)
p.citDate(c)
p.citNotes(c)
p.citUrl(c)
p.citIsbn(c)
p.citIssn(c)
p.citDoi(c)
p.citId(c)
p.citVolume(c)
p.citChapterPage(c)
p.citLanguage(c)
table.insert(c.r, '</cite>')
-- p.citCoinsSbornik(c)
return table.concat(c.r)
end
function p.debug(frame)
--[[
if frame.callParserFunction ~= nil and type(callParserFunction) == 'function' then
local aModule = require('Modul:Arguments')
local args = aModule.getArgs(frame)
end
--]]
-- local a = '';
-- return 'Titul: ' .. args.titul .. ';'
result = {}
table.insert(result, type(frame))
for k, v in pairs(frame) do
table.insert(result, k .. ' = ' .. type(v) .. '; ')
end
return table.concat(result)
end
function p.nowiki(c, txt)
if type(c.frame.extensionTag) == 'function' then
return c.frame:extensionTag('nowiki', (txt and txt or ''), {})
else
if not p.empty(txt) then
return "<nowiki>" .. txt .. "</nowiki>"
else
return "<nowiki/>"
end
end
end
function p.identity(x)
return x
end
function p.empty(x)
-- return x == nil or x == 0 or x == ""
return x == nil or x == ""
end
-- vrátí první neprázdný argument
function p.coalesce(x, y)
return ((x and x ~= "") and x or ((y and y ~= "") and y or ""))
end
function p.coalesceN(len, args)
for i = 1, len do
local v = args[i]
if v ~= nil and v ~= "" then
return v
end
end
return ""
end
function p.provideArg(args, x, y)
if args[x] == nil then
args[x] = args[y]
end
end
function p.convertUnderscoreArgs(args)
local t = {}
for k, v in pairs(args) do
k = tostring(k)
t.k, t.count = k:gsub('_', ' ')
if t.k ~= k then
args[t.k] = v
end
end
end
function p.provideArgs(args, map)
for src, dest in pairs(map) do
if (args[dest] == nil or args[dest] == "") and (args[src] ~= nil and args[src] ~= "") then
args[dest] = args[src]
end
end
end
function p.plural(num, s1, s2, s3)
num = tonumber(num) or 0
return (num == 1 and s1) or (1 < num and num < 5 and s2 or s3)
end
function p.lastChar(s)
if p.frame then
local len = mw.ustring.len(s)
return mw.ustring.sub(len, len)
else
return s:sub(s:len(), s:len())
end
end
-- nevim, zda lze nejak nastavit locale pro systemovy upper
function p.upper(s)
-- return "<span style='text-transform: uppercase'>" .. s .. "</span>"
if p.frame then
-- return p.frame:callParserFunction('uc', s)
return mw.ustring.upper(s)
else
return s:upper()
end
end
function p.upperFirst(s)
if p.frame then
return p.upper(mw.ustring.sub(s, 1, 1)) .. mw.ustring.sub(s, 2)
else
return p.upper(s:sub(1, 1)) .. s:sub(2)
end
end
function p.wikilink(odkaz, popis)
if not p.empty(odkaz) then
if not p.empty(popis) then
return "[[" .. odkaz .. "|" .. popis .. "]]"
else
return "[[" .. odkaz .. "]]"
end
else
return popis
end
end
function p.wikiextlink(odkaz, popis)
if not p.empty(odkaz) then
if not p.empty(popis) then
return "[" .. odkaz .. " " .. popis .. "]"
else
return "[" .. odkaz .. "]"
end
else
return popis
end
end
function p.date(args, params)
local r = {}
local postfix = ""
if (params and params.postfix) then
postfix = params.postfix
end
if not p.empty(args["datum" .. postfix]) then
table.insert(r, ""
.. args["datum" .. postfix]
)
elseif not p.empty(args["rok" .. postfix]) then
table.insert(r, ""
.. args["rok" .. postfix]
.. (not p.empty(args["měsíc" .. postfix])
and "-" .. args["měsíc" .. postfix] .. (not p.empty(args["den" .. postfix]) and "-" .. args["den" .. postfix] or "")
or ""
)
)
end
return table.concat(r)
end
function p.dateCs(args, params)
local r = {}
if not p.empty(args["datum"]) then
table.insert(r, ""
.. args["datum"]
)
elseif not p.empty(args["rok"]) then
table.insert(r, ""
.. (not p.empty(args["měsíc"])
and (not p.empty(args["den"]) and args["den"] .. ". " or "") .. args["měsíc"] .. " "
or ""
)
.. args["rok"]
)
end
return table.concat(r)
end
-- *** Pomocné funkce přidávající výstup do pole c.r ***
-- Odkazy pro harvardské citace
-- Srovnej cs:Modul:Footnotes / core() / grep CITEREF
-- Srovnej en:Module:Citation/CS1 fce / anchor_id() -- tam je trochu jiné řešení, bere v úvahu více polí
function p.citAnchorId(c)
local t = {}
if c.printAnchor then
if c.args.ref == "harv" then
t.r = {}
if not p.empty(c.args["rok"]) and not p.empty(c.args["příjmení1"]) then
for i = 1, 4 do
if not p.empty(c.args["příjmení" .. i]) then
table.insert(t.r, c.args["příjmení" .. i])
end
end
table.insert(t.r, c.args["rok"])
end
t.ref = "CITEREF" .. table.concat(t.r)
else
t.ref = "CITEREF" .. c.args.ref
end
table.insert(c.r, ' id="' .. t.ref .. '"')
end
end
function p.citAuthors(c, params)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}, i
if params.honorCorporation and not p.empty(c.args["korporace"]) then
t.lastAutor = c.args["korporace"]
table.insert(c.r, ""
.. p.wikilink(c.args["odkaz na korporaci"], c.args["korporace"])
)
else
for i = 1, params.maxAuthors do
p.citAuthor(t, c, i)
end
end
-- if not p.empty(c.args["korporace"]) or not p.empty(c.args["autor1"]) or not p.empty(c.args["příjmení1"]) then
if not p.empty(t.lastAuthor) then
if not p.empty(c.args["spoluautoři"]) then
t.lastAutor = c.args["spoluautoři"]
table.insert(c.r, ", " .. c.args["spoluautoři"])
end
end
if c.useHarvardFormat and not p.empty(c.args["rok"]) then
t.lastAutor = c.args["rok"]
table.insert(c.r, ", " .. c.args["rok"])
end
-- pokud posledni jmeno nekonci teckou, pak ji vlozime
if t.lastAutor ~= nil and p.lastChar(t.lastAutor) ~= '.' then
table.insert(c.r, ".")
end
end
function p.citAuthor(t, c, i)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
t["autor"] = nil
if not p.empty(c.args["autor" .. i]) then
t["autor"] = c.args["autor" .. i]
elseif not p.empty(c.args["příjmení" .. i]) then
t["autor"] = p.upper(c.args["příjmení" .. i])
.. (not p.empty(c.args["jméno" .. i]) and (', ' .. c.args["jméno" .. i]) or "")
;
end
if t["autor"] ~= nil then
t.lastAutor = t.autor
table.insert(c.r, ""
.. (i == 1 and "" or "; ")
.. p.wikilink(c.args["odkaz na autora" .. i], t.autor)
)
end
end
function p.citCompilers(c, params)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}, i
if params.honorCorporation and not p.empty(c.args["sestavující korporace"]) then
t.lastAutor = c.args["sestavující korporace"]
table.insert(c.r, ""
.. p.wikilink(c.args["odkaz na sestavující korporaci"], c.args["sestavující korporace"])
)
else
for i = 1, 1 do
p.citCompiler(c, t, i)
end
end
if not p.empty(t.lastAuthor) then
if not p.empty(c.args["spolusestavitelé"]) then
t.lastAutor = c.args["spolusestavitelé"]
table.insert(c.r, ", " .. c.args["spolusestavitelé"])
else
for i = 2, params.maxAuthors do
p.citCompiler(c, t, i)
end
end
end
-- pokud posledni jmeno nekonci teckou, pak ji vlozime
if t.lastAutor ~= nil and p.lastChar(t.lastAutor) ~= '.' then
table.insert(c.r, ".")
end
end
function p.citCompiler(c, t, i)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
t["sestavitel"] = nil
if not p.empty(c.args["sestavitel" .. i]) then
t["sestavitel"] = c.args["sestavitel" .. i]
elseif not p.empty(c.args["příjmení sestavitele" .. i]) then
t["sestavitel"] = p.upper(c.args["příjmení sestavitele" .. i])
.. (not p.empty(c.args["jméno sestavitele" .. i]) and (', ' .. c.args["jméno sestavitele" .. i]) or "")
;
end
if t["sestavitel"] ~= nil then
t.lastAutor = t.sestavitel
table.insert(c.r, ""
.. (i == 1 and "" or "; ")
.. p.wikilink(c.args["odkaz na sestavitele" .. i], t.sestavitel)
)
end
end
-- editor, preklad apod.
-- NOTE: texty převzaty ze šablony "citace monografie" V š. "citace periodika" byly drobné rozdíly ve std. textech.
function p.citOtherPersons(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}, i
t.dalsi = {}
if not p.empty(c.args["editoři"]) then
table.insert(t.dalsi, "příprava vydání " .. c.args["editoři"])
end
if not p.empty(c.args["redaktoři"]) then
table.insert(t.dalsi, "redakce " .. c.args["redaktoři"])
end
if not p.empty(c.args["překladatelé"]) then
table.insert(t.dalsi, "překlad " .. c.args["překladatelé"])
end
if not p.empty(c.args["ilustrátoři"]) then
table.insert(t.dalsi, "ilustrace " .. c.args["ilustrátoři"])
end
if not p.empty(c.args["fotografové"]) then
table.insert(t.dalsi, "fotografie " .. c.args["fotografové"])
end
if not p.empty(c.args["další"]) then
table.insert(t.dalsi, c.args["další"])
end
i = 0
for k, v in pairs(t.dalsi) do
t.v = i == 0 and " " .. p.upperFirst(v) or "; " .. v
table.insert(c.r, t.v)
i = i + 1
end
if i > 0 then
table.insert(c.r, ".")
end
end
function p.citTitle(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["titul"]) then
table.insert(c.r, " ")
if c.type == 'citaceMonografie' then
table.insert(c.r, ""
.. "''" .. p.nowiki(c)
.. p.wikilink(c.args["odkaz na titul"], c.args["titul"])
.. p.nowiki(c) .. "''"
.. (not p.empty(c.args["titul původní"]) and " (původním názvem: ''" .. p.nowiki(c) .. c.args["titul původní"] .. p.nowiki(c) .. "'')" or "")
.. "."
)
elseif c.type == 'citaceElMonografie' then
table.insert(c.r, ""
.. "''" .. p.nowiki(c)
.. p.wikilink(c.args["odkaz na titul"], c.args["titul"])
.. p.nowiki(c) .. "''"
.. " [" .. p.coalesceN(3, { c.args["druh nosiče"], c.args["formát"], "online" }) .. "]"
.. "."
)
else
table.insert(c.r, ""
.. p.wikilink(c.args["odkaz na titul"], c.args["titul"])
.. "."
)
end
end
end
function p.citCompilation(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["sborník"]) then
table.insert(c.r, " "
.. "''" .. p.nowiki(c)
.. p.wikilink(c.args["odkaz na sborník"], c.args["sborník"])
.. p.nowiki(c) .. "''"
.. "."
)
end
end
function p.citPeriodical(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["periodikum"]) then
table.insert(c.r, " "
.. "''" .. p.nowiki(c)
.. p.wikilink(c.args["odkaz na periodikum"], c.args["periodikum"])
.. p.nowiki(c) .. "''"
.. (c.type == "citaceElPeriodika"
and " " .. p.nowiki(c, "[") .. p.coalesceN(3, { c.args["druh nosiče"], c.args["formát"], "online" }) .. p.nowiki(c, "]")
or ""
)
.. "."
)
else
table.insert(c.r, '<small>Chybí název periodika!</small>')
end
end
function p.citEdition(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["vydání"]) then
table.insert(c.r, " "
.. c.args["vydání"] .. "."
.. (not p.empty(c.args["typ vydání"]) and ", " .. c.args["typ vydání"] or "")
.. " vyd."
)
end
end
function p.citVolume(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["svazek"]) then
table.insert(c.r, " "
.. (not p.empty(c.args["typ svazku"]) and p.upperFirst(c.args["typ svazku"]) or "Svazek")
.. " " .. c.args["svazek"] .. "."
)
end
end
-- dle ISO 690 platne od dubna 2011 uz neni vyzadovana mezera pred ":"
function p.citPlacePublisher(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if c.type == 'citacePeriodika' or c.type == 'citaceElMonografie' or c.type == 'citaceElPeriodika' then
table.insert(c.r, ""
.. " " .. (not p.empty(c.args["místo"]) and " " .. c.args["místo"] .. ": " or "")
.. "" .. (not p.empty(c.args["vydavatel"]) and p.wikilink(c.args["odkaz na vydavatele"], c.args["vydavatel"]) or "")
)
else
table.insert(c.r, ""
.. " " .. (not p.empty(c.args["místo"]) and c.args["místo"] or "[s.l.]")
.. ": " .. (not p.empty(c.args["vydavatel"]) and p.wikilink(c.args["odkaz na vydavatele"], c.args["vydavatel"]) or "[s.n.]")
)
end
end
-- NOTE: Neprehledny kod. Pokud mozno zjednodusit, pripadne take sjednotit format data.
function p.citDate(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
if c.type == 'citaceElMonografie' or c.type == 'citaceElPeriodika' then
if not p.empty(c.args["vydavatel"]) then
t.finalDot = true;
end
if not p.empty(c.args["datum"]) then
t.finalDot = true;
table.insert(c.r, ""
.. (not p.empty(c.args["vydavatel"]) and ", " or "")
.. c.args["datum"]
)
end
if not p.empty(c.args["datum aktualizace"]) then
t.finalDot = true;
if not p.empty(c.args["vydavatel"]) or not p.empty(c.args["datum"]) then
table.insert(c.r, ", " .. p.coalesce(c.args["typ aktualizace"], "rev."))
elseif not p.empty(c.args["místo"]) then
table.insert(c.r, " " .. p.coalesce(c.args["typ aktualizace"], "rev."))
else
table.insert(c.r, " " .. p.upperFirst(p.coalesce(c.args["typ aktualizace"], "rev.")))
end
table.insert(c.r, " " .. c.args["datum aktualizace"])
end
if not p.empty(c.args["datum přístupu"]) then
t.finalDot = true;
if not p.empty(c.args["vydavatel"]) or not p.empty(c.args["datum"]) or not p.empty(c.args["datum aktualizace"]) then
-- table.insert(c.r, ", ") -- TODO ???
table.insert(c.r, " ")
end
table.insert(c.r, "[cit. " .. c.args["datum přístupu"] .. "]");
-- TODO: {{#time: Y-m-d|{{{datum přístupu|{{{datum_přístupu}}}}}}}}] -- callParserFunction ??? // Celkove sjednotit zpracovani datumu
end
if (t.finalDot) then
table.insert(c.r, ". ")
end
elseif c.type == "citacePeriodika" then
t.datum = p.dateCs(c.args)
if c.useHarvardFormat and t.datum == c.args["rok"] then
t.datum = ""
end
if not p.empty(t.datum) then
c.flags.isDatum = true
table.insert(c.r, ""
.. (not p.empty(c.args["vydavatel"]) and ", " or "")
.. t.datum
)
end
else
t.datum = p.date(c.args)
if c.useHarvardFormat and t.datum == c.args["rok"] then
t.datum = ""
t.finalDot = true
end
if t.datum ~= "" then
table.insert(c.r, ", " .. t.datum)
elseif not p.empty(c.args["rok copyrightu"]) then
table.insert(c.r, ", c" .. c.args["rok copyrightu"])
end
if not p.empty(c.args["rok tisku"]) then
if not p.empty(c.args["rok"]) or not p.empty(c.args["rok copyrightu"]) then
table.insert(c.r, " (")
else
table.insert(c.r, ", ")
end
table.insert(c.r, p.date(c.args, { postfix = " tisku" }) .. " tisk")
if not p.empty(c.args["rok"]) or not p.empty(c.args["rok copyrightu"]) then
table.insert(c.r, ")")
end
end
if t.datum ~= "" or not p.empty(c.args["rok tisku"]) or t.finalDot then
table.insert(c.r, ".")
end
end
end
function p.citYearNumber(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["ročník"]) then
if c.flags.isDatum then
table.insert(c.r, ", " .. (not p.empty(c.args["typ ročníku"]) and c.args["typ ročníku"] or "roč.") )
else
table.insert(c.r, " " .. p.upperFirst(not p.empty(c.args["typ ročníku"]) and c.args["typ ročníku"] or "roč."))
end
table.insert(c.r, " " .. c.args["ročník"] )
end
if not p.empty(c.args["číslo"]) then
if not p.empty(c.args["ročník"]) then
table.insert(c.r, ""
.. ", "
.. (not p.empty(c.args["typ čísla"]) and c.args["typ čísla"] or "čís.")
)
else
table.insert(c.r, ""
.. " "
.. p.upperFirst(not p.empty(c.args["typ čísla"]) and c.args["typ čísla"] or "čís.")
)
end
table.insert(c.r, ""
.. " "
.. c.args["číslo"]
)
end
end
function p.citPage(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["strany"]) then
table.insert(c.r, ""
.. ", s. "
.. c.args["strany"]
.. "."
)
end
end
function p.citChapterPage(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
t.kapitola = ""
if not p.empty(c.args["kapitola"]) then
t.kapitola = " "
.. (not p.empty(c.args["typ kapitoly"]) and p.upperFirst(c.args["typ kapitoly"]) or "Kapitola")
.. " "
.. p.wikiextlink(c.args["url kapitoly"], c.args["kapitola"])
;
end;
table.insert(c.r, t.kapitola)
if c.type == 'citaceElMonografie' or c.type == 'citaceElPeriodika' then
-- TODO: postupne prodluzujici se testy OR se daji osetrit i elegantneji - pomocnou promennou
if not p.empty(c.args["číslování"]) then
table.insert(c.r, (not p.empty(t.kapitola) and ", " .. c.args["číslování"] or " " .. p.upperFirst(c.args["číslování"])))
end
if not p.empty(c.args["strany"]) then
table.insert(c.r, ""
.. ((not p.empty(c.args["kapitola"]) or not p.empty(c.args["číslování"])) and ", s" or " S")
.. ". "
.. c.args["strany"]
);
end
if not p.empty(c.args["lokace"]) then
table.insert(c.r, ""
.. ((not p.empty(c.args["kapitola"]) or not p.empty(c.args["číslování"]) or not p.empty(c.args["strany"]))
and ", " .. c.args["lokace"]
or " " .. p.upperFirst(c.args["lokace"])
)
);
end
if (not p.empty(c.args["kapitola"]) or not p.empty(c.args["číslování"]) or not p.empty(c.args["strany"]) or not p.empty(c.args["lokace"])) then
table.insert(c.r, ".")
end
else
if not p.empty(c.args["strany"]) then
table.insert(c.r, ""
.. (not p.empty(c.args["kapitola"]) and ", s" or " S")
.. ". "
.. c.args["strany"]
.. "."
);
end
end
end
-- pocetSvazku, pocetStranPlusPrilohy
function p.citNumberOfVolumesPagesAppendices(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
t.pocetSvazku = ""
if not p.empty(c.args["počet svazků"]) and (tonumber(c.args["počet svazků"]) or 0) > 1 then
t.pocetSvazku = ""
.. c.args["počet svazků"]
.. " "
.. p.plural(c.args["počet svazků"], "svazek", "svazky", "svazků")
;
end
if not p.empty(c.args["počet stran"]) then
t.pocetStranPlusPrilohy = ""
.. c.args["počet stran"] .. " s."
.. (not p.empty(c.args["přílohy"]) and ", " .. c.args["přílohy"] or "")
;
else
t.pocetStranPlusPrilohy = ""
.. (not p.empty(c.args["přílohy"]) and c.args["přílohy"] or "")
;
end
if t.pocetSvazku ~= "" then
if (t.pocetStranPlusPrilohy ~= "") then
table.insert(c.r, t.pocetSvazku .. " (" .. t.pocetStranPlusPrilohy .. ").")
else
table.insert(c.r, t.pocetSvazku .. ".")
end
else
if (t.pocetStranPlusPrilohy ~= "") then
table.insert(c.r, " " .. t.pocetStranPlusPrilohy)
if p.lastChar(t.pocetStranPlusPrilohy) ~= "." then
table.insert(c.r, ".")
end
end
end
end
function p.citEdition(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["edice"]) then
table.insert(c.r, " "
.. "("
.. p.upperFirst(c.args["edice"])
.. (not p.empty(c.args["subedice"]) and ". " .. p.upperFirst(c.args["subedice"]) or "")
.. (not p.empty(c.args["svazek edice"]) and p.nowiki(c, ';') .. " sv. " .. c.args["svazek edice"] or "")
.. ")."
)
end
end
function p.citUrl(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
if c.type == 'citacePeriodika' then
if not p.empty(c.args["url"]) then
t.afterUrl = {}
if not p.empty(c.args["formát"]) then
table.insert(t.afterUrl, c.args["formát"])
end
if not p.empty(c.args["datum přístupu"]) then
table.insert(t.afterUrl, "cit. " .. c.args["datum přístupu"])
elseif not p.empty(c.args["rok přístupu"]) then
table.insert(t.afterUrl, "cit. " .. c.args["rok přístupu"]
.. (not p.empty(c.args["měsíc přístupu"])
and "-" .. c.args["měsíc přístupu"] .. (not p.empty(c.args["den přístupu"]) and "-" .. c.args["den přístupu"] or "")
or ""
))
;
end
t.afterUrlStr = table.concat(t.afterUrl, ", ");
if t.afterUrlStr ~= "" then
t.afterUrlStr = " " .. p.nowiki(c, "[") .. t.afterUrlStr .. "]"
end
table.insert(c.r, ""
.. " [" .. c.args["url"] .. " Dostupné online]"
.. t.afterUrlStr
.. "."
)
end
if not p.empty(c.args["url alt"]) then
table.insert(c.r, " [" .. c.args["url alt"] .. " (Alternativní odkaz)]")
end
else
if not p.empty(c.args["url"]) then
table.insert(c.r, " "
.. p.wikiextlink(c.args["url"], p.coalesce(c.args["dostupnost"], "Dostupné online"))
.. "."
)
end
end
if c.type == 'citaceElMonografie' or c.type == 'citaceElPeriodika' then
if not p.empty(c.args["url2"]) then
table.insert(c.r, " "
.. p.coalesce(c.args["dostupnost2"], "Dostupné také na:")
.. " "
.. p.wikiextlink(c.args["url2"])
.. "."
)
end
if not p.empty(c.args["url3"]) then
table.insert(c.r, " "
.. p.coalesce(c.args["dostupnost3"], "Dále dostupné na:")
.. " "
.. p.wikiextlink(c.args["url3"])
.. "."
)
end
end
end
function p.citIsbn(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["isbn"]) then
-- OLD
-- table.insert(c.r, " [.[International Standard Book Number|ISBN].] [http://worldcat.org/isbn/" .. c.args["isbn"] .. " " .. c.args["isbn"] .. "].")
-- NEW
if c.localTest then
table.insert(c.r, " "
.. "{{ISBN|{{{isbn}}}}}"
.. (not p.empty(c.args["isbn2"]) and ", {{ISBN|{{{isbn2}}}}}" or "")
.. "."
)
else
table.insert(c.r, " "
.. c.frame:expandTemplate{title = 'ISBN', args = { c.args["isbn"] }}
.. (not p.empty(c.args["isbn2"]) and ", " .. c.frame:expandTemplate{title = 'ISBN', args = { c.args["isbn2"] }} or "")
.. "."
)
end
end
end
function p.citIssn(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["issn"]) then
table.insert(c.r, " [[International Standard Serial Number|ISSN]] [http://worldcat.org/issn/" .. c.args["issn"] .. " " .. c.args["issn"] .. "].")
end;
end
function p.citDoi(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["doi"]) then
table.insert(c.r, " [[Digital object identifier|DOI]]:[http://dx.doi.org/" .. mw.uri.encode(c.args["doi"]) .. " " .. c.args["doi"] .. "].")
end;
end
function p.citOclc(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["oclc"]) then
table.insert(c.r, " [[Online Computer Library Center|OCLC]] [http://worldcat.org/oclc/" .. mw.uri.encode(c.args["oclc"]) .. " " .. c.args["oclc"] .. "]")
end;
end
function p.citPmid(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["pmid"]) then
table.insert(c.r, " PMID " .. c.args["pmid"] .. ".")
end;
end
function p.citBibcode(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["bibcode"]) then
table.insert(c.r, " [[Bibcode]]: [http://adsabs.harvard.edu/abs/" .. mw.uri.encode(c.args["bibcode"]) .. c.args["bibcode"] .. "].")
end;
end
function p.citArxiv(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["arxiv"]) then
table.insert(c.r, " [[arXiv]]: [http://arxiv.org/abs/" .. mw.uri.encode(c.args["arxiv"]) .. c.args["arxiv"] .. "].")
end;
end
function p.citId(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["id"]) then
table.insert(c.r, " " .. c.args["id"] .. ".")
end;
end
function p.citNotes(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
if not p.empty(c.args["poznámky"]) then
table.insert(c.r, " " .. p.upperFirst(c.args["poznámky"]) .. ".")
end;
end
function p.citLanguage(c)
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
if not p.empty(c.args["jazyk"]) then
if c.localTest then
t.jazykem = c.args["jazyk"]
else
t.jazykem = c.frame:expandTemplate{title = 'jazykem', args = { c.args["jazyk"], toleruj = 'toleruj'}}
end
table.insert(c.r, " (" .. t.jazykem .. ")")
end;
end
function p.citCoinsMonografie(c)
if c.noCoins then return end
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
if c.type == 'citaceElMonografie' then
t.tplName = 'citaceelmonografie'
else
t.tplName = 'citacemonografie'
end
t.coins = 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rfr_id=info:sid/cs.wikipedia.org:template' .. t.tplName
.. '&rft.btitle=' .. mw.uri.encode(p.coalesce(c.args["titul"]))
.. (not p.empty(c.args["doi"]) and "&rft_id=info:doi/" .. mw.uri.encode(c.args["doi"]) or "")
.. (not p.empty(c.args["url"]) and "&rft_id=" .. mw.uri.encode(c.args["url"]) or "")
.. (not p.empty(c.args["isbn"]) and "&rft.isbn=" .. mw.uri.encode(c.args["isbn"]) or "")
.. (not p.empty(c.args["příjmení1"]) and "&rft.aulast=" .. mw.uri.encode(c.args["příjmení1"]) or "")
.. (not p.empty(c.args["jméno1"]) and "&rft.aufirst=" .. mw.uri.encode(c.args["jméno1"]) or "")
.. (not p.empty(c.args["autor1"]) and "&rft.au=" .. mw.uri.encode(c.args["autor1"]) or "")
.. (not p.empty(c.args["příjmení2"]) and "&rft.au=" .. mw.uri.encode(c.args["příjmení2"] .. ", " .. p.coalesce(c.args["jméno2"])) or "")
.. (not p.empty(c.args["autor2"]) and "&rft.au=" .. mw.uri.encode(c.args["autor2"]) or "")
.. (not p.empty(c.args["příjmení3"]) and "&rft.au=" .. mw.uri.encode(c.args["příjmení3"] .. ", " .. p.coalesce(c.args["jméno3"])) or "")
.. (not p.empty(c.args["autor3"]) and "&rft.au=" .. mw.uri.encode(c.args["autor3"]) or "")
.. (not p.empty(c.args["korporace"]) and "&rft.aucorp=" .. mw.uri.encode(c.args["korporace"]) or "")
.. (not p.empty(c.args["kapitola"]) and "&rft.atitle=" .. mw.uri.encode(c.args["kapitola"]) or "")
.. (not p.empty(c.args["místo"]) and "&rft.place=" .. mw.uri.encode(c.args["místo"]) or "")
.. (not p.empty(c.args["vydavatel"]) and "&rft.pub=" .. mw.uri.encode(c.args["vydavatel"]) or "")
.. (not p.empty(c.args["rok"]) and "&rft.date=" .. mw.uri.encode(c.args["rok"]) or "")
.. (not p.empty(c.args["vydání"]) and "&rft.edition=" .. mw.uri.encode(c.args["vydání"]) or "")
.. (not p.empty(c.args["počet stran"]) and "&rft.tpages=" .. mw.uri.encode(c.args["počet stran"]) or "")
.. (not p.empty(c.args["edice"]) and "&rft.series=" .. mw.uri.encode(c.args["edice"]) or "")
.. (not p.empty(c.args["strany"]) and "&rft.pages=" .. mw.uri.encode(c.args["strany"]) or "")
;
if c.localTest then
t.coins = "(COinS:" .. t.coins .. ")"
else
t.coins = c.frame:expandTemplate{title = 'COinS', args = { obj = t.coins }}
end
table.insert(c.r, t.coins)
end
function p.citCoinsPeriodikum(c)
if c.noCoins then return end
if c.trace then p.trace(c, debug.getinfo(1, "n")) end
local t = {}
if c.type == 'citaceElPeriodika' then
t.tplName = 'citaceelperiodika'
else
t.tplName = 'citaceperiodika'
end
t.coins = 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rfr_id=info:sid/cs.wikipedia.org:template' .. t.tplName
.. '&rft.jtitle=' .. mw.uri.encode(p.coalesce(c.args["periodikum"]))
.. (not p.empty(c.args["doi"]) and "&rft_id=info:doi/" .. mw.uri.encode(c.args["doi"]) or "")
.. (not p.empty(c.args["url"]) and "&rft_id=" .. mw.uri.encode(c.args["url"]) or "")
.. (not p.empty(c.args["titul"]) and "&rft.atitle=" .. mw.uri.encode(c.args["titul"]) or "")
.. (not p.empty(c.args["datum"])
and "&rft.date=" .. mw.uri.encode(c.args["datum"])
or (not p.empty(c.args["rok"])
and "&rft.date=" .. mw.uri.encode(c.args["rok"])
.. (not p.empty(c.args["měsíc"])
and "&rft.chron=" .. (not p.empty(c.args["den"])
and mw.uri.encode(c.args["den"]) .. ". "
or ""
) .. mw.uri.encode(c.args["měsíc"])
or ""
)
or ""
)
)
.. (not p.empty(c.args["ročník"]) and "&rft.volume=" .. mw.uri.encode(c.args["ročník"]) or "")
.. (not p.empty(c.args["číslo"]) and "&rft.issue=" .. mw.uri.encode(c.args["číslo"]) or "")
.. (not p.empty(c.args["strany"]) and "&rft.pages=" .. mw.uri.encode(c.args["strany"]) or "")
.. (not p.empty(c.args["issn"]) and "&rft.issn=" .. mw.uri.encode(c.args["issn"]) or "")
.. (not p.empty(c.args["příjmení1"]) and "&rft.aulast=" .. mw.uri.encode(c.args["příjmení1"]) or "")
.. (not p.empty(c.args["jméno1"]) and "&rft.aufirst=" .. mw.uri.encode(c.args["jméno1"]) or "")
.. (not p.empty(c.args["autor1"]) and "&rft.au=" .. mw.uri.encode(c.args["autor1"]) or "")
.. (not p.empty(c.args["příjmení2"]) and "&rft.au=" .. mw.uri.encode(c.args["příjmení2"] .. ", " .. p.coalesce(c.args["jméno2"])) or "")
.. (not p.empty(c.args["autor2"]) and "&rft.au=" .. mw.uri.encode(c.args["autor2"]) or "")
.. (not p.empty(c.args["příjmení3"]) and "&rft.au=" .. mw.uri.encode(c.args["příjmení3"] .. ", " .. p.coalesce(c.args["jméno3"])) or "")
.. (not p.empty(c.args["autor3"]) and "&rft.au=" .. mw.uri.encode(c.args["autor3"]) or "")
.. (not p.empty(c.args["korporace"]) and "&rft.aucorp=" .. mw.uri.encode(c.args["korporace"]) or "")
.. (not p.empty(c.args["místo"]) and "&rft.place=" .. mw.uri.encode(c.args["místo"]) or "")
.. (not p.empty(c.args["vydavatel"]) and "&rft.pub=" .. mw.uri.encode(c.args["vydavatel"]) or "")
.. (not p.empty(c.args["počet stran"]) and "&rft.tpages=" .. mw.uri.encode(c.args["počet stran"]) or "")
;
if c.localTest then
t.coins = "(COinS:" .. t.coins .. ")"
else
t.coins = c.frame:expandTemplate{title = 'COinS', args = { obj = t.coins }}
end
table.insert(c.r, t.coins)
end
return p