X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=search-tags.py;h=fec3705e91fa0a710cd8b687f8e14cf8a5edfd5f;hb=7affd5882b4c0af22bddb5916fae47da166987af;hp=4f6810adc65a34a95c08ca3b843e6eb5316569d0;hpb=3db3a1c52868d865cac4e96d6521f62feb15cf77;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/search-tags.py b/search-tags.py index 4f6810a..fec3705 100755 --- a/search-tags.py +++ b/search-tags.py @@ -1,18 +1,21 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # coding: koi8-r """Search tags CGI""" __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2014-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2014-2024 PhiloSoft Design" __license__ = "GNU GPL" -import cgi, sys -from ometa.runtime import ParseError +import sys + +from lark import ParseError +import mycgi + from html.response import redirect, response from parser import parser -form = cgi.FieldStorage() -if not form.has_key('q'): +form = mycgi.Form() +if 'q' not in form: status = "400 Bad request" title = "Error!" body = "Required parameter is missing!" @@ -26,28 +29,32 @@ else: title = "Error!" body = "Bad query syntax!" else: - if tree[0] == 'NAME': # Single tag - just do redirect + if 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") + redirect( + "/Russian/blog/tags/%s.html" % tag, status="301 Moved") sys.exit() status = "404 Tag not found" title = "ïÛÉÂËÁ!" body = "ôÅÇ %s ÎÅ ÓÕÝÅÓÔ×ÕÅÔ!" % tag - else: # Process tree + else: # Process tree from tags import find_tags posts = find_tags(tree) status = None - title = "úÁÐÉÓÉ, ÎÁÊÄÅÎÎÙÅ ÄÌÑ ×ÙÒÁÖÅÎÉÑ " + cgi.escape(q) + title = "úÁÐÉÓÉ, ÎÁÊÄÅÎÎÙÅ ÄÌÑ ×ÙÒÁÖÅÎÉÑ " + mycgi.escape(q) if posts: _posts = ["""\