Editing
Module:Portal-inline
From Thetacola Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- determine whether we're being called from a sandbox local isSandbox = mw.getCurrentFrame():getTitle():find('sandbox', 1, true) local sandbox = isSandbox and '/sandbox' or '' local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local portalModule = require('Module:Portal'..sandbox) local getImageName = portalModule._image local checkPortals = portalModule._checkPortals local processPortalArgs = portalModule._processPortalArgs local p = {} -- Function to format error message and tracking category -- Arguments: -- errMsg: string, or nil/false if no error -- trackingCat: string for tracking category (or empty string) local function formatError(errMsg, trackingCat) local result = trackingCat or '' if errMsg then local errTag = mw.html.create('span') errTag:addClass("error") errTag:css("font-size",'100%') errTag:wikitext("Error: "..errMsg) result = tostring(errTag)..result end return result end local function image(portal, args) local size = args.size == "tiny" and "16x16px" or "32x28px" return string.format('[[File:%s|class=noviewer|%s]]',getImageName(portal,true), size) end local function link(portal, args) local displayName = "" if not (args.text == "" or args.text == nil) then displayName = args.text elseif args.short then displayName = portal else displayName = portal .. " portal" end return string.format('[[Portal:%s|%s]]',portal,displayName) end function p._main(portals, args) mw.logObject(args) -- Normalize all arguments if args.redlinks == 'include' then args.redlinks = true end for key, default in pairs({tracking=true,redlinks=false,short=false}) do if args[key] == nil then args[key] = default end args[key] = yesno(args[key], default) end local trackingCat = '' local errMsg = nil -- Check for existing categories, drop if not. -- Possible generate tracking category & error message if needed args.minPortals = args.minPortals or 1 args.maxPortals = args.maxPortals or 1 portals, trackingCat, errMsg = checkPortals(portals,args) -- use more specific tracking cat for inline portal trackingCat = mw.ustring.gsub(trackingCat,"Portal templates","Portal-inline template") -- either too many/few portals, or no portals left after filtering, then return if errMsg or #portals == 0 then return formatError(errMsg, trackingCat) end return image(portals[1],args)..' '..link(portals[1],args)..(trackingCat or '') end function p.main(frame) local origArgs = getArgs(frame) local portals, args = processPortalArgs(origArgs) return p._main(portals, args) end return p
Summary:
Please note that all contributions to Thetacola Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation subpage
(
edit
)
Template:High-use
(
edit
)
Template:Lua
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Sandbox other
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:High-use
(
edit
)
Module:List
(
edit
)
Module:Lua banner
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Portal-inline/doc
(
edit
)
Module:String
(
edit
)
Module:TableTools
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/P
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information