+ 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 = "Ошибка!"
+ body = "Тег %s не существует!" % tag
+ else: # Process tree
+ from tags import find_tags
+ posts = find_tags(tree)
+ status = None
+ title = "Записи, найденные для выражения " + q
+ if posts:
+ _posts = ["""\
+<p class="head">
+<ul>
+"""]
+ for year, month, day, suburl, _title in posts:
+ _posts.append('<li>%s-%s-%s <a href="../../../../Russian/blog/%s">%s</a></li>\n' % (year, month, day, suburl, _title))
+ _posts .append("""\
+</ul>
+</p>
+""")
+ body = ''.join(_posts)
+ else:
+ body = "Не найдено ни одной записи."