Jump to content
Wikipedia The Free Encyclopedia

Module:Portal image banner

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page semi-protected Editing of this module by new or unregistered users is currently disabled.
See the protection policy and protection log for more details. If you cannot edit this module and you wish to make a change, you can submit an edit request , discuss changes on the talk page, request unprotection, log in, or create an account.
This module depends on the following other modules:

This module implements {{Portal image banner }}; see documentation there for usage instructions. This module will not work when used directly (as {{#invoke:Portal image banner|main}}). Rather it is advisable that the main template Portal image banner is used.

See also

Portal templates
Layout and formatting
Content transclusion
Content slideshows
Content randomisation
General
Linking templates
Talk pages / Maintenance
Images
Modules
Usage
The above documentation is transcluded from Module:Portal image banner/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}
 localrandomModule=require('Module:Random')

 p.main=function(frame)
 localparent=frame.getParent(frame)
 localparentArgs=parent.args
 localargs=cleanupArgs(parentArgs)
 localoutput=p._main(args)
 returnframe:preprocess(output)
 end

 functioncleanupArgs(argsTable)
 localcleanArgs={}
 forkey,valinpairs(argsTable)do
 iftype(val)=='string'then
 val=val:match('^%s*(.-)%s*$')
 ifval~=''then
 cleanArgs[key]=val
 end
 else
 cleanArgs[key]=val
 end
 end
 returncleanArgs
 end

 p._main=function(args)
 ifnotargs[1]then
 returnerror('No page specified',0)
 end
 locallines=makeGalleryLinesTable(args)
 returnmakeOutput(lines,args.overflow,args.maxheight,args.mode,args.croptop)
 end

 functionmakeGalleryLine(file,caption,link)
 localtitle=mw.title.new(file,"File")
 locallinktext=(linkand'{{!}}link='..linkor'')
 localmaxImageWidth='{{!}}800px'
 return'[['..title.prefixedText..(captionand'{{!}}'..captionor'')..maxImageWidth..linktext..']]'..(captionand'\n<div style="text-align:center;">'..caption..'</div>'or'\n')
 end

 functionmakeGalleryLineSlideshow(file,caption)
 localtitle=mw.title.new(file,"File")
 localcaptiontext='[[File:OOjs_UI_icon_info-progressive.svg|link=:'..title.prefixedText..']]&nbsp;<span style="font-size:110%;">'..(captionor'')..'</span>'
 returntitle.prefixedText..'{{!}}'..captiontext
 end

 functionmakeGalleryLinesTable(args)
 localgalleryLinesTable={}
 locali=1
 whileargs[i]do
 ifnotargs.modethen
 table.insert(galleryLinesTable,makeGalleryLine(args[i],args[i+1],args.link))
 elseifargs.mode=='slideshow'then
 table.insert(galleryLinesTable,makeGalleryLineSlideshow(args[i],args[i+1],args.link))
 else
 error('Mode not supported')
 end
 i=i+2
 end

 returngalleryLinesTable
 end

 functionmakeOutput(imageLines,overflow,maxHeight,mode,croptop)
 localrandomiseArgs={['t']=imageLines}
 localrandomisedLines=randomModule.main('array',randomiseArgs)
 localoutput,galleryContent
 ifnotmodethen
 galleryContent=table.concat(randomisedLines,'\n',1,1)
 seperate=mw.text.split(galleryContent,'\n')
 output='<div class="portal-banner-image" style="max-height:'..(maxHeightor'initial')..'; overflow:'..(overflowor'auto')..
 ';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptopor'0')..'%;">'..seperate[1]..'</div></div>'..seperate[2]
 elseifmode=='slideshow'then
 galleryContent=table.concat(randomisedLines,'\n')
 output='<div class="portal-banner-image-slideshow nomobile" style="max-height:'..(maxHeightor'initial')..'; overflow:'..(overflowor'auto')..
 ';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptopor'0')..'%;">'..'{{#tag:gallery|'..galleryContent..'|mode=slideshow}}'..'</div></div>'
 else
 error('Mode not supported')
 end

 returnoutput
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /