Difference between revisions of "User:Yfmcpxpj/Sandbox"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Add demos for now "override2x" parameter.)
m (Overriding 2x target: Remove redundant text.)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Yfmcpxpj's Sandbox =
 
 
 
Sandbox for testing things.
 
Sandbox for testing things.
  
== 2x comic template test ==
+
= 2x comic template test =
  
 
Test template: [[User:Yfmcpxpj/Template:comic 2x test]]
 
Test template: [[User:Yfmcpxpj/Template:comic 2x test]]
Line 9: Line 7:
 
Experimental template, adding a "2x" button to automatically link to the double-resolution comic images on xkcd.com.
 
Experimental template, adding a "2x" button to automatically link to the double-resolution comic images on xkcd.com.
  
=== Comics up to and including [[1083]] (no 2x image) ===
+
== Comics as of [[1084]] ==
 +
 
 +
Comic [[1084]] was the first comic to include a 2x image, so for all comics as of 1084, automatically insert a "2x" button to link directly to the higher resolution image on xkcd.com.
 +
 
 +
Code:
 +
 
 +
<pre>
 +
{{User:Yfmcpxpj/Template:comic 2x test
 +
| number    = 1084
 +
| date      = July 20, 2012
 +
| title    = Server Problem
 +
| image    = server_problem.png
 +
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
 +
}}
 +
</pre>
 +
 
 +
Result:
 +
 
 +
{{User:Yfmcpxpj/Template:comic 2x test
 +
| number    = 1084
 +
| date      = July 20, 2012
 +
| title    = Server Problem
 +
| image    = server_problem.png
 +
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
 +
}}
 +
 
 +
== Comics up to and including [[1083]] (no 2x image) ==
  
[[1084]] was the first comic to include a 2x image, so comics before that should ''not'' have a "2x" button.
+
For comics ''before'' [[1084]], no double-resolution image exists, so they should ''not'' have a "2x" button.
  
 
Code:
 
Code:
Line 35: Line 59:
 
}}
 
}}
  
=== Comics as of [[1084]] ===
+
== Comics without a number ==
  
For comics as of [[1084]], insert a "2x" button to link directly to the higher resolution image on xkcd.com.
+
[[Template:comic]] is also used for one-off comics hosted outside of xkcd.com, for example, [[:Category:Extra comics]].  Those comics don't have a "number", and should also ''not'' have a "2x" button.
  
 
Code:
 
Code:
Line 43: Line 67:
 
<pre>
 
<pre>
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
+
| date      = October 22, 2015
| date      = July 20, 2012
+
| title    = XKCD Marks the Spot
| title    = Server Problem
+
| image    = world_polio_day.png
| image    = server_problem.png
+
| before    = Original blog post on ''gatesnotes'': http://www.gatesnotes.com/Health/XKCD-Marks-the-Spot
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
+
| titletext    = World Polio Day XKCD comic
 +
| ldomain  = gatesnotes.com/Health/XKCD-Marks-the-Spot#
 +
| lappend  =
 +
| extra    = yes
 
}}
 
}}
 
</pre>
 
</pre>
Line 54: Line 81:
  
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
+
| date      = October 22, 2015
| date      = July 20, 2012
+
| title    = XKCD Marks the Spot
| title    = Server Problem
+
| image    = world_polio_day.png
| image    = server_problem.png
+
| before    = Original blog post on ''gatesnotes'': http://www.gatesnotes.com/Health/XKCD-Marks-the-Spot
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
+
| titletext    = World Polio Day XKCD comic
 +
| ldomain  = gatesnotes.com/Health/XKCD-Marks-the-Spot#
 +
| lappend  =
 +
| extra    = yes
 
}}
 
}}
  
=== Omitting 2x button ===
+
== Omitting 2x button ==
  
If the 2x button is broken or needs to be omitted for whatever reason, that can be done with the new <code>omit2x</code> parameter.
+
If the "2x" button target is broken, or if the button just needs to be omitted for whatever reason, that can be done with the new <code>omit2x</code> parameter.
  
 
Code:
 
Code:
Line 69: Line 99:
 
<pre>
 
<pre>
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
 
| omit2x    = true
 
| omit2x    = true
 
}}
 
}}
Line 81: Line 111:
  
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
 
| omit2x    = true
 
| omit2x    = true
 
}}
 
}}
  
=== Overriding 2x target ===
+
== Overriding 2x target ==
  
If the 2x button needs to link to a different file (for example, if the filename on xkcd.com doesn't match the filename on explainxkcd.com), the alternate filename can be specified in the <code>override2x</code> parameter.
+
Alternatively, if the "2x" button needs to link to a different filename (for example, if the filename on xkcd.com doesn't match the filename on explainxkcd.com), the alternate filename can be specified in the <code>override2x</code> parameter.
  
 
Code:
 
Code:
Line 97: Line 127:
 
<pre>
 
<pre>
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
}}
 
}}
 
</pre>
 
</pre>
Line 109: Line 139:
  
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
}}
 
}}
  
Line 128: Line 158:
 
| image    = barrel_cropped_(1).jpg
 
| image    = barrel_cropped_(1).jpg
 
| titletext = Don't we all.
 
| titletext = Don't we all.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
}}
 
}}
 
</pre>
 
</pre>
Line 140: Line 170:
 
| image    = barrel_cropped_(1).jpg
 
| image    = barrel_cropped_(1).jpg
 
| titletext = Don't we all.
 
| titletext = Don't we all.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
}}
 
}}
  
Line 149: Line 179:
 
<pre>
 
<pre>
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
| omit2x    = true
 
| omit2x    = true
 
}}
 
}}
Line 162: Line 192:
  
 
{{User:Yfmcpxpj/Template:comic 2x test
 
{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1085
+
| number    = 1084
| date      = July 23, 2012
+
| date      = July 20, 2012
| title    = ContextBot
+
| title    = Server Problem
| image    = contextbot.png
+
| image    = server_problem.png
| titletext = If you read all vaguebooking/vaguetweeting with the assumption that they're saying everything they can without revealing classified military information, the internet gets way more exciting.
+
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= server_problem_2x.png
+
| override2x= contextbot_2x.png
 
| omit2x    = true
 
| omit2x    = true
 
}}
 
}}
 +
 +
== Reference documentation ==
 +
 +
* [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions MediaWiki: ParserFunctions Extension]
 +
** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##expr <code>#expr</code>] – evaluate an expression.
 +
** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##if <code>#if</code>] – conditional inclusion.
 +
** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##ifeq <code>#ifeq</code>] – conditional inclusion from string equality/inequality.
 +
** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##ifexpr <code>#ifexpr</code>] – conditional from the result of an expression.
 +
** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#StringFunctions StringFunctions]
 +
*** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##rpos <code>#rpos</code>] – return the ''last'' position of the specified text within a string.
 +
*** [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##sub <code>#sub</code>] – return a sub-string.
 +
* [https://www.mediawiki.org/wiki/Help:Parser_functions_in_templates MediaWiki: Parser functions in templates]
 +
* [https://www.mediawiki.org/wiki/Help:Magic_words#Technical_metadata MediaWiki: Magic words > Technical metadata] > <code>DEFAULTSORT</code>

Latest revision as of 07:38, 13 October 2020

Sandbox for testing things.

2x comic template test[edit]

Test template: User:Yfmcpxpj/Template:comic 2x test

Experimental template, adding a "2x" button to automatically link to the double-resolution comic images on xkcd.com.

Comics as of 1084[edit]

Comic 1084 was the first comic to include a 2x image, so for all comics as of 1084, automatically insert a "2x" button to link directly to the higher resolution image on xkcd.com.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
| date      = July 20, 2012
| title     = Server Problem
| image     = server_problem.png
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
}}

Result:

Server Problem
Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
Title text: Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.

Comics up to and including 1083 (no 2x image)[edit]

For comics before 1084, no double-resolution image exists, so they should not have a "2x" button.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1083
| date      = July 18, 2012
| title     = Writing Styles
| image     = writing_styles.png
| titletext = I liked the idea, suggested by h00k on bash.org, of a Twitter bot that messages prominent politicians to tell them when they've unnecessarily used sms-speak abbreviations despite having plenty of characters left.
}}

Result:

Writing Styles
I liked the idea, suggested by h00k on bash.org, of a Twitter bot that messages prominent politicians to tell them when they've unnecessarily used sms-speak abbreviations despite having plenty of characters left.
Title text: I liked the idea, suggested by h00k on bash.org, of a Twitter bot that messages prominent politicians to tell them when they've unnecessarily used sms-speak abbreviations despite having plenty of characters left.

Comics without a number[edit]

Template:comic is also used for one-off comics hosted outside of xkcd.com, for example, Category:Extra comics. Those comics don't have a "number", and should also not have a "2x" button.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| date      = October 22, 2015
| title     = XKCD Marks the Spot
| image     = world_polio_day.png
| before    = Original blog post on ''gatesnotes'': http://www.gatesnotes.com/Health/XKCD-Marks-the-Spot
| titletext    = World Polio Day XKCD comic
| ldomain   = gatesnotes.com/Health/XKCD-Marks-the-Spot#
| lappend   = 
| extra     = yes
}}

Result:

XKCD Marks the Spot
Original blog post on gatesnotes: http://www.gatesnotes.com/Health/XKCD-Marks-the-Spot
World Polio Day XKCD comic
Title text: World Polio Day XKCD comic

Omitting 2x button[edit]

If the "2x" button target is broken, or if the button just needs to be omitted for whatever reason, that can be done with the new omit2x parameter.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
| date      = July 20, 2012
| title     = Server Problem
| image     = server_problem.png
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| omit2x    = true
}}

Result:

Server Problem
Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
Title text: Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.

Overriding 2x target[edit]

Alternatively, if the "2x" button needs to link to a different filename (for example, if the filename on xkcd.com doesn't match the filename on explainxkcd.com), the alternate filename can be specified in the override2x parameter.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
| date      = July 20, 2012
| title     = Server Problem
| image     = server_problem.png
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= contextbot_2x.png
}}

Result:

Server Problem
Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
Title text: Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.

This could also be used to add a "2x" button to older comics, if appropriate.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1
| date      = September 30, 2005
| title     = Barrel - Part 1
| image     = barrel_cropped_(1).jpg
| titletext = Don't we all.
| override2x= contextbot_2x.png
}}

Result:

Barrel - Part 1
Don't we all.
Title text: Don't we all.

Note, however, that omit2x takes precedence over override2x.

Code:

{{User:Yfmcpxpj/Template:comic 2x test
| number    = 1084
| date      = July 20, 2012
| title     = Server Problem
| image     = server_problem.png
| titletext = Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
| override2x= contextbot_2x.png
| omit2x    = true
}}

Result:

Server Problem
Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.
Title text: Protip: Annoy Ray Kurzweil by always referring to it as the 'Cybersingularity'.

Reference documentation[edit]