1 #! /usr/bin/env python3
5 __author__ = "Oleg Broytman <phd@phdru.name>"
6 __copyright__ = "Copyright (C) 2014-2024 PhiloSoft Design"
7 __license__ = "GNU GPL"
9 from html import escape
12 from lark import ParseError
15 from html_output.response import redirect, response
16 from parser import parser
20 status = "400 Bad request"
22 body = "Required parameter is missing!"
27 tree = parser.parse(q)
29 status = "400 Bad request"
31 body = "Bad query syntax!"
33 if tree[0] == 'NAME': # Single tag - just do redirect
35 assert isinstance(tag, str)
36 from tags import real_tag
40 "/Russian/blog/tags/%s.html" % rtag, status="301 Moved")
42 status = "404 Tag not found"
44 body = "Тег %s не существует!" % tag
46 from tags import find_tags
47 posts = find_tags(tree)
49 title = "Записи, найденные для выражения " + escape(q)
55 for year, month, day, suburl, _title in posts:
58 '<a href="../../../../Russian/blog/%s">%s</a></li>\n'
59 % (year, month, day, suburl, _title))
64 body = ''.join(_posts)
66 body = "Не найдено ни одной записи."
68 response(title, body, status)