模組:Class/icon
外观
require('Module:No globals')
local config = {
fa = {
image = 'Symbol star.svg', alt = '典范级',
alias = {'典范', '典範', '典范条目', '典範條目', '特', '特色', '特色条目', '特色條目'}
},
fl = {
image = 'Symbol star.svg', alt = '特色列表级',
alias = {'特表', '特色列表'}
},
fm = {
image = 'Symbol star.svg', alt = '特色图片级',
alias = {'fi', '特图', '特圖', '特色图片', '特色圖片'}
},
fpo = {
image = 'Linecons big-star.svg', alt = '特色主题级',
alias = {'特色主题', '特色主题'}
},
a = {
image = 'Symbol a class.svg', alt = '甲级',
alias = {'甲', '甲级', '甲級'}
},
al = {
image = 'Symbol a class.svg', alt = '甲级列表级',
alias = {'甲表', '甲级列表', '甲級列表'}
},
ga = {
image = 'Symbol support vote.svg', alt = '优良级',
alias = {'优', '優', '良', '优良', '優良', '优良条目', '優良條目'}
},
gl = { --[[d:Q51759403]]
image = 'Symbol support vote.svg', alt = '优良列表级',
alias = {'優表','优表','良表', '优良列表', '優良列表'}
},
bplus = {
image = 'Symbol bplus class.svg', alt = '乙上级',
alias = {'b+', '乙+', '乙上'}
},
b = {
image = 'Symbol b class.svg', alt = '乙级',
alias = {'乙', '乙级', '乙級'},
},
bl = {
image = 'Symbol b class.svg', alt = '乙级列表级',
alias = {'乙表', '乙级列表', '乙級列表'}
},
complete = {
image = 'Symbol portal class.svg', alt = '完成级',
alias = {'完成', '完成主题','完成主題'},
},
c = {
image = 'Symbol c class.svg', alt = '丙级',
alias = {'丙', '丙级', '丙級'}
},
cl = {
image = 'Symbol c class.svg', alt = '丙级列表级',
alias = {'丙表', '丙级列表', '丙級列表'}
},
substantial = {
image = 'Symbol portal class.svg', alt = '充实级',
alias = {'基本', '基本主题','基本主題','充实','充實','充实主题','充實主題'}
},
d = {
image = 'Symbol d class.svg', alt = '丁级',
alias = {'丁', '丁级', '丁級'}
},
start = {
image = 'Start-icon.svg', alt = '初级',
alias = {'初', '初级', '初級'}
},
basic = {
image = 'Symbol portal class.svg', alt = '简单级',
alias = {'简单', '簡單','简单主题','簡單主題'}
},
list = {
image = 'Symbol list class.svg', alt = '列表级',
alias = {'l', '表', '列表'}
},
stub = {
image = 'Symbol stub class.svg', alt = '小作品级',
alias = {'小', '小作品'}
},
sl = {
image = 'Symbol sl class.svg', alt = '小列表级',
alias = {'小表', '小列表'}
},
substub = {
image = 'Wikivoyage usable icon.png', alt = '小小作品级',
alias = {'小小', '小小作品'}
},
sia = {
image = 'Symbol sia class.svg', alt = '同类索引级',
alias = {'同类索引', '同類索引', '索引'}
},
book = {
image = 'Symbol book class.svg', alt = '图书级',
alias = {'書', '书', '圖書', '图书'}
},
sandbox = {
image = 'Symbol sandbox class.svg', alt = '沙盒级',
alias = {'沙', '沙盒', '砂盒'}
},
category = {
image = 'Symbol category class.svg', alt = '分类级',
alias = {'cat', '类', '類', '分类', '分類'}
},
disambig = {
image = 'Symbol dab class.svg', alt = '消歧义级',
alias = {'dab', 'disamb', '消', '消歧义', '消歧義'}
},
redirect = {
image = 'Symbol redirect class.svg', alt = '重定向级',
alias = {'red', 'redir', '重', '重定向', '重新導向', '重新导向'}
},
template = {
image = 'Symbol template class.svg', alt = '模板级',
alias = {'temp', '模', '板', '模板'}
},
module = {
image = 'Symbol code red.svg', alt = '模块级',
alias = {'mod', '模組', '模组', '模塊', '模块'}
},
na = {
image = 'Symbol na class.svg', alt = '非条目级',
alias = {'非', '非条目', '非條目'}
},
napage = {
image = 'Symbol na class.svg', alt = '非页面级',
alias = {'非页面', '非頁面'}
},
file = {
image = 'Symbol file class.svg', alt = '文件级',
alias = {'image', '图', '圖', '文件', '图像', '圖像', '档案', '檔案', '多媒体', '多媒體', '媒体'}
},
audio = {
image = 'Audio-itunes.svg', alt = '文件级',
alias = {'music', '音', '音频', '音頻', '音訊', '音讯'}
},
portal = {
image = 'Symbol portal class.svg', alt = '主题级',
alias = {'主', '主题', '主題'}
},
project = {
image = 'Symbol project class.svg', alt = '专题级',
alias = {'专', '專', '专题', '專題'}
},
draft = {
image = 'Symbol draft class.svg', alt = '草稿级',
alias = {'稿', '草稿'}
},
user = {
image = 'Symbol user class.svg', alt = '用户级',
alias = {'用户', '使用者'}
},
help = {
image = 'Symbol information vote.svg', alt = '使用说明级',
alias = {'使用说明', '使用說明', '说明','說明'}
},
interface = {
image = 'Pliers Symbol.svg', alt = '使用说明级',
alias = {'界面','介面'}
},
council = {
image = 'WikiProject Council with transparent background.svg', alt = '委员会级',
alias = {'委员会','委員會'}
},
future = {
image = 'Symbol future class.svg', alt = '未来级',
alias = {'未来', '未來'}
},
current = {
image = 'Symbol current class.svg', alt = '动态级',
alias = {'动', '動', '动态', '動態', '新闻动态', '新聞動態'}
},
merge = {
image = 'Symbol merge vote.svg', alt = '合并级',
alias = {'并', '併', '合并', '合併'}
},
needed = {
image = 'Symbol needed class.svg', alt = '请求级',
alias = {'请', '請', '请求', '請求'}
},
deferred = {
image = 'Symbol deferred.svg', alt = '搁置级',
alias = {'搁置', '擱置'}
},
no = {
image = 'Wikivoyage outline icon.png', alt = '无级别',
alias = {'无', '無'}
},
unassessed = {
image = 'Symbol question.svg', alt = '未评级',
alias = {'un', '未', '未评级', '未評級', '未评', '未評'}
},
unknown = {
image = 'Symbol question.svg', alt = '未知级',
alias = {'', ' ', '未知级', '未知級', '未知', '¬'}
},
error = {
image = 'Template-X.svg', alt = '错误',
alias = {'错误', '錯誤'}
},
}
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local ret = ''
local class
-- 预处理输入等级
local input = args.class or args[1]
if input == nil then
input = 'unassessed'
else
input = mw.ustring.lower(input)
end
-- 获取输入等级
for k, _ in pairs(config) do
if k == input then
class = k
break
end
end
if class == nil then
for k, v in pairs(config) do
for _, w in pairs(v.alias) do
if w == input then
class = k
break
end
end
if class ~= nil then break end
end
end
-- 获取评级图示
if class == nil then
ret = mw.getCurrentFrame():expandTemplate{ title = 'icon', args = {args[1]} }
else
ret = '[[File:' .. config[class].image .. '|' .. config[class].alt .. '|16px]]'
end
if args['css-class'] or args.style then
local span = ''
if args['css-class'] then
span = span .. ' class="' .. args['css-class'] .. '"'
end
if args.style then
span = span .. ' style="' .. args.style .. '"'
end
ret = '<span' .. span .. '>' .. ret .. '</span>'
end
-- RETURN
return ret
end
return p