Module:Vital article
| This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| Editing of this module by new or unregistered users is currently disabled. See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request, discuss changes on the talk page, request unprotection, log in, or create an account. |
Usage
This module implements the following templates:
Please refer to those templates' documentation.
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
end
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)
if codepoint<65 or codepoint>90 then --first letter is not between A-Z
subpage = 'others'
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=='4' or level=='5') and data.topic then
link = link .. '/' .. data.topic
end
if data.sublist then
link = link .. '/' .. data.sublist
end
if data.section then
link = link .. '#' .. data.section
end
return link, level
end
end
end
p.link = function(frame)
local pargs = frame:getParent().args
local page
if frame.args.page and frame.args.page~='' then
page = mw.title.new(frame.args.page)
else
page = mw.title.getCurrentTitle()
end
page = page.subjectPageTitle.text
local link, level = getLink(page)
lcfg = {
'pv', -- page views
'edit', -- edit
't', -- talk
'h', -- history
}
local args = {page = page}
if pargs.links=='yes' then
for i, l in ipairs(lcfg) do
args[i] = l
end
end
local class = pargs.class and (' ' .. frame:expandTemplate{title = 'icon', args = {[1] = pargs.class}}) or ''
local icon = '<span style="color:#2b1c72">'
.. frame:expandTemplate{
title = 'Tooltip',
args = {
[1] = '◎',
[2] = 'Vital article',
dotted = 'no'
}
} .. '</span>'
return require('Module:PageLinks').main(args)
.. (link and (icon .. ' [[' .. link .. '|' .. level .. ']]') or '[[File:Escape suspect.svg|11px|Non-vital article]]')
.. class
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
local top = function(container, frame)
return (container and '' or frame:expandTemplate{title = 'Possibly empty category'})
.. frame:expandTemplate{title = 'Wikipedia category', args = {container = container}}
.. frame:expandTemplate{title = 'CatAutoTOC'}
end
p.header = function(frame)
local pargs = frame:getParent().args
local cat = pargs.category~='' and pargs.category or mw.title.getCurrentTitle().subjectPageTitle.text
local topic, class, level
topic = cat:match('^Vital articles in ([%a ]+) by quality$')
if topic then -- Category:Vital articles in TOPIC by quality
return top(true, frame)
.. '[[Category:Wikipedia vital articles in ' .. topic .. '|Quality]]'
.. '[[Category:Vital articles by topic and quality|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
class = cat:match('^([%a-]+) vital articles by topic$')
if class then -- Category:CLASS vital articles by topic
return top(true, frame)
.. '[[Category:' .. class .. ' vital articles|Topic]]'
.. '[[Category:Vital articles by quality by topic|' .. class .. ']]'
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$')
if level then -- Category:Wikipedia level-LEVEL vital articles by topic
return top(true, frame)
.. '[[Category:Wikipedia level-' .. level .. ' vital articles|Topic]]'
.. '[[Category:Wikipedia vital articles by level and topic|' .. level .. ']]'
end
class = cat:match('^([%a-]+) vital articles by level$')
if class then -- Category:CLASS vital articles by level
return top(true, frame)
.. '[[Category:' .. class .. ' vital articles|Level]]'
.. '[[Category:Vital articles by quality and level|' .. class .. ']]'
end
level = cat:match('^Level%-(%w+) vital articles by quality$')
if level then -- Category:Level-LEVEL vital articles by quality
return top(true, frame)
.. '[[Category:Wikipedia level-' .. level .. ' vital articles|Quality]]'
.. '[[Category:Vital articles by level and quality|' .. level .. ']]'
end
topic = cat:match('^Wikipedia vital articles in ([%a ]+)$')
if topic then -- Category:Wikipedia vital articles in TOPIC
return top(false, frame)
.. '[[Category:Wikipedia vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
level = cat:match('^Wikipedia level%-(%w+) vital articles$')
if level then -- Category:Wikipedia level-LEVEL vital articles
return top(true, frame)
.. '[[Category:Wikipedia vital articles by level|' .. level .. ']]'
end
class, level = cat:match('^([%a%-]+) level%-(%w+) vital articles$')
if class and level then -- Category:CLASS level-LEVEL vital articles
return top(false, frame)
.. '[[Category:' .. class .. ' vital articles by level|' .. level .. ']]'
.. '[[Category:Level-' .. string.lower(level) .. ' vital articles by quality|' ..class .. ']]'
end
class = cat:match('^([%a-]+) vital articles$')
if class then -- Category:CLASS vital articles
class = class:match('(%a+)-Class') or class
return top(true, frame)
.. '[[Category:Vital articles by quality|' .. class .. ']]'
end
level, topic = cat:match('^Wikipedia level%-(%w+) vital articles in ([%a ]+)$')
if level and topic then -- Category:Wikipedia level-LEVEL vital articles in TOPIC
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:Vital articles in ' .. topic .. ' by quality|' .. class .. ']]'
.. '[[Category:' .. class .. ' vital articles by topic|' .. (topic=='an unknown topic' and 'Unknown' or topic) .. ']]'
end
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.