「モジュール:Information」の版間の差分

ナビゲーションに移動 検索に移動
(1版 をインポートしました)
bsd>Jarekt
(allow "strict=false" in lua-only mode)
135行目: 135行目:
if namespace==6 or namespace==10 then
if namespace==6 or namespace==10 then
local allowedFields = {'description', 'date', 'permission', 'author', 'other_versions',   
local allowedFields = {'description', 'date', 'permission', 'author', 'other_versions',   
'source','other_fields', 'other_fields_1', 'demo', 'lang'}
'source','other_fields', 'other_fields_1', 'demo', 'lang', 'strict'}
local set, badField = {}, {}
local set, badField = {}, {}
for _, field in ipairs(allowedFields) do set[field] = true end
for _, field in ipairs(allowedFields) do set[field] = true end
154行目: 154行目:
end  
end  
args.pagename = page.text
args.pagename = page.text


-- ====================================================
-- ====================================================
177行目: 176行目:


-- files are required to have at least the 3 fields below
-- files are required to have at least the 3 fields below
local reqFields = {description='Media lacking a description', author='Media lacking author information', source='Images without source'}
if args.strict~=false then
for field, errCat in pairs(reqFields) do  
local reqFields = {description='Media lacking a description', author='Media lacking author information', source='Images without source'}
if args[field] and mw.ustring.match(args[field],"^[%s%p]+$") then  
for field, errCat in pairs(reqFields) do  
args[field]=nil;  
if args[field] and mw.ustring.match(args[field],"^[%s%p]+$") then  
end -- ignore punctuation only fields
args[field]=nil;  
if not args[field] then
end -- ignore punctuation only fields
-- code equivalent to Template:Source missing, Template:Author missing, Template:Description missing
if not args[field] then
local tag1 = 'class="boilerplate metadata" id="cleanup" style="text-align: center; background: #ffe; '..
-- code equivalent to Template:Source missing, Template:Author missing, Template:Description missing
'margin: .75em 15%; padding: .5em; border: 1px solid #e3e3b0;'
local tag1 = 'class="boilerplate metadata" id="cleanup" style="text-align: center; background: #ffe; '..
local tag2 = message(field..'-missing', lang)
'margin: .75em 15%; padding: .5em; border: 1px solid #e3e3b0;'
local tag3 = message(field..'-missing-request', lang)
local tag2 = message(field..'-missing', lang)
local dir  = mw.language.new( lang ):getDir()    -- get text direction
local tag3 = message(field..'-missing-request', lang)
args[field] = {missing =  mw.ustring.format('<div %s direction: %s;" lang="%s">%s\n%s\n</div>', tag1, dir, lang, tag2, tag3)}
local dir  = mw.language.new( lang ):getDir()    -- get text direction
cats = cats .. '\n[[Category:'.. errCat ..']]'
args[field] = {missing =  mw.ustring.format('<div %s direction: %s;" lang="%s">%s\n%s\n</div>', tag1, dir, lang, tag2, tag3)}
cats = cats .. '\n[[Category:'.. errCat ..']]'
end
end
end
end
end
391行目: 392行目:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
function p.information(frame)
function p.information(frame)
return p._information(core.getArgs(frame))
local args = core.getArgs(frame)
args.strict = true
return p._information(args)
end
end