1 #! /usr/bin/env python3
5 __author__ = "Oleg Broytman <phd@phdru.name>"
6 __copyright__ = "Copyright (C) 2014-2024 PhiloSoft Design"
7 __license__ = "GNU GPL"
11 from lark import ParseError
14 from html.response import redirect, response
15 from parser import parser
19 status = "400 Bad request"
21 body = "Required parameter is missing!"
26 tree = parser.parse(q)
28 status = "400 Bad request"
30 body = "Bad query syntax!"
32 if tree[0] == 'NAME': # Single tag - just do redirect
34 assert isinstance(tag, str)
35 from tags import tag_exists
38 "/Russian/blog/tags/%s.html" % tag, status="301 Moved")
40 status = "404 Tag not found"
42 body = "Тег %s не существует!" % tag
44 from tags import find_tags
45 posts = find_tags(tree)
47 title = "Записи, найденные для выражения " + mycgi.escape(q)
53 for year, month, day, suburl, _title in posts:
56 '<a href="../../../../Russian/blog/%s">%s</a></li>\n'
57 % (year, month, day, suburl, _title))
62 body = ''.join(_posts)
64 body = "Не найдено ни одной записи."
66 response(title, body, status)