aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/conf.py51
-rwxr-xr-xsource/feedgetter.py3
-rwxr-xr-xsource/pyAggr3g470r.py15
-rwxr-xr-xsource/utils.py23
4 files changed, 62 insertions, 30 deletions
diff --git a/source/conf.py b/source/conf.py
new file mode 100644
index 00000000..60289315
--- /dev/null
+++ b/source/conf.py
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+#-*- coding: utf-8 -*-
+
+# pyAggr3g470r - A Web based news aggregator.
+# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/
+#
+# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+
+__author__ = "Cedric Bonhomme"
+__version__ = "$Revision: 0.1 $"
+__date__ = "$Date: 2012/04/22 $"
+__revision__ = "$Date: 2012/04/22 $"
+__copyright__ = "Copyright (c) Cedric Bonhomme"
+__license__ = "GPLv3"
+
+
+import os
+import ConfigParser
+# load the configuration
+config = ConfigParser.RawConfigParser()
+try:
+ config.read("./cfg/pyAggr3g470r.cfg")
+except:
+ config.read("./cfg/pyAggr3g470r.cfg-sample")
+path = os.path.abspath(".")
+
+MONGODB_ADDRESS = config.get('MongoDB', 'address')
+MONGODB_PORT = int(config.get('MongoDB', 'port'))
+MONGODB_USER = config.get('MongoDB', 'user')
+MONGODB_PASSWORD = config.get('MongoDB', 'password')
+
+mail_from = config.get('mail','mail_from')
+mail_to = config.get('mail','mail_to')
+smtp_server = config.get('mail','smtp')
+username = config.get('mail','username')
+password = config.get('mail','password')
+
+DIASPORA_POD = config.get('misc', 'diaspora_pod') \ No newline at end of file
diff --git a/source/feedgetter.py b/source/feedgetter.py
index f713f672..aa25f2a3 100755
--- a/source/feedgetter.py
+++ b/source/feedgetter.py
@@ -32,6 +32,7 @@ from BeautifulSoup import BeautifulSoup
from datetime import datetime
+import conf
import utils
import mongodb
@@ -145,7 +146,7 @@ class FeedGetter(object):
self.articles.add_articles(articles, feed_id)
# send new articles by e-mail if desired.
- #threading.Thread(None, utils.send_mail, None, (utils.mail_from, utils.mail_to, \
+ #threading.Thread(None, utils.send_mail, None, (conf.mail_from, conf.mail_to, \
#a_feed.feed.title.encode('utf-8'), \
#article_title, description) \
#).start()
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index 7c4c8fde..a9434fba 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -46,6 +46,7 @@ import calendar
from collections import Counter
import datetime
+import conf
import utils
import export
import mongodb
@@ -108,7 +109,7 @@ class Root:
def __init__(self):
"""
"""
- self.mongo = mongodb.Articles(utils.MONGODB_ADDRESS, utils.MONGODB_PORT)
+ self.mongo = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT)
def index(self):
"""
@@ -506,7 +507,7 @@ class Root:
# 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""" % \
- (utils.DIASPORA_POD, article["article_link"], article["article_title"], "via pyAggr3g470r")
+ (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>""" % \
@@ -578,7 +579,7 @@ class Root:
" unread article" + (self.mongo.nb_unread_articles(feed_id) == 1 and [""] or ["s"])[0]])[0] + ".</p>"
if feed["mail"] == True:
html += """<p>You are receiving articles from this feed to the address: <a href="mail:%s">%s</a>. """ % \
- (utils.mail_to, utils.mail_to)
+ (conf.mail_to, conf.mail_to)
html += """<a href="/mail_notification/0:%s">Stop</a> receiving articles from this feed.</p>""" % \
(feed_id, )
@@ -991,7 +992,7 @@ class Root:
else:
html += "<p>No active notifications.<p>\n"
html += """<p>Notifications are sent to: <a href="mail:%s">%s</a></p>""" % \
- (utils.mail_to, utils.mail_to)
+ (conf.mail_to, conf.mail_to)
html += "\n<hr />\n" + htmlfooter
return html
@@ -1217,7 +1218,7 @@ class Root:
except:
self.error_page("This article do not exists.")
try:
- folder = utils.path + "/var/export/epub/"
+ folder = conf.path + "/var/export/epub/"
os.makedirs(folder)
except OSError:
# directories already exists (not a problem)
@@ -1237,9 +1238,9 @@ if __name__ == '__main__':
print "Launching pyAggr3g470r..."
root = Root()
- root.favicon_ico = cherrypy.tools.staticfile.handler(filename=os.path.join(utils.path + "/img/favicon.png"))
+ root.favicon_ico = cherrypy.tools.staticfile.handler(filename=os.path.join(conf.path + "/img/favicon.png"))
cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': "0.0.0.0"})
cherrypy.config.update({'error_page.404': error_page_404})
_cp_config = {'request.error_response': handle_error}
- cherrypy.quickstart(root, "/" ,config=utils.path + "/cfg/cherrypy.cfg")
+ cherrypy.quickstart(root, "/" ,config=conf.path + "/cfg/cherrypy.cfg")
diff --git a/source/utils.py b/source/utils.py
index 6230f005..9efe9d83 100755
--- a/source/utils.py
+++ b/source/utils.py
@@ -34,6 +34,7 @@ __license__ = "GPLv3"
# - mail notifications.
#
+import os
import re
import sqlite3
import operator
@@ -53,28 +54,6 @@ from BeautifulSoup import BeautifulSoup
from datetime import datetime
from collections import Counter
-import os
-import ConfigParser
-# load the configuration
-config = ConfigParser.RawConfigParser()
-try:
- config.read("./cfg/pyAggr3g470r.cfg")
-except:
- config.read("./cfg/pyAggr3g470r.cfg-sample")
-path = os.path.abspath(".")
-
-MONGODB_ADDRESS = config.get('MongoDB', 'address')
-MONGODB_PORT = int(config.get('MongoDB', 'port'))
-MONGODB_USER = config.get('MongoDB', 'user')
-MONGODB_PASSWORD = config.get('MongoDB', 'password')
-
-mail_from = config.get('mail','mail_from')
-mail_to = config.get('mail','mail_to')
-smtp_server = config.get('mail','smtp')
-username = config.get('mail','username')
-password = config.get('mail','password')
-
-DIASPORA_POD = config.get('misc', 'diaspora_pod')
# regular expression to chech URL
url_finders = [ \
bgstack15