Home
Random
Log in
Settings
About Brighter Shores Wiki
Disclaimers
Search
Editing
Module:Forumheader
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[=[ Implements {{Forumheader}}, displaying a header and adding relevant categories. Categories added by this module: > [[Category:Forum Grove]] > [[Category:Active threads]] > [[Category:Forums excluded from the main page]] > [[Category:Forum archives/$type]] > [[Category:Forum archives with invalid type parameter]] > [[Category:Forum archives with missing type parameter]] > [[Category:Forum archives by date closed]] > [[Category:Forum archives by month/$year]] > [[Category:Forum archives with missing date parameter]] > [[Category:Forum archives with missing name parameter]] > [[Category:Forum archives with missing subject parameter]] > [[Category:Forum archives with invalid closure parameter]] > [[Category:Forum archives with missing closure parameter]] ]=] require('strict') local lang = mw.getContentLanguage() local yesno = require('Module:Yesno') local p = {} -- Types of threads -> name of category local types = { community = 'Community', content = 'Content', discussion = 'Discussion', miscellaneous = 'Miscellaneous', policy = 'Policy', technical = 'Technical', ['user-related'] = 'User-related', meta = 'Meta', } -- Valid arguments for the "closure" parameter local closures = { 'allow', 'disallow', 'no consensus', 'withdrawn', 'no proposal', 'no formal closure', 'partial allow and partial disallow', } -- Category handler local function categories(_args, title) local cats = {} local args = {} -- make blank params behave like missing params for k, v in pairs(_args) do if v ~= '' then args[k] = v end end -- forum grove table.insert(cats, '[[Category:Forum Grove|' .. title .. ']]') -- option to hide the forum on the main page if yesno(args.mainpage) == false and not yesno(args.archive) then table.insert(cats, '[[Category:Forums excluded from the main page]]') end -- active/closed threads if yesno(args.archive) then -- handle type if args.type then local catType = types[args.type] if catType then table.insert(cats, '[[Category:Forum archives/' .. catType .. '|'.. title .. ']]') else table.insert(cats, '[[Category:Forum archives with invalid type parameter]]') end else table.insert(cats, '[[Category:Forum archives with missing type parameter]]') end -- date closed if args.date then local date_str = lang:formatDate('!c', args.date) table.insert(cats, '[[Category:Forum archives by date closed|*' .. dateStr .. ']]') local year = lang:formatDate('!Y', args.date) local month = tonumber(lang:formatDate('!n', args.date)) table.insert(cats, ('[[Category:Forum archives by month/%s|%x%s]]'):format(year, month, dateStr)) else table.insert(cats, '[[Category:Forum archives with missing date parameter]]') end -- other args if not args.user then -- @todo Should we do anything here? end if not args.name then table.insert(cats, '[[Category:Forum archives with missing name parameter]]') end if not args.subject then table.insert(cats, '[[Category:Forum archives with missing subject parameter]]') end if args.closure then local closure for _, v in pairs(closures) do if v == args.closure then closure = v break end end if not closure then table.insert(cats, '[[Category:Forum archives with invalid closure parameter]]') end else table.insert(cats, '[[Category:Forum archives with missing closure parameter]]') end else table.insert(cats, '[[Category:Active threads|'.. title .. ']]') end return table.concat(cats, '') end function p.main(frame) local args = frame:getParent().args local title = mw.title.getCurrentTitle().text local result = mw.html.create('div') :addClass('forumheader') :tag('strong'):wikitext('Forums:'):done() :wikitext(' [[Forum:Forum Grove|Forum Grove]] > ') :tag('strong'):wikitext(title):done() :done() -- Add [[Template:Archive]] if this is an archive -- @todo convert {{Archive}} into a module if yesno(args.archive) then result:node(frame:expandTemplate{ title = 'Archive', args = { date = args.date or '', user = args.user or '' } }) end -- Don't add categories to preload page [[Template:Forumheader/Forum Grove]] if title ~= 'Forumheader/Forum Grove' then result:wikitext(categories(args, title)) end return result end return p
Summary:
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see
Brighter Shores:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Forumheader/doc
(
view source
)