X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=search-tags.py;h=8d322d12057ed3290646c67c3c99b94846a6e877;hb=ed552696f81f160ff233a268cbc9b506e76edce9;hp=9bdfc8bb5bc1e4cd6711e6f7f4caad5fe5bc464c;hpb=9017a731ba1591d385909809c86cc74ce842dd37;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/search-tags.py b/search-tags.py index 9bdfc8b..8d322d1 100755 --- a/search-tags.py +++ b/search-tags.py @@ -5,10 +5,10 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2014 PhiloSoft Design" __license__ = "GNU GPL" -import cgi +import cgi, sys from ply.lex import LexError -from html.response import response +from html.response import redirect, response from parser.parser import parser form = cgi.FieldStorage() @@ -27,5 +27,15 @@ else: status = "400 Bad request" title = "Error!" body = "Bad query syntax!" + elif tree[0] == 'NAME': # Single tag - just do redirect + tag = tree[1] + assert isinstance(tag, str) + from tags import tag_exists + if tag_exists(tag): + redirect("/Russian/blog/tags/%s.html" % tag, status="301 Moved") + sys.exit() + status = "404 Tag not found" + title = "Error!" + body = "Tag does not exist!" response(title, body, status)