r12934 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12933‎ | r12934 | r12935 >
Date:07:17, 2 February 2006
Author:vibber
Status:old
Tags:
Comment:
Include a link to the next-previous dump if any on the status page
Modified paths:
  • /trunk/backup/WikiBackup.py (modified) (history)
  • /trunk/backup/report.html (modified) (history)

Diff [purge]

Index: trunk/backup/WikiBackup.py
@@ -76,6 +76,10 @@
7777 def prettyTime():
7878 return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
7979
 80+def prettyDate(key):
 81+ "Prettify a MediaWiki date key"
 82+ return "-".join((key[0:4], key[4:6], key[6:8]))
 83+
8084 def dumpFile(filename, text):
8185 """Dump a string to a file."""
8286 file = open(filename, "wt")
@@ -406,6 +410,7 @@
407411 return html
408412
409413 def reportStatus(self, items, done=False):
 414+ """Put together a status page for this database, with all its component dumps."""
410415 statusItems = [self.reportItem(item) for item in items]
411416 statusItems.reverse()
412417 html = "\n".join(statusItems)
@@ -413,8 +418,18 @@
414419 "db": self.db,
415420 "date": self.date,
416421 "status": self.reportStatusLine(done),
 422+ "previous": self.reportPreviousDump(),
417423 "items": html}
418424
 425+ def reportPreviousDump(self):
 426+ """Produce a link to the previous dump, if any"""
 427+ try:
 428+ raw = self.latestDump(self.db, -2)
 429+ except:
 430+ return "No prior dumps of this database stored.";
 431+ date = prettyDate(raw)
 432+ return "<a href=\"../%s/\">Last dumped on %s</a>" % (raw, date)
 433+
419434 def reportStatusLine(self, done=False):
420435 if done:
421436 classes = "done"
Index: trunk/backup/report.html
@@ -62,6 +62,10 @@
6363
6464 <p>See <a href="../../">all databases list</a>.</p>
6565
 66+ <div class="previous">
 67+ %(previous)s
 68+ </div>
 69+
6670 <div class="status">
6771 %(status)s
6872 </div>

Status & tagging log