Difference between revisions of "Template:Class mask/doc/custom"

From blackwiki
Jump to navigation Jump to search
imported>Funandtrvl
('image' depr.)
imported>Zyxw
m (Since <tt> is obsolete in HTML5, replace it with <kbd> – see HTML element#tt, Wikipedia:HTML5, and mw:Help:Extension:Linter/obsolete-tag. using AWB)
 
(4 intermediate revisions by one other user not shown)
Line 7: Line 7:
 
Some caveats:
 
Some caveats:
 
*{{tlx|WPBannerMeta/qualityscale}} treats a null output from the mask as "unassessed"
 
*{{tlx|WPBannerMeta/qualityscale}} treats a null output from the mask as "unassessed"
*{{tlx|WPBannerMeta/importancescale}} handles importance ratings differently when the mask outputs "<tt>NA</tt>"
+
*{{tlx|WPBannerMeta/importancescale}} handles importance ratings differently when the mask outputs "<kbd>NA</kbd>"
  
 
Any alternative mask needs to be carefully designed to handle all inputs correctly, with care given to case-insentivity, etc.
 
Any alternative mask needs to be carefully designed to handle all inputs correctly, with care given to case-insentivity, etc.
Line 99: Line 99:
 
}}
 
}}
 
</pre>
 
</pre>
 
 
===Generic self-documentation===
 
===Generic self-documentation===
 
A minor problem with the examples above is that someone clicking the link from the banner template to see the custom mask will be presented with a blank page (you have to edit the page to see there's actually code). A simple solution is to add a local wrapper to your code, replacing the basic structure:
 
A minor problem with the examples above is that someone clicking the link from the banner template to see the custom mask will be presented with a blank page (you have to edit the page to see there's actually code). A simple solution is to add a local wrapper to your code, replacing the basic structure:
Line 114: Line 113:
 
used by {{tl|{{BASEPAGENAME}}}}:''
 
used by {{tl|{{BASEPAGENAME}}}}:''
 
&lt;pre>&lt;/noinclude>{{#switch: {{lc:{{{class}}}}}
 
&lt;pre>&lt;/noinclude>{{#switch: {{lc:{{{class}}}}}
 
 
...
 
...
  

Latest revision as of 06:37, 5 August 2018

This template subpage contains a mask which normalises the input passed to |class=. This can be thought of as the 'default' mask, but it is possible for banners to define their own individual masks with wider or fewer choices of acceptable inputs.

If the page corresponding to {{{BANNER_NAME}}}/class exists and QUALITY_SCALE=subpage is set in the banner, then control is passed to the code on that page to normalise the input, and no modification is performed by the WPBannerMeta itself. The following parameters are available to be used:

  • |class=
  • |b1= through |b6=

Some caveats:

Any alternative mask needs to be carefully designed to handle all inputs correctly, with care given to case-insentivity, etc.

Examples

The following code accepts only the standard 1.0 assessment scale with a few extras:

{{#switch:{{lc:{{{class|}}}}}
 |fa       = FA
 |fl       = FL
 |a        = A
 |ga       = GA
 |b        = B
 |c        = C
 |start    = Start
 |stub     = Stub
 |list     = List
 |template = Template
 |file     = File
}}

This code imitates the MilHist scale: no C-Class and a B-Class checklist:

{{#switch:{{lc:{{{class|}}}}}
 |fa   = FA
 |fl   = FL
 |a    = A
 |ga   = GA
 |b={{#ifexpr:
      {{#switch:{{lc:{{{b1|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b2|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b3|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b4|}}}}}|y|yes|1=1|0}}*
      {{#switch:{{lc:{{{b5|}}}}}|y|yes|1=1|0}}
     |B
     |Start
    }}
 |start= Start
 |stub = Stub
}}

This code imitates the WPMaths scale, which also incorporates a "B+" class:

{{#switch:{{lc:{{{class|}}}}}
 |fa       = FA
 |fl       = FL
 |a        = A
 |ga       = GA
 |bplus|b+ = Bplus
 |b        = B
 |start    = Start
 |stub     = Stub
 |list     = List
}}

An example with Merge, Needed, Future & Current classes:

{{#switch: {{lc:{{{class}}}}}
 |fa   = FA
 |fl   = FL
 |a    = A
 |ga   = GA
 |b    = B
 |c    = C
 |start= Start
 |stub = Stub
 |list = List
 |na                  = NA
 |image|file          = File
 |category|cat|categ  = Category
 |disambig|disamb|dab = Disambig
 |portal              = Portal
 |redirect|red|redir  = Redirect
 |template|temp|templ = Template
 |project             = Project
 |current             = Current
 |future              = Future
 |needed              = Needed
 |merge               = Merge
 |#default={{#switch:{{lc:{{NAMESPACE}}}}
  |file talk      = File
  |category talk  = Category
  |portal talk    = Portal
  |template talk  = Template
  |wikipedia talk = Project
 }}
}}

Generic self-documentation

A minor problem with the examples above is that someone clicking the link from the banner template to see the custom mask will be presented with a blank page (you have to edit the page to see there's actually code). A simple solution is to add a local wrapper to your code, replacing the basic structure:

{{#switch: {{lc:{{{class}}}}}

...

}}

with this one:

<noinclude>:''[[Template:WPBannerMeta#Custom masks|Custom mask]]
used by {{tl|{{BASEPAGENAME}}}}:''
<pre></noinclude>{{#switch: {{lc:{{{class}}}}}
...

}}<noinclude></pre></noinclude>

For a visual example, you can go to Template:WikiProject Academic Journals and click the "custom class" link in the warning box: instead of a blank page you will be presented with Template:WikiProject Academic Journals/class that explains what it is and shows the full code of the mask. (Do not pay attention to the "noinclude" showing up around the code, it's a local side-effect of the Pre tag that doesn't affect the banner or the mask at all once transcluded.)