Skip to content

Commit

Permalink
Added some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HazardSJ committed May 28, 2013
1 parent f44c524 commit 7c12d35
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions citationstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self):
self.categories = [
Category(self.site, "Category:Pages with citations having wikilinks embedded in URL titles"),
]
self.doTaskPage = pywikibot.Page(self.wd, 'User:Hazard-Bot/DoTask/21')
self.doTaskPage = pywikibot.Page(self.site, 'User:Hazard-Bot/DoTask/21')

def checkDoTaskPage(self):
try:
Expand All @@ -42,14 +42,17 @@ def replaceWikilinks(template, URL, title):
else:
self.code.replace(link, link.title)
## @fixme: Use a function, and use {{Cite doi}} as well, just in case...
## ...or generate from [[Category:Citation Style 1 templates]]? (doesn't include {{citation}} though)
#template = pywikibot.Page(self.site, "Template:Cite web")
#templates = list()
#templates.append(template.title(withNamespace = False).lower())
#references = template.getReferences(redirectsOnly = True)
#for reference in references:
# templates.append(reference.title(withNamespace = False).lower())
for template in self.code.filter_templates():
if template.name.lower().startswith("cite") or template.name.lower().startswith("web"):
if template.name.lower().strip().startswith("cite") \
or template.name.lower().strip().startswith("web") \
or (template.name.lower().strip() == "citation"):
replaceWikilinks(template, "url", "title" )
replaceWikilinks(template, "chapterurl", "chapter" )
replaceWikilinks(template, "chapterurl", "contribution" )
Expand All @@ -61,6 +64,7 @@ def replaceWikilinks(template, URL, title):
replaceWikilinks(template, "contributionurl", "entry" )
replaceWikilinks(template, "contributionurl", "article" )
replaceWikilinks(template, "transcripturl", "transcript" )

def run(self):
for category in self.categories:
self.checkDoTaskPage()
Expand All @@ -70,7 +74,7 @@ def run(self):
text = self.page.get()
self.code = mwparserfromhell.parse(text)
self.removeWikilinks()
# and all the others, once they're written, if they're written
# and all the others, once they're coded, if they're coded
if text != self.code:
pywikibot.showDiff(text, unicode(self.code))
self.page.put(self.code, u"[[Wikipedia:Bots|Robot]]: Fixed [[Help:Citation Style 1|citation style]] errors")
Expand Down

0 comments on commit 7c12d35

Please sign in to comment.