Difference between revisions of "Help:Introduction to Templates"

From Computer History Wiki
Jump to: navigation, search
m (copyedit)
(Infoboxes: Use correct URL)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
Templates are used in the Computer History Wiki to prevent the reduplication of work and help provide a uniform layout. For example, we have the template ''<nowiki>{{stub}}</nowiki>'' to show a short, very incomplete article. Instead of having to include this text manually on every such article, placing the text <nowiki>{{stub}}</nowiki> in an article produces:
+
Templates are a way to include in an article blocks of MediaWiki [[source]] which have been given a name. They used in the Computer History Wiki to prevent the reduplication of work and help provide a uniform layout. They are invoked with the special [[syntax]] ''<nowiki>{{name}}</nowiki>''.
 +
 
 +
For example, we have the template ''<nowiki>{{stub}}</nowiki>'' to indicate a short, very incomplete article. Instead of having to include this text manually on every such article, placing the text <nowiki>{{stub}}</nowiki> in an article produces:
  
 
{{stub}}
 
{{stub}}
 +
(If you want to see all the articles tagged as stubs, [[Special:WhatLinksHere/Template:Stub|this link]] will show them all to you.) There is also a ''<nowiki>{{semi-stub}}</nowiki>'' variant, for pages that are more complete, but could still use some work; a list of those is available [[Special:WhatLinksHere/Template:Semi-stub|here]].
  
We also have several series of templates which are used to provide information in standardized ways.
+
Template invocations can include [[argument]]s; both named and un-named arguments are available. The latter are simply included after the template name in the template invocation, separated with '|' characters; the former are additionally tagged, with syntax of the form ''name=value''. (See below for an example.)
  
== Infoboxes ==
+
We also have several series of templates which are used to provide information in standardized ways. In addition to these, described below, you can find a list of all the templates in the system [http://gunkies.org/w/index.php?title=Special%3APrefixIndex&prefix=Template%3A&namespace=0&hideredirects=1 here].
  
Infoboxes allow the uniform display of information based on a template.  Custom data can be fed into the template by entering it into the article, for example:
+
==Navigation boxes==
  
 +
Navigation boxes are useful to tie together all the pages on a single subject; e.g. all the models of a particular computer. The navigation box, once prepared, can be placed on all the related pages, and allows easy connection from one to another.
 +
 +
They are easy to prepare, using some 'helper' templates which have already been set up. The body of the navigation box, which will look like this:
 +
<pre>
 +
{{Navigation
 +
| templateName = Nav Help
 +
| title        = Help topics
 +
| body        = <b>Help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]] • [[Help:Introduction to Templates]]
 +
}}
 +
</pre>
 +
is placed in the template page <nowiki>[[Template:Nav Help]]</nowiki> (convention is that all navigation box templates are named 'Nav xxx'). When invoked with <nowiki>{{Nav Help}}</nowiki>, it will produce the following navigation box:
 +
{{Navigation
 +
| templateName = Nav Help
 +
| title        = Help topics
 +
| body        = <b>Help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]] • [[Help:Introduction to Templates]]
 +
}}
 +
(It is important that you get the 'templateName' argument correct, or else the 'view'/'discussion'/'edit' links in the top border of the navigation box will not be correct.) Convention is that navigation boxes are placed towards the bottom of the page.
 +
 +
A list of all the existing navigation boxes in the CHWiki may be found [https://gunkies.org/w/index.php?title=Special%3APrefixIndex&prefix=Template%3ANav%20&namespace=0&hideredirects=1 here].
 +
 +
===Expandable navigation boxes===
 +
 +
Some navigation boxes are getting very large; these overwhelm small pages they are inserted in, and make the most-used links harder to find. There is now a way to have some entries in a navigation box initially 'hidden', so that the reader has to click on a button to see the full content. That reduces the initial size of a navigation box, but leaves everything easily accessible.
 +
 +
Such expandable navigation boxes look much like the ordinary ones (above), but use a different template, 'PartiallyCollapsibleNavBox', and have an additional named argument, 'cbody', to hold the initially-hidden items. The body of such an expandable navigation box will look like this:
 +
<pre>
 +
{{PartiallyCollapsibleNavBox
 +
| templateName = Nav Hidden Help
 +
| title        = Hidden help topics
 +
| body        = <b>Unhidden help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]]
 +
| cbody        = <b>Hidden help pages</b> - [[Help:Introduction to Templates]]
 +
}}
 +
</pre>
 +
which is placed, as above, in the template page <nowiki>[[Template:Nav Hidden Help]]</nowiki>; and when invoked with <nowiki>{{Nav Hidden Help}}</nowiki>, it will produce the following navigation box:
 +
{{PartiallyCollapsibleNavBox
 +
| templateName = Nav Hidden Help
 +
| title        = Hidden help topics
 +
| body        = <b>Unhidden help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]]
 +
| cbody        = <b>Hidden help pages</b> - [[Help:Introduction to Templates]]
 +
}}
 +
If you look in the bottom right corner, you will see a "[Expand]" button which, when clicked, expands that section of the box. Entries 'above the line' are always shown, and entries 'below the line' (for less 'interesting' ones) are initially hidden, and one has to click the '[Expand]" button to see them.
 +
 +
==Infoboxes==
 +
 +
Infoboxes allow the uniform display of information based on a template. Custom data can be fed into the template by entering it into the article, for example:
 
<pre>
 
<pre>
 
{{Infobox Machine
 
{{Infobox Machine
Line 22: Line 70:
 
| successor = [[Apple II]]
 
| successor = [[Apple II]]
 
}}
 
}}
</pre>
+
</pre>{{Infobox Machine
 
 
{{Infobox Machine
 
 
| name = Apple I  
 
| name = Apple I  
 
| manufacturer = [[Apple Computer]]
 
| manufacturer = [[Apple Computer]]
Line 36: Line 82:
 
| successor = [[Apple II]]
 
| successor = [[Apple II]]
 
}}
 
}}
 
+
produces the box on the right of the screen here. (The 'Infobox Machine' template is the general template for most computer systems in this wiki.)
produces the box on the right of the screen here. The Infobox Machine template is the general template for most computer systems in this wiki. See [[Template:Infobox Machine]] for an overview of the values you can use with this template.
 
  
 
To avoid the insanity of a haphazard set of datasheets for a million different devices, we've got some basic templates in place which we <i>really</i> would like you to use:
 
To avoid the insanity of a haphazard set of datasheets for a million different devices, we've got some basic templates in place which we <i>really</i> would like you to use:
  
 
* [[Template:Infobox Machine]] - for a system in general
 
* [[Template:Infobox Machine]] - for a system in general
 +
* [[Template:Infobox CPU]] - for CPUs
 
* [[Template:Infobox Tape drive]] - for tape drives
 
* [[Template:Infobox Tape drive]] - for tape drives
 
* [[Template:Infobox Disk drive]] - for disk drives
 
* [[Template:Infobox Disk drive]] - for disk drives
 +
* [[Template:Infobox Terminal]] - for terminals (both printing and video)
 
* [[Template:Infobox Software]] - for software, etc.
 
* [[Template:Infobox Software]] - for software, etc.
 
* [[Template:Infobox OS]] - for operating systems
 
* [[Template:Infobox OS]] - for operating systems
 
* [[Template:Infobox App]] - for applications (similar to Software above)
 
* [[Template:Infobox App]] - for applications (similar to Software above)
  
If these are not sufficient, or you have any requests or comments, you can discuss it on the [[Help talk:Introduction to Templates|talk page of this article]] -- the people writing the infoboxes are watching these talk pages.
+
Go to each template for an overview of the values you can use with that template (they are self-documenting).
 +
 
 +
There are a few other specialized ones; a complete list is [https://gunkies.org/w/index.php?title=Special%3APrefixIndex&prefix=Infobox&namespace=10&hideredirects=1 here]. If these are not sufficient, or you have any requests or comments, you can discuss it on the [[Help talk:Introduction to Templates|talk page of this article]] -- the people writing the infoboxes are watching these talk pages.
  
 
==Registers==
 
==Registers==
  
For showing the contents of [[register]]s (in [[Central Processing Unit|CPUs]] and devices) we have a series of display templates.
+
For showing the contents of [[register]]s (in [[Central Processing Unit|CPUs]] and [[peripheral|devices]]) we have a series of display templates.
 
 
To begin with, for 16-bit registers, there are [[Template:16bit-header‎]] and [[Template:16bit-bitout‎]], which used thusly:
 
  
 +
To begin with, for 16-bit registers, there are [[Template:16bit-header‎]] and [[Template:16bit-bitout‎]], which, when used thusly:
 
<pre>
 
<pre>
 
{{16bit-header‎}}
 
{{16bit-header‎}}
Line 61: Line 109:
 
{{16bit-bitout‎}}
 
{{16bit-bitout‎}}
 
</pre>
 
</pre>
 +
produce this:
 +
{{16bit-header‎}}
 +
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
 +
{{16bit-bitout‎}}
 +
 +
Following that, a number of similar register templates have been created, for different sizes. For each word length, there's one header template (like the one above), shared between all the versions, and then one or more footer ones, which produced differently-formatted output.
 +
 +
They are:
 +
 +
* 8-bit ([[Template:8bit-header‎]] and [[Template:8bit-bitout‎]])
 +
* 12-bit ([[Template:12bit-header‎]] and [[Template:12bit-bitout‎]])
 +
* 18-bit ([[Template:18bit-header‎]] and [[Template:18bit-bitout‎]])
 +
* 36-bit ([[Template:36bit-header]]), and [[Template: 36bit-bitout‎]])
 +
* 36-bit right half-word ([[Template:36bithalf-header‎]]), and [[Template: 36bithalf-bitout‎]]); these aren't the same as the 18-bit ones, the differ in the bit numbers
 +
* 32-bit, in both [[little-endian]] and [[big-endian]] bit-numbering forms (since there are machines of that [[word]] size for both): just the emitters ([[Template:32bitbig-bitout‎‎]] and [[Template:32bitlittle-bitout‎‎]]); since they both use the same header ([[Template:32bit-header‎]])
  
produces this:
+
Finally, motivated by how nice the 36-bit ones looked, grouped into 3's by colour, 'blocked' versions of the 12- and 18-bit ones, using similar emitters ([[Template:12bitoctal-bitout‎‎]] and [[Template:18bitoctal-bitout‎]]) were added; along with 16-bit ones for both hex and octal machines, again needing only emitters ([[Template:16bitoctal-bitout‎]] and [[Template:16bithex-bitout‎]]).
  
 +
When used:
 +
<pre>
 +
{{16bit-header‎}}
 +
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
 +
{{16bitoctal-bitout‎}}
 +
</pre>
 +
they produce output which looks like this:
 
{{16bit-header‎}}
 
{{16bit-header‎}}
 
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
 
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
{{16bit-bitout‎}}
+
{{16bitoctal-bitout‎}}
  
 +
==External links==
  
Following that, a number of similar register templates have been created. For each word length, there's one header template (like the one above), shared between all the versions, and then one or more footer ones, which produced differently-formatted output.
+
* [https://en.wikipedia.org/wiki/Help:Template Help:Template] - help page which explains the more complex [[syntax]] used for [[argument]]s, [[conditional branch|conditionals]], etc in templates
  
They are 36-bit ([[Template:36bit-bitout‎]]);  32-bit, in both [[little-endian]] and [[big-endian]] ([[Template:32bitbig-bitout‎]] and [[Template:32bitlittle-bitout‎]]) bit-numbering forms (since there are machine of that word size for both). Finally, motivated by how nice the 36-bit ones looked, grouped into 3's by colour, versions of the 16-bit ones for both hex and octal machines ([[Template:16bitoctal-bitout‎]] and [[Template:16bithex-bitout‎]]) were added.
+
[[Category: Help]]

Latest revision as of 21:19, 17 February 2024

Templates are a way to include in an article blocks of MediaWiki source which have been given a name. They used in the Computer History Wiki to prevent the reduplication of work and help provide a uniform layout. They are invoked with the special syntax {{name}}.

For example, we have the template {{stub}} to indicate a short, very incomplete article. Instead of having to include this text manually on every such article, placing the text {{stub}} in an article produces:

(If you want to see all the articles tagged as stubs, this link will show them all to you.) There is also a {{semi-stub}} variant, for pages that are more complete, but could still use some work; a list of those is available here.

Template invocations can include arguments; both named and un-named arguments are available. The latter are simply included after the template name in the template invocation, separated with '|' characters; the former are additionally tagged, with syntax of the form name=value. (See below for an example.)

We also have several series of templates which are used to provide information in standardized ways. In addition to these, described below, you can find a list of all the templates in the system here.

Navigation boxes

Navigation boxes are useful to tie together all the pages on a single subject; e.g. all the models of a particular computer. The navigation box, once prepared, can be placed on all the related pages, and allows easy connection from one to another.

They are easy to prepare, using some 'helper' templates which have already been set up. The body of the navigation box, which will look like this:

{{Navigation
| templateName = Nav Help
| title        = Help topics
| body         = <b>Help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]] • [[Help:Introduction to Templates]]
}}

is placed in the template page [[Template:Nav Help]] (convention is that all navigation box templates are named 'Nav xxx'). When invoked with {{Nav Help}}, it will produce the following navigation box:

(It is important that you get the 'templateName' argument correct, or else the 'view'/'discussion'/'edit' links in the top border of the navigation box will not be correct.) Convention is that navigation boxes are placed towards the bottom of the page.

A list of all the existing navigation boxes in the CHWiki may be found here.

Expandable navigation boxes

Some navigation boxes are getting very large; these overwhelm small pages they are inserted in, and make the most-used links harder to find. There is now a way to have some entries in a navigation box initially 'hidden', so that the reader has to click on a button to see the full content. That reduces the initial size of a navigation box, but leaves everything easily accessible.

Such expandable navigation boxes look much like the ordinary ones (above), but use a different template, 'PartiallyCollapsibleNavBox', and have an additional named argument, 'cbody', to hold the initially-hidden items. The body of such an expandable navigation box will look like this:

{{PartiallyCollapsibleNavBox
| templateName = Nav Hidden Help
| title        = Hidden help topics
| body         = <b>Unhidden help pages</b> - [[Help:Introduction to Categories]] • [[Help:Introduction to Redirects]]
| cbody        = <b>Hidden help pages</b> - [[Help:Introduction to Templates]]
}}

which is placed, as above, in the template page [[Template:Nav Hidden Help]]; and when invoked with {{Nav Hidden Help}}, it will produce the following navigation box:

If you look in the bottom right corner, you will see a "[Expand]" button which, when clicked, expands that section of the box. Entries 'above the line' are always shown, and entries 'below the line' (for less 'interesting' ones) are initially hidden, and one has to click the '[Expand]" button to see them.

Infoboxes

Infoboxes allow the uniform display of information based on a template. Custom data can be fed into the template by entering it into the article, for example:

{{Infobox Machine
| name = Apple I 
| manufacturer = [[Apple Computer]]
| form factor = [[Personal Computer]]
| year introduced = July 1976 
| year discontinued = March 1977
| cpu = [[MOS 6502]]
| clock speed = 1 MHz
| ram = 4 KB standard
| graphics = 40x24 character output
| successor = [[Apple II]]
}}
Apple I
Manufacturer: Apple Computer
Year Introduced: July 1976
Year Discontinued: March 1977
Form Factor: Personal Computer
Clock Speed: 1 MHz
Memory Size: 4 KB standard
Graphics: 40x24 character output
CPU: MOS 6502
Successor(s): Apple II

produces the box on the right of the screen here. (The 'Infobox Machine' template is the general template for most computer systems in this wiki.)

To avoid the insanity of a haphazard set of datasheets for a million different devices, we've got some basic templates in place which we really would like you to use:

Go to each template for an overview of the values you can use with that template (they are self-documenting).

There are a few other specialized ones; a complete list is here. If these are not sufficient, or you have any requests or comments, you can discuss it on the talk page of this article -- the people writing the infoboxes are watching these talk pages.

Registers

For showing the contents of registers (in CPUs and devices) we have a series of display templates.

To begin with, for 16-bit registers, there are Template:16bit-header‎ and Template:16bit-bitout‎, which, when used thusly:

{{16bit-header‎}}
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
{{16bit-bitout‎}}

produce this:

Unused Length Trapped Written Unused Direction Access Control
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00

Following that, a number of similar register templates have been created, for different sizes. For each word length, there's one header template (like the one above), shared between all the versions, and then one or more footer ones, which produced differently-formatted output.

They are:

Finally, motivated by how nice the 36-bit ones looked, grouped into 3's by colour, 'blocked' versions of the 12- and 18-bit ones, using similar emitters (Template:12bitoctal-bitout‎‎ and Template:18bitoctal-bitout‎) were added; along with 16-bit ones for both hex and octal machines, again needing only emitters (Template:16bitoctal-bitout‎ and Template:16bithex-bitout‎).

When used:

{{16bit-header‎}}
| Unused || colspan=7 | Length || Trapped || Written || colspan=2 | Unused || Direction || colspan=3 | Access Control
{{16bitoctal-bitout‎}}

they produce output which looks like this:

Unused Length Trapped Written Unused Direction Access Control
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00

External links