Difference between revisions of "User:Crabbe/Sandbox"

From The Shartak Wiki
Jump to navigationJump to search
(Document Template:Clanbox)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
No syntax highlighting.  No LaTeX.
 
No syntax highlighting.  No LaTeX.
  
==Sandbox/01==
+
__TOC__
[[User:Crabbe/Sandbox/01]], investigating the broken clanbox template 13:27, 15 May 2010 (UTC)
+
 
Template copied to [[User:Crabbe/Sandbox/02]] 13:37, 15 May 2010 (UTC)
+
==Template:Clanbox==
 +
Documentation follows below.  Also some files:
 +
* [[User:Crabbe/Sandbox/01]] - Comparison of four versions of the Clanbox template.
 +
* [[User:Crabbe/Sandbox/02]] - Currently my version of a Clanbox template.
 +
 
 +
<strike>[[User:Crabbe/Sandbox/01]], investigating the broken clanbox template 13:27, 15 May 2010 (UTC)
 +
Template copied to [[User:Crabbe/Sandbox/02]] 13:37, 15 May 2010 (UTC)</strike>
  
 
Pages:
 
Pages:
Line 13: Line 19:
 
* Clan pages:
 
* Clan pages:
 
** Clan [[Eyecons]] - breaks under old template - copied to /01.
 
** Clan [[Eyecons]] - breaks under old template - copied to /01.
 +
 +
'''Adding a carriage return before each of the first two <pre>{{#ifeq:</pre> constructs fixes the problems''' with [[Eyecons]] at least.  '''WTF'''.
 +
===Update 19:59, 15 May 2010 (UTC)===
 +
Okay more investigation today.  I also found Skull Face's version and some discussion:
 +
* [[Template:Clanbox_fix]] - [[User:Skull_Face|Skull Face]] on September 5, 2008.
 +
* [[Template:Clanbox_test]] - [[User:Alien_pirate_demon|Alien pirate demon]] on September 5, 2008.
 +
* [[User_talk:Skull_Face#Clanbox_Template]]
 +
* [[Template_talk:Clanbox#Help_Me]]
 +
 +
After experimentation, reading about templates, reading about parser functions and reading about tables ([http://meta.wikimedia.org/wiki/Help:Table tables at MetaWiki]),  I have come to the conclusion that the problem is because of formatting, specifically lack of line feeds in certain places.  This is very hard to troubleshoot since in the default wiki editor it is impossible to tell the difference between a linefeed and word wrap.  Further sometimes merely editing can cause line feeds to disappear see [http://meta.wikimedia.org/wiki/Help:Newlines_and_spaces#Stripping_on_save MetaWiki].
 +
 +
Using the <code>subst:</code> construct it appears that in the original template we were getting lines like
 +
<pre>
 +
"Eyecons"{{#ifeq:[[Image:PSLogo.gif]]|||
 +
{{!}}-style="background-color: #ffffff; text-align: center;" ...
 +
</pre>
 +
another expansion would give
 +
<pre>
 +
"Eyecons"{{!}}-style="background-color: #ffffff; text-align: center;" ...
 +
</pre>
 +
with a LF being goobled up.  One more expansion gives
 +
<pre>
 +
"Eyecons"|-style="background-color: #ffffff; text-align: center;"
 +
</pre>
 +
When MediaWiki tries to interpret this it gives an error.  It expects the table row indicator, <code>|-</code> to ''begin'' a line.  No new row character then the following <code>style</code> is misplaced etc.
 +
 +
The simple fix is to put in some LFs:
 +
The relevant section from the original template:
 +
<pre>
 +
{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
 +
    border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
 +
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
 +
    '''{{{clan_name|&nbsp;}}}'''{{#ifeq:{{{clan_image|}}}|||¶
 +
{{!}}-style="background-color: #ffffff; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}{{{clan_image}}}}}{{#ifeq:{{{official_id|}}}|||¶
 +
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶
 +
</pre>
 +
Here ¶ indicates a coded line feed, lines with no ¶ at the end have no LF.
 +
To fix the template change it to:
 +
<pre>
 +
{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
 +
    border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
 +
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
 +
    '''{{{clan_name|&nbsp;}}}'''¶
 +
{{#ifeq:{{{clan_image|}}}|||¶
 +
{{!}}-style="background-color: #ffffff; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}{{{clan_image}}}}}¶
 +
{{#ifeq:{{{official_id|}}}|||¶
 +
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶
 +
</pre>
 +
This works for the most part.  See [[User:Crabbe/Sandbox/01]]
 +
 +
There is at least one small problem:
 +
If there is no <code>official_id</code> and no <code>clan_image</code> files specified then both of the
 +
<pre>{{#ifeq: ... }}</pre> sections evaluate to a LF which puts two extra lines in the first row of the table.  The solution was found in the MetaWiki [http://meta.wikimedia.org/wiki/Help:Newlines_and_spaces#Fix help files].  Adding <pre><nowiki /></pre>tags prevents a LF from being goobled up in a parser function so things work as they should.  LFs when they're needed, none when they aren't wanted.
 +
<pre>
 +
{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
 +
    border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
 +
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
 +
    '''{{{clan_name|&nbsp;}}}'''{{#ifeq:{{{clan_image|}}}|||<nowiki />¶
 +
{{!}}-style="background-color: #ffffff; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}{{{clan_image}}}}}{{#ifeq:{{{official_id|}}}|||<nowiki />¶
 +
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
 +
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶
 +
</pre>
 +
 +
My version of the template is at [[User:Crabbe/Sandbox/02]].  Some samples are at [[User:Crabbe/Sandbox/01]].  Please put any comments on my [[http://wiki.shartak.com/index.php/User_talk:Crabbe#Template:Clanbox talk page]].

Latest revision as of 19:59, 15 May 2010

Notes about this wiki

No syntax highlighting. No LaTeX.


Template:Clanbox

Documentation follows below. Also some files:

User:Crabbe/Sandbox/01, investigating the broken clanbox template 13:27, 15 May 2010 (UTC) Template copied to User:Crabbe/Sandbox/02 13:37, 15 May 2010 (UTC)

Pages:

Adding a carriage return before each of the first two

{{#ifeq:

constructs fixes the problems with Eyecons at least. WTF.

Update 19:59, 15 May 2010 (UTC)

Okay more investigation today. I also found Skull Face's version and some discussion:

After experimentation, reading about templates, reading about parser functions and reading about tables (tables at MetaWiki), I have come to the conclusion that the problem is because of formatting, specifically lack of line feeds in certain places. This is very hard to troubleshoot since in the default wiki editor it is impossible to tell the difference between a linefeed and word wrap. Further sometimes merely editing can cause line feeds to disappear see MetaWiki.

Using the subst: construct it appears that in the original template we were getting lines like

"Eyecons"{{#ifeq:[[Image:PSLogo.gif]]|||
{{!}}-style="background-color: #ffffff; text-align: center;" ...

another expansion would give

"Eyecons"{{!}}-style="background-color: #ffffff; text-align: center;" ...

with a LF being goobled up. One more expansion gives

"Eyecons"|-style="background-color: #ffffff; text-align: center;"

When MediaWiki tries to interpret this it gives an error. It expects the table row indicator, |- to begin a line. No new row character then the following style is misplaced etc.

The simple fix is to put in some LFs: The relevant section from the original template:

{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
     border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
     '''{{{clan_name| }}}'''{{#ifeq:{{{clan_image|}}}|||¶
{{!}}-style="background-color: #ffffff; text-align: center;"¶
{{!}}colspan="2"{{!}}{{{clan_image}}}}}{{#ifeq:{{{official_id|}}}|||¶
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶

Here ¶ indicates a coded line feed, lines with no ¶ at the end have no LF. To fix the template change it to:

{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
     border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
     '''{{{clan_name| }}}'''¶
{{#ifeq:{{{clan_image|}}}|||¶
{{!}}-style="background-color: #ffffff; text-align: center;"¶
{{!}}colspan="2"{{!}}{{{clan_image}}}}}¶
{{#ifeq:{{{official_id|}}}|||¶
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶

This works for the most part. See User:Crabbe/Sandbox/01

There is at least one small problem: If there is no official_id and no clan_image files specified then both of the

{{#ifeq: ... }}

sections evaluate to a LF which puts two extra lines in the first row of the table. The solution was found in the MetaWiki help files. Adding

<nowiki />

tags prevents a LF from being goobled up in a parser function so things work as they should. LFs when they're needed, none when they aren't wanted.

{| cellpadding="4" cellspacing="0" style="border: solid 1px #ccc; background-color: #f9f9f9;
     border-collapse: collapse; float: right; font-size: 95%; margin: 0 0 .5em .5em; width: 300px"¶
|colspan="2" style="background-color: #8b8; font-size: large; padding: 5px; text-align: center"|
     '''{{{clan_name| }}}'''{{#ifeq:{{{clan_image|}}}|||<nowiki />¶
{{!}}-style="background-color: #ffffff; text-align: center;"¶
{{!}}colspan="2"{{!}}{{{clan_image}}}}}{{#ifeq:{{{official_id|}}}|||<nowiki />¶
{{!}}-style="background-color: #c3ddc3; text-align: center;"¶
{{!}}colspan="2"{{!}}[http://www.shartak.com/clanview.cgi?id={{{official_id}}} In-game page]}}¶

My version of the template is at User:Crabbe/Sandbox/02. Some samples are at User:Crabbe/Sandbox/01. Please put any comments on my [talk page].