Content deleted Content added
Sophivorus (talk | contribs) No edit summary |
shuffle around |
||
(16 intermediate revisions by 4 users not shown) | |||
Line 1:
local p = {}
local excerptModule =
local slideshowModule = require('Module:Random slideshow/sandbox')
local randomModule = require('Module:Random')
Line 88:
end
)
end▼
end
Line 114 ⟶ 110:
return frame:preprocess(t)
end
-- else
return
▲end
local cleanUpExcerpt = function(excerpt)
return excerpt
end
Line 128 ⟶ 137:
local sortedTitles = nonRandom and titlesSequence or randomModule.main('array', {t=titlesSequence, limit=limit})
for _i, title in ipairs(sortedTitles) do
if (#galleryArgs / 2) < limit then
local success, excerpt =
if
mw.log("require('Module:Excerpt').get failed: " .. excerpt) -- probably got a redlink
excerpt = nil
end▼
end
if excerpt and excerpt ~= '' and #excerpt > 10 then -- check again in case we had a few characters plus
▲ -- strip galleries
▲ excerpt = mw.ustring.gsub(excerpt, "<%s*[Gg]allery.->.-<%s*/%s*[Gg]allery%s*>", "")
excerpt = excerpt .. " ('''[[" .. title .. "|" .. options.more .. "]]''')"
▲ -- strip tables and block templates; strip newlines and replace pipes within inline templates
▲ excerpt = mw.ustring.gsub(excerpt..'\n', '\n?%b{}\n?', processBraces)
▲ excerpt = mw.ustring.gsub(excerpt, '|', '|')
▲ -- replace wikitext bulleted lists with html bulleted lists
▲ excerpt = gsubWikitextLists(excerpt, '*', 'ul', 'li')
▲ -- replace wikitext numbered lists with html numbered lists
▲ excerpt = gsubWikitextLists(excerpt, '#', 'ol', 'li')
▲ excerpt = mw.text.trim(excerpt)
▲ if readmore_text then
end
local text = '<div style
table.insert(galleryArgs, 'File:Blank.png')
table.insert(galleryArgs, text)
Line 175 ⟶ 168:
local makeOptions = function(args)
local options = args -- pick up miscellaneous options: more, errors, fileargs
options.paraflags = excerptModule.numberFlags(args.paragraphs or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
options.fileflags = excerptModule.numberFlags(args.files or "") -- parse file numbers
options.ignoreOnlyincludes = options.ignoreOnlyincludes == nil and true or options.ignoreOnlyincludes -- default to true
if args.nostubs and isDeclined(args.nostubs) then
options.nostubs = false
Line 201 ⟶ 195:
local text = pageContent
if pageSection then -- check relevant section only
if not success then
mw.log("require('Module:Excerpt').getSection failed on the content of " .. args[ii] .. ": " .. result)
result = nil
▲ end
text = result or pageContent
end
-- begin BHG addition for tracking source pages
local thisPage = mw.title.getCurrentTitle().nsText .. ":" .. mw.title.getCurrentTitle().text
thisPage = thisPage:gsub('_', ' ') -- fix the nsText part, until [[phab:T369784]] is resolved
local thisBareParam = mw.ustring.gsub(args[ii], "^([^#]+).*$", "%1", 1) -- strip any section anchor from the parameter's page name
thisBareParam = thisBareParam:gsub('_', ' ') -- support underscores in parameter's page name
if (thisPage == thisBareParam) then
usesEmbeddedList = true;
Line 248 ⟶ 249:
local parent = frame.getParent(frame)
local output = p._excerpt(parent.args, 'random')
return frame:extensionTag{ name='templatestyles', args = { src='Module:Random slideshow/sandbox/styles.css'} }
end
Line 255 ⟶ 257:
local parent = frame.getParent(frame)
local output = p._excerpt(parent.args, 'linked')
return frame:extensionTag{ name='templatestyles', args = { src='Module:Random slideshow/sandbox/styles.css'} }
end
Line 262 ⟶ 265:
local parent = frame.getParent(frame)
local output = p._excerpt(parent.args, 'listitem')
return frame:extensionTag{ name='templatestyles', args = { src='Module:Random slideshow/sandbox/styles.css'} }
end
Line 270 ⟶ 274:
p._excerpt = function(_args, method)
local args = cleanupArgs(_args)
args.more = excerptModule.getMoreLinkText(_args.more)
end▼
local options = makeOptions(args)
local limit = args.limit and tonumber(args.limit) or DEFAULT_LIMIT
Line 286:
return slideshowModule._main(galleryArgs, false, 'excerptSlideshow-container') .. checksourcepages()
end
p._cleanUpExcerpt = cleanUpExcerpt
-- begin BHG addition for tracking source pages
Line 297 ⟶ 299:
local outlinecount = 0;
local retval ="";
local usesEponymousArticle = false;
local debugging = false;
local thisPageBareName = mw.title.getCurrentTitle().text;
if debugging then
retval = '<div style="display:block; border:10px solid green; background-color:#efe; padding:1em; margin:1em">\n----\n'
Line 314 ⟶ 318:
if (string.find(apage, "^[oO]utline +of ") == 1) then
outlinecount = outlinecount + 1;
end
if (apage == thisPageBareName) then
usesEponymousArticle = true;
end
pagecounter = pagecounter + 1
Line 327 ⟶ 334:
if (pagecounter == templatecount) then
if (templatecount == 1) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built solely from one template]]"
elseif (templatecount == 2) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built solely from two templates]]"
elseif (templatecount == 3) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built solely from three templates]]"
elseif (templatecount > 3) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built solely from four or more templates]]"
end
elseif (templatecount > 0) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built using one or more templates, and other sources]]"
end
end
if (outlinecount >= 1) then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built using one or more outline pages]]"
end
if (articlelistcount < 2) then
retval = retval .. "[[Category:Automated article-slideshow portals with less than 2 articles in article list]]"
elseif (articlelistcount <= 5) then
retval = retval .. "[[Category:Automated article-slideshow portals with 2–5 articles in article list]]"
elseif (articlelistcount <= 10) then
retval = retval .. "[[Category:Automated article-slideshow portals with 6–10 articles in article list]]"
elseif (articlelistcount <= 15) then
retval = retval .. "[[Category:Automated article-slideshow portals with 11–15 articles in article list]]"
elseif (articlelistcount <= 20) then
retval = retval .. "[[Category:Automated article-slideshow portals with 16–20 articles in article list]]"
elseif (articlelistcount <= 25) then
retval = retval .. "[[Category:Automated article-slideshow portals with 21–25 articles in article list]]"
elseif (articlelistcount <= 30) then
retval = retval .. "[[Category:Automated article-slideshow portals with 26–30 articles in article list]]"
elseif (articlelistcount <= 40) then
retval = retval .. "[[Category:Automated article-slideshow portals with 31–40 articles in article list]]"
elseif (articlelistcount <= 50) then
retval = retval .. "[[Category:Automated article-slideshow portals with 41–50 articles in article list]]"
elseif (articlelistcount <= 100) then
retval = retval .. "[[Category:Automated article-slideshow portals with 51–100 articles in article list]]"
elseif (articlelistcount <= 200) then
retval = retval .. "[[Category:Automated article-slideshow portals with 101–200 articles in article list]]"
elseif (articlelistcount <= 500) then
retval = retval .. "[[Category:Automated article-slideshow portals with 201–500 articles in article list]]"
elseif (articlelistcount <= 1000) then
retval = retval .. "[[Category:Automated article-slideshow portals with 501–1000 articles in article list]]"
elseif (articlelistcount > 1000) then
retval = retval .. "[[Category:Automated article-slideshow portals with over 1000 articles in article list]]"
end
if usesEmbeddedList then
retval = retval .. "[[Category:Automated article-slideshow portals with embedded list]]"
▲ end
if usesEponymousArticle then
retval = retval .. "[[Category:Automated article-slideshow portals with article list built using eponymous article]]"
end
return retval
|