16,000
回編集
bsd>Jarekt 細 (fix issue with errors in the source field) |
細 (1版 をインポートしました) |
||
(3人の利用者による、間の4版が非表示) | |||
17行目: | 17行目: | ||
-- === Dependencies ====================== | -- === Dependencies ====================== | ||
-- ======================================= | -- ======================================= | ||
require(' | require('strict') -- used for debugging purposes as it detects cases of unintended global variables | ||
local ISOdate = require('Module:ISOdate')._ISOdate -- date localization | local ISOdate = require('Module:ISOdate')._ISOdate -- date localization | ||
local core = require('Module:Core') | local core = require('Module:Core') | ||
91行目: | 91行目: | ||
cell1 = mw.ustring.format('<td %sclass="fileinfo-paramfield" lang="%s">%s</td>\n', id or '', lang, tag) | cell1 = mw.ustring.format('<td %sclass="fileinfo-paramfield" lang="%s">%s</td>\n', id or '', lang, tag) | ||
cell2 = mw.ustring.format('<td %s>\n%s</td>', param.td or '', field or '') | cell2 = mw.ustring.format('<td %s>\n%s</td>', param.td or '', field or '') | ||
field = mw.ustring.format('<tr | field = mw.ustring.format('<tr>\n%s%s\n</tr>\n\n', cell1, cell2) | ||
end | end | ||
end | end | ||
table.insert(results, field) | table.insert(results, field) | ||
end | end | ||
local templatestyles = mw.getCurrentFrame():extensionTag{ | |||
name = 'templatestyles', args = { src = 'Module:Information/styles.css' } | |||
} | |||
-- add table and outer layers | -- add table and outer layers | ||
local style = mw.ustring.format('class="fileinfotpl-type-information | local style = mw.ustring.format('class="fileinfotpl-type-information vevent '.. | ||
'mw-content-%s" style=" | 'mw-content-%s" style="direction: %s;"', dir, dir) | ||
results = mw.ustring.format('<table %s>\n\n%s\n</table>\n', style, table.concat(results)) | results = mw.ustring.format('<table %s>\n\n%s\n</table>\n', style, table.concat(results)) | ||
results = mw.ustring.format('<div class="hproduct commons-file-information-table">\n%s\n</div>', results) | results = mw.ustring.format('<div class="hproduct commons-file-information-table">\n%s\n%s\n</div>', templatestyles, results) | ||
return results | return results | ||
end | end | ||
135行目: | 139行目: | ||
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行目: | 158行目: | ||
end | end | ||
args.pagename = page.text | args.pagename = page.text | ||
-- ==================================================== | -- ==================================================== | ||
177行目: | 180行目: | ||
-- 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行目: | 396行目: | ||
------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||
function p.information(frame) | function p.information(frame) | ||
local args = core.getArgs(frame) | |||
args.strict = true | |||
return p._information(args) | |||
end | end | ||