.mw-parser-output .documentation,.mw-parser-output .documentation-metadata{border:1px solid var(--border-color-base,#a2a9b1);background-color:#ecfcf4;color:inhe
| This is the module sandbox page for Module:Cite certification. |
local p = {}
local getArgs = require('Module:Arguments').getArgs
local cite = require('Module:Citation/CS1')
local handlers = require("Module:Cite certification/handlers/sandbox")
local makeURL = require('Module:Cite certification/URL/sandbox')
local makeArchiveURL = require('Module:Cite certification/archiveurl/sandbox')
local makeArchiveDate = require('Module:Cite certification/archivedate/sandbox')
local function notblank(v) return (v or '') ~= '' end
local function errorMessage(msg)
local cat = (mw.title.getCurrentTitle().namespace == 0)
and '[[Category:Cite certification used with missing parameters]]' or ''
return string.format('<span style="color:red;">%s</span>%s', msg, cat)
end
local function makeTitle(args, titleRegion) -- implement Cite certification/Title
return (notblank(titleRegion) and titleRegion or args.region) ..
(notblank(args.digital) and ' digital' or '') ..
(notblank(args.type) and (' ' .. args.type) or '') ..
(notblank(args.streaming) and ' streaming' or '') ..
' certifications' ..
(notblank(args.artist) and (' - ' .. args.artist) or '') ..
(notblank(args.title) and (' - ' .. args.title) or '')
end
local function buildCitation(args, opts)
local citation
if mw.ustring.lower(args.source or '') == 'book' then
local citeArgs = {}
for k, v in pairs(opts) do
if k ~= 'note' then citeArgs[k] = v end
end
citation = cite._citation(nil, citeArgs, {CitationClass = 'book'})
else
local url = makeURL(args, opts.urlSource)
if type(url) == 'table' then
return errorMessage(url[1])
end
citation = cite._citation(nil,
{
url = url,
title = notblank(opts.title) and opts.title or makeTitle(args, opts.titleRegion),
publisher = opts.publisher,
['access-date'] = notblank(args['access-date']) and args['access-date'] or args.accessdate,
date = args.date,
ref = args.ref,
language = opts.language,
website = opts.website,
format = opts.format,
['archive-url'] = (opts.archive == true) and makeArchiveURL(args) or nil,
['archive-date'] = (opts.archive == true) and makeArchiveDate(args) or nil,
['url-status'] = opts.urlStatus,
['script-title'] = opts.scriptTitle,
['trans-title'] = opts.transTitle,
},
{CitationClass = 'web'}
)
end
return citation .. (opts.note or '')
end
function p._main(args)
if notblank(args.region) then
local region = mw.ustring.lower(args.region)
if handlers[region] then
local output = handlers[region](args)
return type(output) == 'string' and errorMessage(output) or buildCitation(output)
else
return errorMessage('UNSUPPORTED REGION: "' .. args.region .. '".')
end
else
return errorMessage('MISSING OR EMPTY REGION.')
end
end
function p.main(frame)
local args = getArgs(frame,{parentOnly=true,removeBlanks=true})
return p._main(args)
end
return p
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.