From 0e9ce04c4727020645f1bc5d1b5693087aafec51 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 7 Dec 2010 09:48:07 +0100 Subject: Better comments. --- pyAggr3g470r.py | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index bbc4ecf8..32eda14a 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -40,7 +40,6 @@ import feedgetter import PyQRNative bindhost = "0.0.0.0" - cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': bindhost}) # static files @@ -120,7 +119,7 @@ class Root: """ Main page containing the list of feeds and articles. """ - # if there are unread articles, display the number in the tab + # if there are unread articles, display the number in the tab of the browser html = htmlheader((self.nb_unread_articles and \ ['(' + str(self.nb_unread_articles) +') '] or \ [""])[0]) @@ -243,22 +242,26 @@ class Root: def management(self, word_size=6): """ - Management of articles. + Management page. + Allows adding and deleting feeds. Export functions of the SQLite data base + and display some statistics. """ html = htmlheader() html += htmlnav html += """
\n""" html += "

Add Feeds

\n" - html += """
\n
\n""" + # Form: add a feed + html += """
\n
\n""" if self.feeds: + # Form: delete a feed html += "

Delete Feeds

\n" html += """
\n""" + html += """

Active e-mail notifications: %s

\n""" % \ (self.nb_mail_notifications,) html += """

You like %s article(s).

\n""" % \ @@ -266,13 +269,14 @@ class Root: html += "
\n" - # Informations about the data base of articles, export funtions... + # Informations about the data base of articles html += """

The database contains a total of %s article(s) with %s unread article(s).
""" % \ (self.nb_articles, self.nb_unread_articles) html += """Database: %s.\n
Size: %s bytes.

\n""" % \ (os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) + # Export functions html += """
\n
\n""" html += """
\n
\n""" html += "

Export articles

\n\n" @@ -284,7 +288,7 @@ class Root: html += """\n\t\n\n""" html += "
\n\n" - # Some statistics + # Some statistics (most frequent word) if self.feeds: self.top_words = utils.top_words(self.feeds, n=50, size=int(word_size)) html += "

Statistics

\n
\n" @@ -305,7 +309,7 @@ class Root: def q(self, querystring=None): """ - Search for a feed. Simply search for the string 'querystring' + Simply search for the string 'querystring' in the description of the article. """ param, _, value = querystring.partition(':') @@ -332,8 +336,7 @@ class Root: not_read_begin = "" not_read_end = "" - html += article.article_date + \ - " - " + not_read_begin + \ + html += article.article_date + " - " + not_read_begin + \ """%s""" % \ (feed_id, article.article_id, article.article_title) + \ not_read_end + """
\n""" @@ -414,12 +417,13 @@ class Root: html = htmlheader() html += htmlnav html += """
""" + # Generation of the QR Code for the current article try: os.makedirs("./var/qrcode/") except OSError: pass - if not os.path.isfile("./var/qrcode/"+article_id+".png"): - # QR code generation + if not os.path.isfile("./var/qrcode/" + article_id + ".png"): + # QR Code generation try: qr = PyQRNative.QRCode(7, PyQRNative.QRErrorCorrectLevel.L) qr.addData(article.article_link) @@ -431,9 +435,11 @@ class Root: print e if article.article_readed == "0": - self.mark_as_read("Article:"+article.article_link) # update the database + # if the current article is not yet readed, update the database + self.mark_as_read("Article:"+article.article_link) html += '\n
\n' + # Title of the article html += """

%s from %s

\n
\n""" % \ (article.article_title, feed_id, feed.feed_title) if article.like == "1": @@ -445,18 +451,20 @@ class Root: html += """  """ % \ (feed_id, article.article_id) html += "

" + + # Description (full content) of the article description = article.article_description if description: html += description else: html += "No description available." + + # Footer menu html += "\n
\n
\n" - html += """\nPlain text\n""" % \ - (feed_id, article.article_id) - html += """ - Export to EPUB\n""" % \ - (feed_id, article.article_id) - html += """
\nComplete story\n
\n""" % \ - (article.article_link,) + html += """\nPlain text\n""" % (feed_id, article.article_id) + html += """ - Export to EPUB\n""" % (feed_id, article.article_id) + html += """
\nComplete story\n
\n""" % (article.article_link,) + # Share this article: # on Identi.ca html += """\n    \n""" % \ @@ -503,8 +511,8 @@ class Root: html += """

\n\n    """ % \ (article.article_link,) - html += """
\n""" % \ - (article_id,) + # QRCode (for smartphone) + html += """
\n""" % (article_id,) html += "
\n" + htmlfooter return html -- cgit