[csw-devel] SF.net SVN: gar:[20547] csw/mgar/gar/v2/lib/web

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Mar 31 13:35:57 CEST 2013


Revision: 20547
          http://gar.svn.sourceforge.net/gar/?rev=20547&view=rev
Author:   wahwah
Date:     2013-03-31 11:35:54 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
pkgdb-web: Display catalognames grouped by initial

Display catalognames not as one long list, but group them by the initial
letter. Also, add a TOC with the list of available initial letters.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/web/pkgdb_web.py
    csw/mgar/gar/v2/lib/web/static/pkgdb.css
    csw/mgar/gar/v2/lib/web/templates/CatalognameList.html

Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py	2013-03-31 08:22:35 UTC (rev 20546)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2013-03-31 11:35:54 UTC (rev 20547)
@@ -161,7 +161,12 @@
             models.Srv4FileStats.q.use_to_generate_catalogs==True,
             models.Srv4FileStats.q.registered==True),
           orderBy=models.Srv4FileStats.q.catalogname)))
-      return render.CatalognameList(rows)
+      rows_by_letter = {}
+      for row in rows:
+        initial = row[0][0]
+        rows_by_letter.setdefault(initial, [])
+        rows_by_letter[initial].append(row)
+      return render.CatalognameList(rows_by_letter, sorted(rows_by_letter))
     except sqlobject.main.SQLObjectNotFound, e:
       raise web.notfound()
 

Modified: csw/mgar/gar/v2/lib/web/static/pkgdb.css
===================================================================
--- csw/mgar/gar/v2/lib/web/static/pkgdb.css	2013-03-31 08:22:35 UTC (rev 20546)
+++ csw/mgar/gar/v2/lib/web/static/pkgdb.css	2013-03-31 11:35:54 UTC (rev 20547)
@@ -16,7 +16,23 @@
 ul.catalogname-list > li {
   margin: 0.2em;
   padding: 0;
+  display: inline-block;
+  min-width: 10em;
 }
+ul.toc {
+  background-color: #DDD;
+  padding: 5px;
+  list-style: none;
+}
+ul.toc li {
+  display: inline-block;
+  min-width: 1.5em;
+}
+ul.toc li a {
+  padding: 5px;
+  font-size: 15px;
+  text-decoration: none;
+}
 td.wordbag {
   width: 30em;
 }

Modified: csw/mgar/gar/v2/lib/web/templates/CatalognameList.html
===================================================================
--- csw/mgar/gar/v2/lib/web/templates/CatalognameList.html	2013-03-31 08:22:35 UTC (rev 20546)
+++ csw/mgar/gar/v2/lib/web/templates/CatalognameList.html	2013-03-31 11:35:54 UTC (rev 20547)
@@ -1,4 +1,4 @@
-$def with (catalognames)
+$def with (catalognames_by_letter, letters)
 <html>
   <head>
     <title>
@@ -7,12 +7,16 @@
     <link rel="stylesheet" type="text/css" href="/pkgdb-static/pkgdb.css" />
   </head>
   <body>
-    <ul class="catalogname-list">
-$for catalogname in catalognames:
-  <li>
-  <a href="$catalogname[0]/">$catalogname[0]</a>
-  </li>
+    <ul class="toc">
+$for letter in letters:
+  <li><a href="#letter-$letter">$letter</a></li>
 </ul>
+$for letter in letters:
+  <h2 class="initial clear-float"><a name="letter-$letter"></a>$letter</h2>
+  <ul class="catalogname-list">
+  $for catalogname in catalognames_by_letter[letter]:
+    <li><a href="$catalogname[0]/">$catalogname[0]</a></li>
+  </ul>
 </body>
 </html>
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list