Module:Program
This module if used to render a conference program as list, to make it easier to view on narrow screens. It has three functions: start
, item
and end_
(it's called that because end
is a keyword in Lua). that are used to display the program. The start
and end_
functions don't add any visible elements, but are needed for the layout to render properly.
This module was created for Wikimania 2019 and used on 2019:Program List. Several functions were not implemented fully, such as filtering and colour coded items.
Dependencies
editThis module relies on CSS to display properly. Add <templatestyles src="Program List.css" />
to any page invoking it. That CSS is also where you should make any modifications to the appearance of the list.
The items are displayed using Template:Program item.
Examples
edit{{#invoke:Program|start}} {{#invoke:Program|item|start=13:00|end=13:30|space=multimedia|room=Ebadi (D315)|title=Behind the scenes of the Odia Wikipedia how-to video tutorials|presenters=Subhashish Panigrahi, Soumendra Kumar Sahoo|workshop=yes|link=2019%3AMultimedia_knowledge/Behind_the_scenes_of_the_Odia_Wikipedia_how-to_video_tutorials}} {{#invoke:Program|item|start=13:00|end=14:00|space=technology|room=Strickland (B315)|title=Building Technical Capacity in Smaller Wikis|presenters=Birgit Müller|discussion=yes|link=2019%3ATechnology_outreach_%26_innovation/Building_Technical_Capacity_in_Smaller_Wikis}} {{#invoke:Program|end_}}
- 13:00 - 13:30 Ebadi (D315)
Behind the scenes of the Odia Wikipedia how-to video tutorials
Subhashish Panigrahi, Soumendra Kumar Sahoo
- 13:00 - 14:00 Strickland (B315)
Building Technical Capacity in Smaller Wikis
Birgit Müller
Filters
editThe module has been prepared to filter the program by space and identifier. This adds CSS-classes that hide all items that aren't explicitly shown. It has only been implemented for a few spaces and identifiers, more can be added to Template:Program List.css.
{{#invoke:Program|start}} {{#invoke:Program|item|start=13:00|end=13:30|space=multimedia|room=Ebadi (D315)|title=Behind the scenes of the Odia Wikipedia how-to video tutorials|presenters=Subhashish Panigrahi, Soumendra Kumar Sahoo|workshop=yes|link=2019%3AMultimedia_knowledge/Behind_the_scenes_of_the_Odia_Wikipedia_how-to_video_tutorials}} {{#invoke:Program|item|start=13:00|end=14:00|space=technology|room=Strickland (B315)|title=Building Technical Capacity in Smaller Wikis|presenters=Birgit Müller|discussion=yes|link=2019%3ATechnology_outreach_%26_innovation/Building_Technical_Capacity_in_Smaller_Wikis}} {{#invoke:Program|end_}}
local p = {}
local spaces = {
"accessibility",
"research",
"strategy",
"education",
"growth",
"technology",
"partnerships",
"technology",
"strategy",
"health",
"partnerships",
"multimedia",
"glam"
}
local identifiers = {
"workshop",
"panel",
"lightning",
"discussion",
"newbies",
"nophoto"
}
function p.start(frame)
local classString = "program"
local addedHide = false
for k, v in pairs(frame.args) do
if contains(spaces, k) and v == "show" then
if not addedHide then
classString = classString .. " hide-by-space"
addedHide = true
end
classString = classString .. " show-" .. k
end
end
classString = classString .. " " .. identifierClasses(frame.args)
return '<ol class="' .. classString .. ">"
end
function contains(list, item)
for _, i in pairs(list) do
if i == item then
return true
end
end
return false
end
function identifierClasses(args)
local classString = ""
local addedHide = false
for k, v in pairs(args) do
if contains(identifiers, k) and v == "show" then
if not addedHide then
classString = classString .. " hide-by-identifier"
addedHide = true
end
classString = classString .. " show-" .. k
end
end
return classString
end
function p.end_(frame)
return "</ol>"
end
function p.item(frame)
local classString = "item"
if frame.args["space"] ~= nil then
classString = classString .. " " .. frame.args["space"]
end
local timeString = "'''" .. frame.args["start"] .. " - " .. frame.args["end"] .. "'''"
local arguments = {
title = frame.args["link"],
displayname = frame.args["title"],
presenters = frame.args["presenters"]
}
-- Copy identifiers to the template.
for k, v in pairs(frame.args) do
for _, i in pairs(identifiers) do
if i == k then
arguments[k] = v
classString = classString .. " item-" .. k
end
end
end
text = frame:expandTemplate{title = "Program item", args = arguments}
local roomString = "''" .. frame.args["room"] .. "''"
local element = mw.html.create("li")
element
:addClass(classString)
:wikitext(timeString .. " " .. roomString .. "<br />" .. text)
return tostring(element)
end
return p