Editing User:Yfmcpxpj/Template:comic 2x test

Jump to: navigation, search

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 58: Line 58:
 
           --><span style="color: #FFFFFF; padding: 0 12px;">Comic&nbsp;<!--
 
           --><span style="color: #FFFFFF; padding: 0 12px;">Comic&nbsp;<!--
 
           -->{{#ifexpr:{{{number|-1}}}>= 1|&#35;|}}{{{number|}}}&nbsp;{{#if:{{{date|}}}|({{#replace:{{{date}}}| |&nbsp;}})}}</span>]</li><!--
 
           -->{{#ifexpr:{{{number|-1}}}>= 1|&#35;|}}{{{number|}}}&nbsp;{{#if:{{{date|}}}|({{#replace:{{{date}}}| |&nbsp;}})}}</span>]</li><!--
       
 
        Should we include a 2x button?
 
        -->{{#if:{{{omit2x|}}}| |<!--
 
 
            
 
            
           Has a 2x image been explicitly specified?
+
        Check if the comic is #1084 or above.
           -->{{#if:{{{override2x|}}}<!--
+
        -->{{#ifexpr:{{{number|-1}}}>=1084|<!--
 +
         
 +
           If so, add a "2x" button linking to the 2x image.
 +
           --><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"><!--
 +
           
 +
            The image files are hosted at imgs.xkcd.com/comics/
 +
            -->[https://imgs.xkcd.com/comics/<!--
 +
           
 +
            The filename is the same as the original comic, but with "_2x" inserted at the end of the filename before the extension.
 +
            So take everything before the final dot.
 +
            -->{{#sub:{{{image|}}}|0|{{#rpos:{{{image|}}}|.}}}}<!--
 +
           
 +
            Then insert "_2x".
 +
            -->_2x<!--
 
              
 
              
             Use that target for the 2x button.
+
             Then append the dot and filename extension.
             -->|<li style="background-color: #6E7B91;
+
             -->{{#sub:{{{image|}}}|{{#rpos:{{{image|}}}|.}}}}<!--
                          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"><!--
 
             
 
              The image files are hosted at imgs.xkcd.com/comics/
 
              -->[https://imgs.xkcd.com/comics/{{{override2x}}} <span style="color: #FFFFFF; padding: 0 12px;">2x</span>]</li><!--
 
 
              
 
              
             Otherwise, check if the comic is #1084 or above.
+
             Finally, add the displayed text for the button.
            -->|{{#ifexpr:{{{number|-1}}}>=1084|<!--
+
            --> <span style="color: #FFFFFF; padding: 0 12px;">2x</span>]</li>}}<!--
             
 
              If so, add a "2x" button linking to the 2x image.
 
              --><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"><!--
 
               
 
                The image files are hosted at imgs.xkcd.com/comics/
 
                -->[https://imgs.xkcd.com/comics/<!--
 
               
 
                The filename is the same as the original comic, but with "_2x" inserted at the end of the filename before the extension.
 
                So take everything before the final dot.
 
                -->{{#sub:{{{image|}}}|0|{{#rpos:{{{image|}}}|.}}}}<!--
 
               
 
                Then insert "_2x".
 
                -->_2x<!--
 
               
 
                Then append the dot and filename extension.
 
                -->{{#sub:{{{image|}}}|{{#rpos:{{{image|}}}|.}}}}<!--
 
               
 
                Finally, add the displayed text for the button.
 
                --> <span style="color: #FFFFFF; padding: 0 12px;">2x</span>]</li>}}<!--
 
               
 
          -->}}<!--
 
        -->}}<!--
 
 
          
 
          
 
         Now make the next and >| buttons provided comic number exists
 
         Now make the next and >| buttons provided comic number exists
Line 169: Line 144:
 
     It otherwise sorts 'alphanumerically'; as in since the first char of 10 is 1, it would normally be placed before 9
 
     It otherwise sorts 'alphanumerically'; as in since the first char of 10 is 1, it would normally be placed before 9
 
     The padding turns each into 0009 and 0010 etc. and since 0 is less than 1, #9 gets sorted before #10.
 
     The padding turns each into 0009 and 0010 etc. and since 0 is less than 1, #9 gets sorted before #10.
     -->{{#ifexpr:{{{number|-1}}}>=1|{{DEFAULTSORT: {{padleft:{{{number}}}|4}}|noreplace}}|<!--
+
     -->{{#ifexpr:{{{number|-1}}}>=1|{{DEFAULTSORT: {{padleft:{{{number}}}|4}}}}|<!--
 
     -->}}<!--
 
     -->}}<!--
 
      
 
      
Line 185: Line 160:
 
--></includeonly><noinclude>
 
--></includeonly><noinclude>
 
<!--    DOCUMENTATION  -->
 
<!--    DOCUMENTATION  -->
This is a test version of [[Template:comic]], which 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.  This particular version adds a "2x" button to link to the comic's double-resolution image on xkcd.com.
+
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.
  
 
== Sample ==
 
== Sample ==
  
 
The following is a sample usage of this template:
 
The following is a sample usage of this template:
{{User:Yfmcpxpj/Template:comic 2x test
+
{{comic
| number    = 1084
+
| number    = 16
| date      = July 20, 2012
+
| date      = October 4, 2005
| title    = Server Problem
+
| title    = Monty Python -- Enough
| image    = server_problem.png
+
| image    = monty_python.jpg
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
+
| titletext = I went to a dinner where there was a full 10 minutes of Holy Grail quotes exchanged, with no context, in lieu of conversation.  It depressed me badly.
 
}}
 
}}
  
 
== Usage ==
 
== Usage ==
  
<pre>{{User:Yfmcpxpj/Template:comic 2x test
+
<pre>{{comic
 
| number    =
 
| number    =
 
| date      =
 
| date      =
Line 211: Line 186:
 
| ldomain  =
 
| ldomain  =
 
| lappend  =
 
| lappend  =
| override2x=
 
| omit2x    =
 
 
}}</pre>
 
}}</pre>
  
Line 228: Line 201:
 
** '''lappend''' must be defined as <pre>...kd.com/'''lappend'''/</pre> to keep the link to xkcd.com valid.
 
** '''lappend''' must be defined as <pre>...kd.com/'''lappend'''/</pre> to keep the link to xkcd.com valid.
 
** If the link is to eg. a blog post (blog.xkcd.com) '''ldomain''' can be defined as <pre>blog</pre> to change the subdomain in the link.
 
** If the link is to eg. a blog post (blog.xkcd.com) '''ldomain''' can be defined as <pre>blog</pre> to change the subdomain in the link.
* For comics as of [[1084]], a "2x" button will automatically appear, linking to the double-size version of the comic on xkcd.com.  That behavior can be modified with the following optional parameters:
 
** If the 2x image for a particular comic doesn't exist, or has some other problem, the "2x" button can be omitted by specifying a non-zero/non-empty value for '''omit2x''' (example: <code>omit2x=true</code>).
 
** Or, if the ''filename'' of the 2x file is different, a specific image filename can be specified for '''override2x''', even for older comics (example: <code>override2x=server_problem_2x.png</code>).
 
  
 
The above sample is produced by the following code:
 
The above sample is produced by the following code:
  
<pre>{{User:Yfmcpxpj/Template:comic 2x test
+
<pre>{{comic
| number    = 1084
+
| number    = 16
| date      = July 20, 2012
+
| date      = October 4, 2005
| title    = Server Problem
+
| title    = Monty Python -- Enough
| image    = server_problem.png
+
| image    = monty_python.jpg
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
+
| titletext = I went to a dinner where there was a full 10 minutes of Holy Grail quotes exchanged, with no context, in lieu of conversation.  It depressed me badly.
 
}}</pre>
 
}}</pre>
  
 
[[Category:Templates]]
 
[[Category:Templates]]
 
</noinclude>
 
</noinclude>

Please note that all contributions to explain xkcd 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 explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)

Templates used on this page: