Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:WritingCredits
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
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!
-- This module implements {{WritingCredits}}. -------------------------------------------------------------------------------- -- WritingCredits class -- The main class. -------------------------------------------------------------------------------- local WritingCredits = {} function WritingCredits.splitTable(tab) -- Split comma-separated values by letter/number local t = {} for v in string.gmatch(tab, "[%w%d]+") do t[#t+1] = v end return t end function WritingCredits.hasValue(tab, val) -- Check for value within table for k, v in ipairs(tab) do if v == val then return true end end return false end function WritingCredits.new(frame, args) args = args or {} local categories = "" -- Default order: writer, story, teleplay, storyboard, extras local defaultOrder = "w,s,t,sb,ex1,ex2,ex3" if args.tfirst then -- Teleplay before story (legacy support, will deprecate) defaultOrder = "t,w,s,sb,ex1,ex2,ex3" end local defaultOrder_split = WritingCredits.splitTable(defaultOrder) local givenOrder = args.order or "" local givenOrder_split = WritingCredits.splitTable(givenOrder) -- Order of parameters: any provided by template call in their order, then any undeclared in their default order for k, v in ipairs(defaultOrder_split) do if WritingCredits.hasValue(givenOrder_split, v) == false then table.insert(givenOrder_split, v) end end -- Default or custom labels local labels = {} local extraDefault = "Additional credits" labels['w'] = args['wlabel'] or "Written by" labels['s'] = args['slabel'] or "Story by" labels['t'] = args['tlabel'] or "Teleplay by" labels['sb'] = args['sblabel'] or "Storyboarded by" labels['ex1'] = args['ex1label'] or extraDefault labels['ex2'] = args['ex2label'] or extraDefault labels['ex3'] = args['ex3label'] or extraDefault -- Format labels and values local redundantLabel = false local writingCredits = args[1] or "" for _num, para in ipairs(givenOrder_split) do if args[para] then writingCredits = writingCredits .. (writingCredits ~= "" and "<br />" or "") .. ("<i>" .. labels[para] .. "</i> : " .. args[para]) -- Redundant label check; e.g. |slabel=Written by |s=John Doe (this should just be |w=John Doe) for l_para, l_label in pairs(labels) do -- e.g.: sb ~= t (and) labels[sb] == labels[t] (and) labels[sb] ~= extraDefault if l_para ~= para and labels[l_para] == labels[para] and l_label ~= extraDefault then redundantLabel = true end end end end local title = mw.title.getCurrentTitle() if title.namespace == 0 and redundantLabel then categories = categories .. "[[Category:Pages using Template:WritingCredits with redundant labels]]" end return writingCredits .. categories end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { removeBlanks = false, wrappers = 'Template:WritingCredits' }) return WritingCredits.new(frame, args) end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Category link with count
(
edit
)
Template:Mlx
(
edit
)
Template:Module link expanded
(
edit
)
Template:Sandbox other
(
edit
)
Module:Arguments
(
edit
)
Module:Separated entries
(
edit
)
Module:String
(
edit
)
Module:TableTools
(
edit
)
Module:WritingCredits/doc
(
edit
)