Module:MainPageSkinSwitch: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary Tag: Reverted |
mNo edit summary Tag: Reverted |
||
Line 4: | Line 4: | ||
local currentTitle = mw.title.getCurrentTitle() | local currentTitle = mw.title.getCurrentTitle() | ||
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 debug = "Function: getMainPageContent\n" | |||
debug = debug .. "Current page: " .. currentTitle.text .. "\n" | |||
debug = debug .. "Provided skin: " .. tostring(skin) .. "\n" | |||
debug = debug .. "mw.site.stats.skin: " .. tostring(mw.site.stats.skin) .. "\n" | |||
if currentTitle.text ~= 'Main Page' then | if currentTitle.text ~= 'Main Page' then | ||
debug = debug .. "Not on Main Page, returning empty string\n" | |||
return debug | |||
end | end | ||
local pageName = 'Template:MainPage/' .. (skin == 'citizen' and 'Citizen' or 'Vector') | local pageName = 'Template:MainPage/' .. (skin == 'citizen' and 'Citizen' or 'Vector') | ||
debug = debug .. "Attempting to load: " .. pageName .. "\n" | |||
local page = mw.title.new(pageName) | local page = mw.title.new(pageName) | ||
if not page then | if not page then | ||
debug = debug .. "Error: Page '" .. pageName .. "' does not exist.\n" | |||
return debug | |||
end | end | ||
local content = page:getContent() | local content = page:getContent() | ||
if not content then | if not content then | ||
debug = debug .. "Error: Unable to retrieve content from '" .. pageName .. "'.\n" | |||
return debug | |||
end | end | ||
return frame:preprocess(content) | debug = debug .. "Content retrieved successfully.\n" | ||
return frame:preprocess(content) .. "\n\n<!-- Debug Info:\n" .. debug .. "-->" | |||
end | end | ||
function p.debugInfo(frame) | function p.debugInfo(frame) | ||
return p.getMainPageContent(frame) | |||
end | end | ||
return p | return p |
Revision as of 17:31, 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'
local debug = "Function: getMainPageContent\n"
debug = debug .. "Current page: " .. currentTitle.text .. "\n"
debug = debug .. "Provided skin: " .. tostring(skin) .. "\n"
debug = debug .. "mw.site.stats.skin: " .. tostring(mw.site.stats.skin) .. "\n"
if currentTitle.text ~= 'Main Page' then
debug = debug .. "Not on Main Page, returning empty string\n"
return debug
end
local pageName = 'Template:MainPage/' .. (skin == 'citizen' and 'Citizen' or 'Vector')
debug = debug .. "Attempting to load: " .. pageName .. "\n"
local page = mw.title.new(pageName)
if not page then
debug = debug .. "Error: Page '" .. pageName .. "' does not exist.\n"
return debug
end
local content = page:getContent()
if not content then
debug = debug .. "Error: Unable to retrieve content from '" .. pageName .. "'.\n"
return debug
end
debug = debug .. "Content retrieved successfully.\n"
return frame:preprocess(content) .. "\n\n<!-- Debug Info:\n" .. debug .. "-->"
end
function p.debugInfo(frame)
return p.getMainPageContent(frame)
end
return p