Bản mẫu:Routemap

Bách khoa toàn thư mở Wikipedia
Bước tới: menu, tìm kiếm
Hình tượng tài liệu Tài liệu bản mẫu[xem] [sửa] [lịch sử] [làm tươi]

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:Bản mẫu sơ đồ tuyến because diagrams created by {{Routemap}} load faster.

Cách sử dụng[sửa mã nguồn]

{{{title}}}
{{{top}}}
{{{map}}}
{{{footnote}}}
{{routemap
| inline      =
| title       =
| title color =
| title bg    =
| collapsible =
| collapse    =
| navbar      =
| navbar pos  =
| navbar mini =
| legend      =
| legend alt  =
| float       =
| bg          =
| style       =
| top         =
| footnote    =
| text-width  =
| map =

}}

Đánh dấu cho tham số bản đồ[sửa mã nguồn]

The markup for composing the diagram in the |map = parameter is different to the {{BSrow}}-based templates. The major differences are the separators in each row. Subtemplates are not necessary, since a new row in the table is simply created by a carriage return (newline).

{{Routemap
Add other parameters like |title =  here.
|map=
Map markup goes here!
}}

Cơ bản[sửa mã nguồn]

Ví dụ 1.1
exCONTg
ENDExa
CONTgq\KRZu\CONTfq
BHF
\ABZlf\CONTfq
CONTf
icon ID\icon ID\icon ID
  • Icons are separated by the backslash \.
  • Each group of icons is centered in its row. The nameless icon (at the start of row 5 in the diagram) can be used as a spacer.
  • The ID of each icon can be seen in its tooltip. Move your cursor over the icons to see them.

Văn bản thanh bên[sửa mã nguồn]

icon ID\icon ID\icon ID~~dist./time~~main text~~remark~~right remark

or

icon ID\icon ID\icon ID~~main text
{{Routemap
|title=Ví dụ 1.2
|map=
KBHFa~~terminus
WASSERq\WBRÜCKE\WASSERq~~ ~~ ~~ ~~Bridge
LDER\INT\~~1 km~~station~~transfer for HSR
\KBHFe\BUS~~2 km~~terminus~~bus terminal
}}
Ví dụ 1.2
terminus
Bridge
1 km station transfer for HSR
2 km terminus bus terminal
  • The third and fourth pairs of tildes can be omitted if there is no content following either of them.
  • 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 the tildes will be treated as a signature.

Văn bản các ô trong hàng biểu tượng[sửa mã nguồn]

*text\d*text\cd*text~~main text
{{Routemap
|title=Ví dụ 1.3
|map=
ENDEa~~ ~~ ~~Reversing siding
SPLa
cBS\vSTR\cBS~~Station
d*1\cBS\vSTR\cBS\d*2~~ ~~ ~~Platform numbers
cBS\vSTR\cBS
vCONTfge~~ ~~ ~~''to City''
}}
Ví dụ 1.3
Reversing siding
Station
1 2
Platform numbers
to City

The asterisk indicating a text cell can be preceded by one of the BSicons' width prefixes. (Normal BSicons are square.)

Letters c d cd none b s bs w
Width 14 12 34 1 2 4 6 8

Lớp phủ biểu tượng, liên kết biểu tượng, màu nền và colspan[sửa mã nguồn]

{{Routemap
|title=Ví dụ 2.1
|map=
-colspan-1
Icon overlay
uSTRq!~STR2!~BHF!~lHUB
-colspan-2-style=border-bottom:5px solid red;
----
icon link
utBHF!@Superhub
-colspan
----
background color
-colspan-end
utSTR~~ ~~ ~~ ~~ ~~bg=#7af
}}
Ví dụ 2.1

Icon overlay


icon link


background color

  • 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 parameter (bg=) requires 5 sets of preceding text separators to be recognizable even if there is no text on that row whatsoever.

Tùy chọn định dạng khác[sửa mã nguồn]

Hàng[sửa mã nguồn]

Ví dụ 2.2
bg=#007CC3
1 2 3
color=red,bold=yes
A C E
align=l,b=1,fontsize=cmt
B D F
colour=orange, align=b, i=y

Aside from bg=, there are several other parameters, separated by commas (,), which can be used to customize the display of a row. Only bg= can be used to change the display of icons; all others only affect text cells.

Các ô/biểu tượng cá nhân[sửa mã nguồn]

icon!_bg=purple\*text__align=l!~*more text__align=r,b=yes
  • Parameters for all of a stack of multiple overlaid icons and/or text boxes (or a single icon or text box with no overlays) are separated to the left by an exclamation mark and an underscore (!_). This must go after the link (if any).
  • Parameters for part of a stack of multiple overlaid items are separated to the left by two underscores (__).
  • For the last overlaid item in a stack, the individual item parameters (if any) must go before the stack parameters.
  • Most of the parameters are the same as those for rows, but there are a few additional ones. Additionally, the values for align=, bg= and color= can override those of the row parameters.

Đóng mở[sửa mã nguồn]

{{Routemap
|title=Ví dụ 3.1: Đóng mở cơ bản
|text-width=80
|map=
-startCollapsible-collapsed
\KBHFa\~~terminus
hSTRag
WASSERq\hWSTR\WASSERq~~ ~~ ~~ ~~bridge
hSTRef
-endCollapsible-
LDER\INT\~~ ~~station~~transfer for HSR
\KBHFe\BUS~~ ~~terminus~~bus terminal
}}
Ví dụ 3.1: Đóng mở cơ bản
terminus
bridge
station transfer for HSR
terminus bus terminal
{{Routemap
|title=Ví dụ 3.2: Mixed odd and even rows
|tw=70
|map=
-startCollapsible-collapsed
d\KBHFa\d~~terminus
hWSTR~~ ~~ ~~ ~~bridge
-endCollapsible-
BS2+l\BS2+r~~junction
}}
Ví dụ 3.2: Mixed odd and even rows
terminus
bridge
junction
  • Adjust |text-width = (or |tw = ) parameter until there is no break.
    • Unit is "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 be equal to or greater than the icon number of the widest non-collapsible row.
    • As in example 3.2, use half-width empty icon   (d) as filler when you are mixing both odd and even rows in the same map.
  • Changing "collapsed" to "nil" will change the default state of the collapible section to uncollapsed.

Thay thế đóng mở[sửa mã nguồn]

{{Routemap
|title=Ví dụ 4.1
|text-width=150
|map=
KBHFa~~terminus
-startCollapsible-collapsed-replace
\LSTR\~~dispensable section
\hSTRag\
WASSERq\hWSTR\WASSERq~~ ~~ ~~ ~~bridge
hSTRef
-endCollapsible-
LDER\INT\~~ ~~station~~transfer for HSR
\KBHFe\BUS~~ ~~terminus~~bus terminal
}}
Ví dụ 4.1
terminus
dispensable section
bridge
station transfer for HSR
terminus bus terminal
{{Routemap
|title=Ví dụ 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
}}
Ví dụ 4.2: Empty filler
under construction
future terminus
future station
terminus
terminus
  • Both replacement and replaced rows must be as wide as the widest non-collapsible row in the diagram.
  • If you want to hide the replaced row after expanding the collapsible, use icon   (leer) as empty filler as in example 4.2.
  • In any case, mind to provide a sufficient text-width. Here, using text-width=120 would break the alignment of the icons.
  • Collapsible elements are intentionally disabled in mobile view, so the replaced row will never be visible. Keep this in mind while creating a diagram.

Hai văn bản thanh bên[sửa mã nguồn]

For larger and more complicated diagrams, it often helps to have a text sidebar on the left as well as the right.

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=Ví dụ 5
|map=
commuter terminus! !uKBHFa\\KBHFa~~regional terminus
River Boris~~ ~~ ~~! !uhWSTR\WASSERq\hWSTR~~ ~~ ~~ ~~bridge
transfer for HSR~~station~~1 km! !uINT\LDER\LSTR
commuter terminus~~2 km! !uKBHFe\\KBHFe~~2 km~~regional terminus
}}
Ví dụ 5
commuter terminus
regional terminus
River Boris
bridge
transfer for HSR station 1 km
commuter terminus 2 km
2 km regional terminus
  • Left text cells require "exclamation mark-space-exclamation mark" (! !) separating them 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 the separator will be displayed in the left main text cell.

Hai văn bản thanh bên đóng mở[sửa mã nguồn]

{{Routemap
|title=Ví dụ 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~~ ~~ ~~! !uhWSTR\WASSERq\hWSTR~~ ~~ ~~ ~~bridge
-endCollapsible
transfer for HSR~~station~~1 km! !uINT\LDER\LSTR
commuter terminus~~2 km! !uKBHFe\\KBHFe~~2 km~~regional terminus
}}
Ví dụ 6.1: All text cells applied
commuter terminus
regional terminus
River Boris
bridge
transfer for HSR station 1 km
commuter terminus 2 km
2 km regional terminus
{{Routemap
|map-title=Ví dụ 6.2: Only main text cell applied
|style=width:380px
|text-width=,120,,,120,
|map=
-startCollapsible
commuter terminus! !uKBHFa\\KBHFa~~regional terminus
River Boris! !uhWSTR\WASSERq\hWSTR~~bridge
-endCollapsible
station! !uINT\LDER\LSTR
commuter terminus! !uKBHFe\\KBHFe~~regional terminus
}}
Ví dụ 6.2: Only main text cell applied
commuter terminus
regional terminus
River Boris
bridge
station
commuter terminus
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.
  • 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   (leer) to fixate the icon columns.

Chuyển đổi từ bản mẫu hàng BS kế thừa đến đánh dấu Routemap[sửa mã nguồn]

Chính sách chuyển đổi[sửa mã nguồn]

Many contributors of the English Route Diagram Template project during the implementation of Routemap have conflicting opinions about the justification of replacing all maps of legacy BS row templates by the Lua-based Routemap. Opponents deem the map markups of Routemap to be too esoteric for editors unfamiliar with Routemap markup to modify. While proponents support a complete conversion for better performance. There is no consensus reached at the moment so any transition without massively updating the map appearance for reflecting service and/or structural change in reality should only be done with the following considerations:

  • The map of the legacy BS row template design has exceeded template size limit in the transcluding page, which means the template does not expand into its intended appearance but only the link to the template page is shown, so there is an imminent need to translate the map into Routemap design to reduce post-expand include size.
  • If there is no template size issue, respect the preference of the initial contributor of the first completed version of the diagram. If that contributor contests the change to Routemap, retain the BS row template design.

Tùy chọn kỹ thuật[sửa mã nguồn]

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.

"Column mode editing" can avoid the trouble of find and replace to add safesubst: on all rows efficiently. This function is common in advanced text editors like Notepad++[1] and Sublime Text[2].

You can also use the "convertbs" function of Modeule:Routemap or an Unix script.

Hàm convertbs[sửa mã nguồn]

Copy/paste the following code to any edit area of this wiki, maybe the map page you are working on:

{{#gọi:Routemap|convertbs|<nowiki>

</nowiki>}}

Then copy/paste the original BS-map or Railway line header map code between the <nowiki> tags (alternatively paste the invoke convertbs header before the original map code and the </nowiki>}} ending after the map code) and show preview. It will generate the safesubst version and show the original versions (for comparison) of the map code. You copy the safesubst code from the preview area back to the edit area, and you should remove everything of #gọi:Routemap|convertbs if the preview of the new code works properly.

Kịch bản Unix[sửa mã nguồn]

  • 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¶||}}<!--¶|&#32;|}}<!--¶

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¶||}}<!--¶|&#32;|}}<!--¶ is required when using #if structures

When using Railway line header to avoid a template overflow, the following additional rules can 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

Nhúng vào hộp thông tin[sửa mã nguồn]

  • 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 = {{color box|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
}}
}}
     Station layout
Placeholder.png
Platform level
Thông tin khái quát
Đường xe lửa 2
Thông tin thêm
Mở cửa 15 tháng 5, 1935 (1935-05-15)
Bản đồ hành trính
terminus
Bridge
1 km station transfer for HSR
2 km terminus bus terminal

Dữ liệu bản mẫu[sửa mã nguồn]

Template for displaying diagram composed of icon images and text labels in uniform style.

Tham số bản mẫu

Bản mẫu này có định dạng tùy biến.

Tham số Miêu tả Kiểu Trạng thái
Inline state inline

Remove title bar and border for transclusion in infobox

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
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

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Title font color title colortitle-color

Color of the title's text; automatically black or white to contrast with the title background color. Only use colors that contrast well with the background color

Mặc định
#FFF or #252525; depends
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Title background color title bg colortitle-bg

Background color of the title

Mặc định
#27404E
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Collapsibility collapsible

Whether the whole infobox is collapsible or not

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Collapsing state collapsecollapsed

Collapsing state. Shown by default. Any value will make the table collapse by default

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Template name for Navbar navbartnavbar

Type the diagram template page name so the Navbar template will appear and link to the template page

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
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

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Small navbar navbar mini

If the navbar is not in default position, then this changes whether the navbar displays as "V · T · E" (default for navbar pos 1; values: «1», «y», «yes», «true») or "This diagram: view · talk · edit" (default for navbar pos 2; values: «0», «n», «no», «false»).

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Legend appearance legend

Alias of the legend link. It can be «bus», «canal», «footpath» or «track». «0» or «no» for no legend at all

Mặc định
Template:Railway line legend
Ví dụ
trống
Giá trị tự động
trống
Trang tùy chọn
Legend link text legend alt

Different link name in place of «Legend» if desirable

Mặc định
Legend
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Floating state float

Floating state of the whole box: «right» by default; optionally «left» or «none»

Mặc định
right
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Background color bg

Background color of the whole map area

Mặc định
#F9F9F9
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
CSS style values style

Additional CSS style definition of the whole infobox

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Top note topon top

Space for optional note or infobox above the map

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Bottom note footnotebottom

Space for optional note or infobox below the map

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Width of map text cell text-widthtw

Extend the width of the map text cell so the collapsible section within the map does not break

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi tùy chọn
Map markups map1

Map data which uses specific markup/separators to load icon image and arrange the text in the uniform style

Mặc định
trống
Ví dụ
trống
Giá trị tự động
trống
Chuỗi bắt buộc