Module:Navbar: Difference between revisions
also trap talk title
m>Dragons flight (handle expensive parser function limit without killing the box) |
m>Dragons flight (also trap talk title) |
||
Line 21: | Line 21: | ||
function getTitle( pageName ) | function getTitle( pageName ) | ||
pageName = trim( pageName ); | pageName = trim( pageName ); | ||
local page_title, talk_page_title; | |||
if mw.ustring.sub(pageName, 1, 1) == ':' then | if mw.ustring.sub(pageName, 1, 1) == ':' then | ||
page_title = mw.title.new( mw.ustring.sub(pageName, 2) ); | |||
else | else | ||
page_title = mw.title.new( pageName, 'Template' ); | |||
end | end | ||
if page_title then | |||
talk_page_title = page_title.talkPageTitle; | |||
else | |||
talk_page_title = nil; | |||
end | |||
return page_title, talk_page_title; | |||
end | end | ||
Line 33: | Line 43: | ||
end | end | ||
local good, title; | local good, title, talk_title; | ||
good, title = pcall( getTitle, args[1] ); | good, title, talk_title = pcall( getTitle, args[1] ); | ||
if not good then | if not good then | ||
return error('Expensive parser function limit exceeded'); | return error('Expensive parser function limit exceeded'); | ||
Line 44: | Line 54: | ||
local mainpage = title.fullText; | local mainpage = title.fullText; | ||
local talkpage = | local talkpage = talk_title and talk_title.fullText or '' | ||
local editurl = title:fullUrl( 'action=edit' ); | local editurl = title:fullUrl( 'action=edit' ); | ||