Module:MainPageSkinSwitch: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary Tag: Reverted |
||
Line 2: | Line 2: | ||
function p.getMainPageContent(frame) | function p.getMainPageContent(frame) | ||
local | local vectorContent = p.getSkinContent('vector') | ||
local citizenContent = p.getSkinContent('citizen') | |||
return '<div id="vector-content" class="skin-content">' .. vectorContent .. '</div>' .. | |||
'<div id="citizen-content" class="skin-content" style="display:none;">' .. citizenContent .. '</div>' | |||
end | |||
function p.getSkinContent(skin) | |||
local pageName = 'Template:MainPage/' .. skin:gsub("^%l", string.upper) | |||
local page = mw.title.new(pageName) | local page = mw.title.new(pageName) | ||
if not page then | if not page then | ||
return "Error: Page '" .. pageName .. "' does not exist." | return "Error: Page '" .. pageName .. "' does not exist." | ||
end | end | ||
Line 21: | Line 19: | ||
local content = page:getContent() | local content = page:getContent() | ||
if not content then | if not content then | ||
return "Error: Unable to retrieve content from '" .. pageName .. "'." | return "Error: Unable to retrieve content from '" .. pageName .. "'." | ||
end | end | ||
return frame:preprocess(content) | return frame:preprocess(content) | ||
end | end | ||
return p | return p |
Revision as of 16:24, 1 August 2024
Documentation for this module may be created at Module:MainPageSkinSwitch/doc
local p = {}
function p.getMainPageContent(frame)
local vectorContent = p.getSkinContent('vector')
local citizenContent = p.getSkinContent('citizen')
return '<div id="vector-content" class="skin-content">' .. vectorContent .. '</div>' ..
'<div id="citizen-content" class="skin-content" style="display:none;">' .. citizenContent .. '</div>'
end
function p.getSkinContent(skin)
local pageName = 'Template:MainPage/' .. skin:gsub("^%l", string.upper)
local page = mw.title.new(pageName)
if not page then
return "Error: Page '" .. pageName .. "' does not exist."
end
local content = page:getContent()
if not content then
return "Error: Unable to retrieve content from '" .. pageName .. "'."
end
return frame:preprocess(content)
end
return p