Moduł:Cytuj
Narzędzia
Ogólne
Drukuj lub eksportuj
W innych projektach
Moduł wspierający szablony cytowania.
auto
Implementacja {{Cytuj}}.
custom
Wsparcie dla wyspecjalizowanych szablonów cytowania. Wymaga jawnego podawania wszystkich pól opisanych w dokumentacji {{Cytuj}} w wywołaniu {{#invoke:Cytuj|custom|...}}.
Błędy należy zgłaszać na stronie Wikipedia:Kawiarenka/Kwestie techniczne.
local resources = mw.loadData("Moduł:Cytuj/dane")local access = mw.loadData("Moduł:Cytuj/dostęp")local function createCategories()local result = {}local mt = {__index = function(t,k)return resources.categories[k]or resources.categories.checkend,__newindex = function(t,k,v)error("Kategorie są tylko do odczytu")end,}setmetatable(result, mt)return resultendlocal categories = createCategories()local function killLinkInterwiki(value)-- usuń z treści wikilinki generowane przez szablon link-interwiki-- szablon oznacza jako podejrzane wartości z tekstem "Wikipedia"local result, count = string.gsub(value, "%[%[:d:Q[0-9]+#sitelinks%-wikipedia|%(inne języki%)%]%]", "")return resultendlocal function checkUri(uri)local urilen = #urifor _,v in ipairs(resources.supportedUriSchemas) doif (#v < urilen) and (string.lower(string.sub(uri,1, #v)) == v) thenreturn not string.match(uri, '%s')endendendlocal function softNoWiki(text)local result, count = string.gsub(text, "['%[%]{|}\"]", { ["\""] = """, ["'"] = "'", ["["] = "[", ["]"] = "]", ["{"] = "{", ["|"] = "|", ["}"] = "}"})-- przywróc [[szablon:J]] z kursywą tak/nieresult, count = string.gsub(result, "<span +style="font%-style: ?([a-z]+);?" +lang="([a-z%-]+)" *>", "<span style=\"font-style: %1;\" lang=\"%2\">")-- przywróc [[szablon:J]] gołyresult, count = string.gsub(result, "<span +lang="([a-z%-]+)" *>", "<span lang=\"%1\">")-- przywróć nowikiresult, count = string.gsub(result, "\127'"`UNIQ%-%-(nowiki%-[0-9A-F]+)%-QINU`"'\127", "\127'\"`UNIQ--%1-QINU`\"'\127")return resultendlocal function escapeUrl(url)local result, count = string.gsub(url, "[ '%[%]\"]", { [" "] = "%20", ["'"] = "%27", ["["] = "%5B", ["]"] = "%5D", ["\""] = "%22"})return resultendlocal function plainText(text)local result, count = string.gsub(text, "</?[Ss][Pp][Aa][Nn][^>]*>", "")return resultendlocal function first(data)return type(data) == "table" and data[1] or dataendlocal function determineMode(p)local detector = {}local count = 0for i, v in ipairs(resources.modes) dodetector[i] = vcount = count + 1enddetector[1] = false -- skip 'auto'count = count - 1for k, v in pairs(resources.params) dolocal arg = p.args[v.name]for i, w in ipairs(v.used) doif not w and arg then-- unexpected argumentif detector[i] thendetector[i] = falsecount = count - 1if count == 0 then-- the mode cannot be determinedbreakendendendendif count == 0 then-- the mode cannot be determinedbreakendendif count == 1 thenfor i, v in ipairs(detector) doif detector[i] thenreturn i, resources.COinS[i]endendendif detector[4] -- web?and p.args[resources.params.url.name]then-- promote to web but without COinSreturn 4, falseendfor i, v in ipairs(detector) doif detector[i] then-- if type is determined more than once-- use only the first one without COinSreturn i, falseendend-- in case nothing is selected-- use the auto mode as default fallbackreturn 1endlocal authorMetatable = {}local authorMethodtable = {}authorMetatable.__index = authorMethodtablelocal function checkPatterns(author, prefixes, suffixes)if author.exact thenreturn falseendif author.prefix and prefixes thenfor _, v in ipairs(prefixes) doif mw.ustring.match(author.prefix, v) thenreturn trueendendendif author.suffix and suffixes thenfor _, v in ipairs(suffixes) doif mw.ustring.match(author.suffix, v) thenreturn trueendendendreturn falseendauthorMethodtable.format = function(data, namefirst)if data.exact thenreturn data.exactendif namefirst and data.familynamefirst thennamefirst = falseendlocal builder = mw.html.create()local name = data.name and (#data.name > 0)local initials = data.nameinitials and (#data.nameinitials > 0)local namehint = nilif name and initials and (data.name ~= data.nameinitials) thennamehint = data.nameendif not data.familynamefirst and (name or initials) thenlocal before = namefirst and builder or builder:tag("span"):addClass("cite-name-before")if name thenbefore:tag("span"):addClass("cite-name-full"):wikitext(softNoWiki(data.name))endif initials thenbefore:tag("span"):css("display", "none"):addClass("cite-name-initials"):attr("title", namehint):wikitext(softNoWiki(data.nameinitials))endbefore:wikitext(" ")endbuilder:tag("span"):addClass("cite-lastname"):wikitext(softNoWiki(data.lastname))if not namefirst and (name or initials) thenlocal after = data.familynamefirst and builder or builder:tag("span"):css("display", "none"):addClass("cite-name-after")after:wikitext(" ")if name thenafter:tag("span"):addClass("cite-name-full"):wikitext(softNoWiki(data.name))endif initials thenafter:tag("span"):addClass("cite-name-initials"):attr("title", namehint):wikitext(softNoWiki(data.nameinitials))endif data.js thenafter:wikitext(",")endendif data.js thenbuilder:wikitext(" ", data.js)endreturn tostring(builder)endauthorMethodtable.towiki = function(data)if data.exact thenreturn data.exactendlocal result = {}local name = data.name and (#data.name > 0)if not data.familynamefirst and name thentable.insert(result,softNoWiki(data.name))table.insert(result, " ")endtable.insert(result, softNoWiki(data.lastname))if data.familynamefirst and name thentable.insert(result, " ")table.insert(result, softNoWiki(data.name))endreturn table.concat(result)endlocal function makeInitials(name)local nameinitials = mw.ustring.gsub(name, "(%w[Hh]?)[%w]*%.?([%s%-–—]?)%s*", "%1. ") -- zostaw początki słów (jedna litera + opcjonalne następujące 'h')nameinitials = mw.ustring.gsub(nameinitials, "%f[%w]%l%.%s", "") -- usuń inicjały z małych liternameinitials = mw.ustring.gsub(nameinitials, "([^C%W])[Hh]%.?%s", "%1. ") -- usuń drugie 'h' jeśli nie zaczyna się na 'C'nameinitials = mw.ustring.gsub(nameinitials, "(%u[Hh]?)[%.%s]*", "%1.") -- dodaj brakujące kropki i usuń zbędne spacjereturn mw.text.trim(nameinitials)endlocal function fixInitials(name)local result, _ = mw.ustring.gsub(name, "^(%uh?)%.?%s+(%uh?)%.", "%1.%2.") -- popraw inicjały na początkuresult, _ = mw.ustring.gsub(result, "%f[%a](%uh?)%.%s+(%uh?)%.", "%1.%2.") -- popraw inicjały w środkuresult, _ = mw.ustring.gsub(result, "%f[%a](%uh?)%.%s+(%uh?)%.", "%1.%2.") -- popraw kolejne inicjały w środkureturn resultendlocal function isInQuotes(text)if (string.len(text) < 2) thenreturn false;endlocal tstart = text:sub(1, 1);if (tstart ~= '"') thenreturn false;endlocal tend = text:sub(-1);if (tend ~= '"') thenreturn false;endreturn true; endlocal function parseAuthor(author)local result = {}if string.match(author, "\127") then -- wpisy z <nowiki> nie są analizowaneresult.exact = authorsetmetatable(result, authorMetatable)return resultendlocal author = mw.text.trim(author)local a = string.gsub(author, "\\[\\%.:]", { ["\\\\"]="\\", ["\\."]=",", ["\\:"]=";", })if a ~= author thenresult.exact = asetmetatable(result, authorMetatable)return resultendif resources.exactAuthors[author] thenresult.exact = authorsetmetatable(result, authorMetatable)return resultendlocal exactName = mw.ustring.match(author, "^%s*%*%s*(.*)$")if exactName thenresult.exact = mw.text.trim(exactName)if #result.exact == 0 thenreturn nilendsetmetatable(result, authorMetatable)return resultendlocal prefix0, link, description, suffix0 = mw.ustring.match(author, "^(.-)%[%[(.-)%|(.-)%]%](.*)$")if prefix0 thenresult.link = linkauthor = descriptionelseprefix0, link, suffix0 = mw.ustring.match(author, "^(.-)%[%[(.-)%]%](.*)$")if prefix0 thenauthor = linkresult.link = linkelseprefix0 = ""suffix0 = ""endendlocal prefix1, rest = mw.ustring.match(author, "^([%l%p%s]+)(.+)$")if not prefix1 thenrest = authorprefix1 = ""endlocal prefix = mw.text.trim(prefix0.." "..prefix1)if #prefix > 0 thenif mw.ustring.sub(prefix, -1) == "#" thenresult.familynamefirst = trueprefix = mw.text.trim(mw.ustring.match(prefix, "^(.-)#$"))endif #prefix > 0 thenresult.prefix = mw.ustring.gsub(prefix, "%s+", " ") -- collapse spacesendendlocal rest2, suffix = mw.ustring.match(rest, "^([%w%-%.%s]-)%s([%l%p%s]-)$")if not suffix thenrest2 = restsuffix = ""endsuffix = mw.text.trim(suffix.." "..suffix0)if #suffix > 0 thenresult.suffix = mw.ustring.gsub(suffix, "%s+", " ") -- collapse spacessuffix = " "..result.suffixfor i, v in ipairs(resources.js) doif mw.ustring.match(suffix, v[1]) thenresult.suffix = mw.text.trim(mw.ustring.gsub(suffix, v[1], ""))result.js = v[2]breakendendelsefor i, v in ipairs(resources.js) doif mw.ustring.match(rest2, v[1]) thenrest2 = mw.text.trim(mw.ustring.gsub(rest2, v[1], ""))result.js = v[2]breakendendendlocal lastname, name = mw.ustring.match(rest2, "%s*([^,]-)%s*,%s*(.-)%s*$")if not lastname thenif result.familynamefirst thenlastname, name = mw.ustring.match(rest2, "%s*(%u[%l%d%p]*)%s+(.-)%s*$")elselocal prefix2name, lastname, prefix2 = mw.ustring.match(rest2, "%s*(.-)%s+((%l[%l%p]%l?)%u[%w%p]-)%s*$")if not resources.lastnamePrefixes[prefix2] thenname, lastname = mw.ustring.match(rest2, "%s*(.-)%s+(%u[%w%p]-)%s*$")endendelseif resources.lastnamePrefixes[prefix1] thenlastname = prefix1 .. lastnameelseif resources.lastnamePrefixes[prefix1] == false thenname = name.." "..mw.text.trim(prefix1)endif not lastname thenresult.lastname = mw.text.trim(rest2)elseresult.name = fixInitials(name)result.lastname = lastnameresult.nameinitials = makeInitials(name)endif #result.lastname == 0 thenreturn nilendsetmetatable(result, authorMetatable)return resultendlocal function parseDate(date, month, year, patch)local result = {}-- parse full datelocal y, m, d = false, false, falsey, m, d = mw.ustring.match(date, "(%d%d%d%d)[%-%s%./](%d%d?)[%-%s%./](%d%d?)")if y and patch and (date == (y.."-01-01")) thenresult.year = tonumber(y)result.month = falseresult.day = falsereturn result, trueendif not y thend, m, y = mw.ustring.match(date, "(%d%d?)[%-%s%.](%d%d?)[%-%s%.](%d%d%d%d)")if not y theny, m, d = mw.ustring.match(date, "(%d%d%d%d)%s*(%w+)%s*(%d%d?)")if not y thend, m, y = mw.ustring.match(date, "(%d%d?)%s*(%w+)%s*(%d%d%d%d)")endif m thenm = resources.monthparser[mw.ustring.lower(m)]if not m theny = falsem = falsed = falseendendendendif y theny = tonumber(y)m = tonumber(m)d = tonumber(d)endif y and ((d > 31) or (m > 12) or (d < 1) or (m < 1)) then y = falsem = falsed = falseelseif y thenresult.year = yresult.month = mresult.day = dreturn result, falseend-- parse year and monthy, m = mw.ustring.match(date, "(%d%d%d%d)[%-%s%./](%d%d?)")if not y thenm, y = mw.ustring.match(date, "(%d%d?)[%-%s%./](%d%d%d%d)")if not y theny, m = mw.ustring.match(date, "(%d%d%d%d)%s*(%w+)")if not y thenm, y = mw.ustring.match(date, "(%w+)%s*(%d%d%d%d)")endif m thenm = resources.monthparser[mw.ustring.lower(m)]if not m theny = falsem = falseendendendendif y theny = tonumber(y)m = tonumber(m)endif y and ((m > 12) or (m < 1)) then y = falsem = falseelseif y thenresult.year = yresult.month = mreturn result, falseend-- try any method to extract year or monthif not y theny = mw.ustring.match(date, "[%s%p%-–]?(%d%d%d%d)[%s%p%-–]?")if y theny = tonumber(y)endif y thenresult.year = yendendif y thenif not m thenm = mw.ustring.match(date, "[%s%p%-–]?(%w+)[%s%p%-–]?")if m thenm = resources.monthparser[mw.ustring.lower(m)]endif m thenresult.month = mendendelse-- reset only monthresult.month = nilendif y thenreturn result, falseendendlocal function collectAuthors(author, checkForAltFormat)if not author thenreturnend-- Obsługa cudzysłowów w autorach (treat quoted authors as-is)if (isInQuotes(mw.text.trim(author))) thenlocal strippedAuthor = mw.text.trim(author, '"\t\r\n\f ')return { items = {strippedAuthor}, more=false, comma=false, etal=false, separator="" }endfunction findUtf8CharAt(text, at)local back = falseif at < 0 thenat = #text + at + 1back = trueendwhile at > 1 dolocal b = string.byte(text, at, at)if (b < 128) or (b >= 192) thenbreakendat = at - 1endreturn back and at - #text - 1 or atendlocal etal = falselocal authorTail = #author <= 50 and author or string.sub(author, findUtf8CharAt(author, -50))for i, p in ipairs(resources.etalPatterns) dolocal a, e = string.match(authorTail, p)if a thenauthor = string.sub(author, 1, #author-#e)etal = ebreakendendfunction decodeEntity(s)local result = nillocal hex = string.match(s, "^&#[xX]([0-9A-Fa-f]+);$")if hex thenresult = mw.ustring.char(tonumber(hex, 16))elselocal dec = string.match(s, "^&#([0-9]+);$")if dec thenresult = mw.ustring.char(tonumber(dec, 10))elseif resources.htmlEntities[s] thenresult = mw.ustring.char(resources.htmlEntities[s])elsereturn string.gsub(s, ";", "\\:")endendif result == ";" thenreturn "\\:"elseif result == "," thenreturn "\\."elseif result == "\\" thenreturn "\\\\"elsereturn resultendendlocal authorHead = #author <= 500 and author or string.sub(author, 1, findUtf8CharAt(author, 500) - 1)local result = {}local esc1 = string.gsub(authorHead, "\\", "\\\\")local esc2 = string.gsub(esc1, "&#?[a-zA-Z0-9]+;", decodeEntity)local splitter = string.match(esc2, ";") and ";" or ","local authors = mw.text.split(esc2, splitter.."%s*", false)local nth = falselocal count = #authorsif (#authorHead < #author) and (count > 4) thenif count > 5 thentable.remove(authors, count)count = count - 1endlocal at, _ = string.find(authorHead, authors[count], 1, true)nth = string.sub(author, at)table.remove(authors, count)count = count - 1endlocal alt = falseif (splitter == ",") and checkForAltFormat thenlocal altAuthors = {}alt = truefor i, v in ipairs(authors) dolocal n0 = ""local s, n = mw.ustring.match(v, "^(%u%l+)%s(%u+)%.?$")if not s thens, n = mw.ustring.match(v, "^(%u%l+[%s%-–]%u%l+)%s(%u+)%.?$")endif not s thenn0, s, n = mw.ustring.match(v, "^(%l%l%l?)%s(%u%l+)%s(%u+)%.?$") -- de, von, van, der etc.endif not s thenalt = falsebreakendlocal initials, _ = mw.ustring.gsub(n, "(%u)", "%1.")if #n0 > 0 thenn0 = " "..n0endtable.insert(altAuthors, s..", "..initials..n0)endif alt thenauthors = altAuthorssplitter = ";"endendfor i, v in ipairs(authors) dolocal author = parseAuthor(v)if author thentable.insert(result, author)endendif #result == 0 thenreturnendlocal check = falseif alt thencheck = "alt"elseif (#result == 2) and (splitter == ",") thencheck = not result[1].link and not result[1].exact and not result[1].nameornot result[2].link and not result[2].exact and not result[2].nameif check thenif result[1].lastname and not result[1].name and not result[2].exactand not mw.ustring.match(result[1].lastname, "%S%s+%S") thenlocal oneAuthor = parseAuthor(author)if oneAuthor thentable.remove(result,2)result[1] = oneAuthorcheck = falseendendendif check thenmw.logObject(result,"przecinek u autora")endendreturn { items = result, more=nth, comma = check, etal = etal, separator=splitter.." " }endlocal function formatAuthors(authors, useDecorations, nextgroup, etalForm)local count = #authors.itemsif count == 0 thenreturn nil, falseendlocal suffix = function(author)if useDecorations thenfor _, v in ipairs(resources.authorFunc) doif checkPatterns(author, v.prefixes, v.suffixes) thenreturn v.appendendendendreturn ""endlocal formatter = function(author)local a = author:format(nextgroup)local r = author.link and ("[["..author.link.."|"..a.."]]") or areturn r..suffix(author)endif count == 1 thenlocal a1 = formatter(authors.items[1])local etal = authors.etal and (etalForm or " i inni") or ""return a1..etal, falseendlocal result = {}table.insert(result, formatter(authors.items[1]))if not authors.etal and (count <= 3) thentable.insert(result, ", ");table.insert(result, formatter(authors.items[2]))if count == 3 thentable.insert(result, ", ");table.insert(result, formatter(authors.items[3]))endreturn table.concat(result, ""), falseendlocal title = {}for i = 1, count dotable.insert(title, authors.items[i]:towiki()..suffix(authors.items[i]))endif authors.more thentable.insert(title, authors.more)endtable.insert(result, "<span class=\"cite-at-al\" title=\"")table.insert(result, table.concat(title, authors.separator))if authors.etal thentable.insert(result, etalForm or " i inni")endtable.insert(result, "\">")table.insert(result, etalForm or " i inni")table.insert(result, "</span>")return table.concat(result, ""), trueendlocal function collectLanguages(value)if value thenlocal result = {}local values = mw.text.split(value, "%s+")for _, v in ipairs(values) doif #v > 0 thentable.insert(result, v)endendif #result > 0 thenreturn resultendendreturn nilendlocal function splitFileLink(link)local linkTitle = string.match(link, "^:(.+)$")if not linkTitle thenreturn link, falseendlocal title = mw.title.new(link)if not title thenreturn link, falseendmw.logObject(title.text, "splitFileLink - title.text")if title.namespace == 6 thenlocal name, ext = mw.ustring.match(title.text, "(.-)%.(%a+)$")if ext and resources.wikilinks.extensions[mw.ustring.lower(ext)] thenreturn name, extendelseif #title.interwiki > 0 thenlocal prefix, name, ext = mw.ustring.match(title.text, "(%a+):(.-)%.(%a+)$")if prefix and resources.wikilinks.files[mw.ustring.upper(prefix)] and ext and resources.wikilinks.extensions[mw.ustring.lower(ext)] thenreturn name, extendendreturn link, falseendlocal function splitWikiLink(text)local link, description = mw.ustring.match(text, "^%[%[(.-)%|(.-)%]%]$")if link thenlocal name, ext = splitFileLink(link)return description, link, false, extendlocal link = mw.ustring.match(text, "^%[%[(.-)%]%]$")if link thenlocal name, ext = splitFileLink(link)return name or link, link, false, extendlocal link, description = mw.ustring.match(text, "^%[(%S*)%s+(.-)%]$")if link and checkUri(link) thenreturn description, false, link, falseendreturn text, false, false, falseendlocal function detectArchive(url)local uri = mw.uri.new(url)local detectors = resources.archiveDecoders.services[resources.archiveDecoders.hosts[uri.host]]if detectors then--mw.logObject(uri.host,"detectArchive uri.host")--mw.logObject(uri.relativePath,"detectArchive uri.relativePath")--mw.logObject(resources.archiveDecoders.hosts[uri.host],"detectArchive service")for i, v in ipairs(detectors) dolocal pattern = v.patternlocal decoder = resources.archiveDecoders.decoders[v.decoder]if pattern and decoder thenlocal items = { mw.ustring.match(uri.relativePath, pattern) }if #items > 0 then--mw.logObject(items[decoder.link],"detectArchive link")--mw.logObject(items[decoder.year].."-"..items[decoder.month].."-"..items[decoder.day],"detectArchive date")return items[decoder.link], items[decoder.year].."-"..items[decoder.month].."-"..items[decoder.day]endendendendreturn false, falseendlocal function isAutoGeneratedUrl(url)local address = string.gsub(url, "^https?:", "")for k, v in pairs(resources.params) doif v.link thenlocal links = type(v.link) == "table" and v.link or { v.link }for _, vlink in ipairs(links) dolocal prefix = string.gsub(vlink, "^https?:", "")if (#address > #prefix) and (string.sub(address, 1, #prefix) == prefix) thenreturn v.nameendendendendreturn falseendlocal function loadCitation(frame, mode)local result = {}-- copy parametersfor k, v in pairs(resources.params) doif v.used[mode] thenlocal value = frame.args[v.name]if value thenvalue = mw.text.trim(value)if #value > 0 thenresult[k] = valueendendif (v.used[mode] == "!") and not result[k] then-- simulate missing mandatory parameterresult[k] = "{{{"..v.name.."}}}"if not result.missing thenresult.missing = v.nameendendendend-- check url argumentif result.url == "nie" thenresult.url = falseelseif result.url thenif not checkUri(result.url) thenlocal unstrip = mw.text.unstripNoWiki( result.url )result.url = falseif unstrip thenresult.urlnowiki = checkUri(unstrip)endendend-- translate some parameterslocal altAuthorParser = falseif result.journal and result.pmid and result.author and not result.chapterauthor and not result.editor and not result.others thenaltAuthorParser = trueendresult.chapterauthor = collectAuthors(result.chapterauthor, false)result.author = collectAuthors(result.author, altAuthorParser)result.lang = collectLanguages(result.lang)result.editor = collectAuthors(result.editor, false)result.others = collectAuthors(result.others, false)-- parse main bibliographic dateif result.date thenlocal bibDate = falselocal bibDateHint = falselocal coinsDate = falselocal odnDate = falsefor _, v in ipairs(resources.bibDates) dofor _, p in ipairs(v.patterns) dolocal bib, c = mw.ustring.gsub(result.date, p, v.show)if bib and (c > 0) thenbibDate = bibbibDateHint = v.hintif v.coins thenlocal cd, cc = mw.ustring.gsub(result.date, p, v.coins)if cd and (cc > 0) thencoinsDate = cdendendif v.odn thenlocal od, oc = mw.ustring.gsub(result.date, p, v.odn)if od and (oc > 0) thenodnDate = odendendbreakendif bibDate thenbreakendendendif bibDate thenresult.date = { bib = bibDate, hint = bibDateHint, coins = coinsDate, odn = odnDate }elselocal date, patch = parseDate(result.date or "", false, false, true)if date thendate.coins = (patch and date.year)or (date.day and string.format("%04d-%02d-%02d", date.year, date.month, date.day)) or (date.month and string.format("%04d-%02d", date.year, date.month))or date.yeardate.odn = date.yearelseif result.date thenresult.badDate = trueendresult.date = dateresult.patchCitoidDate = patchendend-- fix other datesif result.accessdate thenresult.accessdate = parseDate(result.accessdate or "", false, false, false)if result.accessdate and not result.accessdate.day thenresult.badAccessDate = trueresult.accessdate = nilelseif not result.accessdate thenresult.badAccessDate = trueendend-- allow more ISBN numbersif result.isbn then-- TODO allow "(info)" for custom description followed each identifierresult.isbn = mw.text.split(result.isbn, "%s+")endif result.title thenlocal urlresult.title, result.titlelink, url, result.titleext = splitWikiLink(result.title)if url or result.titlelink thenif result.url and (#result.url > 0) and (result.url ~= "{{{url}}}") thenresult.urlWarning = trueendresult.url = urlendendif result.chapter thenresult.chapter, result.chapterlink, result.chapterurl, result.chapterext = splitWikiLink(result.chapter)endif result.journal thenlocal journalAbbr, _ = mw.ustring.gsub(result.journal, "[%.%s]+", " ")mw.logObject(journalAbbr, "journalAbbr")if mw.ustring.match(journalAbbr, "^[%a%s&]+[,:]?[%a%s&]+%d?$") -- kandydat na skrót powinien mieć tylko litery z opcjonalnymi odstępami i co najwyżej jednym dwukropkiem lub przecinkiemor mw.ustring.match(journalAbbr, "^[%a%s&]+%([%a%s&,:]+%d*%)$") then -- opcjonalnie jakieś dookreślenie w nawiasielocal expandedJournal = mw.loadData("Moduł:Cytuj/czasopisma")[mw.text.trim(journalAbbr)]if expandedJournal thenresult.originalJournal = result.journalresult.journal = expandedJournalendendresult.journal, result.journallink, result.journalurl, result.journalext = splitWikiLink(result.journal)endif result.journal and not result.journallink and not result.journalurl and not result.title and result.url thenresult.journalurl = result.urlresult.url = falseendif result.url thenlocal n = isAutoGeneratedUrl(result.url)if n thenresult.rejectedurl = trueif result[n] thenresult.url = falseendendendif result.chapterurl thenlocal n = isAutoGeneratedUrl(result.chapterurl)if n thenresult.rejectedurl = trueif result[n] thenresult.chapterurl = falseendendendif result.journalurl thenlocal n = isAutoGeneratedUrl(result.journalurl)if n thenresult.rejectedurl = trueif result[n] thenresult.journalurl = falseendendendif not result.archive and result.url thenlocal al, ad = detectArchive(result.url)if al thenresult.archiveurl = trueresult.archive = result.urlresult.url = alif ad then result.archived = ad endendelseif not result.archive and result.chapterurl thenlocal al, ad = detectArchive(result.chapterurl)if al thenresult.archivechapter = trueresult.archive = result.chapterurlresult.chapterurl = alif ad then result.archived = ad endendelseif not result.archive and result.journalurl thenlocal al, ad = detectArchive(result.journalurl)if al thenresult.archivejournal = trueresult.archive = result.journalurlresult.journalurl = alif ad then result.archived = ad endendelseif result.archive and not result.archived thenlocal al, ad = detectArchive(result.archive)if ad and not result.archived then result.archived = adendendif result.archive thenif result.chapterurl and not result.url thenresult.archivechapter = trueelseif result.title thenresult.archiveurl = trueelseif result.journal thenresult.archivejournal = trueendendif result.archived thenresult.archived = parseDate(result.archived or "", false, false, false)if result.archived and not result.archived.day thenresult.badArchivedDate = trueresult.archived = nullelseif not result.archived thenresult.badArchivedDate = trueendendif result.edition and result.journal and not result.volume and not result.issue thenlocal volume, issue = mw.ustring.match(result.edition, "^%s*([^%(]+)%s+%((.-)%)%s*$");if volume thenresult.volume = volumeresult.issue = issueresult.edition = nilendendif result.pmc and (#result.pmc > 3) and (mw.ustring.sub(result.pmc, 1, 3) == "PMC") thenresult.pmc = mw.ustring.sub(result.pmc, 4, #result.pmc)endif result.accessKind thenresult.accessKind = access.choice[result.accessKind]result.unknownAccess = not result.accessKindelseresult.accessKind = (result.pmc and "open")or access.doi[doiPrefix]or access.journals[result.journal]endif result.doi thenresult.doi = mw.text.split(result.doi, '%s+', false)for i, v in ipairs(result.doi) dolocal doiPrefixlocal doiSuffixdoiPrefix, doiSuffix = mw.ustring.match(v, "^10%.([^/]+)/(.+)$")if (doiPrefix == "2307") and not result.jstor thenresult.jstor = doiSuffixendif not result.accessKind and not result.unknownAccess thenresult.accessKind = access.doi[doiPrefix]endendendif result.patent thenmw.logObject(result.patent,"input:patent")local patentPatterns = mw.loadData("Moduł:Cytuj/patent")local patent = nilfor _, v in ipairs(patentPatterns) doif string.match(result.patent, v.pattern) thenlocal patentNumber, _ = string.gsub(result.patent, v.pattern, v.number or "%1")local patentCountry, _ = string.gsub(result.patent, v.pattern, v.country)local patentInfo = v.info or patentPatterns.ccinfo[patentCountry]if (result.url == nil) and v.url thenlocal url, _ = string.gsub(result.patent, v.pattern, v.url)if checkUri(url) thenresult.url = urlendendlocal patentTitleif v.title thenpatentTitle, _ = string.gsub(result.patent, v.pattern, v.title)elseif patentInfo thenpatentTitle = string.format('<span title="%s">%s %s</span>', patentInfo, patentCountry, patentNumber)elsepatentTitle = patentCountry.." "..patentNumberendpatent = {number = patentNumber,application = v.application,country = patentCountry,title = patentTitle,}breakendendresult.patent = patentmw.logObject(result.patent,"parsed:patent")end-- return collected parameters if there is anyfor k, v in pairs(result) doreturn resultend-- there are no supported parametersreturn nilendlocal function prepareOdnIdentifier(data)if not data.odn or (#data.odn == 0) or (data.odn == "nie") thenreturn nilenddata.diferentiator = mw.ustring.match(data.odn, "^([a-z])$") or falseif data.odn ~= "tak" and not data.diferentiator then-- TODO return only CITEREF...return data.odnendlocal authors = data.chapterauthor or data.author or data.editorif not authors then-- required custom identifierreturn nilendreturn "CITEREF".. (authors.items[1] and (authors.items[1].lastname or authors.items[1].exact) or "").. (authors.items[2] and (authors.items[2].lastname or authors.items[2].exact) or "").. (authors.items[3] and (authors.items[3].lastname or authors.items[3].exact) or "").. (authors.items[4] and (authors.items[4].lastname or authors.items[4].exact) or "").. (data.date and data.date.odn or "").. (data.diferentiator or "")endlocal function bookCOinS(data)local authors = data.chapterauthor or data.authorlocal result = {}result["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:book"if data.chapter and (#data.chapter > 0) thenresult["rft.gengre"] = "bookitem"result["rft.atitle"] = plainText(data.chapter)result["rft.btitle"] = plainText(data.title)elseif data.work and (#data.work > 0) thenresult["rft.gengre"] = "bookitem"result["rft.atitle"] = plainText(data.title)result["rft.btitle"] = plainText(data.work)elseresult["rft.btitle"] = plainText(data.title)result["rft.gengre"] = "book"endif authors thenif authors.items[1].lastname then result["rft.aulast"] = authors.items[1].lastname endif authors.items[1].name then result["rft.aufirst"] = authors.items[1].name endif authors.items[1].exact then result["rft.au"] = authors.items[1].exact endendif data.date and data.date.coins thenresult["rft.date"] = data.date.coinsendif data.series then result["rft.series"] = data.series endif data.edition then result["rft.edition"] = data.edition endif data.publisher then result["rft.pub"] = data.publisher endif data.place then result["rft.place"] = data.place endif data.pages then result["rft.pages"] = data.pages endif data.isbn then result["rft.isbn"] = data.isbn[1] endif data.issn then result["rft.issn"] = data.issn endlocal params = {"ctx_ver=Z39.88-2004",mw.uri.buildQueryString(result),}if data.oclc then table.insert(params, mw.uri.buildQueryString( {rft_id = "info:oclcnum/"..data.oclc})) endif data.doi thenfor _, v in ipairs(data.doi) dotable.insert(params, mw.uri.buildQueryString( {rft_id = "info:doi/"..v}))endendif data.url then table.insert(params, mw.uri.buildQueryString( {rft_id = data.url})) endif data.pmid then table.insert(params, mw.uri.buildQueryString( {rft_id = "info:pmid/"..data.pmid})) endif data.lccn then table.insert(params, mw.uri.buildQueryString( {rft_id = "info:lccn/"..data.lccn})) endlocal coinsData = table.concat(params, "&")return coinsData;endlocal function journalCOinS(data)local result = {}result["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:journal"local gengre = (data.arxiv and (#data.arxiv > 0)) and "preprint" or "article"result["rft.gengre"] = data.title and gengre or "journal"if data.title then result["rft.atitle"] = plainText(data.title) endresult["rft.jtitle"] = plainText(data.journal)if data.chapter then result["rft.atitle"] = plainText(data.chapter) endif data.date and data.date.coins thenresult["rft.date"] = data.date.coinsendif data.title and author thenif author[1].lastname then result["rft.aulast"] = author[1].lastname endif author[1].name then result["rft.aufirst"] = author[1].name endif author[1].exact then result["rft.au"] = author[1].exact endendif data.volume then result["rft.volume"] = data.volume endif data.issue then result["rft.edition"] = data.issue endif data.publisher then result["rft.pub"] = data.publisher endif data.place then result["rft.place"] = data.place endif data.pages then result["rft.pages"] = data.pages endif data.issn then result["rft.issn"] = data.issn endlocal params = {"ctx_ver=Z39.88-2004",mw.uri.buildQueryString(result),}if data.pmid then table.insert(params, mw.uri.buildQueryString( {rft_id = "info:pmid/"..data.pmid})) endif data.pmc then table.insert(params, mw.uri.buildQueryString( {rft_id = "info:pmc/"..data.pmc})) endif data.doi thenfor _, v in ipairs(data.doi) dotable.insert(params, mw.uri.buildQueryString( {rft_id = "info:doi/"..v}))endendif data.url then table.insert(params, mw.uri.buildQueryString( {rft_id = data.url})) endlocal coinsData = table.concat(params, "&")return coinsData;endlocal function webCOinS(data)local result = {}result["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:journal"result["rft.gengre"] = "unknown"if data.title then result["rft.atitle"] = plainText(data.title) endresult["rft.jtitle"] = plainText(data.published)if data.date and data.date.coins thenresult["rft.date"] = data.date.coinsendif data.title and author thenif author[1].lastname then result["rft.aulast"] = author[1].lastname endif author[1].name then result["rft.aufirst"] = author[1].name endif author[1].exact then result["rft.au"] = author[1].exact endendlocal params = {"ctx_ver=Z39.88-2004",mw.uri.buildQueryString(result),}if data.url then table.insert(params, mw.uri.buildQueryString( {rft_id = data.url})) endlocal coinsData = table.concat(params, "&")return coinsData;endlocal function patentCOinS(data)local result = {}result["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:journal"if data.title then result["rft.title"] = plainText(data.title) endresult[data.patent.application and "rft.applnumber" or "rft.number"] = data.patent.numberresult["rft.cc"] = data.patent.countryif data.date and data.date.coins thenresult[data.patent.application and "rft.appldate" or "rft.date"] = data.date.coinsendif author thenif author[1].lastname then result["rft.aulast"] = author[1].lastname endif author[1].name then result["rft.aufirst"] = author[1].name endif author[1].exact then result["rft.au"] = author[1].exact endend-- rft.assignee = author (wszyscy?)-- rft.inventor = others (wszyscy?)local params = {"ctx_ver=Z39.88-2004",mw.uri.buildQueryString(result),}if data.url then table.insert(params, mw.uri.buildQueryString( {rft_id = data.url})) endlocal coinsData = table.concat(params, "&")return coinsData;endlocal function COinS(data, coinsFormat)if resources.abbrTitles[data.title] then-- full citation is elsewherereturn falseelseif (coinsFormat == "info:ofi/fmt:kev:mtx:book") and data.title and (#data.title > 0) then-- title is mandatory element for booksreturn bookCOinS(data)elseif coinsFormat == "info:ofi/fmt:kev:mtx:journal" and data.journal and (#data.journal > 0) and (not data.published or (data.journal ~= data.published)) then-- journal title is mandatory element for journalsreturn journalCOinS(data)elseif coinsFormat == "info:ofi/fmt:kev:mtx:journal" and data.published and (#data.published > 0) thenreturn webCOinS(data)elseif coinsFormat == "info:ofi/fmt:kev:mtx:patent" and data.patent thenreturn patentCOinS(data)elseif data.title and (#data.title > 0) then-- treat web or unrecognized citations as bookreturn bookCOinS(data)elsereturn falseendend--[[Format edition (number or marc 250$a).Different for journal.Tests: Wikipedysta:Nux/test Cytuj wydanie--]]local function formatEdition(edition, journal) local prefix = false if not journal then prefix = true if string.find(edition, "[Ww]yd[a. ]") then prefix = false elseif string.find(edition, "[Ee]dition") then prefix = false end end return (prefix and "wyd. " or "") .. editionend--[[Main.--]]local function Cite(p, mode, appendText, firewall)-- debug helperif p.args[3] then mw.log(p.args[3]) endlocal customMode = mode-- try to determine type basing on passed parameterslocal coinsFormat = resources.COinS[mode]if not mode thenmode, coinsFormat = determineMode(p)endlocal data = loadCitation(p, mode)if not data then local result = mw.html.create("span") :addClass("problemy"):attr("aria-hidden", "true"):attr("data-nosnippet", ""):attr("data-problemy", "Brak wyników w szablonie cytowania") if mw.title.getCurrentTitle().namespace == 0 then result:wikitext(categories.empty) end result:wikitext(" ") -- thin space return tostring(result)end-- convert web page to book for old dateif (mode == 4) and data.date and data.date.odn thenlocal year = tonumber(data.date.odn)if year and (year < 1990) thenmode = 2endendif data.missing then-- do not produce any COiNS info-- if some mandatory argument is missingcoinsFormat = falseendlocal builder = mw.html.create("cite")builder:addClass("citation"):addClass(resources.cite[mode] or nil):addClass(access.class[data.accessKind]):attr("id", prepareOdnIdentifier(data))--:wikitext(access.render[data.accessKind], ' ')local needDot = falselocal nextAuthorGroup = falseif data.title or data.patent thenif data.chapter thenlocal authors = data.editor and data.author or data.chapterauthorif authors thenlocal list, etal = formatAuthors(authors, false, nextAuthorGroup, nil)builder:wikitext(list, ", ")nextAuthorGroup = trueendlocal title = softNoWiki(data.chapter)if data.chapterurl thenbuilder:wikitext("[", escapeUrl(data.archivechapter and data.archive or data.chapterurl), " ''", title, "'']")elseif data.chapterlink thenbuilder:wikitext("[[", data.chapterlink, "|''", title, "'']]")elsebuilder:wikitext("''", title, "''")endif data.format thenbuilder:wikitext(" [", data.format, "]")endbuilder:wikitext(", [w:] ")endlocal authors = falselocal editor = falseif not data.chapter and data.author thenauthors = data.authorelseauthors = data.editor or data.authoreditor = data.editorendif authors thenlocal list, etal = formatAuthors(authors, not (editor or false), nextAuthorGroup, editor and " i inni red." or nil)builder:wikitext(list)nextAuthorGroup = trueif editor and not etal and not authors.etal thenbuilder:wikitext(" (red.)")endbuilder:wikitext(", ")endif customMode and data.authorextra thenbuilder:wikitext(data.authorextra, ", ")endif resources.abbrTitles[data.title] thenlocal title = resources.abbrTitles[data.title]builder:wikitext(title)needDot = not mw.ustring.match(title, "%.%]%]$")and not mw.ustring.match(title, "%.$")elseif data.title thenlocal title = softNoWiki(data.title)if data.url or data.archiveurl thenbuilder:wikitext("[", escapeUrl(data.archiveurl and data.archive or data.url), " ''", title, "'']")elseif data.titlelink thenbuilder:wikitext("[[", data.titlelink, "|''", title, "'']]")elsebuilder:wikitext("''", title, "''")endif not data.chapter and data.format thenbuilder:wikitext(" [", data.format, "]")needDot = trueelseif not mw.ustring.match(plainText(title), "[%.,!?]$") thenneedDot = trueendlocal showmediatype = data.mediatype and (#data.mediatype > 0)if showmediatype thenbuilder:wikitext(" [", data.mediatype, "]")needDot = trueendendif not editor and data.editor thenlocal list, etal = formatAuthors(data.editor, false, true, " i inni red.")builder:wikitext(needDot and ", " or " ", list, (etal or data.editor.etal) and "" or " (red.)")needDot = trueendif data.others thenlocal list, etal = formatAuthors(data.others, true, true, nil)builder:wikitext(needDot and ", " or " ", data.patent and resources.patent.inventor.." " or "", list)needDot = trueendif data.patent thenlocal title = (not data.title and data.url) and string.format("[%s %s]", escapeUrl(data.url), data.patent.title) or data.patent.titlebuilder:wikitext(needDot and ", " or " ", resources.patent[data.patent.application], " ", title)needDot = trueendelseif data.journal and data.author thenlocal list, etal = formatAuthors(data.author, false, false, nil)builder:wikitext(list, ", ")endif data.work thenbuilder:wikitext((data.title or data.patent) and ", " or "", "[w:] ", data.work)needDot = trueend-- web -> [online]if (mode == 4) and not data.mediatype thenbuilder:wikitext(" [online]")endif data.journal and (not data.published or (data.journal ~= data.published)) thenbuilder:wikitext((data.title or data.work) and ", " or "")local title = softNoWiki(data.journal)if data.journalurl or data.archivejournal thenbuilder:wikitext("[", escapeUrl(data.archivejournal and data.archive or data.journalurl), " „", title, "”]")elseif data.journallink thenbuilder:wikitext("„[[", data.journallink, "|", title, "]]”")elsebuilder:wikitext("„", title, "”")endneedDot = trueendif data.responsibility thenbuilder:wikitext(", ", data.responsibility)needDot = trueendif data.edition thenbuilder:wikitext(", ", formatEdition(data.edition, data.journal))needDot = trueendif data.volume thenbuilder:wikitext(data.journal and ", " or ", t. ", data.volume)needDot = trueendif data.journal and data.issue thenbuilder:wikitext(" (", data.issue, ")")needDot = trueendif data.description and (#data.description > 0) thenbuilder:wikitext(", ", data.description)needDot = trueendif data.published and not data.publisher thenbuilder:wikitext(", ", data.published)needDot = trueendlocal place = falseif data.place thenbuilder:wikitext(", ", data.place)needDot = trueplace = trueendif data.publisher thenbuilder:wikitext(place and ": " or ", ", data.publisher)needDot = trueplace = falseendif data.date thenlocal shortDate = data.journal and (data.doi or data.pmid or data.pmc)if data.date.bib and data.date.hint thenbuilder:wikitext(place and " " or ", "):tag("span"):attr("title", data.date.hint):wikitext(data.date.bib)elseif data.date.bib thenbuilder:wikitext(place and " " or ", ", data.date.bib)elseif data.date.day and shortDate thenbuilder:wikitext(place and " " or ", "):tag("span"):attr("title", tostring(data.date.day).." "..resources.months[data.date.month].d.." "..tostring(data.date.year)):wikitext(data.date.year)elseif data.date.month and shortDate thenbuilder:wikitext(place and " " or ", "):tag("span"):attr("title", resources.months[data.date.month].m.." "..tostring(data.date.year)):wikitext(data.date.year)elseif data.date.day thenbuilder:wikitext(", ", tostring(data.date.day), " ", resources.months[data.date.month].d, " ", tostring(data.date.year))elseif data.date.month thenbuilder:wikitext(", ", resources.months[data.date.month].m, " ", tostring(data.date.year))elsebuilder:wikitext(place and " " or ", ", data.date.year)endbuilder:wikitext(data.diferentiator or "")needDot = trueendif not data.journal and (data.series or data.issue) thenbuilder:wikitext(" (", data.series or "", (data.series and data.issue) and "; " or "", data.issue or "", ")")needDot = trueelseif data.journal and data.series thenbuilder:wikitext(" (", data.series, ")")needDot = trueendif data.p and #data.p > 0 thenlocal isNonStandardPageNumber = mw.ustring.match(data.p, "[^%s0-9,%-–]")builder:wikitext(isNonStandardPageNumber and ", " or ", s.\194\160", data.p)needDot = trueendif data.doi thenlocal separator = " "builder:addClass("doi"):wikitext(", [[DOI (identyfikator cyfrowy)|DOI]]:")local doiLink = first(resources.params.doi.link)for _, v in ipairs(data.doi) dobuilder:wikitext(separator, "[", doiLink, mw.uri.encode(v), " ", softNoWiki(v), "]")separator = ", "endneedDot = trueendif data.isbn thenfor i,v in ipairs(data.isbn) dobuilder:wikitext(", ")require("Moduł:ISBN").link(builder, v)endneedDot = trueendif data.lccn thenbuilder:wikitext(", [[Biblioteka Kongresu|LCCN]] [", first(resources.params.lccn.link), mw.uri.encode(data.lccn), " ", data.lccn, "]")needDot = trueendif data.issn thenbuilder:tag("span"):addClass("issn"):wikitext(", [[International Standard Serial Number|ISSN]] [", first(resources.params.issn.link), data.issn, " ", data.issn, "]")needDot = trueendif data.pmid thenbuilder:addClass("pmid"):wikitext(", [[PMID]]: [", first(resources.params.pmid.link), data.pmid, " ", data.pmid, "]")needDot = trueendif data.pmc thenbuilder:addClass("pmc"):wikitext(", [[PMCID]]: [", first(resources.params.pmc.link), data.pmc, "/ PMC", data.pmc, "]")needDot = trueendif data.bibcode thenbuilder:wikitext(", [[Bibcode]]: [", first(resources.params.bibcode.link), data.bibcode, " ", data.bibcode, "]")needDot = trueendif data.oclc thenbuilder:wikitext(", [[Online Computer Library Center|OCLC]] [", first(resources.params.oclc.link), mw.uri.encode(data.oclc), " ", data.oclc, "]")needDot = trueendif data.arxiv thenbuilder:wikitext(", [[arXiv]]:")local eprint, class = mw.ustring.match(data.arxiv, "^(%S+)%s+%[([^%[%]]+)%]$")if eprint thenbuilder:wikitext("[", first(resources.params.arxiv.link), eprint, " ", eprint, "] [[//arxiv.org/archive/", class, " ", class, "]]" )elsebuilder:wikitext("[", first(resources.params.arxiv.link), data.arxiv, " ", data.arxiv, "]" )endneedDot = trueendif data.jstor thenbuilder:tag("span"):addClass("jstor"):wikitext(", [[JSTOR]]: [", first(resources.params.jstor.link), data.jstor, " ", data.jstor, "]")needDot = trueendif data.ol thenbuilder:tag("span"):addClass("open-library"):wikitext(", [[Open Library|OL]]: [", first(resources.params.ol.link), data.ol, " ", data.ol, "]")needDot = trueendif data.id thenbuilder:wikitext(", ", data.id)needDot = trueendif data.accessdate thenbuilder:tag("span"):addClass("accessdate"):wikitext(" [dostęp ", string.format("%04d-%02d-%02d", data.accessdate.year, data.accessdate.month, data.accessdate.day), "]")needDot = trueendif data.archive thenbuilder:wikitext(" [zarchiwizowane")local url = data.archiveurl and data.url or (data.archivechapter and data.chapterurl or data.journalurl)if url thenbuilder:wikitext(" z [", escapeUrl(url), " adresu]")endif data.archived and data.archived.day thenbuilder:wikitext(" ", string.format("%04d-%02d-%02d", data.archived.year, data.archived.month, data.archived.day))endbuilder:wikitext("]")needDot = trueendif data.quotation thenbuilder:wikitext(", Cytat: ", data.quotation)needDot = trueendlocal coinsData = COinS(data, coinsFormat)if coinsData thenbuilder:tag("span"):addClass("Z3988"):attr("title",coinsData):css("display","none"):wikitext(" ")endif data.lang thenlocal languages = require("Moduł:Lang").lang({args = data.lang})builder:wikitext(" ", languages)needDot = trueendif data.fullStop thenif not mw.ustring.match(data.fullStop, "^[%.!?,;:]") thenbuilder:wikitext(", ")endbuilder:wikitext(data.fullStop)needDot = mw.ustring.match(data.fullStop, "[%.!?,;:]$") == nilendif needDot thenbuilder:wikitext(".")endif appendText thenbuilder:wikitext(appendText)end-- categorieslocal addCategories = mw.title.getCurrentTitle().namespace == 0local problems = {}if not customMode and (mode == 1) thenbuilder:wikitext(categories.undetermined)table.insert(problems, "???")endif data.publisher and data.published thentable.insert(problems, "p?")if addCategories thentable.insert(problems, categories.unusedPublished)endendif data.journal and data.published and (data.journal == data.published) thentable.insert(problems, "j?")if addCategories thentable.insert(problems, categories.sameJournalAndPublished)endendif (not data.url and not data.chapterurl) or (not data.title and not data.journalurl) thenbuilder:addClass(data.urlnowiki and "urlnowiki" or "nourl")endlocal missing = falselocal needurl = ((resources.params.published.used[mode] == "*") and data.published) or (resources.params.url.used[mode] == "*")if data.missing then-- usually missing title, this is the first check for mandatory argumentstable.insert(problems, data.missing)missing = trueelseif needurl and not data.url and not data.chapterurl and not data.arxiv and not data.archive then-- build in support for missing external link for page citationtable.insert(problems, resources.params.url.name)missing = trueelse-- any other missing value (first catch)for k, v in pairs(resources.params) doif (v.used[mode] == "!") and (not data[k] or (#data[k] == 0)) thentable.insert(problems, v.name)missing = truebreakendendendif missing and addCategories thenbuilder:wikitext(string.format(categories.missingArg or categories.check, resources.modes[mode]))endif (data.chapterauthor and data.chapterauthor.comma)or (data.author and (data.author.comma == true))or (data.editor and data.editor.comma)or (data.others and data.others.comma) thentable.insert(problems, "!!!")if addCategories thenbuilder:wikitext(categories.suspectedComma)endendif data.author and (data.author.comma == "alt") thentable.insert(problems, "a?")if addCategories thenbuilder:wikitext(categories.altAuthor)endendif data.originalJournal thenbuilder:addClass("c") -- CSS dla lokalizacji w treściif addCategories thenbuilder:wikitext(categories.altJournal)endendlocal citewiki = (data.url and mw.ustring.match(data.url, "%.wikipedia%.org"))or (data.journal and mw.ustring.match(killLinkInterwiki(data.journal), "[Ww]ikipedia"))or (data.publisher and mw.ustring.match(killLinkInterwiki(data.publisher), "[Ww]ikipedia"))or (data.published and mw.ustring.match(killLinkInterwiki(data.published), "[Ww]ikipedia"))if citewiki thenlocal justification = falselocal acceptedLinks = mw.loadData("Moduł:Cytuj/wiki")[mw.wikibase.getEntityIdForCurrentPage()] or {}for i, v in ipairs(acceptedLinks) dojustification = (v == data.url) or (v == data.archive)if justification thenbreakendendif not justification thentable.insert(problems, "wiki?")if addCategories thenbuilder:wikitext(categories.wiki)endendendif data.unknownAccess thentable.insert(problems, "dostęp?")if addCategories thenbuilder:wikitext(categories.unknownAccess)endendif data.rejectedurl thentable.insert(problems, "<s>url</s>")if addCategories thenbuilder:wikitext(categories.rejectedUrl)endendif data.urlWarning thentable.insert(problems, "Url")if addCategories thenbuilder:wikitext(categories.unusedUrl)endendif data.patchCitoidDate thentable.insert(problems, "1 stycznia")endif data.badDate thentable.insert(problems, "data?")endif data.badAccessDate thentable.insert(problems, "data dostępu?")endif data.badArchivedDate thentable.insert(problems, "zarchiwizowano?")endif addCategories and (data.badDate or data.badAccessDate or data.badArchiveDate) thenbuilder:wikitext(categories.badDate)endif (data.author and data.author.etal)or (data.chapterauthor and data.chapterauthor.etal)or (data.editor and data.editor.etal)or (data.others and data.others.etal) thentable.insert(problems, "i inni")if addCategories thenbuilder:wikitext(categories.etal)endendif firewall thenlocal reportFirewall = function(report)if report thentable.insert(problems, report.info)if addCategories and report.cat thenlocal cat = mw.ustring.format(categories.firewall, report.cat)builder:wikitext(cat)endendendlocal reportCommonsFile = function(ext)mw.logObject(ext, "ext")if ext and (firewall.commonsFile[ext] ~= false) thenlocal issue = firewall.commonsFile[ext] or firewall.commonsFile[true]reportFirewall(firewall.reports[issue])endendif data.url and firewall.url[data.url] ~= false thenlocal uri = mw.uri.new(data.url)local issue = firewall.url[data.url]or firewall.host[uri.host]or firewall.path[uri.relativePath]reportFirewall(firewall.reports[issue])endreportCommonsFile(data.chapterext)reportCommonsFile(data.titleext)reportCommonsFile(data.journalext)endif #problems > 0 thenlocal info = builder:tag("span"):addClass("problemy"):addClass("problemy-w-cytuj"):attr("aria-hidden", "true"):attr("data-nosnippet", "")info:wikitext(table.concat(problems,", "))endreturn builder:done()endreturn {auto = function(frame)return Cite(frame:getParent(), nil, nil, mw.loadData("Moduł:Cytuj/firewall"))end,custom = function(frame)local traceCategory = falselocal pagename = mw.title.getCurrentTitle()if (pagename.namespace == 10) and frame.getParent thenlocal template = mw.title.new( frame:getParent():getTitle(), "Szablon" )if mw.title.compare(template, pagename) == 0 thentraceCategory = categories.traceInvokeCustomendendlocal customMode = frame.args[1]local mode = 1if customMode thencustomMode = mw.text.trim(customMode)for i, v in ipairs(resources.modes) doif customMode == v thenmode = ibreakendendendreturn Cite(frame, mode, traceCategory, null)end,}