aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource/pyAggr3g470r.py23
-rw-r--r--source/templates/statistics.html17
2 files changed, 21 insertions, 19 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index fb7da783..a7f12de8 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -289,25 +289,10 @@ class pyAggr3g470r(object):
More advanced statistics.
"""
articles = self.mongo.get_all_articles()
- html = htmlheader()
- html += htmlnav
- html += """<div class="left inner">\n"""
-
- # Some statistics (most frequent word)
- if articles:
- top_words = utils.top_words(articles, n=50, size=int(word_size))
- html += "<h1>Statistics</h1>\n"
- html += "<h3>Tag cloud</h3>\n"
- # Tags cloud
- html += '<form method=get action="/statistics/">\n'
- html += "Minimum size of a word:\n"
- html += """<input type="number" name="word_size" value="%s" min="2" max="15" step="1" size="2"></form>\n""" % (word_size)
- html += '<div style="width: 35%; overflow:hidden; text-align: justify">' + \
- utils.tag_cloud(top_words) + '</div>'
- html += "<hr />\n"
-
- html += htmlfooter
- return html
+ top_words = utils.top_words(articles, n=50, size=int(word_size))
+ tag_cloud = utils.tag_cloud(top_words)
+ tmpl = lookup.get_template("statistics.html")
+ return tmpl.render(articles=articles, word_size=word_size, tag_cloud=tag_cloud)
statistics.exposed = True
diff --git a/source/templates/statistics.html b/source/templates/statistics.html
new file mode 100644
index 00000000..42577efd
--- /dev/null
+++ b/source/templates/statistics.html
@@ -0,0 +1,17 @@
+## statistics.html
+<%inherit file="base.html"/>
+<h1><div class="right innerlogo"><a href="/"><img src="/img/tuxrss.png" title="What's new today?"/></a>
+</div><a name="top"><a href="/">pyAggr3g470r - News aggregator</a></a></h1>
+<a href="http://bitbucket.org/cedricbonhomme/pyaggr3g470r/" rel="noreferrer" target="_blank">pyAggr3g470r (source code)</a>
+<div class="left inner">
+ %if articles:
+ <h1>Statistics</h1>
+ <h3>Tag cloud</h3>
+ <form method=get action="/statistics/">
+ Minimum size of a word:
+ <input type="number" name="word_size" value="${word_size}" min="2" max="15" step="1" size="2">
+ </form>
+ <div style="width: 35%; overflow:hidden; text-align: justify">
+ ${tag_cloud}
+ </div>
+ %endif \ No newline at end of file
bgstack15