“模块:FileInfo”的版本间的差异
跳到导航
跳到搜索
(建立内容为“local module = {} local getArgs = require('Module:Arguments').getArgs local nowiki_blocks = { 'do', 'condition' } function pack_inner_loop(loop) -- 给内…”的新页面) |
(页面内容被替换为“local module = {} module.main = function(frame) local fileName = frame.args[1] local name = frame.args[2] local attrNames = { 'width', 'height', 'size', 'mimeTyp…”) 标签:替换 |
||
| 第1行: | 第1行: | ||
local module = {} | local module = {} | ||
| − | + | module.main = function(frame) | |
| − | + | local fileName = frame.args[1] | |
| − | + | local name = frame.args[2] | |
| − | + | local attrNames = { 'width', 'height', 'size', 'mimeType' } | |
| − | function | + | local title = mw.title.new('File:'..fileName) |
| − | + | if title ~= nil then | |
| − | + | for i, v in ipairs(attrNames) do | |
| − | + | if v == name then | |
| − | + | return title.file[name] | |
| − | + | end | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
end | end | ||
| − | + | if (frame.args['w'] or '') ~= 'false' then | |
| − | + | error('没有这个文件属性,可用的文件属性包含:width、height、size、mimeType') | |
| − | + | end | |
| − | + | else | |
| − | + | if (frame.args['w'] or '') ~= 'false' then | |
| − | + | error('没有这个文件,请检查文件名是否正确!') | |
| − | |||
end | end | ||
end | end | ||
| − | |||
end | end | ||
return module | return module | ||
2024年12月1日 (日) 10:41的最新版本
此模块的文档可以在模块:FileInfo/doc创建
local module = {}
module.main = function(frame)
local fileName = frame.args[1]
local name = frame.args[2]
local attrNames = { 'width', 'height', 'size', 'mimeType' }
local title = mw.title.new('File:'..fileName)
if title ~= nil then
for i, v in ipairs(attrNames) do
if v == name then
return title.file[name]
end
end
if (frame.args['w'] or '') ~= 'false' then
error('没有这个文件属性,可用的文件属性包含:width、height、size、mimeType')
end
else
if (frame.args['w'] or '') ~= 'false' then
error('没有这个文件,请检查文件名是否正确!')
end
end
end
return module