The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
function p.getWorldbuilderSection(frame) | function p.getWorldbuilderSection(frame) | ||
-- Get the title of the current page | -- Get the title of the current page | ||
local pageTitle = mw.title.getCurrentTitle(). | local pageTitle = mw.title.getCurrentTitle().text | ||
-- | -- Fetch the content of the Talk page | ||
local talkPageTitle = pageTitle | local talkPageTitle = 'Talk:' .. pageTitle | ||
local | local talkPage = mw.title.new(talkPageTitle) | ||
local | local talkContent = talkPage:getContent() | ||
-- | -- Define the URL for adding the Worldbuilder section | ||
local | local addSectionParams = { | ||
action = 'edit', | |||
section = 'new', | |||
preloadtitle = 'Worldbuilders', | |||
preload = 'Template:WorldbuilderPreload' -- Assuming you have a template for preload content | |||
} | |||
local addSectionUrl = mw.uri.fullUrl(talkPageTitle, addSectionParams).full | |||
-- Link text | -- Link text | ||
local addLinkText = 'Add worldbuilding credits now!' | local addLinkText = 'Add worldbuilding credits now!' | ||
-- Check if the Talk page exists and has content | -- Check if the Talk page exists and has content | ||
if not talkContent | if not talkContent then | ||
return '[' .. | return '[' .. addSectionUrl .. ' ' .. addLinkText .. ']' | ||
end | end | ||
Line 31: | Line 33: | ||
-- Check if the Worldbuilder section exists | -- Check if the Worldbuilder section exists | ||
if not worldbuilderSection then | if not worldbuilderSection then | ||
return '[' .. | return '[' .. addSectionUrl .. ' ' .. addLinkText .. ']' | ||
end | end | ||