Difference between revisions of "Template:comic/sandbox"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
Line 93: Line 93:
 
               -->[[{{LATESTCOMIC}}{{!}}<span style="color: #FFFFFF; padding: 0 12px; white-space: nowrap;" title="">&gt;&#124;</span>]]</li><!--
 
               -->[[{{LATESTCOMIC}}{{!}}<span style="color: #FFFFFF; padding: 0 12px; white-space: nowrap;" title="">&gt;&#124;</span>]]</li><!--
  
         Comic number (plus one) is the latest, so don't show the buttons
+
         Comic number (plus one) is the latest, so don't show the buttons.
 +
        These spaces below are needed to make the other buttons look like they're centered even tho they're left-aligned
 
         -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}|          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}<!--
 
         -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}|          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}<!--
 
     --></ul></td></tr><!--
 
     --></ul></td></tr><!--
Line 125: Line 126:
 
     --></span>}}</td></tr><!--</table>
 
     --></span>}}</td></tr><!--</table>
  
       Ok, the upper row is done! Now, let's make the lower WHITE row.
+
       Ok, the upper navigation bar is done! Now, let's make the lower WHITE navbar.
 
       You probably haven't seen this, check out comic [[10]] and others.
 
       You probably haven't seen this, check out comic [[10]] and others.
 
       This is only displayed if {{{ognumber}}} is specified, otherwise it's replaced by the "gray" navbar (we'll make it below).
 
       This is only displayed if {{{ognumber}}} is specified, otherwise it's replaced by the "gray" navbar (we'll make it below).
Line 136: Line 137:
 
     -->{{#if:{{{ognumber|}}}|{{#ifexpr:{{{ognumber|1}}}!=7<!--
 
     -->{{#if:{{{ognumber|}}}|{{#ifexpr:{{{ognumber|1}}}!=7<!--
  
         {{{ognumber}}} is GIVEN and not 7, so make a list item and put a button in it that links to #7
+
         {{{ognumber}}} is given and not 7 (Why #7 and not #1? → see [[LiveJournal]]), so make a list item and put a button in it that links to #7
 
       -->|<li style="background-color: #FFFFF;
 
       -->|<li style="background-color: #FFFFF;
 
               border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
 
               border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
Line 156: Line 157:
 
               -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- added 9 cuz september
 
               -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- added 9 cuz september
  
-->}}}}<!-- NEW 2 CURLY BRACKET here
+
-->}}}}<!--
  
           Regarding {{{ognumber}}}, we need to say the original comic number at the center.
+
           Since we have {{{ognumber}}}, we need to say the original comic number at the center.
 
       -->{{#if:{{{ognumber|}}}|<!--{{#ifexpr:{{{ognumber|1}}}!=7|--><!--
 
       -->{{#if:{{{ognumber|}}}|<!--{{#ifexpr:{{{ognumber|1}}}!=7|--><!--
  
           Ok it's not #7, go wild
+
           Ok it's not #7 (Why #7 and not #1? → see [[LiveJournal]]), go wild
 
       --><li style="background-color: #FFFFFF;
 
       --><li style="background-color: #FFFFFF;
 
           border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
 
           border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
Line 167: Line 168:
 
           margin: 0 4px; padding: 1.5px 0;" class="plainlinks"><!--
 
           margin: 0 4px; padding: 1.5px 0;" class="plainlinks"><!--
  
          [ and ] makes an external link, vs. [[ and ]] which are internal only.
 
 
           Depending on whether {{{ognumber}}} is 7 or not, toggle between using wide link mode or number link mode.
 
           Depending on whether {{{ognumber}}} is 7 or not, toggle between using wide link mode or number link mode.
 
           Wide link mode requires {{{lappend}}} to be set, while {{{ldomain}}} can default to www
 
           Wide link mode requires {{{lappend}}} to be set, while {{{ldomain}}} can default to www
Line 177: Line 177:
  
 
           NOT USING THESE - Comic number is invalid or doesn't exist, use wide link mode
 
           NOT USING THESE - Comic number is invalid or doesn't exist, use wide link mode
           |https://{{{ldomain|www}}}.xkcd.com/{{{lappend}}}}}        would need another two curly because added another IF statement
+
           |https://{{{ldomain|www}}}.xkcd.com/{{{lappend}}}}}        This would need another two curly because added another IF statement
  
           Generate the title, with ognote if it exists
+
           Ok now generate the number, with ognote if it exists (or else it defaults to "(Original Order)")
 
           -->[[LiveJournal#G|<span style="color: #6E7B91; padding: 0 12px;" title="Learn why the original xkcd comics were in a different order!"><!--
 
           -->[[LiveJournal#G|<span style="color: #6E7B91; padding: 0 12px;" title="Learn why the original xkcd comics were in a different order!"><!--
 
            
 
            
 
           Add ognote in parenthesis
 
           Add ognote in parenthesis
 
           -->&#35;{{{ognumber|}}}&nbsp;{{#if:{{{ognote|}}}|({{#replace:{{{ognote}}}| |&nbsp;}})|(Original&nbsp;Order)}}<!-- Comic&nbsp;&#35;{{{ognumber|}}}&nbsp;<u>(Original&nbsp;order)</u>
 
           -->&#35;{{{ognumber|}}}&nbsp;{{#if:{{{ognote|}}}|({{#replace:{{{ognote}}}| |&nbsp;}})|(Original&nbsp;Order)}}<!-- Comic&nbsp;&#35;{{{ognumber|}}}&nbsp;<u>(Original&nbsp;order)</u>
 
 
           --></span>]]}}</li><!--
 
           --></span>]]}}</li><!--
  
         Now make the next and >| buttons, provided the ognumber exists
+
         Now make the next and >| buttons, provided the {{{ognumber}}} exists
        I won't touch these
 
        I WILL!
 
 
       -->{{#ifexist:{{#expr:{{{ognumber|-2}}}+1}}<!--
 
       -->{{#ifexist:{{#expr:{{{ognumber|-2}}}+1}}<!--
  
 
         Check if this is 55 (which is the latest LiveJournal comic). If it is 55, then don't display the "Next" and >| buttons.
 
         Check if this is 55 (which is the latest LiveJournal comic). If it is 55, then don't display the "Next" and >| buttons.
 +
        (Why #55 and not #LATESTCOMIC? → see [[LiveJournal]])
 
         -->|{{#ifexpr:55-{{{ognumber|1}}}>0<!--
 
         -->|{{#ifexpr:55-{{{ognumber|1}}}>0<!--
  
         Comic number IS NOT 55, generate the Next buttons
+
         Comic number IS NOT 55, generate the Next and >| buttons
 
         -->|<li style="background-color: #FFFFF;
 
         -->|<li style="background-color: #FFFFF;
 
               border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
 
               border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
Line 210: Line 208:
  
 
         Comic number (plus one) is the latest, so don't show the buttons
 
         Comic number (plus one) is the latest, so don't show the buttons
         -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              }}|}}</ul></td></tr><!-- YES I ADDED TWO
+
         -->|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              }}|}}</ul></td></tr>
 
 
  
 
       Ok, that row's done. But it'll be hidden if the comic is one of the first 55.
 
       Ok, that row's done. But it'll be hidden if the comic is one of the first 55.
 
       So let's make the lower GRAY row. This is hidden if {{{ognumber}}} is specified, because it's replaced by the "white" navbar above.
 
       So let's make the lower GRAY row. This is hidden if {{{ognumber}}} is specified, because it's replaced by the "white" navbar above.
 +
      This will be shown on almost all comics.
 
       This table will contain a table row (tr) and cell (td)
 
       This table will contain a table row (tr) and cell (td)
 
       -->{{#ifexist: {{{ognumber}}} | <!-- If ognumber is provided, hide the entire block, if not show it  
 
       -->{{#ifexist: {{{ognumber}}} | <!-- If ognumber is provided, hide the entire block, if not show it  
Line 242: Line 240:
 
       -->[[{{#expr:{{{number|2}}}-1}}|<span style="color: #FFFFFF; padding: 0 12px;" title="">&lt;&nbsp;Prev</span>]]</li><!--
 
       -->[[{{#expr:{{{number|2}}}-1}}|<span style="color: #FFFFFF; padding: 0 12px;" title="">&lt;&nbsp;Prev</span>]]</li><!--
  
If {{{number}}} is valid, we need to make the RANDOM COMIC LINK
+
If {{{number}}} is valid, we need to make the RANDOM COMIC LINK in the center
 
--><li style="background-color: #6E7B91;
 
--><li style="background-color: #6E7B91;
 
     border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
 
     border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
Line 258: Line 256:
 
     -->|{{#ifexpr:{{LATESTCOMIC}}-{{{number|0}}}>0<!--
 
     -->|{{#ifexpr:{{LATESTCOMIC}}-{{{number|0}}}>0<!--
  
     Comic number is not the latest, generate the buttons
+
     Comic number is not the latest, so generate the Next and >| buttons
 
     -->|<li style="background-color: #6E7B91;
 
     -->|<li style="background-color: #6E7B91;
 
           border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
 
           border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray;
Line 272: Line 270:
 
           -->[[{{LATESTCOMIC}}{{!}}<span style="color: #FFFFFF; padding: 0 12px; white-space: nowrap;" title="">&gt;&#124;</span>]]</li><!--
 
           -->[[{{LATESTCOMIC}}{{!}}<span style="color: #FFFFFF; padding: 0 12px; white-space: nowrap;" title="">&gt;&#124;</span>]]</li><!--
  
     Instead here comic number (plus one) is the latest, so don't show the buttons
+
     Instead here comic number (plus one) is the latest, so don't show the Next buttons (there are no next comics)
 
     -->|}}|}}<!--
 
     -->|}}|}}<!--
 
          
 
          
 
 
       Here {{{number}}} doesn't exist or is less than 1; just put nothing here
 
       Here {{{number}}} doesn't exist or is less than 1; just put nothing here
 
         -->|}}<!--
 
         -->|}}<!--
 
--></ul></td></tr>}}</table><!--
 
--></ul></td></tr>}}</table><!--
 
  
 
     Add the comics to the automatic categories.
 
     Add the comics to the automatic categories.
  
     Sort this page in categories by number. The padding ensures that #9 comes before #10
+
     Put this page in categories by number. The padding ensures that #9 comes before #10
 
     It otherwise sorts 'alphanumerically'; since the first character of "10" is "1", it would normally be placed before "9" even though it should be placed after
 
     It otherwise sorts 'alphanumerically'; since the first character of "10" is "1", it would normally be placed before "9" even though it should be placed after
 
     The padding turns each into 0009 and 0010 etc. Now, since "0" is less than "1", #9 gets sorted before #10.
 
     The padding turns each into 0009 and 0010 etc. Now, since "0" is less than "1", #9 gets sorted before #10.
Line 302: Line 298:
 
     --></includeonly><noinclude><!--
 
     --></includeonly><noinclude><!--
  
       DOCUMENTATION
+
       DOCUMENTATION-->{{:Template:comic/doc}}[[Category:Templates]]</noinclude>
-->{{:Template:comic/doc}}
 
[[Category:Templates]]</noinclude>
 

Revision as of 17:26, 22 April 2025

The template {{comic}} has an associated sandbox, available at Template:comic/sandbox.


This is the basic infobox-style header template used to display xkcd comics on their own pages, including the comic number (with external link to xkcd), publication date, title, comic image, and title text.

(edit documentation)

Usage

{{comic
| number    =
| date      =
| title     =
| ognumber  =
| oglink    =
| ogttlabel =
| ogtitle   =
| ogprev    =
| ognote    =
| ognext    =
| before    =
| image     =
| custom    =
| imagesize =
| noexpand  =
| titletext =
| ttstyle   =
| bodystyle =
| bodyclass =
| extra     =
| ldomain   =
| lappend   =
}}
Ambox notice.png The new parameters are undocumented! There's some info about them in the code.
ogttlabel = optional
ognumber  = 
ogprev    = required if ognumber given, otherwise throws an error
ognote    = optional
ognext    = required if ognumber given, otherwise throws an error
Parameter Usage Description
number Required in normal circumstances The comic's basic information. In normal circumstances, these should always be defined.
title Required in normal circumstances
image Required in normal circumstances
date Optional; omit if unreleased or undated The date the comic was first published and should be written in the form mmmm d, yyyy. (Full month name, day number without digit padding, 4-digit year. Example: January 1, 2006). If the comic has no date or has not been released, it should be omitted.
ognumber Optional; only used for early comics Must always be used together for the early xkcd comics, not when Randall changes the title of an existing comic. Note that if ognumber is given, some parameters are required.
oglink
ogtitle
before Optional; used for long comics Used to insert text before the comic, usually to insert a link to skip to the explanation on extremely large comics like 1732: Earth Temperature Timeline or for the comic itself if it's just text like Blue Eyes. The text provided to this parameter is placed on the line between the title and the image. This parameter is optional. The wikitext used to jump to the ==Explanation== is [[#Explanation|↓ Skip to explanation ↓]].
imagesize Optional; limits image display size Limits the size of the image in pixels.
  • To limit the width, simply list the width. E.g.: 350px
  • To limit the height, prepend an "x" to the desired height. E.g.: x400px

Note that, if the imagesize is larger than the image, the image will be stretched.

noexpand Optional; used when imagesize limits display Boolean to hide the "Click to enlarge" button, usually when using imagesize.
custom Optional; overrides image Replaces the comic image with custom text or content.
titletext Optional; sets title text Sets the title text of the comic.
ttstyle Optional; styles title text Sets the CSS style of the titletext span element.
bodystyle Optional; sets wrapper style Sets the inline CSS style of the outer comic container.
bodyclass Optional; sets wrapper class Sets the HTML class attribute of the outer comic container.
extra Optional; boolean When set to yes, adds the page to the Extra comics category.
lappend Required if number is missing The part of the link appended to xkcd.com/ in "wide link mode". Required when number is not set.
ldomain Optional; changes link domain Sets the subdomain for the link (e.g., blog for blog.xkcd.com). Defaults to www. For example, if the link is to a blog post (blog.xkcd.com), ldomain should be set to blog. The resulting link when using lappend and optionally ldomain is:

https://ldomain.xkcd.com/lappend

Example 1

Suspension Bridge
As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it.
Title text: As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it.

The example above is produced by the following code:

{{comic
| number    = 3048
| date      = February 7, 2025
| title     = Suspension Bridge
| image     = suspension_bridge_2x.png
| imagesize = 362x365px
| noexpand  = true
| titletext = As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it.
}}

Example 2

Pi Equals
My most famous drawing, and one of the first I did for the site
Title text: My most famous drawing, and one of the first I did for the site
Warning: Default sort key "0010" overrides earlier default sort key "3048".

The example above is produced by the following code:

{{comic
| ognumber    = 10
| ognumber    = 10
| date      = September 30, 2005
| title     = Pi Equals
| oglink    = https://web.archive.org/web/20070927001941/http://xkcd-drawings.livejournal.com/?skip=40#:~:text=8%3A44%20pm-,Pi%20equals,-(4%20Comments
| ogtitle   = Pi equals
| image     = pi.jpg
| titletext = My most famous drawing, and one of the first I did for the site
}}

Tests

Air Fact
'Wow, that must be why you swallow so many of them per year!' 'No, that's spiders. You swallow WAY more ants.'
Title text: 'Wow, that must be why you swallow so many of them per year!' 'No, that's spiders. You swallow WAY more ants.'
Warning: Default sort key "3070" overrides earlier default sort key "0010".
Suspension Bridge
As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it.
Title text: As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it.
Warning: Default sort key "3048" overrides earlier default sort key "3070".


Pi Equals
My most famous drawing, and one of the first I did for the site
Title text: My most famous drawing, and one of the first I did for the site
Warning: Default sort key "0008" overrides earlier default sort key "3048".
Pi Equals
My most famous drawing, and one of the first I did for the site
Title text: My most famous drawing, and one of the first I did for the site
Warning: Default sort key "0010" overrides earlier default sort key "0008".