diff --git a/Mailman/Archiver/Archiver.py b/Mailman/Archiver/Archiver.py index 3289203..cae605b 100644 --- a/Mailman/Archiver/Archiver.py +++ b/Mailman/Archiver/Archiver.py @@ -72,6 +72,8 @@ class Archiver: self.archive_private = mm_cfg.DEFAULT_ARCHIVE_PRIVATE self.archive_volume_frequency = \ mm_cfg.DEFAULT_ARCHIVE_VOLUME_FREQUENCY + self.archive_idx_date_format = \ + mm_cfg.DEFAULT_ARCHIVE_IDX_DATE_FORMAT # The archive file structure by default is: # # archives/ diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py index a532c81..9127def 100644 --- a/Mailman/Archiver/HyperArch.py +++ b/Mailman/Archiver/HyperArch.py @@ -32,6 +32,7 @@ import sys import re import errno import urllib +import datetime import time import os import types @@ -136,7 +137,7 @@ def sizeof(filename, lang): return ' %d MB ' % (size / 1000000) -html_charset = '' def CGIescape(arg, lang=None): @@ -491,20 +492,37 @@ class Article(pipermail.Article): charset = Utils.GetCharSet(self._lang) d["encoding"] = html_charset % charset + d['listid'] = self._mlist.internal_name() self._add_decoded(d) - return quick_maketext( + articletext = quick_maketext( 'article.html', d, lang=self._lang, mlist=self._mlist) + articletitle = quick_maketext('articletitle.html', d, + lang=self._lang, mlist=self._mlist) + + articleheader = quick_maketext('articleheader.html', d, + lang=self._lang, mlist=self._mlist) + + return quick_maketext( + 'tocpage.html', + {'innertext': articletext, + 'title': articletitle, + 'header': articleheader, + 'listid': self._mlist.internal_name(), + 'mailmanurl': '../../', + }, + lang=self._lang, mlist=self._mlist) + def _get_prev(self): """Return the href and subject for the previous message""" if self.prev: subject = self._get_subject_enc(self.prev) - prev = ('' + prev = ('' % (url_quote(self.prev.filename))) - prev_wsubj = ('
  • ' + _('Previous message:') + - ' %s\n
  • ' + prev_wsubj = ('
  • ' + _('Previous message:') + + ' %s\n
  • ' % (url_quote(self.prev.filename), self.quote(subject))) else: @@ -523,10 +541,10 @@ class Article(pipermail.Article): """Return the href and subject for the previous message""" if self.next: subject = self._get_subject_enc(self.next) - next = ('' + next = ('' % (url_quote(self.next.filename))) - next_wsubj = ('
  • ' + _('Next message:') + - ' %s\n
  • ' + next_wsubj = ('
  • ' + _('Next message:') + + ' %s\n
  • ' % (url_quote(self.next.filename), self.quote(subject))) else: @@ -675,7 +693,7 @@ class HyperArchive(pipermail.T): 'quarter': '^' + yre + r'q(?P[1234])$', 'month': '^' + yre + r'-(?P[a-zA-Z]+)$', 'week': r'^Week-of-Mon-' + yre + mre + dre, - 'day': '^' + yre + mre + dre + '$' + 'day': '^' + yre + mre + dre + '$', } def _makeArticle(self, msg, sequence): @@ -754,6 +772,8 @@ class HyperArchive(pipermail.T): d["encoding"] = html_charset % self.charset else: d["encoding"] = "" + self._head_params = d + d['listid'] = mlist.internal_name() return quick_maketext( 'archidxhead.html', d, mlist=mlist) @@ -801,7 +821,20 @@ class HyperArchive(pipermail.T): template = 'archtoc.html' else: template = 'archtocnombox.html' - return quick_maketext(template, d, mlist=mlist) + d['listid'] = mlist.internal_name(); + toctext = quick_maketext(template, d, mlist=mlist) + + title = quick_maketext('archtoctitle.html', d, mlist=mlist) + header = quick_maketext('archtocheader.html', d, mlist=mlist) + + return quick_maketext( + 'tocpage.html', + {'innertext':toctext, + 'title':title, + 'listid': mlist.internal_name(), + 'mailmanurl': '../', + 'header':header}, + mlist=mlist) def html_TOC_entry(self, arch): # Check to see if the archive is gzip'd or not @@ -811,12 +844,12 @@ class HyperArchive(pipermail.T): if os.path.exists(gzfile): file = gzfile url = arch + '.txt.gz' - templ = '[ ' + _('Gzip\'d Text%(sz)s') \ + templ = '[ ' + _('Gzip\'d Text%(sz)s') \ + ']' elif os.path.exists(txtfile): file = txtfile url = arch + '.txt' - templ = '[ ' + _('Text%(sz)s') + ']' + templ = '[ ' + _('Text%(sz)s') + ']' else: # neither found? file = None @@ -905,9 +938,9 @@ class HyperArchive(pipermail.T): """Return a list of indexes where the article should be filed. A string can be returned if the list only contains one entry, and the empty list is legal.""" - res = self.dateToVolName(float(article.date)) + res = [self.dateToVolName(float(article.date))] self.message(_("figuring article archives\n")) - self.message(res + "\n") + self.message(str(res) + "\n") return res def volNameToDesc(self, volname): @@ -924,7 +957,7 @@ class HyperArchive(pipermail.T): match = re.match(self._volre[each], volname) # Let ValueErrors percolate up if match: - year = int(match.group('year')) + year = '' if each == 'quarter': d =["", _("First"), _("Second"), _("Third"), _("Fourth") ] ord = d[int(match.group('quarter'))] @@ -1040,21 +1073,29 @@ class HyperArchive(pipermail.T): pass os.symlink(self.DEFAULTINDEX+'.html',index_html) - def write_index_header(self): + def index_header(self): self.depth=0 - print self.html_head() + txt = self.html_head() if not self.THREADLAZY and self.type=='Thread': self.message(_("Computing threaded index\n")) self.updateThreadedIndex() + return txt - def write_index_footer(self): + def index_footer(self): + txt = [] for i in range(self.depth): - print '' - print self.html_foot() + txt.append('') + txt.append(self.html_foot()) + return ''.join(txt) - def write_index_entry(self, article): + def index_entry(self, article): subject = self.get_header("subject", article) author = self.get_header("author", article) + datestamp = int(self.get_header("date", article)) + + dateobj = datetime.datetime.fromtimestamp(datestamp) + date = dateobj.strftime(self.maillist.archive_idx_date_format) + if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS: try: author = re.sub('@', _(' at '), author) @@ -1068,12 +1109,26 @@ class HyperArchive(pipermail.T): 'filename': urllib.quote(article.filename), 'subject': subject, 'sequence': article.sequence, - 'author': author + 'author': author, + 'date': date, } - print quick_maketext( + return quick_maketext( 'archidxentry.html', d, mlist=self.maillist) + def index_page(self, txt): + title = quick_maketext('archidxtitle.html', self._head_params, mlist=self.maillist) + header = quick_maketext('archidxheader.html', self._head_params, mlist=self.maillist) + return quick_maketext( + 'tocpage.html', + {'innertext': txt, + 'title': title, + 'header': header, + 'encoding': self._head_params['encoding'], + 'mailmanurl': '../../', + 'listid': self.maillist.internal_name()}, + mlist=self.maillist) + def get_header(self, field, article): # if we have no decoded header, return the encoded one result = article.decoded.get(field) @@ -1082,7 +1137,8 @@ class HyperArchive(pipermail.T): # otherwise, the decoded one will be Unicode return result - def write_threadindex_entry(self, article, depth): + def threadindex_entry(self, article, depth): + txt = [] if depth < 0: self.message('depth<0') depth = 0 @@ -1090,13 +1146,14 @@ class HyperArchive(pipermail.T): depth = self.THREADLEVELS if depth < self.depth: for i in range(self.depth-depth): - print '' + txt.append('') elif depth > self.depth: for i in range(depth-self.depth): - print ' + +
    +
    Last message date:
    %(lastdate)s
    +
    Archived on:
    %(archivedate)s
    +
    +
    + + + +
    +This archive was generated by +Pipermail %(version)s. +
    + + diff --git a/templates/en/archidxhead.html b/templates/en/archidxhead.html index 4fdf473..f58c082 100644 --- a/templates/en/archidxhead.html +++ b/templates/en/archidxhead.html @@ -1,24 +1,22 @@ - - - - The %(listname)s %(archive)s Archive by %(archtype)s - - %(encoding)s - - - -

    %(archive)s Archives by %(archtype)s

    -