aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rwxr-xr-xsource/pyAggr3g470r.py90
-rw-r--r--source/templates/article.html61
2 files changed, 66 insertions, 85 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index 43023a1a..a8659e1a 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -451,40 +451,21 @@ class pyAggr3g470r(object):
article = self.mongo.get_article(feed_id, article_id)
except:
return self.error_page("Bad URL. This article do not exists.")
- html = htmlheader(article["article_title"])
- html += htmlnav
- html += """<div>"""
if article["article_readed"] == False:
# if the current article is not yet readed, update the database
self.mark_as_read("Article:"+article["article_id"]+":"+feed["feed_id"])
- html += '\n<div style="width: 50%; overflow:hidden; text-align: justify; margin:0 auto">\n'
- # Title of the article
- html += """<h1><i>%s</i> from <a href="/feed/%s">%s</a></h1>\n<br />\n""" % \
- (article["article_title"], feed_id, feed["feed_title"])
- if article["article_like"] == True:
- html += """<a href="/like/0:%s:%s"><img src="/img/heart.png" title="I like this article!" /></a>""" % \
- (feed_id, article["article_id"])
- else:
- html += """<a href="/like/1:%s:%s"><img src="/img/heart_open.png" title="Click if you like this article." /></a>""" % \
- (feed_id, article["article_id"])
- html += """&nbsp;&nbsp;<a href="/delete_article/%s:%s"><img src="/img/cross.png" title="Delete this article" /></a>""" % \
- (feed_id, article["article_id"])
- html += "<br /><br />"
-
# Description (full content) of the article
description = article["article_content"]
if description:
p = re.compile(r'<code><')
q = re.compile(r'></code>')
-
description = p.sub('<code>&lt;', description)
description = q.sub('&gt;</code>', description)
-
- html += description + "\n<br /><br /><br />"
+ description = description + "\n<br /><br /><br />"
else:
- html += "No description available.\n<br /><br /><br />"
+ description += "No description available.\n<br /><br /><br />"
"""
# Generation of the QR Code for the current article
try:
@@ -517,70 +498,9 @@ class pyAggr3g470r(object):
except StopIteration:
previous = liste[0]
- html += """<div style="float:right;"><a href="/article/%s:%s" title="%s"><img src="/img/following-article.png" /></a></div>\n""" % \
- (feed_id, following["article_id"], following["article_title"])
- html += """<div style="float:left;"><a href="/article/%s:%s" title="%s"><img src="/img/previous-article.png" /></a></div>\n""" % \
- (feed_id, previous["article_id"], previous["article_title"])
-
- html += "\n</div>\n"
-
- # Footer menu
- html += "<hr />\n"
- html += """\n<a href="/plain_text/%s:%s">Plain text</a>\n""" % (feed_id, article["article_id"])
- html += """ - <a href="/epub/%s:%s">Export to EPUB</a>\n""" % (feed_id, article["article_id"])
- html += """<br />\n<a href="%s">Complete story</a>\n<br />\n""" % (article["article_link"],)
-
- # Share this article:
- html += "Share this article:<br />\n"
- # on Diaspora
- html += """<a href="javascript:(function(){f='https://%s/bookmarklet?url=%s&amp;title=%s&amp;notes=%s&amp;v=1&amp;';a=function(){if(!window.open(f+'noui=1&amp;jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()">\n\t
- <img src="/img/diaspora.png" title="Share on Diaspora" /></a>\n""" % \
- (conf.DIASPORA_POD, article["article_link"], article["article_title"], "via pyAggr3g470r")
-
- # on Identi.ca
- html += """\n\n<a href="http://identi.ca/index.php?action=newnotice&status_textarea=%s: %s" title="Share on Identi.ca" target="_blank"><img src="/img/identica.png" /></a>""" % \
- (article["article_title"], article["article_link"])
-
- # on Hacker News
- html += """\n\n<a href='javascript:window.location="http://news.ycombinator.com/submitlink?u="+encodeURIComponent("%s")+"&t="+encodeURIComponent("%s")'><img src="/img/hacker-news.png" title="Share on Hacker News" /></a>""" % \
- (article["article_link"], article["article_title"])
-
- # on Pinboard
- html += """\n\n\t<a href="https://api.pinboard.in/v1/posts/add?url=%s&description=%s"
- rel="noreferrer" target="_blank">\n
- <img src="/img/pinboard.png" title="Share on Pinboard" /></a>""" % \
- (article["article_link"], article["article_title"])
-
- # on Digg
- html += """\n\n\t<a href="http://digg.com/submit?url=%s&title=%s"
- rel="noreferrer" target="_blank">\n
- <img src="/img/digg.png" title="Share on Digg" /></a>""" % \
- (article["article_link"], article["article_title"])
- # on reddit
- html += """\n\n\t<a href="http://reddit.com/submit?url=%s&title=%s"
- rel="noreferrer" target="_blank">\n
- <img src="/img/reddit.png" title="Share on reddit" /></a>""" % \
- (article["article_link"], article["article_title"])
- # on Scoopeo
- html += """\n\n\t<a href="http://scoopeo.com/scoop/new?newurl=%s&title=%s"
- rel="noreferrer" target="_blank">\n
- <img src="/img/scoopeo.png" title="Share on Scoopeo" /></a>""" % \
- (article["article_link"], article["article_title"])
- # on Blogmarks
- html += """\n\n\t<a href="http://blogmarks.net/my/new.php?url=%s&title=%s"
- rel="noreferrer" target="_blank">\n
- <img src="/img/blogmarks.png" title="Share on Blogmarks" /></a>""" % \
- (article["article_link"], article["article_title"])
-
- # Google +1 button
- html += """\n\n<g:plusone size="standard" count="true" href="%s"></g:plusone>""" % \
- (article["article_link"],)
-
-
- # QRCode (for smartphone)
- html += """<br />\n<a href="/var/qrcode/%s.png"><img src="/var/qrcode/%s.png" title="Share with your smartphone" width="500" height="500" /></a>""" % (article_id, article_id)
- html += "<hr />\n" + htmlfooter
- return html
+ tmpl = lookup.get_template("article.html")
+ return tmpl.render(article=article, previous=previous, following=following, \
+ diaspora=conf.DIASPORA_POD, feed=feed, description=description)
article.exposed = True
diff --git a/source/templates/article.html b/source/templates/article.html
new file mode 100644
index 00000000..110442f6
--- /dev/null
+++ b/source/templates/article.html
@@ -0,0 +1,61 @@
+## article.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>
+ <div style="width: 50%; overflow:hidden; text-align: justify; margin:0 auto">
+ <h1><i>${article["article_title"]}</i> from <a href="/feed/${feed['feed_id']}">${feed["feed_title"]}</a></h1>
+ <br />
+ %if article["article_like"]:
+ <a href="/like/0:${feed['feed_id']}:${article['article_id']}"><img src="/img/heart.png" title="I like this article!" /></a>
+ %else:
+ <a href="/like/1:${feed['feed_id']}:${article['article_id']}"><img src="/img/heart_open.png" title="Click if you like this article." /></a>
+ %endif
+ &nbsp;&nbsp;<a href="/delete_article/${feed['feed_id']}:${article['article_id']}"><img src="/img/cross.png" title="Delete this article" /></a>
+ <br /><br />
+
+ ${description}
+
+ <div style="float:right;"><a href="/article/${feed['feed_id']}:${following['article_id']}" title="${following['article_title']}"><img src="/img/following-article.png" /></a></div>
+ <div style="float:left;"><a href="/article/${feed['feed_id']}:${previous['article_id']}" title="${previous['article_title']}"><img src="/img/previous-article.png" /></a></div>
+ </div>
+
+ <hr />
+ <a href="/plain_text/${feed['feed_id']}:${article['article_id']}">Plain text</a>
+ - <a href="/epub/${feed['feed_id']}:${article['article_id']}">Export to EPUB</a>
+ <br />
+ <a href="${article['article_link']}">Complete story</a>
+ <br />
+
+ Share this article:<br />
+ <a href="javascript:(function(){f='https://${diaspora}/bookmarklet?url=${article['article_link']}&amp;title=${article['article_title']}&amp;notes=via pyAggr3g470r&amp;v=1&amp;';a=function(){if(!window.open(f+'noui=1&amp;jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()">
+ <img src="/img/diaspora.png" title="Share on Diaspora" /></a>
+
+ <a href="http://identi.ca/index.php?action=newnotice&status_textarea=${article['article_title']}:${article['article_link']}" title="Share on Identi.ca" target="_blank"><img src="/img/identica.png" /></a>
+
+ <a href="https://api.pinboard.in/v1/posts/add?url=${article['article_link']}&description=${article['article_title']}"
+ rel="noreferrer" target="_blank">
+ <img src="/img/pinboard.png" title="Share on Pinboard" /></a>
+
+ <a href="http://digg.com/submit?url=${article['article_link']}&title=${article['article_title']}"
+ rel="noreferrer" target="_blank">
+ <img src="/img/digg.png" title="Share on Digg" /></a>
+
+ <a href="http://reddit.com/submit?url=${article['article_link']}&title=${article['article_title']}"
+ rel="noreferrer" target="_blank">
+ <img src="/img/reddit.png" title="Share on reddit" /></a>
+
+ <a href="http://scoopeo.com/scoop/new?newurl=${article['article_link']}&title=${article['article_title']}"
+ rel="noreferrer" target="_blank">
+ <img src="/img/scoopeo.png" title="Share on Scoopeo" /></a>
+
+ <a href="http://blogmarks.net/my/new.php?url=${article['article_link']}&title=${article['article_title']}"
+ rel="noreferrer" target="_blank">
+ <img src="/img/blogmarks.png" title="Share on Blogmarks" /></a>
+
+ <g:plusone size="standard" count="true" href="${article['article_link']}"></g:plusone>
+
+
+ <br />
+ <a href="/var/qrcode/${article['article_id']}.png"><img src="/var/qrcode/${article['article_id']}.png" title="Share with your smartphone" width="500" height="500" /></a> \ No newline at end of file
bgstack15