Module:Draft topics
Implements {{Draft topics}}
local getArgs = require('Module:Arguments').getArgs
local resolveRedirect = require('Module:Resolve category redirect')
local p = {}
local map = {
['biography'] = 'biographies',
['women'] = 'women',
['food-and-drink'] = 'food and drink',
['internet-culture'] = 'Internet culture',
['linguistics'] = 'linguistics',
['literature'] = 'literature',
['books'] = 'books',
['entertainment'] = 'entertainment',
['films'] = 'films',
['media'] = 'media',
['music'] = 'music',
['radio'] = 'radio',
['software'] = 'software',
['television'] = 'television',
['video-games'] = 'video games',
['performing-arts'] = 'performing arts',
['philosophy-and-religion'] = 'philosophy and religion',
['sports'] = 'sports',
['architecture'] = 'architecture',
['comics-and-anime'] = 'comics and anime',
['fashion'] = 'fashion',
['visual-arts'] = 'visual arts',
['geographical'] = 'geography',
['africa'] = 'Africa',
['central-africa'] = 'Central Africa',
['eastern-africa'] = 'Eastern Africa',
['northern-africa'] = 'Northern Africa',
['southern-africa'] = 'Southern Africa',
['western-africa'] = 'Western Africa',
['central-america'] = 'Central America',
['north-america'] = 'North America',
['south-america'] = 'South America',
['asia'] = 'Asia',
['central-asia'] = 'Central Asia',
['east-asia'] = 'East Asia',
['north-asia'] = 'North Asia',
['south-asia'] = 'South Asia',
['southeast-asia'] = 'Southeast Asia',
['west-asia'] = 'West Asia',
['eastern-europe'] = 'Eastern Europe',
['europe'] = 'Europe',
['northern-europe'] = 'Northern Europe',
['southern-europe'] = 'Southern Europe',
['western-europe'] = 'Western Europe',
['oceania'] = 'Oceania',
['business-and-economics'] = 'business and economics',
['education'] = 'education',
['history'] = 'history',
['military-and-warfare'] = 'military and warfare',
['politics-and-government'] = 'politics and government',
['society'] = 'society',
['transportation'] = 'transportation',
['biology'] = 'biology',
['chemistry'] = 'chemistry',
['computing'] = 'computing',
['earth-and-environment'] = 'earth and environment',
['engineering'] = 'engineering',
['libraries-and-information'] = 'libraries and information',
['mathematics'] = 'mathematics',
['medicine-and-health'] = 'medicine and health',
['physics'] = 'physics',
['stem'] = 'STEM',
['space'] = 'space',
['technology'] = 'technology'
}
local allowed = {}
for _, v in pairs(map) do
allowed[v] = true
end
local function resolve(cat, frame)
local full = 'Draft articles about ' .. cat
local ok, result = pcall(function()
return resolveRedirect.rtarget(full, frame)
end)
if not ok or not result or result == '' then
return cat
end
result = result:gsub('^Category:%s*', '')
result = result:gsub('^Draft articles about%s+', '')
return result
end
function p.main(frame)
local args = getArgs(frame)
local ns = mw.title.getCurrentTitle().namespace
if ns ~= 118 and ns ~= 2 then
return '[[Category:Draft topics used in wrong namespace]]'
end
if not args[1] then
return '[[Category:Draft articles tagged with invalid topic parameter]]'
end
local output = {}
local hasError = false
for _, topic in ipairs(args) do
local base = map[topic] or topic
local resolved = resolve(base, frame)
if not allowed[resolved] then
hasError = true
else
table.insert(output, '[[Category:Draft articles about ' .. resolved .. ']]')
end
end
if hasError then
table.insert(output, '[[Category:Draft articles tagged with invalid topic parameter]]')
end
return table.concat(output)
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.