Module:Vital article: Difference between revisions

Content deleted Content added
m don't add level for level 3
no cat class
 
(6 intermediate revisions by 2 users not shown)
Line 8:
end
 
p.local getLink = function(page)
local subpage = mw.ustring.upper(mw.ustring.sub(page, 1, 1)) -- get first letter of article name
local codepoint = mw.ustring.codepoint(page, 1, 1)
Line 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)[page2]
if data then
local level = tostring(data.level)
if level then
local link = 'Wikipedia:Vital articles/Level/' .. level
if level~='3' then
link = link .. '/Level/' .. level
end
if (level=='4' or level=='5') and data.topic then
link = link .. '/' .. data.topic
Line 33 ⟶ 30:
link = link .. '#' .. data.section
end
return link, level, data.topic
end
end
Line 40 ⟶ 37:
p.link = function(frame)
local page = frame.args.page~='' and frame.args.page or mw.title.getCurrentTitle().subjectPageTitle.text
local link, level = p.getLink(page)
return '[[' .. page .. ']]' .. (link and ' [[File:Círculos Concéntricos.svg|11px]] [[' .. link .. '|' .. level .. ']]' or '')
end
Line 98 ⟶ 95:
topic = cat:match('^Wikipedia vital articles in ([%a ]+)$')
if topic then -- Category:Wikipedia vital articles in TOPIC
return top(truefalse, frame)
.. '[[Category:Wikipedia vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
Line 116 ⟶ 113:
class = class:match('(%a+)-Class') or class
return top(true, frame)
.. frame:expandTemplate{title = 'cat class', args = {topic = 'vital', class = class}}
end
level, topic = cat:match('^Wikipedia level%-(%w+) vital articles in ([%a ]+)$')