Modul:Portal class
Penampilan
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local classification = require('Module:Library of Congress Classification')._classification
function p._portal_class(args)
local stylesheet = mw.getCurrentFrame():preprocess('<templatestyles src="Template:Portal Class/styles.css" />')
local box_div = mw.html.create('div'):addClass('wst-portal-class')
local in_portal_ns = (mw.title.getCurrentTitle().nsText == 'Portal')
-- title
local class_title = tostring(mw.html.create('div'):addClass('wst-portal-class-title'):wikitext('Kelas'))
-- class
local class_text = mw.html.create('div'):addClass('wst-portal-class-text')
local main_class = ''
if args.class == 'none' then
main_class = 'n/a'
elseif args.class then
main_class = '[[Portal:' .. classification({class = args.class}) .. '|' .. string.upper(args.class) .. ']]'
elseif in_portal_ns then
main_class = '?'
else
main_class = 'n/a'
end
local subclass1 = ''
if args.subclass1 then
subclass1 = '[[Portal:' .. classification({class = args.class, subclass1 = args.subclass1}) .. '|' .. string.upper(args.subclass1) .. ']]'
end
local subclass2 = ''
if args.subclass2 then
subclass2 = '[[Portal:' .. classification({class = args.class, subclass1 = args.subclass1, subclass2 = args.subclass2}) .. '|' .. string.upper(args.subclass2) .. ']]'
end
class_text:wikitext(main_class .. subclass1 .. subclass2)
class_text = tostring(class_text)
-- base
local base_text = tostring(mw.html.create('div'):addClass('wst-portal-class-base'):wikitext('[[Portal:Utama|Utama]]/[[Portal:Indeks|Indeks]]'))
-- categorization
local cat = ''
if args.class ~= 'none' and in_portal_ns then
args.class = string.lower(args.class or 'default')
local portal_categories = {
a = 'am',
b = 'ideologi',
c = 'historiografi',
d = 'sejarah',
-- e = 'United States',
-- f = 'American history',
g = 'geoantropologi',
h = 'sains sosial',
i = 'kebangsaan',
j = 'sains politik',
k = 'undang-undang',
l = 'pendidikan',
m = 'muzik',
n = 'seni',
p = 'bahasa',
q = 'sains',
r = 'perubatan',
s = 'pertanian',
t = 'teknologi',
u = 'ketenteraan',
v = 'perlautan',
x = 'lain-lain',
z = 'kepustakaan',
default = 'tanpa pengelasan'
}
cat = '[[Kategori:Portal ' .. (portal_categories[args.class] or portal_categories['default']) .. ']]'
end
box_div:wikitext(class_title .. class_text .. base_text .. cat)
return stylesheet .. tostring(box_div)
end
function p.portal_class(frame)
return p._portal_class(getArgs(frame))
end
return p