# HG changeset patch # User fabien@tzone.org # Date 1230485042 18000 # Node ID 004a32370ba56b43215f7ee3ff1ef463ea149fcd # Parent 31271426f879f127bd20c4f3c65edb1fb0710985 Correct some bugs and make keywords edition with the new action mechanic. diff -r 31271426f879 -r 004a32370ba5 add_bk.tmpl --- a/add_bk.tmpl Sat Dec 27 20:23:39 2008 -0500 +++ b/add_bk.tmpl Sun Dec 28 12:24:02 2008 -0500 @@ -2,7 +2,7 @@

's Edit Bookmark

-
+
diff -r 31271426f879 -r 004a32370ba5 add_result.py --- a/add_result.py Sat Dec 27 20:23:39 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#!/usr/bin/python - -import sys -import traceback -sys.path.insert(0, "/home/fabien/lib/python") -sys.path.insert(0, "./lib") -sys.stderr = sys.stdout - -print "Content-type: text/html; charset=iso-8859-1;" -print - -# import cgitb; cgitb.enable() -import cgi -from templates import Template -import time -from utils import unique -import my_db -from add_confirm import get_bk_from_form, get_new_kw_from_form -from webutils import load_index -import os - -def add_new_keywords(db, newkw): - kw = [0] # Default keyword, so that every bookmarks appears in - # the bookmarks_keywords db. - (ids, kws) = map(list,apply(zip, db.get_all_keywords())) - for elem in unique(newkw): - if elem in kws: - kw.append(ids[kws.index(elem)]) - else: - id = db.add_keyword(elem) - kw.append(id) - return kw - -def main(bk, kw, prefs): - tmpl = Template("add_result.tmpl", prefs) - tmpl.set("url", bk.url) - tmpl.set("name", bk.name) - tmpl.set("added", bk.added) - tmpl.set("desc", bk.desc) - tmpl.set("Keywords", kw) - print tmpl.process() - -if (__name__ == "__main__"): - form = cgi.FieldStorage() - db = my_db.connect(os.environ["REMOTE_USER"]) - prefs = db.get_preferences() - action = form['action'].value - if action == 'cancel': - load_index(db, prefs) - elif action == 'delete': - db.remove_bookmark(int(form['id'].value)) - load_index(db, prefs) - else: - bk = get_bk_from_form(form) - newkw = get_new_kw_from_form(form) - kw = add_new_keywords(db, newkw) - if bk.id == -1: - id = db.add_bookmark(bk) - else: - db.update_bookmark(bk) - id = bk.id - db.update_keywords(id, kw) - kw = map(lambda e: { 'keyword': e[1] }, db.get_keywords([id])[1:]) - main(bk, kw, prefs) diff -r 31271426f879 -r 004a32370ba5 add_result.tmpl --- a/add_result.tmpl Sat Dec 27 20:23:39 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ - - - - -

's Add Result

-

Bookmark successfully added:

-

-

-

Keywords: - - ; -

-
-

Back to the main page

- - - diff -r 31271426f879 -r 004a32370ba5 do_edit_kw.py --- a/do_edit_kw.py Sat Dec 27 20:23:39 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -#!/usr/bin/python - -import sys -import traceback -sys.path.insert(0, "/home/fabien/lib/python") -sys.path.insert(0, "./lib") -sys.stderr = sys.stdout - -print "Content-type: text/html; charset=iso-8859-1;" -print - -# import cgitb; cgitb.enable() -import cgi -from templates import Template -import my_db -from bkmark import Bookmark -from keywords import get_keywords -import os - -def main(action, sel_keywords, keywords, prefs): - tmpl = Template("kw_confirm.tmpl", prefs) - tmpl.set("confirm_delete", action == 'delete') - tmpl.set("confirm_merge", action == 'merge') - tmpl.set("confirm_rename", action == 'rename') - tmpl.set("action", action) - tmpl.set("Selected", sel_keywords) - tmpl.set("Keywords", keywords) - print tmpl.process() - -if (__name__ == "__main__"): - form = cgi.FieldStorage() - db = my_db.connect(os.environ["REMOTE_USER"]) - ids = get_keywords(form, 'kw') - keywords = map(lambda e: { 'id': e[0], 'keyword': e[1]}, - db.get_all_keywords()[1:]) - keywords.sort(lambda x, y: cmp(x['keyword'],y['keyword'])) - sel_keywords = filter(lambda e: e['id'] in ids, keywords) - keywords = filter(lambda e: e['id'] not in ids, keywords) - action = form['action'].value - main(action, sel_keywords, keywords, db.get_preferences()) - diff -r 31271426f879 -r 004a32370ba5 dynamic.tmpl --- a/dynamic.tmpl Sat Dec 27 20:23:39 2008 -0500 +++ b/dynamic.tmpl Sun Dec 28 12:24:02 2008 -0500 @@ -2,7 +2,7 @@ -

's XBelWeb

+

Total bookmarks:

diff -r 31271426f879 -r 004a32370ba5 edit_kw.py --- a/edit_kw.py Sat Dec 27 20:23:39 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#!/usr/bin/python - -import sys -import traceback -sys.path.insert(0, "/home/fabien/lib/python") -sys.path.insert(0, "./lib") -sys.stderr = sys.stdout - -print "Content-type: text/html; charset=iso-8859-1;" -print - -# import cgitb; cgitb.enable() -import cgi -from templates import Template -import my_db -import time -import os - -def main(keywords, prefs): - tmpl = Template("edit_kw.tmpl", prefs) - tmpl.set('Keywords', keywords) - print tmpl.process() - -if (__name__ == "__main__"): - form = cgi.FieldStorage() - db = my_db.connect(os.environ["REMOTE_USER"]) - kw = db.get_all_keywords()[1:] - kw = map(lambda elem: { - 'id' : elem[0], - 'keyword' : elem[1] }, kw) - kw.sort(lambda l,r: cmp(l['keyword'],r['keyword'])) - main(kw, db.get_preferences()) diff -r 31271426f879 -r 004a32370ba5 edit_kw.tmpl --- a/edit_kw.tmpl Sat Dec 27 20:23:39 2008 -0500 +++ b/edit_kw.tmpl Sun Dec 28 12:24:02 2008 -0500 @@ -2,15 +2,16 @@

's Edit Keywords

- + +