From edf1a885d61ddd578b220c5a21dff66dfa4e254a Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 23 Jul 2010 09:25:07 +0200 Subject: Added QR Code (for example to share articles with smartphone). --- pyAggr3g470r.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 1903eae6..45341381 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -18,6 +18,7 @@ from cherrypy.lib.static import serve_file import utils import feedgetter +import PyQRNative bindhost = "0.0.0.0" @@ -48,7 +49,9 @@ path = {'/css/style.css': {'tools.staticfile.on': True, \ '/css/img/email.png': {'tools.staticfile.on': True, \ 'tools.staticfile.filename':utils.path+'css/img/email.png'}, \ '/css/img/cross.png': {'tools.staticfile.on': True, \ - 'tools.staticfile.filename':utils.path+'css/img/cross.png'}} + 'tools.staticfile.filename':utils.path+'css/img/cross.png'}, \ + '/var/qrcode': {'tools.staticdir.on': True, + 'tools.staticdir.dir': os.path.join(utils.path, './var/qrcode')}} htmlheader = '\n' + \ '' + \ @@ -359,6 +362,14 @@ class Root: for article in articles_list: if article_id == article[0]: + if not os.path.isfile("./var/qrcode/"+article_id+".png"): + # QR code generation + qr = PyQRNative.QRCode(5, PyQRNative.QRErrorCorrectLevel.L) + qr.addData(article[3]) + qr.make() + im = qr.makeImage() + im.save("./var/qrcode/"+article_id+".png", format='png') + if article[5] == "0": self.mark_as_read("Article:"+article[3]) # update the database @@ -422,6 +433,9 @@ class Root: html += """
\n""" % \ (article[3].encode('utf-8'),) + + html += """
\n""" % \ + (article_id,) break html += "
\n" + htmlfooter return html -- cgit