Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
Undid revision 953910898 by Sophivorus (talk)
Use i18n for errors and excerpt() strings
Line 553:
-- Main function returns a string value: text of the lead of a page
local function main(pageNames, options)
if not pageNames or #pageNames < 1 then return err("No page names givenpageNames") end
local pageName
local text
Line 588:
end
if not normalisedPageName then
return err("No title for page name noTitle" .., pageName)
else
pageName = normalisedPageName
Line 605:
pageCount = pageCount - 1 -- ensure that we exit the loop after at most #pageNames iterations
end
if not text then return err("Cannot read a valid page: first name is firstPage" .., firstPage) end
 
text = cleanupText(text, options)
Line 689:
local articleCount = #args -- must be 1 except with selected=Foo and Foo=Somepage
if articleCount < 1 and not (template == "selected" and args[template] and args[args[template]]) then
return err("No articles providednoArticle")
end
 
Line 700:
local text, title = getContent(page)
if not title then
return err("No title for page name noTitle" .., page)
elseif not text then
return err("No content for page name noContent" .., page)
end
if args["section"] then -- check relevant section only
text = getSection(text, args["section"], args["sectiononly"])
if not text then return err("No section noSection" .., args["section"] .. " in page " .., page) end
end
-- replace annotated links with real links
Line 775:
else
local hatnote = {}
hatnote[1] = 'This' .. (is(args.indicator) and ''d.excerpt.hatnote or ' section') d.excerpt. ' is an excerpt from 'hatnoteSection
hatnote[2] = '[['
hatnote[3] = article .. (is(section) and ('#' .. frame:callParserFunction( 'urlencode', section, 'WIKI' )) or '')
Line 783:
hatnote[7] = "''" .. '<span class="mw-editsection-like plainlinks"><span>[ </span>['
local title = mw.title.new(article) or mw.title.getCurrentTitle()
hatnote[8] = title:fullUrl('action=edit') .. ' edit' .. d.excerpt.edit
hatnote[9] = ']<span> ]</span></span>' .. "''"
output[4] = require('Module:Hatnote')._hatnote(table.concat(hatnote), {selfref=true}) or err("Error generating hatnote")
end
output[5] = '<' .. tag .. ' class="excerpt">\n'
Line 805:
output[6] = "[[Category:" .. d.brokenCategory .. "]]"
else
output[6] = frame:preprocess(text) or err("Error processing textpreprocess")
end
else
output[6] = err("No article providednoArticle")
end
output[7] = '</' .. tag .. '>'
output[8] = is(args.indicator) and ('</' .. tag .. '>') or ''
output[9] = '</' .. tag .. '>'
output[10] = mw.title.getCurrentTitle().isContentPage and ('[[Category:Articles' with.. excerptsd.excerpt.category .. ']]') or ''
return table.concat(output)