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

1版 をインポートしました
(1版 をインポートしました)
(1版 をインポートしました)
 
(3人の利用者による、間の3版が非表示)
17行目: 17行目:
-- === Dependencies ======================
-- === Dependencies ======================
-- =======================================
-- =======================================
require('Module:No globals') -- used for debugging purposes as it detects cases of unintended global variables
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 style="vertical-align: top">\n%s%s\n</tr>\n\n', cell1, cell2)
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 toccolours vevent '..
local style = mw.ustring.format('class="fileinfotpl-type-information vevent '..
'mw-content-%s" style="width: 100%%; direction: %s;" cellpadding="4"', dir, dir)
'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
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行目: 396行目:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
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