aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2012-12-29 15:30:05 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2012-12-29 15:30:05 +0100
commited57d6090faf521a05a51786325fdd69cd794bf4 (patch)
tree703b9c0dedffb6a954ad0996691f9facb3a04347 /source
parentTypo. (diff)
downloadnewspipe-ed57d6090faf521a05a51786325fdd69cd794bf4.tar.gz
newspipe-ed57d6090faf521a05a51786325fdd69cd794bf4.tar.bz2
newspipe-ed57d6090faf521a05a51786325fdd69cd794bf4.zip
Template for the /history page.
Diffstat (limited to 'source')
-rwxr-xr-xsource/pyAggr3g470r.py87
-rw-r--r--source/templates/history.html80
2 files changed, 83 insertions, 84 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index a2cb29da..73fc26a3 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -42,16 +42,12 @@ __license__ = "GPLv3"
import os
import re
-import calendar
-
+import datetime
import cherrypy
from mako.template import Template
from mako.lookup import TemplateLookup
lookup = TemplateLookup(directories=['templates'])
-from collections import Counter
-import datetime
-
import conf
import utils
import export
@@ -413,85 +409,8 @@ class pyAggr3g470r(object):
This page enables to browse articles chronologically.
"""
feeds = self.mongo.get_all_feeds()
- html = htmlheader()
- html += htmlnav
- html += """<div class="left inner">\n"""
-
- # Get the date from the tag cloud
- # Format: /history/?query=year:2011-month:06 to get the
- # list of articles of June, 2011.
- if m != "":
- query = """year:%s-month:%s""" % tuple(m.split('-'))
-
- if query == "all":
- html += "<h1>Search with tags cloud</h1>\n"
- html += "<h4>Choose a year</h4>\n"
- if "year" in query:
- the_year = query.split('-')[0].split(':')[1]
- if "month" not in query:
- html += "<h1>Choose a month for " + the_year + "</h1>\n"
- if "month" in query:
- the_month = query.split('-')[1].split(':')[1]
- html += "<h1>Articles of "+ calendar.month_name[int(the_month)] + \
- ", "+ the_year +".</h1>\n"
-
- timeline = Counter()
- for feed in feeds:
- new_feed_section = True
- for article in self.mongo.get_articles(feed["feed_id"]):
-
- if query == "all":
- timeline[article["article_date"].strftime('%Y')] += 1
-
- elif query[:4] == "year":
-
- if article["article_date"].strftime('%Y') == the_year:
- timeline[article["article_date"].strftime('%m')] += 1
-
- if "month" in query:
- if article["article_date"].strftime('%m') == the_month:
- 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 = "", ""
-
- 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."
- # Title of the article
- article_title = article["article_title"]
- if len(article_title) >= 80:
- article_title = article_title[:80] + " ..."
-
- if new_feed_section is True:
- new_feed_section = False
- html += """<h2><a name="%s"><a href="%s" rel="noreferrer"
- target="_blank">%s</a></a><a href="%s" rel="noreferrer"
- target="_blank"><img src="%s" width="28" height="28" /></a></h2>\n""" % \
- (feed["feed_id"], feed["site_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"])
-
- html += article["article_date"].strftime("%a %d (%H:%M:%S) ") + " - " + \
- """<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_title, not_read_end, description) + like + "<br />\n"
- if query == "all":
- query_string = "year"
- elif "year" in query:
- query_string = "year:" + the_year + "-month"
- if "month" not in query:
- html += '<div style="width: 35%; overflow:hidden; text-align: justify">' + \
- utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], query_string) + '</div>'
- html += '<hr />'
- html += htmlfooter
- return html
+ tmpl = lookup.get_template("history.html")
+ return tmpl.render(feeds=feeds, mongo=self.mongo, query=query, m=m)
history.exposed = True
diff --git a/source/templates/history.html b/source/templates/history.html
new file mode 100644
index 00000000..e6826032
--- /dev/null
+++ b/source/templates/history.html
@@ -0,0 +1,80 @@
+## history.html
+<%inherit file="base.html"/>
+<%
+import utils
+import calendar
+from collections import Counter
+%>
+<div class="left inner">
+ <%
+ html = ""
+ # Get the date from the tag cloud
+ # Format: /history/?query=year:2011-month:06 to get the
+ # list of articles of June, 2011.
+ if query == "all":
+ html += "<h1>Search with tags cloud</h1>\n"
+ html += "<h4>Choose a year</h4>\n"
+ if "year" in query:
+ the_year = query.split('-')[0].split(':')[1]
+ if "month" not in query:
+ html += "<h1>Choose a month for " + the_year + "</h1>\n"
+ if "month" in query:
+ the_month = query.split('-')[1].split(':')[1]
+ html += "<h1>Articles of "+ calendar.month_name[int(the_month)] + ", "+ the_year +".</h1>\n"
+
+ timeline = Counter()
+ for feed in feeds:
+ new_feed_section = True
+ for article in mongo.get_articles(feed["feed_id"]):
+
+ if query == "all":
+ timeline[article["article_date"].strftime('%Y')] += 1
+
+ elif query[:4] == "year":
+
+ if article["article_date"].strftime('%Y') == the_year:
+ timeline[article["article_date"].strftime('%m')] += 1
+
+ if "month" in query:
+ if article["article_date"].strftime('%m') == the_month:
+ 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 = "", ""
+
+ 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."
+ # Title of the article
+ article_title = article["article_title"]
+ if len(article_title) >= 80:
+ article_title = article_title[:80] + " ..."
+
+ if new_feed_section is True:
+ new_feed_section = False
+ html += """<h2><a name="%s"><a href="%s" rel="noreferrer"
+ target="_blank">%s</a></a><a href="%s" rel="noreferrer"
+ target="_blank"><img src="%s" width="28" height="28" /></a></h2>\n""" % \
+ (feed["feed_id"], feed["site_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"])
+
+ html += article["article_date"].strftime("%a %d (%H:%M:%S) ") + " - " + \
+ """<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_title, not_read_end, description) + like + "<br />\n"
+ if query == "all":
+ query_string = "year"
+ elif "year" in query:
+ query_string = "year:" + the_year + "-month"
+ if "month" not in query:
+ html += '<div style="width: 35%; overflow:hidden; text-align: justify">' + \
+ utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], query_string) + '</div>'
+ %>
+ ${html} \ No newline at end of file
bgstack15