「モジュール:Information」の版間の差分
ナビゲーションに移動
検索に移動
細
allow "strict=false" in lua-only mode
細 (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 | ||
local reqFields = {description='Media lacking a description', author='Media lacking author information', source='Images without source'} | |||
for field, errCat in pairs(reqFields) do | |||
if args[field] and mw.ustring.match(args[field],"^[%s%p]+$") then | |||
args[field]=nil; | |||
end -- ignore punctuation only fields | |||
if not args[field] then | |||
-- code equivalent to Template:Source missing, Template:Author missing, Template:Description missing | |||
local tag1 = 'class="boilerplate metadata" id="cleanup" style="text-align: center; background: #ffe; '.. | |||
'margin: .75em 15%; padding: .5em; border: 1px solid #e3e3b0;' | |||
local tag2 = message(field..'-missing', lang) | |||
local tag3 = message(field..'-missing-request', lang) | |||
local dir = mw.language.new( lang ):getDir() -- get text direction | |||
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) | ||
local args = core.getArgs(frame) | |||
args.strict = true | |||
return p._information(args) | |||
end | end | ||