Module:Portal-inline
Appearance
![]() | 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 Lua module is used on approximately 242,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
This module implements Template:Portal-inline. This module accepts one unnamed parameter which is the portal to link to and several named parameters:
size
— optional; Specify|size=small
to show a 23x20 image or|size=tiny
for a 17×15 image instead of the usual size.text
— optional; Specify|text=(name)
for a different associated name to appear.short
— optional; Specify|short=anything
to remove portal from the output.redlinks
— optional; Specify|redlinks=yes
to show the portal if it is redlinked.nowrap
— optional; Specify|nowrap=yes
to prevent the entire output from wrapping.
local getImageName = require( 'Module:Portal' ).image
local p = {}
local function checkPortalExists(portal)
return not (mw.title.makeTitle(100, portal).id == 0)
end
function p._main(portal)
-- If no portals have been specified, display an error and add the page to a tracking category.
if not portal then
root:wikitext('<span style="font-size:100%;" class="error">error: missing portal name.</span></strong>[[Category:Portal templates without a parameter]]')
return tostring(root)
end
if not pcall(checkPortalExists, portal) or not checkPortalExists(portal) then
-- Getting here means a redlinked portal has been found
if not ((args.redlinks == 'yes') or (args.redlinks == 'y') or (args.redlinks == 'true') or (args.redlinks == 'include')) then
-- just return if redlinks is not "yes" or similar
root:wikitext('[[Category:Portal templates all redlinked portals]]')
return tostring(root)
end
root:wikitext('[[Category:Portal templates all redlinked portals]]')
end
-- display portal-inline content
end