diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2012-12-04 22:57:12 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2012-12-04 22:57:12 +0100 |
commit | 0bdd781b29a5435c022148703299314034cc091a (patch) | |
tree | c6f8efe20c84d2af67215013666dd0f44a2349eb | |
parent | Updated revision date. (diff) | |
download | newspipe-0bdd781b29a5435c022148703299314034cc091a.tar.gz newspipe-0bdd781b29a5435c022148703299314034cc091a.tar.bz2 newspipe-0bdd781b29a5435c022148703299314034cc091a.zip |
Template for the /search page.
-rwxr-xr-x | source/pyAggr3g470r.py | 67 | ||||
-rw-r--r-- | source/templates/search.html | 56 |
2 files changed, 60 insertions, 63 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index b0024f41..f1a05edf 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -192,69 +192,10 @@ class pyAggr3g470r(object): feed_id = None if param == "Feed": feed_id, _, query = value.partition(':') - html = htmlheader() - html += htmlnav - html += """<div class="left inner">""" - html += """<h1>Articles containing the string <i>%s</i></h1><br />""" % (query,) - - if feed_id is not None: - for article in self.mongo.get_articles(feed_id): - article_content = utils.clear_string(article.article_description) - if not article_content: - utils.clear_string(article.article_title) - if wordre.findall(article_content) != []: - if article.article_readed == "0": - # not readed articles are in bold - not_read_begin, not_read_end = "<b>", "</b>" - else: - not_read_begin, not_read_end = "", "" - - html += article.article_date + " - " + not_read_begin + \ - """<a href="/article/%s:%s" rel="noreferrer" target="_blank">%s</a>""" % \ - (feed_id, article.article_id, article.article_title) + \ - not_read_end + """<br />\n""" - else: - feeds = self.mongo.get_all_feeds() - for feed in feeds: - new_feed_section = True - for article in self.mongo.get_articles(feed["feed_id"]): - article_content = utils.clear_string(article["article_content"]) - if not article_content: - utils.clear_string(article["article_title"]) - if wordre.findall(article_content) != []: - if new_feed_section is True: - new_feed_section = False - html += """<h2><a href="/articles/%s" rel="noreferrer" target="_blank">%s</a><a href="%s" rel="noreferrer" target="_blank"><img src="%s" width="28" height="28" /></a></h2>\n""" % \ - (feed["feed_id"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) - - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "<b>", "</b>" - else: - not_read_begin, not_read_end = "", "" - - # display a heart for faved articles - if article["article_like"] == True: - like = """ <img src="/img/heart.png" title="I like this article!" />""" - else: - like = "" - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].strftime('%Y-%m-%d %H:%M') + " - " + \ - """<a class="tooltip" href="/article/%s:%s" rel="noreferrer" target="_blank">%s%s%s<span class="classic">%s</span></a>""" % \ - (feed["feed_id"], article["article_id"], not_read_begin, \ - article["article_title"][:150], not_read_end, description) + like + "<br />\n" - html += "<hr />" - html += htmlfooter - return html + feeds = self.mongo.get_all_feeds() + tmpl = lookup.get_template("search.html") + return tmpl.render(feeds=feeds, feed_id=feed_id, query=query, \ + wordre=wordre, mongo=self.mongo) search.exposed = True diff --git a/source/templates/search.html b/source/templates/search.html new file mode 100644 index 00000000..e4a4ac9c --- /dev/null +++ b/source/templates/search.html @@ -0,0 +1,56 @@ +## search.html +<%inherit file="base.html"/> +<% +import re +import utils +%> +<div class="left inner"> +<h1>Articles containing the string <i>${query}</i></h1> +<br /> +<% + html = "" +%> +%if feed_id is None: + %for feed in feeds: + <% + new_feed_section = True + for article in mongo.get_articles(feed["feed_id"]): + article_content = utils.clear_string(article["article_content"]) + if not article_content: + utils.clear_string(article["article_title"]) + if wordre.findall(article_content) != []: + if new_feed_section is True: + new_feed_section = False + html += """<h2><a href="/articles/%s" rel="noreferrer" target="_blank">%s</a><a href="%s" rel="noreferrer" target="_blank"><img src="%s" width="28" height="28" /></a></h2>\n""" % \ + (feed["feed_id"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "<b>", "</b>" + else: + not_read_begin, not_read_end = "", "" + + # display a heart for faved articles + if article["article_like"] == True: + like = """ <img src="/img/heart.png" title="I like this article!" />""" + else: + like = "" + + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].strftime('%Y-%m-%d %H:%M') + " - " + \ + """<a class="tooltip" href="/article/%s:%s" rel="noreferrer" target="_blank">%s%s%s<span class="classic">%s</span></a>""" % \ + (feed["feed_id"], article["article_id"], not_read_begin, \ + article["article_title"][:150], not_read_end, description) + like + "<br />\n" + %> + %endfor +%endif + ${html} +
\ No newline at end of file |