From 6ab92ddbac84f87dc598016de45845a26818dd52 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Mon, 3 Sep 2018 20:54:07 +0200 Subject: [PATCH] Add a handler when pages aren't found. (#379) Fixes #356 --- ihatemoney/messages.pot | 6 +++++ ihatemoney/run.py | 9 +++++-- ihatemoney/templates/404.html | 13 +++++++++++ ihatemoney/templates/layout.html | 22 +++++++++--------- .../translations/fr/LC_MESSAGES/messages.mo | Bin 9909 -> 10180 bytes .../translations/fr/LC_MESSAGES/messages.po | 11 ++++++--- 6 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 ihatemoney/templates/404.html diff --git a/ihatemoney/messages.pot b/ihatemoney/messages.pot index bc8a8f39..bd4dcc49 100644 --- a/ihatemoney/messages.pot +++ b/ihatemoney/messages.pot @@ -182,6 +182,12 @@ msgstr "" msgid "The bill has been modified" msgstr "" +msgid "Sorry, we were unable to find the page you've asked for." +msgstr "" + +msgid "The best thing to do is probably to get back to the main page." +msgstr "" + msgid "Back to the list" msgstr "" diff --git a/ihatemoney/run.py b/ihatemoney/run.py index 1a5ac17e..e9b3ce16 100644 --- a/ihatemoney/run.py +++ b/ihatemoney/run.py @@ -2,7 +2,7 @@ import os import os.path import warnings -from flask import Flask, g, request, session +from flask import Flask, g, request, session, render_template from flask_babel import Babel from flask_mail import Mail from flask_migrate import Migrate, upgrade, stamp @@ -102,6 +102,10 @@ def validate_configuration(app): ) +def page_not_found(e): + return render_template('404.html', root="main"), 404 + + def create_app(configuration=None, instance_path='/etc/ihatemoney', instance_relative_config=True): app = Flask( @@ -121,8 +125,9 @@ def create_app(configuration=None, instance_path='/etc/ihatemoney', validate_configuration(app) app.register_blueprint(web_interface) app.register_blueprint(api) + app.register_error_handler(404, page_not_found) - # Configure the application + # Configure the a, root="main"pplication setup_database(app) mail = Mail() diff --git a/ihatemoney/templates/404.html b/ihatemoney/templates/404.html new file mode 100644 index 00000000..7e282c2e --- /dev/null +++ b/ihatemoney/templates/404.html @@ -0,0 +1,13 @@ +{% extends "layout.html" %} + +{% block body %} + +
+ +{% endblock %} diff --git a/ihatemoney/templates/layout.html b/ihatemoney/templates/layout.html index cb36a6fe..3523ef7b 100644 --- a/ihatemoney/templates/layout.html +++ b/ihatemoney/templates/layout.html @@ -32,13 +32,13 @@ diff --git a/ihatemoney/translations/fr/LC_MESSAGES/messages.mo b/ihatemoney/translations/fr/LC_MESSAGES/messages.mo index 3fa8d8f4c52f34ffbdb3e90d8579f61864b1ce5a..ab8a831618f68d3f7c23b560196812096c4c9bb8 100644 GIT binary patch delta 2505 zcmYM!e@sg$HTLH_gj-=3kjO7Iq@VIENzU=e0xEpo{;qiWcS zBCic0M**}z3bzs`_G{&{Tfy2 zWn73qqT<~0%pxmwpa@mq1E@|kq02qy2?lC;09APqb>2nY_%bTMFsgN@QA=_bmFPuO zLO-CMyMfv>K5o_$Ek$*%5(}{gYq2$x^&esIDkqd#HDxMrJu2`P)Prq!7uu-S4d8kl z!9{olHR0c=R_Bnlg%voBTd)ypXiFUX@ge*HDwp$W?YFeRK>?otsTR)IDzWO z4OF6jzL?W2#vraj?Tw>o;VAMkU-G5STt^l37v|$Fmw_tJr%!SPYSWc^R-x8-J>G{K zu>qe(y>_Qj1^kYhcpe*o?wfK{2kTLBn{XLEf{MS}yY9vqC?gj&(TkpkP@Cw8cYOr4 zM-oWR<|Jx@k5B>6qbmFgwfm>N^Rsh}+3#Z?pb~t8Y*ok@(qY&9%0NF9nJjP$Y2!+ltd2~=w@p%P3Xx+=*=b#Mc!kS5gT+JTDu4C?toRA)a#C3*o} zJ@6d^weBC(8m6*S7@929gcV59<}obCZd3(tqAEX*N@xrf=M1Vd=TM!yikk2@REPa! zrv!8J=|9DqYL3*RM^Tk;NA2ov{b5?F~^ign)kjmQ$;W11N#KnH4qFlz1kP@C-~@AyEUlWc* z`pc}R96k}piihm>pku|tR%cfzV8wPh)*gGOWA%sQCB2SiN4uSX)ftXdBx^HseYH+B z#ywr3oq8e=wz{I$o=CWz82vi4(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&X@WB>aL2 nft1+XibQ+pt&BufI2Z`l)_bqlZ+N$POT(d0LlYC-o|o}I;g8pC diff --git a/ihatemoney/translations/fr/LC_MESSAGES/messages.po b/ihatemoney/translations/fr/LC_MESSAGES/messages.po index ccab28b1..b3e2fdbe 100644 --- a/ihatemoney/translations/fr/LC_MESSAGES/messages.po +++ b/ihatemoney/translations/fr/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-07-16 23:26+0200\n" +"POT-Creation-Date: 2018-08-05 23:41+0200\n" "PO-Revision-Date: 2018-05-15 22:00+0200\n" "Last-Translator: Adrien CLERC <>\n" "Language: fr\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.5.3\n" +"Generated-By: Babel 2.6.0\n" msgid "Project name" msgstr "Nom de projet" @@ -210,6 +210,12 @@ msgstr "La facture a été supprimée" msgid "The bill has been modified" msgstr "La facture a été modifiée" +msgid "Sorry, we were unable to find the page you've asked for." +msgstr "Navré, nous ne trouvons pas la page que vous avez demandé." + +msgid "The best thing to do is probably to get back to the main page." +msgstr "Votre meilleure piste est probablement la page d'accueil." + msgid "Back to the list" msgstr "Retourner à la liste" @@ -488,4 +494,3 @@ msgstr "Solde" #~ msgid "Invite" #~ msgstr "Invitez" -