From 2c2fb340ad1d62c02cc9a1aadb3921ad31303c6a Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 5 Jan 2013 11:14:35 +0100 Subject: Improved display of error message. --- source/pyAggr3g470r.py | 22 ++++++++++++---------- source/templates/error.html | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 6bb795f0..002eaf36 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -86,7 +86,9 @@ class RestrictedArea(object): @cherrypy.expose def index(self): - return """This is the admin only area.""" + message = "

This is the admin only area.

" + tmpl = lookup.get_template("error.html") + return tmpl.render(message=message) class pyAggr3g470r(object): """ @@ -193,7 +195,7 @@ class pyAggr3g470r(object): articles = self.mongo.get_articles(feed_id) article = self.mongo.get_articles(feed_id, article_id) except: - return self.error("Bad URL. This article do not exists.") + return self.error("

Bad URL. This article do not exists.

") if article["article_readed"] == False: # if the current article is not yet readed, update the database @@ -262,7 +264,7 @@ class pyAggr3g470r(object): nb_unread_articles_feed = self.mongo.nb_unread_articles(feed_id) favorites = self.mongo.get_favorites(feed_id) except KeyError: - return self.error("This feed do not exists.") + return self.error("

This feed do not exists.

") if articles != []: today = datetime.datetime.now() @@ -293,7 +295,7 @@ class pyAggr3g470r(object): feed = self.mongo.get_feed(feed_id) articles = self.mongo.get_articles(feed_id) except KeyError: - return self.error("This feed do not exists.") + return self.error("

This feed do not exists.

") tmpl = lookup.get_template("articles.html") return tmpl.render(articles=articles, feed=feed) @@ -330,7 +332,7 @@ class pyAggr3g470r(object): feed = self.mongo.get_feed(feed_id) article = self.mongo.get_articles(feed_id, article_id) except: - return self.error("Bad URL. This article do not exists.") + return self.error("

Bad URL. This article do not exists.

") description = utils.clear_string(article["article_content"]) if not description: description = "Unvailable" @@ -390,7 +392,7 @@ class pyAggr3g470r(object): try: action, feed_id = param.split(':') except: - return self.error("Bad URL. This feed do not exists.") + return self.error("

Bad URL. This feed do not exists.

") return self.index() mail_notification.exposed = True @@ -404,7 +406,7 @@ class pyAggr3g470r(object): like, feed_id, article_id = param.split(':') articles = self.mongo.get_articles(feed_id, article_id) except: - return self.error("Bad URL. This article do not exists.") + return self.error("

Bad URL. This article do not exists.

") self.mongo.like_article("1"==like, feed_id, article_id) return self.article(feed_id+":"+article_id) @@ -452,7 +454,7 @@ class pyAggr3g470r(object): # search the feed in the HTML page with BeautifulSoup feed_url = utils.search_feed(url) if feed_url is None: - return self.error("Impossible to find a feed at this URL.") + return self.error("

Impossible to find a feed at this URL.

") # if a feed exists else: result = utils.add_feed(feed_url) @@ -523,7 +525,7 @@ class pyAggr3g470r(object): feed_id, article_id = param.split(':') self.mongo.delete_article(feed_id, article_id) except: - return self.error("Bad URL. This article do not exists.") + return self.error("

Bad URL. This article do not exists.

") return self.index() @@ -574,7 +576,7 @@ class pyAggr3g470r(object): articles = self.mongo.get_articles(feed_id) article = self.mongo.get_articles(feed_id, article_id) except: - self.error("This article do not exists.") + self.error("

This article do not exists.

") try: folder = conf.path + "/var/export/epub/" os.makedirs(folder) diff --git a/source/templates/error.html b/source/templates/error.html index dbdf66db..3790d3e9 100644 --- a/source/templates/error.html +++ b/source/templates/error.html @@ -1,4 +1,5 @@ ## error.html <%inherit file="base.html"/>
-${message} \ No newline at end of file +

An error occured:

+ ${message} \ No newline at end of file -- cgit