VOOZH about

URL: https://en.wikipedia.org/wiki/Module:Sister_project_logo

⇱ Module:Sister project logo - Wikipedia


Jump to content
From Wikipedia, the free encyclopedia
👁 Image
Module documentation
[view] [edit] [history] [purge]
👁 Image
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 template-protected
This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
👁 Warning
This Lua module is used on approximately 21,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
👁 Image
This module depends on the following other modules:

Usage

{{#invoke:Sister project logo|main}}

Generates correct wiki image markup for the logo of a sister project.

Parameters
project: A project name (e.g., "commons") or prefix (e.g., "n") that specifies a sister project
image: An image to use instead of the logo. "image=none" returns blank
size: The size of the logo, using the same format as standard image wiki markup. defaults to "40x40px". When "size=large", produces correct sizing for Template:Wikipedia's sister projects
class: One or more CSS classes to add to the logo. If more than one, they should be space-separated.

Logo filenames and other metadata are stored in Module:Sister project logo/data

require('strict')
localp={}
-- Lazy-load logo file names and other metadata
localdata=mw.loadData('Module:Sister project logo/data')
-- Convert table of arguments into wiki image markup
localfunctionimageMarkup(args)
localx={}
-- positional arguments first
for_,arginipairs(args)do
table.insert(x,arg)
end
-- named arguments converted to foo=bar
fork,vinpairs(args)do
ifnottonumber(k)then
table.insert(x,k..'='..v)
end
end
return'[['..table.concat(x,'|')..']]'
end
functionp._main(args)
locallocalArgs={}
-- map possibly verbose project argument into canonical project string
localproject=args.projectandargs.project:lower()
project=data.projectMap[project]orproject
-- image=none means bail (for [[Template:Sister project]])
ifargs.image=='none'then
return''
-- if image specified, return it instead of stored logo (for [[Template:Sister project]])
elseifargs.imagethen
returnargs.image
else
locallogoImage=data.logo[project]
-- if project is unknown, use Wikimedia logo (for [[Template:Sister project]])
ifnotlogoImagethen
project='wm'
logoImage=data.logo['wm']
end
table.insert(localArgs,'File:'..logoImage)
end
-- size=large means use sizes from [[Template:Wikipedia's sister projects]]
-- size defaults to 40x40px (for [[Template:Sister project]])
table.insert(localArgs,args.size=='large'and(data.largeSize[project]or'35px')orargs.sizeor'40x40px')
-- if logo is PD, blank link and alt (to suppress from screen readers)
ifdata.PDicon[project]then
localArgs.link=''
localArgs.alt=''
else
localArgs.alt=data.logoAlt[project]
end
-- For dark mode, flip dark-on-light icons to be light-on-dark
-- Also: use editor-specified classes (for [[Template:Sister-inline]])
localArgs.class="noviewer"..(data.darkOnLight[project]and" skin-invert-image"or"")
..(args.classand" "..args.classor"")
returnimageMarkup(localArgs)
end
functionp.main(frame)
localargs=require('Module:Arguments').getArgs(frame)
returnp._main(args)or''
end
returnp