# HG changeset patch # User fabien # Date 1067029469 14400 # Node ID 2781ac85b807b3b5df9041fb791ef16665800935 # Parent d3c1de4d929e6875cb6d8970f4c152d0085bacf7 [svn r1604] Implement default_view preferences, which move things around a lot. diff -r d3c1de4d929e -r 2781ac85b807 ChangeLog --- a/ChangeLog Fri Oct 24 14:19:30 2003 -0400 +++ b/ChangeLog Fri Oct 24 17:04:29 2003 -0400 @@ -2,6 +2,8 @@ * Add display name to Preferences. * Add folders view with Add. + * Add a default view between folders and dynamic view. + * Move things around so the code is a bit (really a bit) cleaner. -- Fabien Ninoles Fri, 17 Oct 2003 15:04:26 -0400 diff -r d3c1de4d929e -r 2781ac85b807 TODO --- a/TODO Fri Oct 24 14:19:30 2003 -0400 +++ b/TODO Fri Oct 24 17:04:29 2003 -0400 @@ -1,14 +1,14 @@ +* Selection based bookmarks editions. * Used SQL sequence instead of the db_sequence table. * Add CSS. * Add Search capabilities. -* Add default (dynamic?) tree expansion. +* Add default (dynamic?) tree expansion using colltags. * Add XBel Export. * Add support for icons. * Add modified time. * Add access/check time. * Add user session support. * Better unicode handling. -* Selection based bookmark manipulation. * More user preferences. * Clean up of all the code. This is a real mess currently! * Optimization of some code part. diff -r d3c1de4d929e -r 2781ac85b807 add.py --- a/add.py Fri Oct 24 14:19:30 2003 -0400 +++ b/add.py Fri Oct 24 17:04:29 2003 -0400 @@ -11,22 +11,20 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager -from webutils import get_template_processor; +from templates import Template import my_db import time from bkmark import Bookmark import os def main(keywords, title, url, prefs): - tmpl = TemplateManager().prepare("add_bk.tmpl") - tproc = get_template_processor(prefs) - tproc.set('ctitle', title) - tproc.set('curl', url) - tproc.set('desc', '') - tproc.set('bkid', -1) - tproc.set('Keywords', keywords) - print tproc.process(tmpl) + tmpl = Template("add_bk.tmpl", prefs) + tmpl.set('ctitle', title) + tmpl.set('curl', url) + tmpl.set('desc', '') + tmpl.set('bkid', -1) + tmpl.set('Keywords', keywords) + print tmpl.process() if (__name__ == "__main__"): form = cgi.FieldStorage() diff -r d3c1de4d929e -r 2781ac85b807 add_confirm.py --- a/add_confirm.py Fri Oct 24 14:19:30 2003 -0400 +++ b/add_confirm.py Fri Oct 24 17:04:29 2003 -0400 @@ -13,12 +13,11 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager -from webutils import get_template_processor import my_db import time from bkmark import Bookmark -from index import load_index +from webutils import load_index +from templates import Template from utils import unique import os @@ -58,24 +57,24 @@ return kw def main(action, bk, kw, prefs): - tmpl = TemplateManager().prepare("add_confirm.tmpl") - tproc = get_template_processor(prefs) - tproc.set("confirm_delete", action == 'delete') - tproc.set("confirm_update", action == 'update') - tproc.set("action", action) - tproc.set("id", bk.id) - tproc.set("name", bk.name) - tproc.set("url", bk.url) - tproc.set("Keywords", map(lambda x: {'keyword': x }, kw)) - print tproc.process(tmpl) + tmpl = Template("add_confirm.tmpl", prefs) + tmpl.set("confirm_delete", action == 'delete') + tmpl.set("confirm_update", action == 'update') + tmpl.set("action", action) + tmpl.set("id", bk.id) + tmpl.set("name", bk.name) + tmpl.set("url", bk.url) + tmpl.set("Keywords", map(lambda x: {'keyword': x }, kw)) + print tmpl.process() if (__name__ == "__main__"): form = cgi.FieldStorage() db = my_db.connect(os.environ["REMOTE_USER"]) + prefs = db.get_preferences() id = int(form['id'].value) action = form['action'].value if action == 'cancel' or (action == 'delete' and id == -1): - load_index(db) + load_index(db, prefs) else: if action == 'update': bk = get_bk_from_form(form) @@ -84,5 +83,5 @@ bk = db.get_bookmarks([id])[0] (ids, kw) = apply(zip,db.get_keywords([id])) kw = kw[1:] - main(action, bk, kw, db.get_preferences()) + main(action, bk, kw, prefs) diff -r d3c1de4d929e -r 2781ac85b807 add_result.py --- a/add_result.py Fri Oct 24 14:19:30 2003 -0400 +++ b/add_result.py Fri Oct 24 17:04:29 2003 -0400 @@ -11,13 +11,12 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager -from webutils import get_template_processor +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 index import load_index +from webutils import load_index import os def add_new_keywords(db, newkw): @@ -33,24 +32,24 @@ return kw def main(bk, kw, prefs): - tmpl = TemplateManager().prepare("add_result.tmpl") - tproc = get_template_processor(prefs) - tproc.set("url", bk.url) - tproc.set("name", bk.name) - tproc.set("added", bk.added) - tproc.set("desc", bk.desc) - tproc.set("Keywords", kw) - print tproc.process(tmpl) + 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) + load_index(db, prefs) elif action == 'delete': db.remove_bookmark(int(form['id'].value)) - load_index(db) + load_index(db, prefs) else: bk = get_bk_from_form(form) newkw = get_new_kw_from_form(form) @@ -62,4 +61,4 @@ id = bk.id db.update_keywords(id, kw) kw = map(lambda e: { 'keyword': e[1] }, db.get_keywords([id])[1:]) - main(bk, kw, db.get_preferences()) + main(bk, kw, prefs) diff -r d3c1de4d929e -r 2781ac85b807 do_edit_kw.py --- a/do_edit_kw.py Fri Oct 24 14:19:30 2003 -0400 +++ b/do_edit_kw.py Fri Oct 24 17:04:29 2003 -0400 @@ -11,24 +11,22 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager -from webutils import get_template_processor +from templates import Template import my_db from bkmark import Bookmark -from webutils import get_keywords +from keywords import get_keywords import os def main(action, sel_keywords, keywords, prefs): - tmpl = TemplateManager().prepare("kw_confirm.tmpl") - tproc = get_template_processor(prefs) - tproc.set("pagetitle", os.environ["REMOTE_USER"]+"'s XBELWeb Confirmation") - tproc.set("confirm_delete", action == 'delete') - tproc.set("confirm_merge", action == 'merge') - tproc.set("confirm_rename", action == 'rename') - tproc.set("action", action) - tproc.set("Selected", sel_keywords) - tproc.set("Keywords", keywords) - print tproc.process(tmpl) + tmpl = Template("kw_confirm.tmpl", prefs) + tmpl.set("pagetitle", os.environ["REMOTE_USER"]+"'s XBELWeb Confirmation") + 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() diff -r d3c1de4d929e -r 2781ac85b807 do_import.py --- a/do_import.py Fri Oct 24 14:19:30 2003 -0400 +++ b/do_import.py Fri Oct 24 17:04:29 2003 -0400 @@ -21,7 +21,8 @@ if (__name__ == "__main__"): form = cgi.FieldStorage() db = my_db.connect(os.environ["REMOTE_USER"]) + prefs = db.get_preferences() file = form["xbelfile"].file bms = parse_xbel(file) import_bookmarks(db, bms) - load_index(db) + load_index(db, prefs) diff -r d3c1de4d929e -r 2781ac85b807 dynamic.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dynamic.tmpl Fri Oct 24 17:04:29 2003 -0400 @@ -0,0 +1,55 @@ + + + + +

's XBelWeb

+

Total bookmarks:

+
+ +
+ Keywords: +

+

+ +
+
+ +
+ Switch to folder view + + + + diff -r d3c1de4d929e -r 2781ac85b807 edit.py --- a/edit.py Fri Oct 24 14:19:30 2003 -0400 +++ b/edit.py Fri Oct 24 17:04:29 2003 -0400 @@ -11,22 +11,20 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager +from templates import Template import my_db import time from bkmark import Bookmark -from webutils import get_template_processor import os def main(keywords, bk, prefs): - tmpl = TemplateManager().prepare("add_bk.tmpl") - tproc = get_template_processor(prefs) - tproc.set('ctitle', bk.name) - tproc.set('curl', bk.url) - tproc.set('desc', bk.desc) - tproc.set('bkid', bk.id) - tproc.set('Keywords', keywords) - print tproc.process(tmpl) + tmpl = Template("add_bk.tmpl", prefs) + tmpl.set('ctitle', bk.name) + tmpl.set('curl', bk.url) + tmpl.set('desc', bk.desc) + tmpl.set('bkid', bk.id) + tmpl.set('Keywords', keywords) + print tmpl.process() if (__name__ == "__main__"): form = cgi.FieldStorage() diff -r d3c1de4d929e -r 2781ac85b807 edit_kw.py --- a/edit_kw.py Fri Oct 24 14:19:30 2003 -0400 +++ b/edit_kw.py Fri Oct 24 17:04:29 2003 -0400 @@ -11,17 +11,15 @@ # import cgitb; cgitb.enable() import cgi -from htmltmpl import TemplateManager -from webutils import get_template_processor +from templates import Template import my_db import time import os def main(keywords, prefs): - tmpl = TemplateManager().prepare("edit_kw.tmpl") - tproc = get_template_processor(prefs) - tproc.set('Keywords', keywords) - print tproc.process(tmpl) + tmpl = Template("edit_kw.tmpl", prefs) + tmpl.set('Keywords', keywords) + print tmpl.process() if (__name__ == "__main__"): form = cgi.FieldStorage() diff -r d3c1de4d929e -r 2781ac85b807 edit_prefs.py --- a/edit_prefs.py Fri Oct 24 14:19:30 2003 -0400 +++ b/edit_prefs.py Fri Oct 24 17:04:29 2003 -0400 @@ -23,8 +23,10 @@ prefs['keywords_box'] = int(form['kw_size'].value) if form.has_key('kw_sort'): prefs['keywords_sort'] = form['kw_sort'].value + if form.has_key('default_view'): + prefs['default_view'] = int(form['default_view'].value) prefs['keywords_reverse'] = form.has_key('kw_reverse') if form.has_key('fullname'): prefs['fullname'] = form['fullname'].value db.set_preferences(prefs) - load_index(db) + load_index(db, prefs) diff -r d3c1de4d929e -r 2781ac85b807 folders.py --- a/folders.py Fri Oct 24 14:19:30 2003 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#!/usr/bin/python - -import sys -import traceback -if (__name__ == '__main__'): - 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 -import my_db -from os import environ -from htmltmpl import TemplateManager -from webutils import get_template_processor, set_selection, sort_keywords - -def output(prefs, folder, parents, children, bookmarks, keywords): - tmpl = TemplateManager().prepare("folders.tmpl") - tproc = get_template_processor(prefs) - tproc.set('Parents', parents) - tproc.set('folder', folder['id']) - tproc.set('name', folder['name']) - tproc.set('total', len(bookmarks)) - bookmarks.sort(lambda l,r: cmp(l['name'],r['name'])) - tproc.set('Bookmarks', bookmarks) - tproc.set('Subfolders', children) - keywords = sort_keywords(keywords[1:], prefs) - tproc.set('Keywords', keywords) - print tproc.process(tmpl) - -if (__name__ == "__main__"): - form = cgi.FieldStorage() - db = my_db.connect(environ["REMOTE_USER"]) - if form.has_key('folder'): - folder = int(form['folder'].value) - else: - folder = 0 - if form.has_key('action'): - if form['action'].value == 'add': - if form.has_key('sel'): - keyword = int(form['sel'].value) - db.add_folder(keyword, folder) - print "Folder successfully add." - parents = db.get_folder_parents_and_self(folder) - children = db.get_subfolders(folder) - parents.reverse() - selection = map(lambda e: e['keyword'], parents) - exclusion = map(lambda e: e['keyword'], children) - bookmarks = db.select_bookmarks(selection, exclusion) - selected_keywords = set_selection(db, - map(lambda e: e[0], bookmarks), - selection, exclusion) - keywords = [] - for keyword in selected_keywords: - if not keyword['id'] in exclusion: - keywords.append(keyword) - for child in children: - child['count'] = len(db.select_bookmarks(selection + [child['keyword']])) - bookmarks = db.get_bookmarks(map(lambda bk: bk[0], bookmarks)) - bookmarks = map(lambda bk: bk.dict(), bookmarks) - output(db.get_preferences(), parents.pop(), parents, children, bookmarks, keywords) diff -r d3c1de4d929e -r 2781ac85b807 folders.tmpl --- a/folders.tmpl Fri Oct 24 14:19:30 2003 -0400 +++ b/folders.tmpl Fri Oct 24 17:04:29 2003 -0400 @@ -4,22 +4,28 @@

's XBelWeb

-

+

:

Main Folder ()

+
+ + + +
-
+ +