Module:MainPageSkinSwitch: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary Tag: Reverted |
mNo edit summary Tag: Reverted |
||
Line 5: | Line 5: | ||
local skin = frame.args[1] or mw.site.stats.skin or 'vector' | local skin = frame.args[1] or mw.site.stats.skin or 'vector' | ||
if currentTitle.text ~= 'Main Page' then | |||
if currentTitle.text ~= ' | return '' -- Return empty string if not on Main Page | ||
return '' -- Return empty string if not on | |||
end | end | ||
local pageName | local pageName = 'Template:MainPage/' .. (skin == 'citizen' and 'Citizen' or 'Vector') | ||
local page = mw.title.new(pageName) | local page = mw.title.new(pageName) | ||
Line 34: | Line 28: | ||
local skin = frame.args[1] or mw.site.stats.skin or 'vector' | local skin = frame.args[1] or mw.site.stats.skin or 'vector' | ||
local info = "Current page: " .. currentTitle.text .. "\n" | local info = "Current page: " .. currentTitle.text .. "\n" | ||
info = info .. "Is | info = info .. "Is Main Page: " .. tostring(currentTitle.text == 'Main Page') .. "\n" | ||
info = info .. "Detected skin: " .. tostring(skin) .. "\n" | info = info .. "Detected skin: " .. tostring(skin) .. "\n" | ||
info = info .. "mw.site.stats.skin: " .. tostring(mw.site.stats.skin) .. "\n" | info = info .. "mw.site.stats.skin: " .. tostring(mw.site.stats.skin) .. "\n" |
Revision as of 17:26, 1 August 2024
Documentation for this module may be created at Module:MainPageSkinSwitch/doc
local p = {}
function p.getMainPageContent(frame)
local currentTitle = mw.title.getCurrentTitle()
local skin = frame.args[1] or mw.site.stats.skin or 'vector'
if currentTitle.text ~= 'Main Page' then
return '' -- Return empty string if not on Main Page
end
local pageName = 'Template:MainPage/' .. (skin == 'citizen' and 'Citizen' or 'Vector')
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
function p.debugInfo(frame)
local currentTitle = mw.title.getCurrentTitle()
local skin = frame.args[1] or mw.site.stats.skin or 'vector'
local info = "Current page: " .. currentTitle.text .. "\n"
info = info .. "Is Main Page: " .. tostring(currentTitle.text == 'Main Page') .. "\n"
info = info .. "Detected skin: " .. tostring(skin) .. "\n"
info = info .. "mw.site.stats.skin: " .. tostring(mw.site.stats.skin) .. "\n"
return info
end
return p