Content deleted Content added
MusikBot II (talk | contribs) m Protected "Module:Vital article": High-risk template or module: 286 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite)) |
no cat class |
||
(24 intermediate revisions by 4 users not shown) | |||
Line 1:
local p = {}
-- Copy from [[Module:Section link]]
local function normalizeTitle(title)
title = mw.ustring.gsub(mw.ustring.gsub(title, "'", ""), '"', '')
title = mw.ustring.gsub(title, "%b<>", "")
return mw.title.new(title).prefixedText
local getLink = function(page)
Line 8 ⟶ 15:
end
local data_page = 'Wikipedia:Vital articles/data/' .. subpage .. '.json'
local page2 = tostring(tonumber(page))==page and tonumber(page) or page --convert to number if page is numerical, otherwise loadJsonData does not work
local data = mw.loadJsonData(data_page)[
if data then
local level = tostring(data.level)
if level then
if trimmed_link then▼
▲ link = 'Wikipedia:Vital articles' .. trimmed_link
link =
▲ if (level=='4' or level=='5') and data.topic then
▲ link = link .. '/' .. data.topic
▲ end
▲ if data.sublist then
▲ end
▲ -- link = link .. '#' .. data.section
▲ --end
end
return link, level
Line 37 ⟶ 39:
local link, level = getLink(page)
return '[[' .. page .. ']]' .. (link and ' [[File:Círculos Concéntricos.svg|11px]] [[' .. link .. '|' .. level .. ']]' or '')
end
p.isVital = function(frame)
local page = frame.args.page~='' and frame.args.page or mw.title.getCurrentTitle().subjectPageTitle.text
local _, level = getLink(page)
return level or ''
end
Line 46 ⟶ 54:
p.header = function(frame)
local
local cat = pargs.category~='' and local topic, class, level
topic = cat:match('^
if topic then -- Category:
return top(true, frame)
.. '[[Category:Wikipedia vital articles in ' .. topic .. '|
.. '[[Category:
end
class = cat:match('^([%a-]+) vital articles by topic$')
Line 58 ⟶ 67:
return top(true, frame)
.. '[[Category:' .. class .. ' vital articles|Topic]]'
.. '[[Category:
end
topic = cat:match('^Wikipedia vital articles in ([%a ]+) by level$')
if topic then -- Category:Wikipedia vital articles in TOPIC by level
return top(true, frame)
.. '[[Category:Wikipedia vital articles in ' .. topic .. '|Level]]'
.. '[[Category:Wikipedia vital articles by topic by level|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
level = cat:match('^Wikipedia level%-(%w+) vital articles by topic$')
Line 72 ⟶ 81:
.. '[[Category:Wikipedia vital articles by level by topic|' .. level .. ']]'
end
class = cat:match('
if class then -- Category:
return top(true, frame)
.. '[[Category:' .. class .. ' vital articles|Level]]'
.. '[[Category:
end
level = cat:match('
if level then -- Category:
return top(true, frame)
.. '[[Category:Wikipedia level-' .. level .. ' vital articles|
.. '[[Category:
end
topic = cat:match('^Wikipedia vital articles in ([%a ]+)$')
if topic then -- Category:Wikipedia vital articles in TOPIC
return top(
.. '[[Category:Wikipedia vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
Line 97 ⟶ 106:
if class and level then -- Category:CLASS level-LEVEL vital articles
return top(false, frame)
.. '[[Category:
.. '[[Category:
end
class = cat:match('^([%a-]+) vital articles$')
Line 104 ⟶ 113:
class = class:match('(%a+)-Class') or class
return top(true, frame)
end
level, topic = cat:match('^Wikipedia level%-(%w+) vital articles in ([%a ]+)$')
Line 110 ⟶ 118:
return top(false, frame)
.. '[[Category:Wikipedia vital articles in ' .. topic .. ' by level|' .. level .. ']]'
.. '[[Category:Wikipedia level-' .. level .. ' vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
class, topic = cat:match('^([%a-]+) vital articles in ([%a ]+)$')
if class and topic then -- Category:CLASS vital articles in TOPIC
return top(false, frame)
.. '[[Category:
.. '[[Category:' .. class .. ' vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
|