Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Abjiklam/sandbox
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!
local p = {} local infobox = require('Module:Infobox').infobox local infobox_image = require('Module:InfoboxImage').InfoboxImage local br = require('Module:Separated entries').br -- Add a book or category in the order it should appear in the infobox. -- The first element of each section is the section name. local books = { asoiaf = { "A Song of Ice and Fire", agot = "A Game of Thrones", acok = "A Clash of Kings", asos = "A Storm of Swords", affc = "A Feast for Crows", adwd = "A Dance with Dragon", twow = "The Winds of Winter", ados = "A Dream of Spring", }, todae = { "Tales of Dunk and Egg", thk = "The Hedge Knight", tss = "The Sworn Sword", tmk = "The Mystery Knight", }, other = { "Other Books", twoiaf = "The World of Ice and Fire", fab = "Fire and Blood", tpatq = "The Princess and the Queen", trp = "The Rogue Prince", tsotd = "The Sons of the Dragon", }, } local function generate_arms(arms) --This function generates small coat of arms icons return infobox_image({ args = { image = arms, size = '50x70px', border = 'no', suppressplaceholder = 'yes', } }) end function p.main(frame) -- The main function cleans up and formats all the arguments before -- passing them to the Infobox module. local original_arguments = frame.args -- arguments passed to this module local infobox_arguments = {} -- arguments given to the Infobox module ------ -- above (arms+name) ------ local above -- name local honorific_prefix = "" local honorific_suffix = "" if original_arguments.honorific_prefix and original_arguments.honorific_prefix ~= "" then honorific_prefix = mw.html.create('span') honorific_prefix:css('font-size', '80%') :css('font-weight', 'normal') :wikitext(original_arguments.honorific_prefix) end if original_arguments.honorific_suffix and original_arguments.honorific_suffix ~= "" then honorific_suffix = mw.html.create('span') honorific_suffix:css('font-size', '80%') :css('font-weight', 'normal') :wikitext(original_arguments.honorific_suffix) end local name = br({ tostring(honorific_prefix), original_arguments.name, tostring(honorific_suffix), }) -- arms -- more than 2 arms if original_arguments['arms3'] then above = mw.html.create('div') local coats_of_arms = above:tag('div') coats_of_arms:css('text-align', 'justify') :css('text-justify', 'distribute-all-lines') :css('margin-bottom', '-1em') for i=1,5 do local arms if i ~= 1 then arms = original_arguments['arms' .. tostring(i)] elseif original_arguments['arms1'] then arms = original_arguments['arms' .. tostring(1)] else arms = original_arguments['arms'] end if arms then coats_of_arms:wikitext(generate_arms(arms)) coats_of_arms:wikitext(" ") end end coats_of_arms:tag('span') :css('display', 'inline-block') :css('width', '100%') :css('height', '0') above:wikitext(name) -- 1 or 2 arms elseif original_arguments['arms'] or original_arguments['arms1'] then above = mw.html.create('table') above:css('width', '100%') above_row = above:tag('tr') local arms1, arms2 if original_arguments['arms1'] then arms1 = original_arguments['arms1'] else arms1 = original_arguments['arms'] end if original_arguments['arms2'] then arms2 = original_arguments['arms2'] else arms2 = arms1 end above_row:tag('td') :css('vertical-align', 'top') :css('text-align', 'left') :css('width', '50px') :wikitext(generate_arms(arms1)) above_row:tag('td') :css('vertical-align', 'middle') :css('text-align', 'center') :css('padding-bottom', '5px') :wikitext(name) above_row:tag('td') :css('vertical-align', 'top') :css('text-align', 'right') :css('width', '50px') :wikitext(generate_arms(arms2)) -- no arms else above = name end infobox_arguments.above = tostring(above) ------ -- image, caption and copyright ------ infobox_arguments.image = infobox_image({ args = { image = original_arguments.image, size = original_arguments.image_size, maxsize = '300px', sizedefault = 'frameless', alt = original_arguments.alt, border = 'yes', suppressplaceholder = 'yes', } }) infobox_arguments.headerstyle = "background-color:#f8e9d0;border:none;" return infobox(infobox_arguments) end return p
Summary:
Please note that all contributions to Stockhub 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
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Abjiklam/sandbox/doc
(
edit
)