Content deleted Content added
Sophivorus (talk | contribs) Move image params to Module:Excerpt/i18n and minor changes |
Sophivorus (talk | contribs) Add getTarget helper function to get the redirect target of a page and use it to solve redirects in the excerpt hatnote. Also make it accessible for templates and other Lua modules. |
||
Line 100:
return title:getContent(), title.prefixedText
end
-- Return the target of the redirect,
-- or the same title if it's not a redirect
-- or nil if the title was not found
local function getTarget(page)
local title = mw.title.new(page)
if title then
local target = title.redirectTarget
if target then
return target.prefixedText
end
return title.prefixedText
end
end
Line 700 ⟶ 714:
local tag = is(args.tag) and args.tag or 'div'
local article = is(args.article) and args.article or args[1] or '{{{1}}}'
article = getTarget(article) -- solve redirects
local section = is(args.section) and args.section or args[2]
local output = {}
output[1] = frame:extensionTag{ name = 'templatestyles', args = {src='Excerpt/styles.css'} }
Line 720 ⟶ 734:
hatnote[8] = title:fullUrl('action=edit') .. ' ' .. d.excerpt.edit
hatnote[9] = ']<span> ]</span></span>' .. "''"
output[4] = require('Module:Hatnote')._hatnote(table.concat(hatnote), {selfref=true}) or err("hatnote")
end
Line 733 ⟶ 746:
options.keepRefs = args.references or 1
options.keepSubsections = args.subsections
local pageNames = { (article .. '#' .. (section or '')) }
local text = main(pageNames, options)
if text == "" and d.brokenCategory and d.brokenCategory ~= "" and mw.title.getCurrentTitle().isContentPage then
output[6] = "[[Category:" .. d.brokenCategory .. "]]"
Line 744 ⟶ 755:
else
output[6] = err("noArticle")
end
output[7] = '</' .. tag .. '>'
Line 750 ⟶ 760:
output[9] = '</' .. tag .. '>'
output[10] = mw.title.getCurrentTitle().isContentPage and ('[[' .. d.excerpt.category .. ']]') or ''
return table.concat(output)
Line 822 ⟶ 831:
end
--
function p.lead(frame) return lead(frame) end
function p.target(frame) return getTarget(frame.args[1]) end
-- Entry points for English Wikipedia templates
Line 833 ⟶ 843:
-- Entry points for other Lua modules
function p.getTarget(page) return getTarget(page) end
function p.getContent(page, frame) return getContent(page, frame) end
function p.getsection(text, section) return getSection(text, section) end
|