# HG changeset patch # User terom # Date 1200793920 0 # Node ID 4b3cf12848c2eb548d75b0915953e0906eb7d224 # Parent 001f52cd057ef853de9f682dc32faff9e3c16f40 tweaks/bugfixes (e.g. support adding multiple tags to an image at once) diff -r 001f52cd057e -r 4b3cf12848c2 de-cgi-bin/taggr2.py --- a/de-cgi-bin/taggr2.py Sun Jan 20 01:07:02 2008 +0000 +++ b/de-cgi-bin/taggr2.py Sun Jan 20 01:52:00 2008 +0000 @@ -75,9 +75,9 @@ elif act == "tag" : img_list = req.get_int_list("img") - tag = req.get_str("tag") + tag_list = req.get_str_list("tag") - db.insert_many("""INSERT INTO tags (image, tag) VALUES (?, ?)""", ((img, tag) for img in img_list)) + db.insert_many("""INSERT INTO tags (image, tag) VALUES (?, ?)""", ((img, tag) for img in img_list for tag in tag_list)) print "OK" diff -r 001f52cd057e -r 4b3cf12848c2 javascript/taggr.js --- a/javascript/taggr.js Sun Jan 20 01:07:02 2008 +0000 +++ b/javascript/taggr.js Sun Jan 20 01:52:00 2008 +0000 @@ -99,6 +99,10 @@ } function new_tag (tag_name) { + if ($("tag_" + tag_name)) { + $("tag_" + tag_name).show().scrollTo(); + } + var tag_images = Builder.node("td", {className:"tag_images", id:"tag_" + tag_name + "_images"}); tag_images._tag = tag_name; @@ -116,6 +120,8 @@ tag_row._tags = new Array(tag_name); $("tag_table").appendChild(tag_row); + + return true; } function tag_add_tag (new_tag, tag) { @@ -177,7 +183,7 @@ parameters: { act: 'tag', img: orig_img._key, - tag: tag, + tag: $("tag_" + tag)._tags, }, method: 'get' @@ -198,7 +204,7 @@ parameters: { act: 'tag', img: img_keys, - tag: tag_name, + tag: $("tag_" + tag_name)._tags, }, method: 'get' @@ -218,21 +224,21 @@ parameters: { act: 'untag', img: img_key, - tag: tag_name, + tag: $("tag_" + tag_name)._tags, }, method: 'get', }); } function hide_tag_image (tag, img) { - $("tagimg_" + tag + "_" + img).hide(); + $("tag_" + tag + "_img_" + img).hide(); if (--$("tag_" + tag + "_images")._visibleCount == 0) $("tag_" + tag).hide(); } function show_tag_image (tag, img) { - $("tagimg_" + tag + "_" + img).hide(); + $("tag_" + tag + "_img_" + img).show(); if ($("tag_" + tag + "_images")._visibleCount++ == 0) $("tag_" + tag).show(); diff -r 001f52cd057e -r 4b3cf12848c2 lib/req.py --- a/lib/req.py Sun Jan 20 01:07:02 2008 +0000 +++ b/lib/req.py Sun Jan 20 01:52:00 2008 +0000 @@ -40,6 +40,14 @@ else : return default +def get_str_list (key, default=REQUIRED_PARAM) : + if key in vars : + return [val.decode('utf8', 'replace') for val in vars.getlist(key)] + elif default is REQUIRED_PARAM : + raise ValueError("Required param %s" % key) + else : + return default + def get_int (key, default=REQUIRED_PARAM) : if key in vars : return int(vars[key].value)