Module:Excerpt slideshow/sandbox
Appearance
![]() | This is the module sandbox page for Module:Excerpt slideshow (diff). |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
This module allows article excerpt (from Module:Excerpt) to be put into a slideshow (using Module:Random slideshow). It is intended to be used in portals.
The following templates use this module:
- {{Transclude excerpts as random slideshow}}
- {{Transclude linked excerpts as random slideshow}}
- {{Transclude list item excerpts as random slideshow}}
Tracking categories
The following categories track use where the "Selected general articles" list is built solely from templates:
- Category:Automated portals with article list built solely from one template (population: 0)
- Category:Automated portals with article list built solely from two templates (population: 0)
- Category:Automated portals with article list built solely from three templates (population: 0)
- Usages with more than three templates are not currently tracked
Pages where the "Selected general articles" list is built from a list embeded in the portal:
- Category:Automated portals with embedded list (population: 0)
Note that the Category:Automated portals with embedded list was enabled on 19 April 2019, and it will probably take a few days for all the portal pages to update
Testcases
The following testcase pages are available for testing changes made to this module's sandbox:
- Template:Transclude excerpts as random slideshow/testcases
- Template:Transclude linked excerpts as random slideshow/testcases
- Template:Transclude list item excerpts as random slideshow/testcases
See also
local p = {}
local excerptModule = require('Module:Excerpt')
local slideshowModule = require('Module:Random slideshow')
function cleanupArgs(argsTable)
local cleanArgs = {}
for key, val in pairs(argsTable) do
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val ~= '' then
cleanArgs[key] = val
end
else
cleanArgs[key] = val
end
end
return cleanArgs
end
local makeGalleryArgs = function(titles, options)
local galleryArgs = {}
local i = 1
while titles[i] do
local excerpt = excerptModule.main({titles[i]}, options)
if excerpt then
local text = '<div style{{=}}text-align:left;>' .. mw.ustring.gsub(excerpt, '%c', '<br>') .. '</div>'
table.insert(galleryArgs, 'File:Blank.png')
table.insert(galleryArgs, text)
end
i = i + 1
end
return galleryArgs
end
-- randomExcerpt: Titles specified in template parameters (equivalent to {{Transclude random excerpt}})
p.randomExcerpt = function(frame)
local parent = frame.getParent(frame)
local output = p._randomExcerpt(parent.args)
return frame:preprocess(output)
end
p._randomExcerpt = function(_args)
local args = cleanupArgs(_args)
-- check for blank value in more parameter
if _args.more and not args.more then
args.more = "Read more..." -- default text for blank more=
end
local galleryArgs = {}
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
local galleryArgs = makeGalleryArgs(args, options)
return slideshowModule._main(galleryArgs, false, 'excerptSlideshow-container')
end
-- TODO linkedExcerpt: Titles from links on a page (equivalent to {{Transclude linked excerpt}})
-- TODO listItemExcerpt: Titles from linked list items on a page (equivalent to {{Transclude list item excerpt}})
return p