Module:Main page: Difference between revisions
Adding IMP pages
https://support.wiki.gg>RheingoldRiver (Adding default set of pages) |
https://support.wiki.gg>Mr Pie 5 (Adding IMP pages) |
||
| Line 1: | Line 1: | ||
local trim = mw.text.trim | |||
local p = {} | local p = {} | ||
| Line 13: | Line 14: | ||
-- parse the arguments into CSS variables that contain legal syntax for grid-template-areas | -- parse the arguments into CSS variables that contain legal syntax for grid-template-areas | ||
local desktop = | local desktop = "--main-page-layout--desktop: '" .. string.gsub(trim(frame.args['desktop']), '\n', "' '") .. "';" | ||
local tablet = | local tablet = "--main-page-layout--tablet: '" .. string.gsub(trim(frame.args['tablet' ]), '\n', "' '") .. "';" | ||
local mobile = | local mobile = "--main-page-layout--mobile: '" .. string.gsub(trim(frame.args['mobile' ]), '\n', "' '") .. "';" | ||
-- grid-template-columns | |||
local desktop_cols = trim(string.gsub(frame.args['desktop-columns'] or '', ';', '')) | |||
local tablet_cols = trim(string.gsub(frame.args[ 'tablet-columns'] or '', ';', '')) | |||
local mobile_cols = trim(string.gsub(frame.args[ 'mobile-columns'] or '', ';', '')) | |||
if desktop_cols ~= '' then | |||
desktop = desktop .. '--main-page-layout-columns--desktop: '.. desktop_cols ..';' | |||
end | |||
if tablet_cols ~= '' then | |||
tablet = tablet .. '--main-page-layout-columns--tablet: '.. tablet_cols ..';' | |||
end | |||
if mobile_cols ~= '' then | |||
mobile = mobile .. '--main-page-layout-columns--mobile: '.. mobile_cols ..';' | |||
end | |||
local boxes = {} | local boxes = {} | ||
| Line 43: | Line 57: | ||
local output = '<div id="mp-container" style="' .. desktop .. tablet .. mobile .. '" data-sitename="' .. sitename .. '">' | local output = '<div id="mp-container" style="' .. desktop .. tablet .. mobile .. '" data-sitename="' .. sitename .. '">' | ||
-- loop through boxes and add the relevant | -- loop through boxes and add the relevant main page subpages into the output | ||
for _,box in pairs(boxes) do | for _,box in pairs(boxes) do | ||
if mw.title.new(sitename .. '/' .. box).exists then | if mw.title.new(sitename .. '/' .. box).exists then | ||