Line 1: |
Line 1: |
− | local NodeInfoInvoke = {} | + | |
| + | local Utils = require('Module:Utils') |
| + | local format = require('Module:StringInterpolation').format |
| local NodeInfo = require('Module:NodeInfo') | | local NodeInfo = require('Module:NodeInfo') |
− | local getContext = require('Module:Utils').getContext
| |
− | local getArgs = require('Module:GetArgs')
| |
| | | |
− | local title_template = [[<div id="${map} ${node} ${diff}" style="width:700px;text-align:center;">${map} ${node}: ${name} ([http://db.kcwiki.moe/drop/map/${event}${map_number}/${diff_number}/${map}-SAB.html PoiDB])</div>]] | + | local title_template = [[<div id="${map} ${node} ${diff}" style="width:700px;text-align:center;">${map} ${node}: ${name} ([http://db.kcwiki.moe/drop/map/${event_number}${map_number}/${diff_number}/${node}-SAB.html PoiDB])</div>]] |
| + | |
| + | local event_numbers = { |
| + | ["Winter 2016 Event"] = 33, |
| + | ["Spring 2016 Event"] = 34, |
| + | ["Summer 2016 Event"] = 35, |
| + | -- ["Fall 2016 Event"] = 36, |
| + | } |
| + | |
| + | local diff_numbers = { |
| + | ["Easy"] = 1, |
| + | ["Normal"] = 2, |
| + | ["Hard"] = 3, |
| + | } |
| + | |
| + | function formatTitle(pagename, args) |
| + | |
| + | local event, map = string.match(pagename, "([^/]+)/([^/]+)") |
| + | event = event or "" |
| + | map = map or "E-?" |
| + | |
| + | local node = args.node and string.match(args.node, "^[A-Z]$") and args.node or "?" |
| + | local diff = diff_numbers[args.diff] and args.diff or "?" |
| + | local name = args.name or "?" |
| + | |
| + | local event_number = event_numbers[event] or "" |
| + | local map_number = string.match(map, "%d") or "" |
| + | local diff_number = diff_numbers[diff] or "" |
| + | |
| + | return format{ |
| + | title_template, |
| + | map = map, |
| + | node = node, |
| + | diff = diff, |
| + | name = name, |
| + | event_number = event_number, |
| + | map_number = map_number, |
| + | diff_number = diff_number, |
| + | } |
| + | |
| + | end |
| + | |
| + | local NodeInfoInvoke = {} |
| | | |
| function NodeInfoInvoke.Table(frame) | | function NodeInfoInvoke.Table(frame) |
− | local context = getContext(frame) | + | local args = Utils.getTemplateArgs(frame) |
− | local table_string = NodeInfo:Table(context.args) | + | local table_string = NodeInfo:Table(args.explicit) |
− | if context.args.title then | + | if args.explicit.node then |
− | local args = getArgs{ frame = frame }
| + | return formatTitle(args.implicit.pagename, args.explicit) .. table_string |
− | return table.concat({ args.pagename or "?", context.pagename, context.args.title, title_template, table_string }, "\n") | |
| else | | else |
| return table_string | | return table_string |