Commit 2d05680c authored by Florent Didier's avatar Florent Didier
Browse files

[dev] mw_utils.rb: add <wbr> tag to enable carriage return in nodeset display

parent 2abbcc08
......@@ -35,7 +35,8 @@ module G5K
SITES = %w{grenoble lille luxembourg lyon nancy nantes rennes sophia}
# This method compacts an array of integers as follows
# nodeset([2,3,4,7,9,10,12]) returns the string '[2-4,7,9-10,12]'
# nodeset([2,3,4,7,9,10,12]) returns the string '[2-4,<wbr>7,<wbr>9-10,<wbr>12]'
# where <wbr> is a hidden tag that enables carriage return in wikimedia
def self.nodeset(a)
l = a.length
return '' if l == 0
......@@ -44,12 +45,12 @@ module G5K
s = "[#{a0}"
i = 1
while i < l
fast_forward = (i < l and a[i] - a0 == 1)?true:false
fast_forward = (i < l and a[i] - a0 == 1) ? true : false
(a0 = a[i] and i+=1 ) while (i < l and a[i] - a0 == 1) # fast forward
if fast_forward
s += (i != l)?"-#{a0},#{a[i]}":"-#{a0}"
s += (i != l) ? "-#{a0},<wbr>#{a[i]}" : "-#{a0}"
else
s += ",#{a[i]}"
s += ",<wbr>#{a[i]}"
end
a0 = a[i]
i += 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment