“模块:快速分类”的版本间的差异
跳到导航
跳到搜索
第6行: | 第6行: | ||
local noMaintainerWarning = "{{无维护者警告}}" | local noMaintainerWarning = "{{无维护者警告}}" | ||
− | function p.display_title( | + | function p.display_title(frame) |
+ | local pagename = mw.title.getCurrentTitle().text | ||
local node = mw.html.create(nil) | local node = mw.html.create(nil) | ||
+ | local type_flag, group_name, page_name | ||
+ | type_flag, group_name, page_name = PageName.parse(pagename) | ||
if type_flag then | if type_flag then | ||
local type_name = PageName.type_name(type_flag) | local type_name = PageName.type_name(type_flag) | ||
第40行: | 第43行: | ||
end | end | ||
local code = node:done() | local code = node:done() | ||
− | + | return code | |
end | end | ||
第72行: | 第75行: | ||
local type_flag, group_name, page_name | local type_flag, group_name, page_name | ||
type_flag, group_name, page_name = PageName.parse(pagename) | type_flag, group_name, page_name = PageName.parse(pagename) | ||
− | |||
mw.smw.set({['设定标题']=pagename}) | mw.smw.set({['设定标题']=pagename}) | ||
local categorize = frame:expandTemplate(p.categorize(type_flag, group_name, page_name)) | local categorize = frame:expandTemplate(p.categorize(type_flag, group_name, page_name)) |
2020年12月31日 (四) 22:37的版本
此模块的文档可以在模块:快速分类/doc创建
local PageName = require("Module:PageName") local p = {} local noStageWarning = "{{未指定创作阶段警告}}" local noMaintainerWarning = "{{无维护者警告}}" function p.display_title(frame) local pagename = mw.title.getCurrentTitle().text local node = mw.html.create(nil) local type_flag, group_name, page_name type_flag, group_name, page_name = PageName.parse(pagename) if type_flag then local type_name = PageName.type_name(type_flag) if page_name then local base, sub base, sub = PageName.split(page_name) if base then node:wikitext(sub) node:tag("span"):addClass("ifw-basepagename"):wikitext("("..type_name.."-"..group_name..":"..base..")") elseif page_name then node:wikitext(page_name) node:tag("span"):addClass("ifw-basepagename"):wikitext("("..type_name.."-"..group_name..")") end else node:wikitext(group_name) node:tag("span"):addClass("ifw-basepagename"):wikitext("("..type_name..")") end else local base, sub base, sub = PageName.split(page_name) if base then node:wikitext(sub) node:tag("span"):addClass("ifw-basepagename"):wikitext("("..base..")") else local type_name = PageName.type_name(page_name) if type_name then node:wikitext(type_name.."汇总页") else node:wikitext(page_name) end end end local code = node:done() return code end function p.categorize(type_flag, group_name, page_name) local temp, args, category if type_flag == 'W' then if page_name then temp = "快速分类/世界观设定" args = {['世界观'] = group_name} else temp = "快速分类/世界观介绍页" args = {['世界观'] = group_name} end elseif type_flag == 'X' then if page_name then temp = "快速分类/联动/设定页" args = {['联动'] = group_name} else temp = "快速分类/联动/首页" args = {['联动'] = group_name} end else temp = "快速分类/公共设定" args = {} end return { title = temp, args = args } end function p.render(frame) local pagename = mw.title.getCurrentTitle().text local type_flag, group_name, page_name type_flag, group_name, page_name = PageName.parse(pagename) mw.smw.set({['设定标题']=pagename}) local categorize = frame:expandTemplate(p.categorize(type_flag, group_name, page_name)) return categorize end return p