[go: up one dir, main page]

Template talk:S-rail

Latest comment: 10 months ago by Thryduulf in topic Northumberland Park Metro station

Proposed change

edit

During a discussion at Wikipedia talk:WikiProject Trains#Transperth boxes the idea of allowing the "skinning" of s-rail arose. The proposed change allows the setting of the background and text colors via the {{{{{SYSTEM}}} style}} template, using the main_color and main_font_color parameters. You would still need to define the color for the actual line name link in Template:S-rail/lines. The code necessary is pasted below:

|-
!{{#ifexist:Template:{{{title}}} style|style="color:{{#if:{{{{{title}}} style|main_font_color}}|#{{{{{title}}} style|main_font_color}}|inherit}}; background-color:{{#if:{{{{{title}}} style|main_color}}|#{{{{{title}}} style|main_color}}|inherit}};"{{!}}}}'''Previous station'''
! style="border: 0px #aaa none; {{#ifexist:Template:{{{title}}} style|background-color:#{{{{{title}}} style|main_color}}}}"| 
! style="border: 0px #aaa none; {{#ifexist:Template:{{{title}}} style|background-color:#{{{{{title}}} style|main_color}}}}"|{{S-rail/lines|title={{{title}}}}}
! style="border: 0px #aaa none; {{#ifexist:Template:{{{title}}} style|background-color:#{{{{{title}}} style|main_color}}}}"| 
!{{#ifexist:Template:{{{title}}} style|style="color:{{#if:{{{{{title}}} style|main_font_color}}|#{{{{{title}}} style|main_font_color}}|inherit}}; background-color:{{#if:{{{{{title}}} style|main_color}}|#{{{{{title}}} style|main_color}}|inherit}};"{{!}}}}'''Next station'''
|-

While this does increase the size of the template from 259 bytes to 1,044 bytes, the template inclusion size only goes up about 3-5K even on high-use articles, which seems tolerable. Thoughts or objections? Mackensen (talk) 21:04, 22 July 2007 (UTC)Reply

Proposed change

edit

Whilst it is the lowest of all importances, could someone please change the wording in the headers from Previous/Next to Preceding/Following. It just makes more technical and geographical sense; and it prevents that crushing of text (that happens when the termini are bigger than the headers). Kevin Steinhardt (talk) 04:13, 18 November 2007 (UTC)Reply

colspan middle column

edit

A minor suggestion to span the middle column by 3, instead of having 3 separate columns, unless they are serving any other specific purposes now?  - oahiyeel talk 20:20, 21 November 2007 (UTC)Reply

Width required by macro

edit

When used on pages with very little content other than the Info Box, the template does not render until the end of the Info Box, leaving a large amount of white space to the right. This does not appear to happen on the older(?) rail template. As examples, see Brigg railway station and Baldock railway station. Can this be fixed? Ajcoxuk (talk) 16:47, 17 February 2008 (UTC)Reply

remove leading and trailing spaces

edit

{{editprotected}}

suggestion to remove the non-breaking spaces &nbsp ; before and after the "preceding station" and "following station". They are causing slight misalignment with regards to being <center>ed. Unless they are there for a reason? - oahiyeel talk 07:20, 2 April 2008 (UTC)Reply

Looks like those got added in November and were cosmetic only, so it's probably safe. Do you have an example of a misalignment? Mackensen (talk) 10:43, 2 April 2008 (UTC)Reply
  Done Happymelon 14:30, 5 April 2008 (UTC)Reply

Edit request

edit

{{editprotected}} This template is currently a member of Category:Rail succession templates, but that category has been redirected to Category:Rail transport succession templates, so the link should be updated. --Russ (talk) 20:11, 9 July 2008 (UTC)   Done--Mackensen (talk) 22:33, 9 July 2008 (UTC)Reply

Bold style is unnecessary

edit

Could someone please remove the bold style from "Preceding station" and "Following station". It is not necessary, as wikitables apply bold automatically. Mitch Ames (talk) 10:56, 8 October 2013 (UTC)Reply

  Done --Redrose64 (talk) 12:33, 8 October 2013 (UTC)Reply

Template-protected edit request on 5 January 2017

edit

can someone fix or revert the recent changes? they make no sense. for example,

{{#if:{{#ifexist:Template:{{{title}}} style|{{{{{title}}} style|main_font_color}}}}|color:#{{{{{title}}} style|main_font_color}};}}

why would you still try to use {{{{{title}}} style}} after you know that it doesn't exist? before the change, Template:Cairo Metro style had links but no transclusions. Now it has transclusions, which means we are going to get a bunch of template clogging up Wikipedia:Database reports/Transclusions of deleted templates. 98.230.196.215 (talk) 01:10, 5 January 2017 (UTC)Reply

  Undone: This request has been undone. As there seem to be good-faith concerns about these recent edits, and they have not been discussed, I have reverted them all and invite User:Jc86035 to get consensus — Martin (MSGJ · talk) 09:40, 5 January 2017 (UTC)Reply
What we have here, when used with |title=Cairo Metro, is
{{#if:{{#ifexist:Template:Cairo Metro style|{{Cairo Metro style|main_font_color}}}}|color:#{{Cairo Metro style|main_font_color}};}}
which since Template:Cairo Metro style doesn't exist, reduces to
{{#if:|color:#{{Cairo Metro style|main_font_color}};}}
and the first test is empty, so it emits nothing. Compare when used with e.g. |title=BART:
{{#if:{{#ifexist:Template:BART style|{{BART style|main_font_color}}}}|color:#{{BART style|main_font_color}};}}
which since Template:BART style does exist, reduces to
{{#if:{{BART style|main_font_color}}|color:#{{BART style|main_font_color}};}}
but {{BART style|main_font_color}} returns the empty string, so again we get
{{#if:|color:#{{BART style|main_font_color}};}}
and the first test is again empty, so it again emits nothing. If we didn't test for existence, the BART one would still reduce cleanly, but the Cairo Metro one would put invalid declarations into the style= attribute. --Redrose64 🌹 (talk) 09:52, 5 January 2017 (UTC)Reply
Clearly that wasn't happening, given the template calls to {{Cairo Metro style}}. The "old"/current version seems to work fine, given that the second option for an #ifexist is the same as a "false" for #if (i.e. there is no reason to have an #if:#ifexist). Maybe I'm just reading the code wrong? Primefac (talk) 15:08, 5 January 2017 (UTC)Reply
@Primefac and Redrose64: Likely the reason there was a transclusion was because I didn't enclose the two instances of {{#ifeq:{{{{{title}}} style|title_nowrap}}|yes|white-space:nowrap}} in #ifexist: (and went off to make a Lua module instead because I thought it would load marginally faster). I've tried fixing that in the sandbox; the main template still needs the header colour fix to match site CSS. Jc86035 (talk) Use {{re|Jc86035}}
to reply to me
14:59, 6 January 2017 (UTC)Reply
@Primefac and Redrose64: I've merged the sandbox into the main template. Jc86035 (talk) Use {{re|Jc86035}}
to reply to me
09:32, 8 January 2017 (UTC)Reply
Did you know that in a declaration like border-left: 0px none; one of the values is redundant? A style of none implies a width of zero, and vice versa. Also, when a width is zero, the units are also redundant, so you can simplify to either border-left: 0; or border-left: none; I prefer the latter as the meaning is clear. --Redrose64 🌹 (talk) 11:34, 8 January 2017 (UTC)Reply
@Redrose64: I've changed all of them to none; thanks for explaining. Jc86035 (talk) Use {{re|Jc86035}}
to reply to me
11:49, 8 January 2017 (UTC)Reply

L-rail

edit

I didn't see the notice, but it looks like {{l-rail}} replaced {{s-rail}}? Frietjes (talk) 18:16, 22 April 2018 (UTC)Reply

Yes, I mentioned that I hope to create a Lua version. However it is still quite rough now. Feedback is welcome. Szqecs (talk) 10:44, 23 April 2018 (UTC)Reply

@Szqecs: The primary issue with this right now, I think, is that this still doesn't seem to have enough advantages over the current set of templates (the transclusions look much the same), especially since it also adds disadvantages such as the current requirement to use |rows=mid and the need for many contributors to learn or improve Lua table skills even though they already know how to use switch parser functions (as well as the feature discrepancy). The only advantage, as far as I can tell, is that the data is all in one place, and this is probably not going to be enough and would also be considered reinventing the wheel. If you can make the table one template (e.g. like Routemap vs. BS-map, or like {{Infobox}} vs. wikitable code) and make it merge table cells automatically, then it will very likely be sufficiently better than the current system. Right now, the current system is slightly more inefficient but much easier to use and extend, and probably more useful overall. Take advantage of Lua's capabilities to make using the template as efficient and as painless as possible.

Thoughts on merging table cells
  • somehow get the table code generated from parameter input into Lua table structure, e.g. something like data = { { left = 'text', line = 'text', right = 'text' }, { … }, … }
  • for k, v in ipairs(data) do
    • if data[[k+1][left]] == v[left] then
      • tmp = k + 1
      • data[tmp[left]] = ''
      • rowspan = 2
      • (while loop iterate through data from tmp until data[tmp[left]] ~= data[k[left]]; each time the loop happens, erase data[tmp[left]] and then add 1 to rowspan and to tmp; when the while loop ends, prepend rowspan to data[k[left]] with mw.ustring.gsub)
    • end
  • end
  • (repeat this for line columns and text column: replace left in previous text with a variable, maybe z where the whole loop is inside for y, z in ipairs('left', 'right', 'line'), to avoid duplicating code)
  • (do this for every contiguous group of data after each system header)

It shouldn't be too hard to change L-rail into a single template, especially since the groundwork for using arbitrarily numbered named parameters already exists in Module:Infobox (I re-used the code in Module:Routemap, incidentally, to allow more than ten maps). Avoiding per-article customizations such as row merges also makes using Wikidata data – at some point in the future – much easier.

Furthermore, I notice you've put a link function at the top of every data page. I don't think it's necessary, and I think using %s for a station name will probably be more intuitive and will be easier to explain in the template documentation (you should keep as much code as possible inside the main module, and the data pages should ideally have no functions so that they're easier to write – e.g. allowing the use of _default table keys instead of needing a whole function).

Finally, I think it would be best to follow stylistic conventions such as putting commas before newlines so that it's easier for others to read your code (even though it's not strictly necessary to do so in Lua). Jc86035 (talk) 12:12, 23 April 2018 (UTC)Reply

I'm lost. 1: What do you mean by 'merging cells' and 'arbitrarily numbered named parameters'? 2: What do you mean by using %s? Szqecs (talk) 12:58, 23 April 2018 (UTC)Reply
@Szqecs:
  1. By "merging cells" I meant usage of colspan and rowspan HTML attributes to combine table cells; an example exists at Template:S-line#One-way operation (several others further down the page). With the current {{S-line}}, |rows1= etc. and |hide1= etc. are used to manually specify cells which span more than one row. By "arbitrarily numbered parameters" (I apologize for using a vague term for something that doesn't actually have a name), I meant named parameters which are suffixed by a number which has no meaning other than to indicate the order of the data in the template; e.g. |header1=, |label2=, |data2=, etc. in {{Infobox}}.
  2. I used %s in line with mw:Extension:Scribunto/Lua reference manual#string.format. For example, if local example = '%s station', then return string.format(example, 'Taipei') would produce the string Taipei station. More than one %s is supported. However, for this module I would use mw.ustring.gsub() or similar for this, since the only input to such a function would be the station name. There may be better ways to do this, but sticking a function inside the data table is probably unnecessarily complex for an editor who is never going to edit the main module itself.
Also, I notice that you haven't allowed for a link table for all lines. This capability (which is the default in the current template) would be quite useful, both for ease of use and for ease of importing existing data. Jc86035 (talk) 13:38, 23 April 2018 (UTC)Reply
@Frietjes: This stems from Template talk:S-line#Lua version. Do you think it'd be necessary to modify the data structure to make the subpages easier to edit? Jc86035 (talk) 13:40, 23 April 2018 (UTC)Reply
  • Merging cells is a feature I have yet implemented. It seems complex though.
  • My module does allow for multiple lines using arbitrarily numbered parameters, but not for multiple systems. This is because if the system parameter was treated the same way you would have to repeat it for the same system (e.g. |system1=Taipei|line1=R|system2=Taipei|line2=G).
  • Actually the link function is optional, and is used to make the module shorter. You could type all the Wikitext as is, but the data module would be huge and messy like Template:LUL stations. Using string.format seems like a good idea but I have no idea how it works, specifically the 'ISO C function sprintf' thing. Szqecs (talk) 14:38, 23 April 2018 (UTC)Reply
@Szqecs: I might work on the pseudocode (collapsed) above and see if it works. I don't think you would need to repeat the system's name: you could have it in |system1=, and then for every row thereafter until the next |systemn= parameter, the system would be assumed to be |system1= (e.g. system1, line2 (left2, right2, …), line3, line4, system5, line6, line7, …). I don't think this would be more complicated than the current system, especially since it's already been implemented in Module:Infobox.
  Done Szqecs (talk) 11:47, 24 April 2018 (UTC)Reply
I think keeping the links as plain wikitext internally would make it simpler – editors will be more used to the wikitext, and you don't actually need to escape any of the characters that you've escaped. As mentioned, string.format() would probably be unnecessary (I don't really know completely how it works either) since you could just use the Lua regular expressions through mw.ustring.gsub() for this particular module. Jc86035 (talk) 16:20, 23 April 2018 (UTC)Reply

Template-protected edit request on 23 April 2019

edit

Please replace To add another line, go [[Template:S-rail/lines|here]]. [[Category:Rail transport succession templates]] with {{documentation}} to allow non-template-editors to develop documentation for this template. I have copied the current instruction and category over to the new /doc page. Thanks, --DannyS712 (talk) 02:28, 23 April 2019 (UTC)Reply

@DannyS712:   Done Jc86035 (talk) 10:17, 23 April 2019 (UTC)Reply

Northumberland Park Metro station

edit

Information icon  There is currently a discussion at Wikipedia talk:WikiProject UK Railways regarding a requested edit to this template. The thread is Northumberland Park in Tyne & Wear. Thank you. Thryduulf (talk) 14:26, 16 January 2024 (UTC)Reply