[mhonarc] create index.html just once :P



commit 4737d443a909d4569b2f58d868d67b0aaa18e699
Author: Olav Vitters <olav vitters nl>
Date:   Wed Feb 13 13:23:04 2013 +0100

    create index.html just once :P

 archive.py |   82 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/archive.py b/archive.py
index ead67d5..3023cb1 100755
--- a/archive.py
+++ b/archive.py
@@ -216,6 +216,7 @@ class Archiver:
 
     @classmethod
     def make_index(cls, listname, private=False):
+        """Create an index.html page with links to all the individually archived months"""
         path = os.path.join(cls.PRIVATE_ARCHIVE_DIR, listname)
 
         # If public add symlink from private to public
@@ -245,8 +246,8 @@ class Archiver:
             else:
                 dirs[a_dir] = a_dir
 
-            with open(os.path.join(path, 'index.html'), 'w') as fp:
-                fp.write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";>
+        with open(os.path.join(path, 'index.html'), 'w') as fp:
+            fp.write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";>
 <html xmlns="http://www.w3.org/1999/xhtml";>
 <head>
   <link href="/css/layout.css" rel="stylesheet" type="text/css" media="screen">
@@ -317,9 +318,8 @@ class Archiver:
       <a href="https://mail.gnome.org/mailman/listinfo/{listname}";>More info on this list...</a>
      </p>'''.format(listname=listname))
 
-
-                if private:
-                    fp.write('''
+            if private:
+                fp.write('''
 <form method="get" action="/mailman/private/{listname}/search">
 <p>
 Search:
@@ -329,52 +329,52 @@ Search:
 </p>
 </form>'''.format(listname=listname))
 
-                # Reshow general info
-                fp.write(get_mailinglist_info(listname))
-
-                # Overview per thread, date, author
-                for link in ("thread", "date", "author"):
-                    fp.write('<h2>By {link_title}<a name="{link}"></a></h2>'.format(link=link, link_title=link.title()))
-                    fp.write('<table border=0>')
-                    for year in sorted(years, reverse=True):
-                        fp.write('''<tr><th>%s</th>''' % year)
-
-                        for monthnr in xrange(1, 13):
-                            if monthnr in years[year]:
-                                fp.write('<td><a href="%s/%s.html">%s</a></td>' % (years[year][monthnr][0], link, years[year][monthnr][1][:3].title()))
-                            else:
-                                fp.write('<td>&nbsp;</td>')
-                        fp.write('</tr>')
-                    fp.write('</table>')
-
-                # Overview of downloadable versions
-                fp.write('<h2>Download<a name="download"></a></h2>')
-                fp.write('<table border=0>')
-                fp.write('<tr><th>Year</th>')
-                for month in sorted(cls.MONTHS, key=cls.MONTHS.get):
-                     fp.write('''<th>%s</th>''' % month[:3].title())
+            # Reshow general info
+            fp.write(get_mailinglist_info(listname))
 
+            # Overview per thread, date, author
+            for link in ("thread", "date", "author"):
+                fp.write('<h2>By {link_title}<a name="{link}"></a></h2>'.format(link=link, link_title=link.title()))
+                fp.write('<table border=0>')
                 for year in sorted(years, reverse=True):
                     fp.write('''<tr><th>%s</th>''' % year)
+
                     for monthnr in xrange(1, 13):
                         if monthnr in years[year]:
-                            mboxsize = 0
-                            a_dir = years[year][monthnr][0]
-                            for fmt in ("%s.txt", "%s.txt.gz"):
-                                mboxfile = fmt % a_dir
-                                if os.path.exists(os.path.join(path, mboxfile)):
-                                    stat = os.stat(os.path.join(path, mboxfile))
-                                    mboxsize = stat.st_size
-                                    break
-
-                            fp.write('<td><a href="%s">%s</a></td>' % (mboxfile, human_size(mboxsize)))
+                            fp.write('<td><a href="%s/%s.html">%s</a></td>' % (years[year][monthnr][0], link, years[year][monthnr][1][:3].title()))
                         else:
                             fp.write('<td>&nbsp;</td>')
                     fp.write('</tr>')
                 fp.write('</table>')
 
-
-                fp.write('''
+            # Overview of downloadable versions
+            fp.write('<h2>Download<a name="download"></a></h2>')
+            fp.write('<table border=0>')
+            fp.write('<tr><th>Year</th>')
+            for month in sorted(cls.MONTHS, key=cls.MONTHS.get):
+                 fp.write('''<th>%s</th>''' % month[:3].title())
+
+            for year in sorted(years, reverse=True):
+                fp.write('''<tr><th>%s</th>''' % year)
+                for monthnr in xrange(1, 13):
+                    if monthnr in years[year]:
+                        mboxsize = 0
+                        a_dir = years[year][monthnr][0]
+                        for fmt in ("%s.txt", "%s.txt.gz"):
+                            mboxfile = fmt % a_dir
+                            if os.path.exists(os.path.join(path, mboxfile)):
+                                stat = os.stat(os.path.join(path, mboxfile))
+                                mboxsize = stat.st_size
+                                break
+
+                        fp.write('<td><a href="%s">%s</a></td>' % (mboxfile, human_size(mboxsize)))
+                    else:
+                        fp.write('<td>&nbsp;</td>')
+                fp.write('</tr>')
+            fp.write('</table>')
+
+
+            fp.write('''
   </div> <!-- end of div.body -->
 
   <div id="footer_community"></div>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]