Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
MediaWiki help
Creopedia
Search
Search
Appearance
Log in
Personal tools
Log in
View source for Module:CreoLink
Module
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
←
Module:CreoLink
require( 'strict' ) local iconLink = require( 'Module:IconLink' ) local getOverworldThumbnail = require( 'Module:Creo' ).getOverworldThumbnail local p = {} --- Each Creo icon is cropped to its own Creo, so the icons have no common size --- to ask for: a width would enlarge the small ones. An empty size leaves the --- parameter out of the file link, which draws every icon at its own dimensions --- and lets the styles size the box around it. local ICON_SIZE = '' local STYLES = 'Module:CreoLink/styles.css' --- Read a wikitext flag --- --- Module:Arguments hands these over as strings, so a plain truth test would --- take 'no' for a yes. --- --- @param value any --- @return boolean local function isTruthy( value ) if value == nil or value == false then return false end value = mw.text.trim( tostring( value ) ):lower() return value ~= '' and value ~= '0' and value ~= 'no' and value ~= 'n' and value ~= 'false' end --- Wikitext entry point for the module --- --- @param frame mw.frame --- @return string function p.main( frame ) local getArgs = require( 'Module:Arguments' ).getArgs return p._main( getArgs( frame ) ) end --- Render the Creo link --- --- Pass inline=yes for the compact variant. A listing gives one Creo a row and --- can afford the box that keeps every Creo the same size; a party cell reads --- '<Creo> 80, <Creo> 80' inside a sentence and cannot, so the inline variant --- keeps to the line height instead. --- --- @param args table --- @return string function p._main( args ) args = args or {} local creoName = args.name or args[1] if type( creoName ) ~= 'string' or creoName == '' then error( 'No Creo name provided' ) end local classes = { isTruthy( args.inline ) and 't-creo-link--inline' or 't-creo-link', 'cp-image-pixelated' } if args.class then table.insert( classes, args.class ) end return mw.getCurrentFrame():extensionTag { name = 'templatestyles', args = { src = STYLES } } .. iconLink._main( { icon = getOverworldThumbnail( creoName ), link = args.link or creoName, text = args.text or creoName, size = ICON_SIZE, class = table.concat( classes, ' ' ) } ) end return p
Template used on this page:
Module:CreoLink/doc
(
view source
)
Return to
Module:CreoLink
.