Module:Subpages 3: Difference between revisions

Undo revision 2020934 by Robkelk (talk)
mNo edit summary
(Undo revision 2020934 by Robkelk (talk))
Tag: Undo
 
(15 intermediate revisions by 2 users not shown)
Line 9:
"Analysis", "Characters", "Laconic", "Recap", "Trivia", "Setting", "YMMV",
"Fridge", "Fanfic Recs", "Haiku", "Headscratchers", "Ho Yay", "Image Links",
"Memes", "Radar", "Quotes", "Reviews", "Source", "Useful Notes", "WMG"
},
["creator"] = {"YMMV", "Quotes", "Fanfic Recs", "Analysis", "Trivia", "WMG", "Image Links", "Haiku", "Laconic"}
Line 15:
local crowners = {
["trope"] = { "Animation", "Animated Films", "Anime", "Anime and Manga", "Board Games", "Comics", "Comic Books",
"Fan Works", "FanfictionFanfic", "FilmFanfiction", "LiteratureFan Fiction", "Live Action TelevisionFilm", "Live Action TVFolklore", "MachinimaLiterature",
"MangaLive Action Television", "MangaLive andAction Anime", "MusicTV", "MusiciansMachinima",
"New MediaManga", "ProfessionalManga Wrestling",and "Puppet ShowsAnime", "RadioMusic", "Tabletop GamesMusicians", "Television",New "TVMedia",
"Opera", "Professional Wrestling", "Puppet Shows", "Radio", "Tabletop Games", "Tabletop RPGs",
"Television", "TV",
"Theatre", "Theater", "Toys",
"Webcomics", "Video Games", "Visual Art", "Visual Novels",
Line 34 ⟶ 36:
local insert = table.insert
local concat = table.concat
local find = mw.ustringstring.find
local len = mw.ustringstring.len
local sub = mw.ustringstring.sub
local rep = mw.ustringstring.rep
local listlevel = { '*', '**', '***', '****', '*****' }
 
Line 51 ⟶ 53:
if template == "index" then
template = "trope"
crowners["trope"] = {}
mainpage = ":" .. page
page = page:gsub("Category:", "", 1)
Line 62 ⟶ 65:
 
local tree = build_tree(page, subpage_list)
if true then return "tree time" end
 
-- initialize result with Main link
Line 108 ⟶ 110:
local jsdata = '<div id="tm-data" style="display:none" '
.. 'data-toplevelpage="' .. page .. '" '
.. 'data-wanted="' .. concat( missingout, "\t&#9;" ) .. '" '
.. 'data-templatetype="' .. template .. '" '
.. '></div>'
Line 128 ⟶ 130:
.. '* <strong><span id="tm-New"></span>Create New</strong><ul id="tm-wantedpages"></ul>\n'
.. jsdata
end
 
function sp.tree ( frame )
local page = frame.args[1] or frame:callParserFunction('TOPLEVELPAGE')
 
local allsptxt = frame:callParserFunction('SUBPAGES', { page, sep = "|" })
local subpage_list = split(allsptxt, "|")
 
local tree = build_tree(page, subpage_list)
 
if page:match("^Category:") then page = ":"..page end
return "; [["..page.."]]\n" .. build_list( tree, page..'/', 1 )
end
 
Line 141 ⟶ 155:
for i, dir in ipairs(list) do
if lastdir[dir] == nil then lastdir[dir] = { } end
lastdir = lastdir[dir]
end
Line 152 ⟶ 166:
local ul = {}
 
for page, branch in pairs(tree) do
local ordered_sp = {}
for page, branch in pairs(tree) do
insert(ordered_sp, page)
end
table.sort(ordered_sp)
 
for i = 1, #ordered_sp do
local page = ordered_sp[i]
local branch = tree[page]
local li