|
@@ -72,6 +72,7 @@ class MetaBooks(ListHandler):
|
|
|
"series": _('"%(name)s"丛书包含的书籍'),
|
|
|
"rating": _("评分为%(name)s星的书籍"),
|
|
|
"publisher": _(u'"%(name)s"出版的书籍'),
|
|
|
+ "search": _(u"搜索:%(name)s")
|
|
|
}
|
|
|
start = self.get_argument_start()
|
|
|
try:
|
|
@@ -110,6 +111,19 @@ class MetaBooks(ListHandler):
|
|
|
"books": [self.fmt(b) for b in books],
|
|
|
}
|
|
|
|
|
|
+ if meta in ["search"]:
|
|
|
+ id_set = set()
|
|
|
+ id_list = []
|
|
|
+ for i in ["title", "author", "tag", "series"]:
|
|
|
+ ids_tmp = self.cache.search("%s:%s" % (i, name))
|
|
|
+ for id in ids_tmp:
|
|
|
+ if id not in id_set:
|
|
|
+ id_set.add(id)
|
|
|
+ id_list.append(id)
|
|
|
+ logging.info("keyword: %s:%s" % (i, name))
|
|
|
+ logging.info("books: {}".format(ids_tmp))
|
|
|
+ return self.render_book_list(ids=id_list, title=title)
|
|
|
+
|
|
|
category = meta + "s" if meta in ["tag", "author"] else meta
|
|
|
if meta in ["rating"]:
|
|
|
try:
|
|
@@ -138,7 +152,7 @@ class MetaBooks(ListHandler):
|
|
|
def routes():
|
|
|
return [
|
|
|
(r"/api/(author|publisher|tag|rating|series)", MetaList),
|
|
|
- (r"/api/(author|publisher|tag|rating|series)/(.*)", MetaBooks),
|
|
|
+ (r"/api/(author|publisher|tag|rating|series|search)/(.*)", MetaBooks),
|
|
|
(r"/api/author/(.*)/update", AuthorBooksUpdate),
|
|
|
(r"/api/publisher/(.*)/update", PubBooksUpdate),
|
|
|
]
|