[svn r1538] Ajout du Quick Mark Link.
--- a/add.py Tue Sep 23 15:11:11 2003 -0400
+++ b/add.py Wed Sep 24 13:29:36 2003 -0400
@@ -16,15 +16,23 @@
import time
from bkmark import Bookmark
-def main(keywords):
+def main(keywords, title, url):
tmpl = TemplateManager().prepare("add_bk.tmpl")
tproc = TemplateProcessor()
+ tproc.set('ctitle', title)
+ tproc.set('curl', url)
tproc.set('Keywords', keywords);
print tproc.process(tmpl)
if (__name__ == "__main__"):
+ form = cgi.FieldStorage()
+ name = url = ""
+ if form.has_key("ctitle"):
+ name = form["ctitle"].value
+ if form.has_key("curl"):
+ url = form["curl"].value
db = my_db.connect()
kw = db.get_all_keywords()[1:]
kw.sort(lambda l,r: cmp(l[1],r[1]))
kw = map(lambda elem: { 'id' : elem[0], 'keyword' : elem[1] }, kw)
- main(kw)
+ main(kw, name, url)
--- a/add_bk.tmpl Tue Sep 23 15:11:11 2003 -0400
+++ b/add_bk.tmpl Wed Sep 24 13:29:36 2003 -0400
@@ -6,8 +6,10 @@
<h1>Add a bookmark</h1>
<form action="add_result.py" method="post" name="add">
<fieldset class="bookmark">
- <label>Nom: <input type="text" name="name"></label><br/>
- <label>URL: <input type="text" name="url"></label><br/>
+ <label>Nom: <input type="text" name="name"
+ value="<TMPL_VAR ctitle>"></label><br/>
+ <label>URL: <input type="text" name="url"
+ value="<TMPL_VAR curl>"></label><br/>
<label for="desc">Description: </label><br/>
<textarea name="desc" rows="5" cols="40"></textarea>
<button type="submit" name="submit">Soumettre</button>
--- a/index.py Tue Sep 23 15:11:11 2003 -0400
+++ b/index.py Wed Sep 24 13:29:36 2003 -0400
@@ -13,6 +13,8 @@
import cgi
from htmltmpl import TemplateManager, TemplateProcessor
import my_db
+from os import environ
+from urlparse import urljoin
def get_selection(form):
kw = form.getvalue("kw")
@@ -32,11 +34,15 @@
'checked' : chk})
return res
-def main(bk, kw):
+def get_curl():
+ return urljoin( 'http://' + environ["HTTP_HOST"] + environ["REQUEST_URI"], 'add.py')
+
+def main(bk, kw, curl):
tmpl = TemplateManager().prepare("index.tmpl")
tproc = TemplateProcessor()
tproc.set("Bookmarks", bk)
tproc.set("Keywords", kw)
+ tproc.set("curl", curl)
print tproc.process(tmpl)
if (__name__ == "__main__"):
@@ -52,4 +58,5 @@
keywords = set_selection(keywords, selection)
bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks))
bookmarks = map(lambda bk: bk.dict(), bookmarks)
- main(bookmarks, keywords)
+ curl = get_curl();
+ main(bookmarks, keywords, curl)
--- a/index.tmpl Tue Sep 23 15:11:11 2003 -0400
+++ b/index.tmpl Wed Sep 24 13:29:36 2003 -0400
@@ -7,6 +7,10 @@
<body>
<h1>Bookmarker 3</h1>
<p>Welcome to bookmarker 3!</p>
+ <p>Here the <a
+ href="javascript:bk1='<TMPL_VAR curl>?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</a>.</p>
+
<dl>
<TMPL_LOOP Bookmarks>
<dt><a href="<TMPL_VAR url>"><TMPL_VAR name></a></dt>