Modul:Routemap: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
RaFaDa20631 (bicara | kontrib) Indonesianisasi |
k update |
||
Baris 10:
},
["error-categories"] = {
default = '[[Category:Pages with errors of Module Routemap]]',
["text-images"] = '[[Category:Pages using Routemap with text images]]',
["separate-navbar"] = '[[Category:Pages using Routemap with a separate navbar template]]',
["missing-text-values"] = '[[Category:Pages using BSto or BSsrws with missing text values]]',
["br-tags"] = '[[Category:Pages using BSto, BSsplit, BSsrws or BScvt with br tags]]',
["srws"] = '[[Category:Pages using BSsplit instead of BSsrws]]',
["rmr-error"] = '[[Category:Pages with bad value for RoutemapRoute template]]'
},
text = {
navbar_mini = false, -- for navbar pos 2 only
navbar_text = 'This diagram:', -- for navbar pos 2 only
legend_text = 'Legend',
legend = {
default = '[[Template:Railway line legend',
track = '[[Template:Railway track legend',
bus = '[[Template:Bus route legend',
canal = '[[Template:Waterways legend',
water = '[[Template:Waterways legend',
waterway = '[[Template:Waterways legend',
foot = '[[Template:Trails legend',
footpath = '[[Template:Trails legend',
walkway = '[[Template:Trails legend'
}
},
html = {
Baris 30 ⟶ 52:
["row-linfo4-fmt"] = '\
|style="width:auto;vertical-align:middle;padding:0 3px 0 0;text-align:left;%s"|<
["row-linfo3-fmt"] = '<
["row-rinfo3-fmt"] = ' <
["row-rinfo4-fmt"] = '\
|style="width:auto;vertical-align:middle;padding:0 0 0 3px;text-align:right;%s"|<
["row-general-fmt"] = '\
|- style="line-height:1" %s\
|colspan="%s" style="width:auto;vertical-align:middle;padding:0;text-align:right;%s"|%s\
|style="width:auto;vertical-align:middle;text-align:left;padding:0 %s;%s"|<
|style="width:auto;padding:0%s"|\
{|cellspacing="0" cellpadding="0" style="display: table; width: unset; line-height: 0; padding:0 !important; margin: 0 auto !important"\
|- style="display:inline-table;%s"%s\
|}\
|style="width:auto;vertical-align:middle;text-align:right;padding:0 %s;%s"|<
|colspan="%s" style="width:auto;vertical-align:middle;padding:0;text-align:left;%s"|%s%s',-- parameters: linfo4-fmt, colspan-left, linfo3+2-width, linfo3+2, linfo1-pad, linfo1-width, linfo1, bg, cells, rinfo1-pad, rinfo1-width, rinfo1, colspan-right, rinfo2+3-width, rinfo2+3, rinfo4-fmt
Baris 58 ⟶ 80:
["row-collapsible-left-linfo4+3+2-fmt"] = '\
{|cellspacing="0" cellpadding="0" style="line-height:1;width:100%%;padding:0 !important;margin:0 !important"\
|style="width:auto;vertical-align:middle;padding:0 3px 0 1px;text-align:left"| <
|style="width:auto;vertical-align:middle;text-align:right"| %s\
|}',-- parameters: linfo4, linfo3+2
Baris 65 ⟶ 87:
{|cellspacing="0" cellpadding="0" style="line-height:1;width:100%%;padding:0 !important;margin:0 !important"\
|style="width:auto;vertical-align:middle;text-align:left"| %s\
|style="width:auto;vertical-align:middle;padding:0 1px 0 3px;text-align:right"| <
|}',-- parameters: rinfo2+3, linfo4
["row-collapsible-right-button-fmt"] = '\n| style="width:auto;vertical-align:middle;padding-left:3px;font-size:90%%;min-width:%s;%s" |',--parameters: right-button-width, rinfo4-width
Baris 80 ⟶ 102:
}
local p,q={},{}
local getArgs = require('Module:Arguments').getArgs
local function makeInvokeFunction(funcName)
-- makes a function that can be returned from #invoke, using
-- [[Module:Arguments]].
return function (frame)
local args = getArgs(frame, {parentOnly = true})
return p[funcName](args)
end
end
local function formaterror(key,param)
local result = string.format(i18n.html['colspan-fmt'], '', '', '', '', '<span class="error">' .. string.format(i18n.errors[key] or (tostring(key) .. ' %s'),
tostring(param or '')) .. '</span>')
if mw.site.namespaces[mw.title.getCurrentTitle().namespace].isContent then result = result .. (i18n['
return result
end
Baris 110 ⟶ 143:
maroon = '800000', ex_maroon = 'B16464',
ochre = 'CC6600', ex_ochre = 'DEA164',
olive = '837902', ex_olive = 'B2AC64',
orange = 'FF6600', ex_orange = 'FF9955',
pink = 'F0668D', ex_pink = 'F4A1B8',
Baris 123 ⟶ 157:
}
return colors[code] or colors.bahn
end
p.RGBbyCode = makeInvokeFunction('_RGBbyCode')
function p._RGBbyCode(args)
return RGBbyCode(args[1])
end
Baris 192 ⟶ 232:
local function widths(p)
local values = {
['w'] = 160, ['+bs'] = ['s'] = ['b'] = 40, ['+cd'] = 35, ['+d'] = 30, ['+c'] = 25,
[''] = 20, ['ocd'] = 17.5, ['cd'] = 15, ['od'] = 12.5,
['d'] = 10, ['oc'] = 7.5, ['c'] = 5, ['o'] = 2.5
} -- in px
return values[p]
end
Baris 247 ⟶ 293:
if not cellProps.fontsize or rowProps.fontsize or cellProps.fontsize == 'info' then
elseif cellProps.fontsize == 'cmt' or cellProps.fontsize == 'comment' then
cellProps._before, cellProps._after = '<
else
cellProps.style = cellProps.style..';font-size:'..cellProps.fontsize
Baris 280 ⟶ 326:
overlapProps.style = overlapProps.style..';font-size:10px'
elseif overlapProps[i].fontsize == 'cmt' or overlapProps[i].fontsize == 'comment' then
overlapProps._before, overlapProps._after = '<
else
overlapProps.style = overlapProps.style..';font-size:'..overlapProps[i].fontsize
Baris 294 ⟶ 340:
overlapProps.tag = {'abbr title="'..string.gsub(overlapProps[i].abbr, '"', '"')..'"', 'abbr'}
else
overlapProps.tag = {'
end
width = (widths(tmp_iconpre) or 20)..'px'
Baris 301 ⟶ 347:
v = mw.text.trim(v)
if string.find(v, 'num') then
if not string.find(v, 'numN%d+') then tracking = tracking..(i18n['error-categories'][
end
table.insert(tmp, string.format(i18n.html['cell-overlapicon-fmt'], overlapProps.style, v, link, icontip))
Baris 323 ⟶ 369:
iconProps.style = iconProps.style..';font-size:10px'
elseif iconProps.fontsize == 'cmt' or iconProps.fontsize == 'comment' then
iconProps._before, iconProps._after = '<
else
iconProps.style = iconProps.style..';font-size:'..iconProps.fontsize
Baris 337 ⟶ 383:
iconProps.tag = {'abbr title="'..string.gsub(iconProps.abbr, '"', '"')..'"', 'abbr'}
else
iconProps.tag = {'
end
if tmp2[1] then iconProps.style = ';'..iconProps.style end
Baris 345 ⟶ 391:
if iconProps.style ~= '' then iconProps.style = string.gsub(' style="'..iconProps.style..'"', '";', '"', 1) end
if string.find(icon, 'num') then
if not string.find(icon, 'numN%d+') then tracking = tracking..(i18n['error-categories'][
end
return string.format(i18n.html['cell-icon-fmt-with-overlap'], cellProps.style, mw.text.trim(table.concat(tmp)), iconProps.style, icon, icontip, tracking)
Baris 360 ⟶ 406:
cellProps.tag = {'abbr title="'..string.gsub(cellProps.abbr, '"', '"')..'"', 'abbr'}
else
cellProps.tag = {'
end
width = (widths(iconpre) or 20)..'px'
Baris 366 ⟶ 412:
else
if string.find(icon, 'num') then
if not string.find(icon, 'numN%d+') then tracking = tracking..(i18n['error-categories'][
end
return string.format(i18n.html['cell-icon-fmt'], cellProps.style, icon, link, icontip, tracking)
Baris 393 ⟶ 439:
]]
local result = {['linfo4'] = '', ['linfo3+2'] = '', ['linfo1'] = '', rowstyle = '', ['cells'] = {}, ['rinfo1'] = '', ['rinfo2+3'] = '', ['rinfo4'] = '', ['rowProp'] = {}}
local lcolspan, rcolspan, linfo4_fmt, rinfo4_fmt = '2', '2', '', ''
local left, right, icons, overlapIcons, tmp = {}, {}, {}, {}, mw.text.split(pattern, '! !')
Baris 456 ⟶ 502:
icons = mw.text.split(tmp[1], '\\')--splitting the string of icons first by "\"
if type(filler) == 'string' then
result.style = ';font-size:0px'
result.rowstyle = 'height:' .. filler .. ';min-height:' .. filler --row parameter before any cells
for i, v in ipairs(icons) do table.insert(result['cells'], fillercell(v)) end--no !@ or !~ for filler row
else
result.style = ''
for i, v in ipairs(icons) do
tmp = mw.text.split(v, '!~')
Baris 468 ⟶ 516:
end
result['cells'] = table.concat(result['cells'])
if result.rowProp.style then result.style = result.style..';'..result.rowProp.style
result.rowProp.bg = result.rowProp.bg or result.rowProp.background or result.rowProp.bgcolor ; result.rowProp.color = result.rowProp.color or result.rowProp.colour ; result.rowProp.bold = result.rowProp.bold or result.rowProp.b ; result.rowProp.italic = result.rowProp.italic or result.rowProp.i or result.rowProp.it
if result.rowProp.bg then result.style = result.style..';background:'..result.rowProp.bg end
Baris 485 ⟶ 533:
return result
else
return string.format(i18n.html['row-general-fmt'], linfo4_fmt, lcolspan, '', result['linfo3+2'], q.linfo1_pad, '', result['linfo1'], result.style, result.rowstyle,
result['cells'], q.rinfo1_pad, '', result['rinfo1'], rcolspan, '', result['rinfo2+3'], rinfo4_fmt)
end
Baris 523 ⟶ 571:
if tmp['linfo4'] ~= '' or tmp['linfo3+2'] ~= '' then linfo4_3_2_fmt = string.format(i18n.html['row-collapsible-left-linfo4+3+2-fmt'], tmp['linfo4'], tmp['linfo3+2']) end
result = result .. string.format(i18n.html['row-general-fmt'], string.format(i18n.html['row-collapsible-left-button-fmt'], i18n.html['row-collapsible-left-button-width'], q.text_width[1]),
'1', q.text_width[2], linfo4_3_2_fmt, q.linfo1_pad, q.text_width[3], tmp['linfo1'], tmp.style, '', tmp['cells'], '', '', '', '1', '', '', string.format(i18n.html['row-rinfo4-fmt'], '', ''))
else
if tmp['rinfo4'] ~= '' or tmp['rinfo2+3'] ~= '' then rinfo2_3_4_fmt = string.format(i18n.html['row-collapsible-right-rinfo2+3+4-fmt'], tmp['rinfo2+3'], tmp['rinfo4']) end
result = result .. string.format(i18n.html['row-general-fmt'], string.format(i18n.html['row-linfo4-fmt'], q.text_width[1], tmp['linfo4']),
'1', q.text_width[2], tmp['linfo3+2'], q.linfo1_pad, q.text_width[3], tmp['linfo1'], tmp.style, '', tmp['cells'], q.rinfo1_pad, q.text_width[4], tmp['rinfo1'],
'1', q.text_width[5], rinfo2_3_4_fmt, string.format(i18n.html['row-collapsible-right-button-fmt'], i18n.html['row-collapsible-right-button-width'], q.text_width[6]))
end
Baris 541 ⟶ 589:
if tmp['linfo4'] ~= '' or tmp['linfo3+2'] ~= '' then linfo4_3_2_fmt = string.format(i18n.html['row-collapsible-left-linfo4+3+2-fmt'], tmp['linfo4'], tmp['linfo3+2']) end
result = result .. string.format(i18n.html['row-general-fmt'], string.format(i18n.html['row-linfo4-fmt'], '', ''), '1', q.text_width[2], linfo4_3_2_fmt,
q.linfo1_pad, q.text_width[3], tmp['linfo1'], tmp.style, '', tmp['cells'], '', '', '', '1', '', '', string.format(i18n.html['row-rinfo4-fmt'], '', ''))
else
if tmp['rinfo4'] ~= '' or tmp['rinfo2+3'] ~= '' then rinfo2_3_4_fmt = string.format(i18n.html['row-collapsible-right-rinfo2+3+4-fmt'], tmp['rinfo2+3'], tmp['rinfo4']) end
result = result .. string.format(i18n.html['row-general-fmt'], string.format(i18n.html['row-linfo4-fmt'], q.text_width[1], tmp['linfo4']), '1', q.text_width[2],
tmp['linfo3+2'], q.linfo1_pad, q.text_width[3], tmp['linfo1'], tmp.style, '', tmp['cells'], q.rinfo1_pad, q.text_width[4], tmp['rinfo1'], '1', q.text_width[5],
rinfo2_3_4_fmt, string.format(i18n.html['row-rinfo4-fmt'], '', ''))
end
Baris 588 ⟶ 636:
end
local function localroute(pattern,ptw,pbg,process)
local tmp = {}
if mw.text.trim(pbg) ~= '' then q.bg = pbg end
Baris 637 ⟶ 685:
local index = 0
local rows = {}
if not process or process == '' or negative(process) then
pattern = mw.ustring.gsub(pattern, '\n(#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])', '%1')
end
for item in pattern:gmatch('([^\n]*)\n?') do
item = mw.text.trim(item)
Baris 665 ⟶ 716:
table.insert(tmp, string.format(i18n.html['empty-row-fmt'], q.text_width[1], q.text_width[2], q.linfo1_pad, q.text_width[3], q.rinfo1_pad, q.text_width[4], q.text_width[5], q.text_width[6]))
return table.concat(tmp)
end
Baris 698 ⟶ 738:
function p._infobox(args) -- Creates a pretty box.
args.map1, args.tw, args['map1-title'], args['map1-collapsible'], args['map1-
local function map_prefix(x) return 'map'..x end
local mapnums, prefix = {}
Baris 718 ⟶ 758:
args.navbar = args.navbar or args.tnavbar
if args.navbar then
navtable = {args.navbar,
args.navbar = navbar(navtable)
else
Baris 790 ⟶ 830:
result = result .. '<div style="float:left;padding-right:5px">' .. args.navbar .. '</div>'
end
args.legend2 =
if args.legend2 ~= 'no' and args.legend2 ~= '0' then
args.legend = i18n.text.legend[args.legend2] or ((args.legend2 ~= '') and ('[['..args.legend) or i18n.text.legend.default)
args.legend = args.legend .. '|' .. (args['legend alt'] or i18n.text.legend_text) .. ']]'
result = result .. '<div class="selfreference noprint" style="text-align:right;font-size:90%;">' .. args.legend .. '</div>'
end
Baris 824 ⟶ 848:
args.header_margin = '0 55px'
args.ending = '\n|}'
if positive(args['map'..v..'-collapse']) or positive(args['map'..v..'-collapsed']) then args.map_collapsed = ' mw-collapsed autocollapse' else args.map_collapsed = '' end
result = result..'\n|-\n|\n{|class="mw-collapsible'..args.map_collapsed..'" cellpadding="0" cellspacing="0" style="display: table; min-width:100%; margin:0 auto;"'
end
Baris 833 ⟶ 857:
if k == 1 then args.border_top = '' else args.border_top = 'border-top: 5px solid '..args.bg..';' end
end
result = result .. '\n|-\n|style="'..args.border_top..'padding:' .. args.padding2 .. '"|\n{|cellpadding="0" cellspacing="0" class="nogrid" style="padding:0px;border:0px;background:transparent;white-space:nowrap;line-height:1.2;font-size:'..(args.fontsize2 * 0.95)..'%;margin:auto"\n'..localroute(args[prefix(v)], (args['tw'..v] or args['text-width'..v] or args['text width'..v] or args.tw or ''), args.bg, args.process)..'\n|}'..args.ending
end
args.bottom = args.bottom or args.footnote
Baris 839 ⟶ 863:
if args.inline then args.padding2 = '6px' else args.padding2 = '0px' end
result = result .. '\n|-\n|style="line-height:normal;text-align:right;padding:' .. args.padding2 .. ' 5px 5px;'..(args.bottomstyle or args.footnotestyle or '')..'"|' .. args.bottom
if string.find(args.bottom, '&action=edit') then result = result .. (i18n['error-categories'][
end
if args.navbar ~= '' and args['navbar pos'] == '2' then
if negative(args['navbar long']) or positive(args['navbar mini']) then navtable.mini = true; args.navbar = navbar(navtable) end
if args.inline and not args.bottom then args.padding2 = '6px' else args.padding2 = '0px' end
result = result .. '\n|-\n|style="line-height:normal;padding:' .. args.padding2 .. ' 5px 3px;text-align:center"|' .. args.navbar
end
return result .. '\n|}'
Baris 981 ⟶ 1.005:
result = result..rowend..'</table> '
if bs == 'to' or bs == 'srws' then
if t1 == ' ' or t2 == ' ' then result = result..
end
if string.find(t1, '<br ?/?>') ~= nil or string.find(t2, '<br ?/?>') ~= nil then result = result..(i18n['error-categories'][
if bs == 'split' then
if link and t1 and t2 then
if string.find(link, '^'..t1..' '..t2..' ') then result = result..(i18n['error-categories'][
end
end
Baris 1.061 ⟶ 1.085:
end
if not result then
return '<span style="color:#f00">Invalid [[Template:RoutemapRoute]] arrow value "<span style="font-style:italic">'..d..'</span>".
else
return result
Baris 1.114 ⟶ 1.138:
end
local count, icons, overlaps, overlapCalc = tonumber(args['$count']) or 1, {}, {}, math.log10(args.n)
local text = (args.text and '*') or ''
if overlapCalc == math.floor(overlapCalc) then overlapCalc = 10^(overlapCalc) else overlapCalc = 10^(math.floor(overlapCalc) + 1) end
while count <= args.n do
local cellparams, overlapn = {}, (string.match(count/overlapCalc, '%.(0+)') or '')..count
table.insert(icons, (text..(args[count] or '')))
if args['O'..overlapn] then
local iconparams, overlapparams, overlapt = {}, {}, {}
Baris 1.137 ⟶ 1.162:
end
if overlapparams[1] then args['O'..overlapn..v] = args['O'..overlapn..v]..'__'..table.concat(overlapparams, ',') end
table.insert(overlapt, text..args['O'..overlapn..v])
end
overlaps = '!~'..text..args['O'..overlapn]..'!~'..table.concat(overlapt, '!~')
else
overlaps = '!~'..text..args['O'..overlapn]
end
icons[count] = icons[count]..overlaps
Baris 1.209 ⟶ 1.234:
end
local count, icons, overlaps, overlapCalc = tonumber(args['$count']) or 1, {}, {}, math.log10(args.n)
local text = (args.text and '*') or ''
if overlapCalc == math.floor(overlapCalc) then overlapCalc = 10^(overlapCalc) else overlapCalc = 10^(math.floor(overlapCalc) + 1) end
while count <= args.n do
local cellparams, overlapn = {}, (string.match(count/overlapCalc, '%.(0+)') or '')..count
table.insert(icons, (text..(args[count] or '')))
if args['O'..overlapn] then
local overlapt = {}
Baris 1.218 ⟶ 1.244:
table.sort(overlaps)
if overlaps[1] then
for i, v in ipairs(overlaps) do table.insert(overlapt, text..args['O'..overlapn..v]) end
overlaps = '!~'..text..args['O'..overlapn]..'!~'..table.concat(overlapt, '!~')
else
overlaps = '!~'..text..args['O'..overlapn]
end
icons[count] = icons[count]..overlaps
Baris 1.284 ⟶ 1.310:
res = string.gsub(res, '{|%s?{{[Rr]ailway line header}}', '{{Routemap')
res = string.gsub(res, '{{[Bb][Ss]%-header%d?|', '{{safesubst:BS-header/safesubst|') -- "%d?" means optional digit in case use of variant template like BS-header3.
res = string.gsub(res, '{{[Bb][Ss]%-table%d?}}', '|map =')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)|', '{{safesubst:BS%1%2/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%-replace|', '!replace{{safesubst:BS%1%2/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%-startCollapsible|', '-startCollapsible-collapsed\n{{safesubst:BS%1%2/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%-sc|', '-startCollapsible-collapsed\n{{safesubst:BS%1%2/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%text|', '{{safesubst:BS%1%2text/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%-2|', '{{safesubst:BS%1%2-2/safesubst|')
res = string.gsub(res, '{{[Bb][Ss](%d?)(%d?)%-2replace|', '!replace{{safesubst:BS%1%2-2|')
Baris 1.299 ⟶ 1.326:
res = string.gsub(res, '<', '<')
res = string.gsub(res, '>', '>')
if string.find(res, '!replace') or string.find(res, '
local restable = mw.text.split(res, '\n')
for i, v in ipairs(restable) do
Baris 1.306 ⟶ 1.333:
restable[i-2] = string.gsub(restable[i-2], 'collapsed', 'collapsed-replace')
end
if (string.find(v, '|%s*bg%s*=%s*#?[a-zA-Z0-9]+') or string.find(v, '|%s*bg%s*=%s*#?{{[^{}]+}}%s*|') or string.find(v, '|%s*bg%s*=%s*#?{{[^{}]+}}%s*}}')) and string.find(restable[i-1], '^-startCollapsible') then
local bg = string.match(v, '|%s*bg%s*=%s*(#?[a-zA-Z0-9]+)') or string.find(v, '|%s*bg%s*=%s*(#?{{[^{}]+}})%s*|') or string.find(v, '|%s*bg%s*=%s*(#?{{[^{}]+}})%s*}}')
restable[i] =
restable[i
restable[i+1] = string.gsub(restable[i+1], '!replace', '')
if (string.find(restable[i+1], '|%s*bg%s*=%s*#?[a-zA-Z0-9]+') or string.find(restable[i+1], '|%s*bg%s*=%s*#?{{[^{}]+}}%s*|') or string.find(restable[i+1], '|%s*bg%s*=%s*#?{{[^{}]+}}%s*}}')) then
local bg2 = string.match(restable[i+1], '|%s*bg%s*=%s*(#?[a-zA-Z0-9]+)') or string.find(restable[i+1], '|%s*bg%s*=%s*(#?{{[^{}]+}})%s*|') or string.find(restable[i+1], '|%s*bg%s*=%s*(#?{{[^{}]+}})%s*}}')
end
end
end
end
|