Skabelon:Routemap/doc
Dette er dokumentationsundersiden til Skabelon:Routemap. Denne side indeholder information om brug, kategorier samt andet indhold, som ikke er en del af den oprindelige skabelonside. |
Denne skabelon indeholder en eller flere valgbare parametre. Skabelonen anvender en syntaks, som er yderst kompliceret og esoterisk. Forsøg ikke at ændre den, medmindre du er helt sikker på, at du forstår opbygningen og er indstillet på at udbedre alle eventuelle uheldige følger af, at ændringer giver et uventet resultat. Alle eksperimenter bør udføres i sandkassen, sandkasse-skabelonen, eller på din egen brugerside. |
Denne skabelon bruger Lua: |
This Lua-based template replaces the older parser-function-based {{BS-map}} (and deprecated {{Railway line header}}, {{BS-header}} and {{BS-table}}) templates for Wikipedia:Route diagram templates because diagrams created by
load faster.
Markup for map parameter
[rediger kildetekst]The markup for composing the diagram in {{{map}}} parameter is different than the legacy BS row templates. The major difference is the separators for separating icon IDs and text of each row. There is no need to call new BS row template for each new row because the hard return itself serves as a separator for calling another new table row in the diagram. You can use other supplementary templates like {{rmr}} in the text cell as usual, but be aware that special treatment is required for templates like {{BSsplit}} and {{BSto}} because they are essentially calling another new table for formatting.
Basic
[rediger kildetekst]icon id\icon id\icon id~~dist./time~~main text~~remark~~right remark
or
icon id\icon id\icon id~~main text
{{Routemap |title=Example 1 |map= KBHFa~~terminus WASSERq\hKRZW\WASSERq~~ ~~ ~~ ~~Bridge LDER\INT\~~1 km~~station~~transfer for HSR \KBHFe\BUS~~2 km~~terminus~~bus terminal }} |
|
- The separator between icon IDs uses backslash (
\
) instead of slash (/
commonly used by XML closing tag). - After the last icon ID, if there is only one set of "tilde-tilde" (
~~
), the following text will be displayed in the main text cell instead of dist./time. - Separating text cells requires at least one empty space, otherwise it will be treated as a signature.
Icon overlay, icon link, background color and colspan
[rediger kildetekst]- Overlay separator "exclamation mark-tilde" (
!~
) must follow the icon id which is to be overlaid. - Overlay is practically unlimited, but legibility should be taken into account.
- When using icon overlay and icon link for the same icon cell, the icon link separator (
!@
) must follow the last (top) overlaying icon id. - The background color separator (
~~bg=
) requires 4 sets of preceding text separators to be recognizable even if there is no text on that row whatsoever.
Collapsible
[rediger kildetekst]{{Routemap |title=Example 3.1: Basic collapsible |text-width=80 |map= -startCollapsible-collapsed \KBHFa\~~terminus hSTRa@g WASSERq\hKRZW\WASSERq~~ ~~ ~~ ~~bridge hSTRe@f -endCollapsible- LDER\INT\~~ ~~station~~transfer for HSR \KBHFe\BUS~~ ~~terminus~~bus terminal }} |
|
{{Routemap |title=Example 3.2: Mixed odd and even rows |tw=70 |map= -startCollapsible-collapsed d\KBHFa\d~~terminus hKRZW~~ ~~ ~~ ~~bridge -endCollapsible- BS2+l\BS2+r~~junction }} |
|
- Adjust {{{text-width}}} (or tw) parameter until there is no break.
- Unit "px" by default, but other units such as "em" are acceptable.
- Check the map in different browser and increase text-width if it breaks.
- The icon number of the first row of collapsible section must equal to or greater than the icon number of the widest non-collapsible row.
- As in example 3.2, use half width empty icon Skabelon:Bsq as filler when you are mixing both odd and even rows in the same map.
- Change "collapsed" to "nil" will change the default state of the collapible to uncollapsed.
Collapsible replacement
[rediger kildetekst]{{Routemap |title=Example 4.1 |text-width=150 |map= KBHFa~~terminus -startCollapsible-collapsed-replace \LSTR\~~dispensable section \hSTRa@g\ WASSERq\hKRZW\WASSERq~~ ~~ ~~ ~~bridge hSTRe@f -endCollapsible- LDER\INT\~~ ~~station~~transfer for HSR \KBHFe\BUS~~ ~~terminus~~bus terminal }} |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{Routemap |title=Example 4.2: Empty filler |text-width=150 |map= -startCollapsible-collapsed-replace exCONTg~~under construction leer exKBHFa~~future terminus exBHF~~future station -endCollapsible KBHFxa~~terminus KBHFe~~terminus }} |
|
- The icon number of both replacement and replaced rows must equal to or greater than the icon number of the widest non-collapsible row.
- If you want to hide the replaced row after expanding the collapsible, use icon Skabelon:Bsq as empty filler as in example 4.2.
- In any case, mind to provide a sufficient text-width. Using here text-width=120 would break the alignment of the icons.
Dual text cell
[rediger kildetekst]left-left remark~~left remark~~left main text~~left dist./time! !icon id~~right dist./time~~right main text~~right remark~~right-right remark
or
left main text! !icon id~~right main text
{{Routemap |title=Example 5 |map= commuter terminus! !uKBHFa\\KBHFa~~regional terminus River Boris~~ ~~ ~~! !uhKRZW\WASSERq\hKRZW~~ ~~ ~~ ~~bridge transfer for HSR~~station~~1 km! !uINT\LDER\LSTR commuter terminus~~2 km! !uKBHFe\\KBHFe~~2 km~~regional terminus }} |
|
- Left text cells require "exclamation mark-space-exclamation mark" (
! !
) to separate from icon cells. - If there is no "tilde-tilde" (
~~
) separator to the left of "exclamation mark-space-exclamation mark", the text to the left of icon cells will be displayed in left main text cell.
Dual text cell collapsible
[rediger kildetekst]{{Routemap |title=Example 6.1: All text cells applied |style=width:540px |text-width=65,150,30,30,120, |map= -startCollapsible commuter terminus! !uKBHFa\leer\KBHFa~~regional terminus River Boris~~ ~~ ~~! !uhKRZW\WASSERq\hKRZW~~ ~~ ~~ ~~bridge -endCollapsible transfer for HSR~~station~~1 km! !uINT\LDER\LSTR commuter terminus~~2 km! !uKBHFe\\KBHFe~~2 km~~regional terminus }} |
|
{{Routemap |map-title=Example 6.2: Only main text cell applied |style=width:380px |text-width=,120,,,120, |map= -startCollapsible commuter terminus! !uKBHFa\\KBHFa~~regional terminus River Boris! !uhKRZW\WASSERq\hKRZW~~bridge -endCollapsible station! !uINT\LDER\LSTR commuter terminus! !uKBHFe\\KBHFe~~regional terminus }} |
|
- Apply {{{text-width}}} to eliminate the break:
- Only 1 value:
right main text+right remark
- 3 values, separated by commas:
right dist./time,right main text+right remark,right-right remark
- 6 values:
Left-left remark,left remark+left main text,left dist./time,right dist./time,right main text+right remark,right-right remark
- If the amount of values does not equal to 1, 3 or 6, the whole parameter will be ignored.
- Only 1 value:
- If the text width of right-right remark is shorter to some degree, its width definition can be omitted, as in example 6.1.
- If the entire map never uses a specific text cell, that width definition can be omitted, as in example 6.2.
- Define the general table width in {{{style}}} parameter as well if {{{text-width}}} alone is ineffective to prevent the break.
- If the empty icon cell of the collapsible row is being squashed, use empty icon Skabelon:Bsq to fixate the icon columns.
BSsplit, BSto templates
[rediger kildetekst]If you use these templates, the vertical line separator (|
) right after the template name must be converted to {{!}} otherwise you will get a mess of unprocessed markups.
{{Routemap |title=Example 7.1: Correct usage |map= BHF~~{{BSsplit{{!}}upper|lower}} }} }} |
|
{{Routemap |title=Example 7.2: Wrong usage |map= BHF~~{{BSto{{!}}upper|lower}} }} }} |
Transition from legacy BS row template to Routemap markup
[rediger kildetekst]All BS row templates have been amended with safesubst commands, hence conversion can be easily done by adding the safesubst:
markup before every BS row template name in the map. For example, change {{BS2|STR|BHF|0|1|2|3|O1=uSTRq}}
in the map to {{safesubst:BS2|STR|BHF|0|1|2|3|O1=uSTRq}}
, then save change, it will produce STR!~uSTRq\BHF~~0~~1~~2~~3
. The process can be sped up by using the "replace all" function of advanced edit tool or separate text editor such as Notepad or Notepad++, but the search rule for the BS row templates should be specified to the number of icon columns in order to avoid templates with similar name such as BSto and BSsplit in case they are present in the map.
One can also use an Unix script (mind all non subst-ed templates, that require the {{!}} protection of their first bar. ):
#! /bin/bash cat <<EOF > tmp_sed s¶{{BS-map¶{{Routemap¶ s¶{{kill-BS-map¶{{Routemap¶ s¶{{BSto|¶{{BSto{{!}}¶g s¶{{BScvt|¶{{BScvt{{!}}¶g s¶{{BSkm|¶{{BSkm{{!}}¶g s¶{{BSsplit|¶{{BSsplit{{!}}¶g s¶{{BS|¶{{subst:BS|¶g s¶{{BS\\([2-9]\\)|¶{{subst:BS\\1|¶g s¶{{BS1\\([0-9]\\)|¶{{subst:BS1\\1|¶g s¶||}}<!--¶| |}}<!--¶ EOF sed -f tmp_sed $from > $vers
Fake template kill-BS-map
is a trick to choose wich template will not be displayed in an overflown source page
The rule s¶||}}<!--¶| |}}<!--¶
is required when using #if structures
When using Railway line header
to avoid a template overflow, the following additional rules can to be used:
#! /bin/bash cat <<EOF >> tmp_sed s¶{|{{Railway line header}}¶{{Routemap¶ s¶{|{{Railway line header|collapse={{#if:{{{collapse|}}}|yes}}}}¶{{Routemap | collapse={{#if:{{{collapse|}}}|yes}}¶ s¶{{BS-header|\\([^|][^|]*\\)|*.*}}¶| title = \\1¶ s¶{{BS-table}}¶| map = ¶ s¶|}\\n|}¶}}¶ EOF
Embedding into infobox
[rediger kildetekst]- Use {{{inline}}} to remove title bar and table border. If creating a separate template which will be embedded into an infobox, wrap inline=1 in <includeonly> tags. Also {{{navbar pos}}} is helpful to locate the {{Navbar}} better.
{{Infobox station | name = {{colorbox|orange}} Station layout | image = Placeholder.png | image_upright = 0.5 | image_caption = Platform level | opened = {{Start date|1935|05|15|df=y}} | tracks = 2 | route_map = {{routemap|inline=1|navbar=asd|navbar pos=2| KBHFa~~terminus WASSERq\hWSTR\WASSERq~~ ~~ ~~ ~~Bridge LDER\INT\~~1 km~~station~~transfer for HSR \KBHFe\BUS~~2 km~~terminus~~bus terminal }} }} |
|
Template data
[rediger kildetekst]Routemap
Template for displaying diagram composed of icon images and text labels in uniform style.
Parameter | Beskrivelse | Type | Status | |
---|---|---|---|---|
Inline state | inline | Remove title bar and border for transclusion in infobox
| Streng | valgfri |
Table title | title | Official title of the system. Value «no» will remove the table title row, but this will also disable the table collapsible switch as well
| Streng | valgfri |
Title font color | title color title-color | Title font color. Use high contrast color to the title background color
| Streng | valgfri |
Title background color | title bg color title-bg | Title background color. Use high contrast color to the title font color
| Streng | valgfri |
Collapsibility | collapsible | Whether the whole infobox is collapsible or not | Streng | valgfri |
Collapsing state | collapse collapsed | Collapsing state. Shown by default. Any value will make the table collapse by default | Streng | valgfri |
Template name for Navbar | navbar tnavbar | Type the diagram template page name so the Navbar template will appear and link to the template page
| Streng | valgfri |
Position of the Navbar | navbar pos | Position of the Navbar template. Float to left in the title bar by default; «1» for top-right corner of the map (just under the title bar); «2» for the middle bottom of the map
| Streng | valgfri |
Legend appearance | legend | Alias of the legend link. It can be «bus», «canal», «footpath» or «track». «0» or «no» for no legend at all
| Sidenavn | valgfri |
Legend link text | legend alt | Different link name in place of «Legend» if desirable
| Streng | valgfri |
Floating state | float | Floating state of the whole box: «right» by default; optionally «left» or «none»
| Streng | valgfri |
Background color | bg | Background color of the whole map area
| Streng | valgfri |
CSS style values | style | Additional CSS style definition of the whole infobox | Streng | valgfri |
Top note | top on top | Space for optional note or infobox above the map | Streng | valgfri |
Bottom note | footnote bottom | Space for optional note or infobox below the map | Streng | valgfri |
Width of map text cell | text-width tw | Extend the width of the map text cell so the collapsible section within the map does not break
| Streng | valgfri |
Map markups | map 1 | Map data which uses specific markup/separators to load icon image and arrange the text in the uniform style | Streng | påkrævet |