# HG changeset patch # User fabien # Date 1064438392 14400 # Node ID 7357230539d2d8833e20ae14e5dbdceb8aff67c1 # Parent 800be3836f3b7a4d8939eca585b88c1f1402b106 [svn r1547] Add count to keywords. diff -r 800be3836f3b -r 7357230539d2 TODO --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TODO Wed Sep 24 17:19:52 2003 -0400 @@ -0,0 +1,10 @@ +* Used SQL sequence instead of the db_sequence table. +* Add delete bookmark. +* Add edit/delete/merge keyword. +* Add CSS. +* Add better navigational means. +* Add limit query page or move keywords up. +* Add Search capabilities. +* Add default (dynamic?) tree expansion. +* Add multiuser support. +* Add XBel Import/Export. diff -r 800be3836f3b -r 7357230539d2 add_result.py --- a/add_result.py Wed Sep 24 16:44:09 2003 -0400 +++ b/add_result.py Wed Sep 24 17:19:52 2003 -0400 @@ -59,7 +59,7 @@ bk = get_bk_from_form(form) kw = get_kw_from_form(form) newkw = get_new_kw_from_form(form) - (ids, kws) = map(list,apply(zip, db.get_all_keywords())) + (ids, kws, cnt) = map(list,apply(zip, db.get_all_keywords())) for elem in newkw: if elem in kws: kw.append(ids[kws.index(elem)]) diff -r 800be3836f3b -r 7357230539d2 index.py --- a/index.py Wed Sep 24 16:44:09 2003 -0400 +++ b/index.py Wed Sep 24 17:19:52 2003 -0400 @@ -31,6 +31,7 @@ chk = key[0] in sel res.append({'id':key[0], 'keyword': key[1], + 'count' : key[2], 'checked' : chk}) res.sort(lambda l,r: cmp(l["keyword"],r["keyword"])) return res @@ -38,18 +39,21 @@ def get_curl(): return urljoin( 'http://' + environ["HTTP_HOST"] + environ["REQUEST_URI"], 'add.py') -def main(bk, kw, curl): +def main(bk, kw, curl, total): tmpl = TemplateManager().prepare("index.tmpl") tproc = TemplateProcessor() tproc.set("Bookmarks", bk) tproc.set("Keywords", kw) tproc.set("curl", curl) + tproc.set("total", total) print tproc.process(tmpl) if (__name__ == "__main__"): form = cgi.FieldStorage() db = my_db.connect() - keywords = db.get_all_keywords()[1:] + keywords = db.get_all_keywords() + total = keywords[0][2] + keywords = keywords[1:] selection = get_selection(form) if selection[0] == 0: exc = map(lambda e: int(e[0]), keywords) @@ -61,4 +65,4 @@ bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks)) bookmarks = map(lambda bk: bk.dict(), bookmarks) curl = get_curl(); - main(bookmarks, keywords, curl) + main(bookmarks, keywords, curl, total) diff -r 800be3836f3b -r 7357230539d2 index.tmpl --- a/index.tmpl Wed Sep 24 16:44:09 2003 -0400 +++ b/index.tmpl Wed Sep 24 17:19:52 2003 -0400 @@ -10,6 +10,7 @@ href="javascript:bk1='?curl='+escape(location.href)+'&ctitle='+escape(document.title);bkwin=window.open(bk1,'bkqm','width=620,height=500,scrollbars=1,resizable=1');bkwin.focus();">Quick Mark Link.

+

Total bookmarks:

@@ -27,7 +28,8 @@
  • checked - value=""/>
  • + value=""/> + ()
    diff -r 800be3836f3b -r 7357230539d2 lib/my_db.py --- a/lib/my_db.py Wed Sep 24 16:44:09 2003 -0400 +++ b/lib/my_db.py Wed Sep 24 17:19:52 2003 -0400 @@ -123,8 +123,12 @@ """ % (into_id, merge_id)) self.remove_keyword(merge_id) def get_all_keywords(self): - """Return a list of pair-elements [id, keyword].""" - self.crs.execute("SELECT id, name FROM keywords ORDER BY id;") + """Return a list of triplets [id, keyword, count].""" + self.crs.execute("""SELECT k.id, k.name, COUNT(bk.keyword) + FROM keywords k, bookmarks_keywords bk + WHERE k.id = bk.keyword + GROUP BY k.id, k.name + ORDER BY k.id;""") return self.crs.fetchall() def select_bookmarks(self, has_kw = [0], except_kw = []): """