1,854
edits
(2 intermediate revisions by the same user not shown) | |||
Line 72: | Line 72: | ||
return link | return link | ||
addLinkFilter(hlwikiLinks) | addLinkFilter(hlwikiLinks) | ||
=== Convert [[:Category:Patches|patch]] links to {{tl|Patch name}} === | |||
def patchNameLinkFilter(l, **kwargs): | |||
if l.getType() != u'internal': | |||
return l | |||
regPatchName = compileRegex(u'(January|February|March|April|May|June|July|August|September|October|November|December)\\s+(\\d+),\\s+(\\d{4,})\\s+Patch(?:/\\w+)?') | |||
result = regPatchName.match(l.getLink()) | |||
if result is None or l.getLabel().find(result.group(2)) == -1 or l.getLabel().find(result.group(3)) == -1: | |||
return l | |||
monthNames = ('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december') | |||
patchType = u'' | |||
if l.getLink().lower().find(u'portal') != -1: | |||
patchType = u'|portal' | |||
elif l.getLink().lower().find(u'tools') != -1: | |||
patchType = u'|tools' | |||
return template(u'<nowiki>{{Patch name|' + u(monthNames.index(result.group(1).lower()) + 1) + u'|' + u(result.group(2)) + u'|' + u(result.group(3)) + patchType + u'}}</nowiki>') | |||
addLinkFilter(patchNameLinkFilter) | |||
== Template filters == | == Template filters == | ||
Line 80: | Line 97: | ||
#'Good template name': ['Bad template lowercase name 1', 'Bad template lowercase name 2', 'Bad template lowercase name 3'], | #'Good template name': ['Bad template lowercase name 1', 'Bad template lowercase name 2', 'Bad template lowercase name 3'], | ||
# Last line has no comma at the end | # Last line has no comma at the end | ||
'Crush': ['pngcrush'] | 'Crush': ['pngcrush'], | ||
'Chamber infobox': ['test chamber infobox'] | |||
} | } | ||
for n in templateMap: | for n in templateMap: | ||
Line 87: | Line 105: | ||
return t | return t | ||
addTemplateFilter(templateRenameMapping) | addTemplateFilter(templateRenameMapping) | ||
=== Reindent all infoboxes === | |||
def infoboxIndentFilter(t, **kwargs): | |||
itemInfoboxes = ('game infobox', 'website infobox', 'item infobox', 'company infobox', 'chamber infobox', 'old aperture infobox', 'twtm chamber infobox', 'mel old aperture infobox') | |||
tName = t.getName().lower() | |||
if 'infobox' in tName and tName not in itemInfoboxes: | |||
t.indentationMatters(True) | |||
t.setDefaultIndentation(2) | |||
return t | |||
addTemplateFilter(infoboxIndentFilter, lowPriority=True) | |||
=== Remove useless templates === | === Remove useless templates === | ||
Line 124: | Line 153: | ||
return t | return t | ||
addTemplateFilter(obsoleteParameterFilter) | addTemplateFilter(obsoleteParameterFilter) | ||
=== Add <code>day</code>/<code>month</code>/<code>year</code> to {{tl|Patch layout}} === | |||
def patchLayoutFilter(t, **kwargs): | |||
if t.getName().lower() != 'patch layout' or 'article' not in kwargs: | |||
return t | |||
t.setPreferedOrder(['game', 'before', 'day', 'month', 'year', 'after', 'source-title', 'source', 'source-lang'] + [['source-' + str(n) + '-title', 'source-' + str(n), 'source-' + str(n) + '-lang'] for n in xrange(10)] + ['updatelink', 'update', 'update-link', 'update-lang', 'hide-diff'] + [['diff-' + str(n)] for n in xrange(10)] + ['notes']) | |||
t.delParam('current') | |||
regPatchName = compileRegex(u'^(January|February|March|April|May|June|July|August|September|October|November|December)\\s+(\\d+),\\s+(\\d{4,})\\s+Patch(?:/\\w+)?') | |||
result = regPatchName.match(u(kwargs['article'].title)) | |||
if result is not None: | |||
t.setParam('day', result.group(2)) | |||
t.setParam('month', result.group(1).lower()) | |||
t.setParam('year', result.group(3)) | |||
return t | |||
addTemplateFilter(patchLayoutFilter) | |||
=== Implement {{tl|Dictionary}} === | === Implement {{tl|Dictionary}} === |