Difference between revisions of "Template:comic/sandbox"
(nvm this ons) |
|||
| Line 12: | Line 12: | ||
Display the (optional) text just before the navigation | Display the (optional) text just before the navigation | ||
| − | -->{{#if:{{{ogtitle|}}}|<tr><td style="padding-bottom:10px; padding-top:5px; font-size: | + | -->{{#if:{{{ogtitle|}}}|<tr><td style="padding-bottom:10px; padding-top:5px; font-size: 19px" class="plainlinks"><!-- |
-->[{{{oglink}}} Original title]: <!-- | -->[{{{oglink}}} Original title]: <!-- | ||
| Line 118: | Line 118: | ||
-->{{#if:{{{titletext|}}}|<br /><span style="margin-top:0.9em; margin-bottom:0.4em; display:inline-block; font-size: 115%; {{{ttstyle|}}}"><!-- | -->{{#if:{{{titletext|}}}|<br /><span style="margin-top:0.9em; margin-bottom:0.4em; display:inline-block; font-size: 115%; {{{ttstyle|}}}"><!-- | ||
--><span<!-- style="color:grey"--> class="plainlinks">[[Title text|Title text]]:</span> {{{titletext}}}<!-- | --><span<!-- style="color:grey"--> class="plainlinks">[[Title text|Title text]]:</span> {{{titletext}}}<!-- | ||
| − | --></span>}}</td></tr></table><!-- | + | --></span>}}<!--</td></tr></table>--><!-- |
| + | |||
| + | |||
| + | |||
| + | |||
| + | This table will contain a table row (tr) and cell (td) | ||
| + | --><tr><td><!-- | ||
| + | |||
| + | Now make an unordered list which will display as the navigation bar | ||
| + | --><ul style="text-align: center; margin-bottom: 10px;" class="no-link-underline"><!-- | ||
| + | |||
| + | Generate the |< and prev buttons, but only if {{{number}}} exists and is greater than 1 | ||
| + | -->{{#ifexpr:{{{number|-1}}}>1<!-- | ||
| + | |||
| + | {{{number}}} is greater than 1; make a list item and put a button in it that links to #1 | ||
| + | -->|<li style="background-color: #6E7B91; | ||
| + | border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray; | ||
| + | display: inline; font-size: 16px; font-variant: small-caps; font-weight: 600; | ||
| + | margin: 0 4px; padding: 1.5px 0;"><!-- | ||
| + | link to #1 | ||
| + | -->[[1|<span style="color: #FFFFFF; padding: 0 12px;">|<</span>]]</li><!-- | ||
| + | |||
| + | We're not done here yet, let's make the back button | ||
| + | --><li style="background-color: #6E7B91; | ||
| + | border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray; | ||
| + | display: inline; font-size: 16px; font-variant: small-caps; font-weight: 600; | ||
| + | margin: 0 4px; padding: 1.5px 0;"><!-- | ||
| + | |||
| + | Link to the previous comic | ||
| + | -->[[{{#expr:{{{number}}}-1}}|<span style="color: #FFFFFF; padding: 0 12px;">< Prev</span>]]</li><!-- | ||
| + | |||
| + | {{{number}}} doesn't exist or is less than 1; just put non-breaking spaces here | ||
| + | -->| }}<!-- | ||
| + | |||
| + | Regardless of {{{number}}}, we need to make the comic date, link etc. | ||
| + | --><li style="background-color: #6E7B91; | ||
| + | border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray; | ||
| + | display: inline; font-size: 16px; font-variant: small-caps; font-weight: 600; | ||
| + | margin: 0 4px; padding: 1.5px 0;" | ||
| + | class="plainlinks"><!-- | ||
| + | |||
| + | [ and ] makes an external link, vs. [[ and ]] which are internal only. | ||
| + | Depending whether {{{number}}} exists 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 | ||
| + | -->[{{#ifexpr:{{{number|-1}}}>=1<!-- | ||
| + | |||
| + | Comic number is probably valid, use number link mode | ||
| + | -->|https://xkcd.com/{{{number}}}<!-- | ||
| + | |||
| + | Comic number is invalid or doesn't exist, use wide link mode | ||
| + | -->|https://{{{ldomain|www}}}.xkcd.com/{{{lappend}}}}}<!-- | ||
| + | |||
| + | Generate the title, with date if it exists | ||
| + | --><span style="color: #FFFFFF; padding: 0 12px;">Comic<!-- | ||
| + | -->{{#ifexpr:{{{number|-1}}}>= 1| #|}}{{{number|}}}{{#if:{{{date|}}}| ({{#replace:{{{date}}}| | }})}}</span>]</li><!-- | ||
| + | |||
| + | Now make the next and >| buttons, provided the comic number exists | ||
| + | -->{{#ifexist:{{#expr:{{{number|-2}}}+1}}<!-- | ||
| + | |||
| + | Check if this is the LATESTCOMIC. If it is, then don't display the "Next" and >| buttons. | ||
| + | -->|{{#ifexpr:{{LATESTCOMIC}}-{{{number}}}>0<!-- | ||
| + | |||
| + | Comic number is valid, generate the buttons | ||
| + | -->|<li style="background-color: #6E7B91; | ||
| + | border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray; | ||
| + | display: inline; font-size: 16px; font-variant: small-caps; font-weight: 600; | ||
| + | margin: 0 4px; padding: 1.5px 0;"><!-- | ||
| + | -->[[{{#expr:{{{number}}}+1}}{{!}}<span style="color: #FFFFFF; padding: 0 12px;">Next ></span>]]</li><!-- | ||
| + | |||
| + | Make a button that points to LATESTCOMIC (which is of course the latest comic) | ||
| + | --><li style="background-color: #6E7B91; | ||
| + | border: 1.5px solid #333333; border-radius: 3px 3px 3px 3px; box-shadow: 0 0 5px 0 gray; | ||
| + | display: inline; font-size: 16px; font-variant: small-caps; font-weight: 600; | ||
| + | margin: 0 4px; padding: 1.5px 0;"><!-- | ||
| + | -->[[{{LATESTCOMIC}}{{!}}<span style="color: #FFFFFF; padding: 0 12px;">>|</span>]]</li><!-- | ||
| + | |||
| + | Comic number (plus one) is not valid, don't show the buttons | ||
| + | -->| }}| }}</ul><!-- | ||
| + | --></td></tr></table><!-- | ||
| + | |||
| + | |||
| + | |||
| + | |||
Add the comics to the standard categories. | Add the comics to the standard categories. | ||
| Line 140: | Line 222: | ||
-->}}}}}}|}}<!-- | -->}}}}}}|}}<!-- | ||
--></includeonly><noinclude><!-- | --></includeonly><noinclude><!-- | ||
| + | |||
| + | |||
| + | |||
DOCUMENTATION | DOCUMENTATION | ||
| − | -->{{:Template:comic/doc}} | + | -->{{comic/sandbox |
| − | [[Category:Templates]] | + | | number = 10 |
| − | </noinclude> | + | | 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 | ||
| + | }} | ||
| + | |||
| + | |||
| + | |||
| + | {{comic/sandbox | ||
| + | | number = 1 | ||
| + | | 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 | ||
| + | }}{{:Template:comic/doc}} | ||
| + | [[Category:Templates]]</noinclude> | ||
Revision as of 18:22, 20 April 2025
| Pi Equals |
| Original title: Pi equals |
![]() Title text: My most famous drawing, and one of the first I did for the site |
| Pi Equals |
| Original title: Pi equals |
![]() Title text: My most famous drawing, and one of the first I did for the site |
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.
Usage
{{comic
| number =
| date =
| title =
| ognumber =
| oglink =
| ogttlabel =
| ogtitle =
| ogprev =
| ognote =
| ognext =
| before =
| image =
| custom =
| imagesize =
| noexpand =
| titletext =
| ttstyle =
| bodystyle =
| bodyclass =
| extra =
| ldomain =
| lappend =
}}
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.
Note that, if the |
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:
|
Example 1
| Suspension Bridge |
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 |
| Original title: Pi equals |
![]() Title text: My most famous drawing, and one of the first I did for the site |
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 |
Title text: 'Wow, that must be why you swallow so many of them per year!' 'No, that's spiders. You swallow WAY more ants.' |
| Suspension Bridge |
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. |
| Pi Equals |
| Libehuornel title: Hello there |
![]() Title text: My most famous drawing, and one of the first I did for the site |
| Pi Equals |
| Original title: Pi equals |
![]() Title text: My most famous drawing, and one of the first I did for the site |

