Editing Module:IL

From Fallen London Wiki (Staging)

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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
 
local workarounds = require('Module:Workarounds')
 
local workarounds = require('Module:Workarounds')
  
--[[
 
--- Generates an image link with optional arguments for customization.
 
 
-- @see the documentation for the {{IL}} template for more information.
 
 
-- @param page The name of the page the image is associated with.
 
-- @param quantity (optional) The quantity of items to display.
 
-- @param appearance (optional) The appearance or label to use instead of the page name.
 
-- @param property (optional) A Semantic MediaWiki property to set for the page.
 
-- @param image (optional) The file name of the image to use. If not provided, it attempts to fetch from SMW.
 
-- @param size (optional) The size of the image. Defaults to '20px' if not provided.
 
-- @param link (optional) The link target for the image. If not provided, defaults to the page name.
 
-- @param small (optional) If set to 'yes', applies a smallification workaround to the image.
 
-- @return A string representing the HTML output for the image link.
 
]]
 
 
function p.IL_with_args(page, quantity, appearance, property, image, size, link, small)
 
function p.IL_with_args(page, quantity, appearance, property, image, size, link, small)
 
if not appearance then
 
if not appearance then
Line 74: Line 59:
 
local image_link = '[[File:' .. image .. '|' .. size .. '|link=' .. link .. '|alt=]]'
 
local image_link = '[[File:' .. image .. '|' .. size .. '|link=' .. link .. '|alt=]]'
 
local page_link_text = '[[' .. page .. (appearance and '|' .. appearance or '') .. ']]'
 
local page_link_text = '[[' .. page .. (appearance and '|' .. appearance or '') .. ']]'
 
 
  
 
-- replace !! with !!, probably to escape it? This was already in the original template: I'm blaming [[Tale of Terror!!]]
 
-- replace !! with !!, probably to escape it? This was already in the original template: I'm blaming [[Tale of Terror!!]]
Line 86: Line 69:
 
local output = mw.html.create('span')
 
local output = mw.html.create('span')
 
:addClass(class)
 
:addClass(class)
+
:wikitext(image_link .. ' ' .. page_link_text)
if appearance == '' then
 
output
 
:wikitext(image_link)
 
else
 
output
 
:wikitext(image_link .. ' ' .. page_link_text)
 
end
 
  
 
return tostring(output)
 
return tostring(output)
 
end
 
end
  
--[[
 
--- Wrapper function for IL_with_args to handle frame arguments from a template call.
 
 
-- @see the documentation for the {{IL}} template for more information.
 
 
-- @param frame The frame object from the invoking template.
 
-- @return A string representing the HTML output for the image link.
 
]]
 
 
function p.IL(frame)
 
function p.IL(frame)
 
local page = workarounds.get_arg(frame, 1)
 
local page = workarounds.get_arg(frame, 1)
 
local quantity = workarounds.get_arg(frame, 2)
 
local quantity = workarounds.get_arg(frame, 2)
local appearance = frame.args.Appearance -- Appearance is weird and needs an workaround, because having it set to a
+
local appearance = workarounds.get_arg(frame, 'Appearance')
-- value of '' is valid for not showing anything. Instead we set the special
 
-- value of nil-appearance in the template if it isn't used, and check for that 
 
 
local property = workarounds.get_arg(frame, 'Property')
 
local property = workarounds.get_arg(frame, 'Property')
 
local image = workarounds.get_arg(frame, 'Image')
 
local image = workarounds.get_arg(frame, 'Image')

Please note that all contributions to Fallen London Wiki (Staging) are considered to be released under the Creative Commons Attribution-ShareAlike (see Fallen London Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, 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. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)
Preview page with this template

Template used on this page: