Browse Source

Implement javascript i18n using a jinja tempate, add Flask-Cache for caching

Gu1 11 years ago
parent
commit
8bbdd2c9f7

+ 2 - 0
babel.cfg

@@ -1,3 +1,5 @@
 [python: **.py]
 [python: **.py]
 [jinja2: **/templates/**.html]
 [jinja2: **/templates/**.html]
 extensions=jinja2.ext.autoescape,jinja2.ext.with_
 extensions=jinja2.ext.autoescape,jinja2.ext.with_
+[jinja2: **/templates/**.js]
+extensions=jinja2.ext.autoescape,jinja2.ext.with_

+ 3 - 2
ffdnispdb/__init__.py

@@ -4,14 +4,14 @@ from flask import Flask, g, current_app, request
 from flask.ext.babel import Babel
 from flask.ext.babel import Babel
 from flask.ext.sqlalchemy import SQLAlchemy, event
 from flask.ext.sqlalchemy import SQLAlchemy, event
 from flask.ext.mail import Mail
 from flask.ext.mail import Mail
-from werkzeug.contrib.cache import NullCache
+from flask.ext.cache import Cache
 from .sessions import MySessionInterface
 from .sessions import MySessionInterface
 
 
 
 
 babel = Babel()
 babel = Babel()
 db = SQLAlchemy()
 db = SQLAlchemy()
 sess = MySessionInterface(db)
 sess = MySessionInterface(db)
-cache = NullCache()
+cache = Cache()
 mail = Mail()
 mail = Mail()
 
 
 def get_locale():
 def get_locale():
@@ -40,6 +40,7 @@ def create_app(config={}):
 
 
     app.session_interface = sess
     app.session_interface = sess
     mail.init_app(app)
     mail.init_app(app)
+    cache.init_app(app)
 
 
     from .views import ispdb
     from .views import ispdb
     from .views_api import ispdbapi
     from .views_api import ispdbapi

+ 1 - 0
ffdnispdb/default_settings.py

@@ -11,3 +11,4 @@ LANGUAGES = {
 }
 }
 ISP_FORM_GEOJSON_MAX_SIZE = 256*1024
 ISP_FORM_GEOJSON_MAX_SIZE = 256*1024
 ISP_FORM_GEOJSON_MAX_SIZE_TOTAL = 1024*1024
 ISP_FORM_GEOJSON_MAX_SIZE_TOTAL = 1024*1024
+CACHE_NO_NULL_WARNING = True

+ 1 - 1
ffdnispdb/forms.py

@@ -77,7 +77,7 @@ class GeoJSONField(TextField):
                 raise StopValidation(_(u'Invalid GeoJSON, please check it'))
                 raise StopValidation(_(u'Invalid GeoJSON, please check it'))
             if not check_geojson_spatialite(self.data):
             if not check_geojson_spatialite(self.data):
                 # TODO: log this
                 # TODO: log this
-                raise StopValidation(_(u'GeoJSON not understood by database'))
+                raise StopValidation(_(u'Unable to store GeoJSON in database'))
 
 
 
 
 class Unique(object):
 class Unique(object):

+ 1 - 1
ffdnispdb/templates/layout.html

@@ -87,7 +87,7 @@
 <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap.js') }}"></script>
 <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap.js') }}"></script>
 <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-select.min.js') }}"></script>
 <script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap-select.min.js') }}"></script>
 <script type="text/javascript" src="{{ url_for('static', filename='js/leaflet.js') }}"></script>
 <script type="text/javascript" src="{{ url_for('static', filename='js/leaflet.js') }}"></script>
-<script type="text/javascript" src="{{ url_for('static', filename='js/site.js') }}"></script>
+<script type="text/javascript" src="{{ url_for('.site_js') }}"></script>
 {%- endblock %}
 {%- endblock %}
 </body>
 </body>
 
 

+ 5 - 5
ffdnispdb/static/js/site.js

@@ -66,15 +66,15 @@ $(function () {
         makeModal: function() {
         makeModal: function() {
             return $('<div class="modal hide geoinput-modal">'+
             return $('<div class="modal hide geoinput-modal">'+
                      '<div class="modal-header">'+
                      '<div class="modal-header">'+
-                     '<h3>GeoJSON Input</h3>'+
+                     '<h3>'+{{ _("GeoJSON Input")|js_str }}+'</h3>'+
                      '</div>'+
                      '</div>'+
                      '<div class="modal-body">'+
                      '<div class="modal-body">'+
-                     '<p>Paste your GeoJSON here:</p>'+
+                     '<p>'+{{ _("Paste your GeoJSON here")|js_str }}+'</p>'+
                      '<textarea style="width: 97%; height: 200px"></textarea>'+
                      '<textarea style="width: 97%; height: 200px"></textarea>'+
                      '</div>'+
                      '</div>'+
                      '<div class="modal-footer">'+
                      '<div class="modal-footer">'+
-                     '<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>'+
-                     '<button class="btn btn-primary">Done</button>'+
+                     '<button class="btn" data-dismiss="modal" aria-hidden="true">'+{{ _("Cancel")|js_str }}+'</button>'+
+                     '<button class="btn btn-primary">'+{{ _("Done")|js_str }}+'</button>'+
                      '</div>'+
                      '</div>'+
                      '</div>')
                      '</div>')
         }
         }
@@ -138,7 +138,7 @@ L.Control.Pinpoint = L.Control.extend({
         this._button.href = '#';
         this._button.href = '#';
         this._button.innerHTML = '<i class="icon-hand-down"></i>';
         this._button.innerHTML = '<i class="icon-hand-down"></i>';
         this._button.style = 'cursor: pointer';
         this._button.style = 'cursor: pointer';
-        this._button.title = 'Find ISPs near you';
+        this._button.title = {{ _('Find ISPs near you')|js_str }};
         L.DomEvent
         L.DomEvent
          .addListener(this._button, 'click', L.DomEvent.stop)
          .addListener(this._button, 'click', L.DomEvent.stop)
          .addListener(this._button, 'click', L.DomEvent.stopPropagation)
          .addListener(this._button, 'click', L.DomEvent.stopPropagation)

BIN
ffdnispdb/translations/fr/LC_MESSAGES/messages.mo


+ 105 - 57
ffdnispdb/translations/fr/LC_MESSAGES/messages.po

@@ -6,8 +6,8 @@
 msgid ""
 msgid ""
 msgstr ""
 msgstr ""
 "Report-Msgid-Bugs-To: gu1@cafai.fr\n"
 "Report-Msgid-Bugs-To: gu1@cafai.fr\n"
-"POT-Creation-Date: 2013-12-19 03:42+0100\n"
-"PO-Revision-Date: 2013-12-19 03:46+0100\n"
+"POT-Creation-Date: 2013-12-21 11:19+0100\n"
+"PO-Revision-Date: 2013-12-21 11:21+0100\n"
 "Last-Translator: Gu1 <gu1@cafai.fr>\n"
 "Last-Translator: Gu1 <gu1@cafai.fr>\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 "MIME-Version: 1.0\n"
 "MIME-Version: 1.0\n"
@@ -47,125 +47,146 @@ msgstr ""
 msgid "ISP fully working"
 msgid "ISP fully working"
 msgstr "FAI pleinement opérationnel"
 msgstr "FAI pleinement opérationnel"
 
 
-#: ffdnispdb/forms.py:46
+#: ffdnispdb/forms.py:58
+#, python-format
+msgid "JSON value too big, must be less than %(max_size)s"
+msgstr "Valeur JSON trop volumineuse, doit peser moins de %(max_size)s"
+
+#: ffdnispdb/forms.py:62
+msgid "Not a valid JSON value"
+msgstr "Valeur JSON invalide"
+
+#: ffdnispdb/forms.py:77
+msgid "Invalid GeoJSON, please check it"
+msgstr "Valeur GeoJSON invalide, vérifiez-la"
+
+#: ffdnispdb/forms.py:80
+msgid "Unable to store GeoJSON in database"
+msgstr "Impossible de stocker votre GeoJSON en base de données"
+
+#: ffdnispdb/forms.py:89
 msgid "this element already exists"
 msgid "this element already exists"
 msgstr "Cet élément existe déjà"
 msgstr "Cet élément existe déjà"
 
 
-#: ffdnispdb/forms.py:59
+#: ffdnispdb/forms.py:102
 msgid "FTTH"
 msgid "FTTH"
 msgstr "FTTH"
 msgstr "FTTH"
 
 
-#: ffdnispdb/forms.py:60
+#: ffdnispdb/forms.py:103
 msgid "DSL"
 msgid "DSL"
 msgstr "DSL"
 msgstr "DSL"
 
 
-#: ffdnispdb/forms.py:61
+#: ffdnispdb/forms.py:104
 msgid "Wi-Fi"
 msgid "Wi-Fi"
 msgstr "Wi-Fi"
 msgstr "Wi-Fi"
 
 
-#: ffdnispdb/forms.py:64 ffdnispdb/forms.py:78
+#: ffdnispdb/forms.py:107 ffdnispdb/forms.py:121
 #: ffdnispdb/templates/project_detail.html:23
 #: ffdnispdb/templates/project_detail.html:23
 msgid "name"
 msgid "name"
 msgstr "nom"
 msgstr "nom"
 
 
-#: ffdnispdb/forms.py:64
+#: ffdnispdb/forms.py:107
 msgid "Area"
 msgid "Area"
 msgstr "Zone"
 msgstr "Zone"
 
 
-#: ffdnispdb/forms.py:65
+#: ffdnispdb/forms.py:108
 msgid "technologies"
 msgid "technologies"
 msgstr "technologies"
 msgstr "technologies"
 
 
-#: ffdnispdb/forms.py:66
+#: ffdnispdb/forms.py:109
 msgid "Technologies deployed"
 msgid "Technologies deployed"
 msgstr "Technologies déployées"
 msgstr "Technologies déployées"
 
 
-#: ffdnispdb/forms.py:72 ffdnispdb/forms.py:121
+#: ffdnispdb/forms.py:110
+msgid "area"
+msgstr "zone"
+
+#: ffdnispdb/forms.py:115 ffdnispdb/forms.py:166
 msgid "You must fill both fields"
 msgid "You must fill both fields"
 msgstr "Vous devez remplir les deux champs"
 msgstr "Vous devez remplir les deux champs"
 
 
-#: ffdnispdb/forms.py:78 ffdnispdb/templates/project_list_macro.html:5
+#: ffdnispdb/forms.py:121 ffdnispdb/templates/project_list_macro.html:5
 msgid "Name"
 msgid "Name"
 msgstr "Nom"
 msgstr "Nom"
 
 
-#: ffdnispdb/forms.py:79
+#: ffdnispdb/forms.py:122
 msgid "url"
 msgid "url"
 msgstr "url"
 msgstr "url"
 
 
-#: ffdnispdb/forms.py:79
+#: ffdnispdb/forms.py:122
 msgid "URL"
 msgid "URL"
 msgstr "URL"
 msgstr "URL"
 
 
-#: ffdnispdb/forms.py:84
+#: ffdnispdb/forms.py:129
 msgid "full name"
 msgid "full name"
 msgstr "nom complet"
 msgstr "nom complet"
 
 
-#: ffdnispdb/forms.py:84
+#: ffdnispdb/forms.py:129
 msgid "E.g. French Data Network"
 msgid "E.g. French Data Network"
 msgstr "E.g. French Data Network"
 msgstr "E.g. French Data Network"
 
 
-#: ffdnispdb/forms.py:86 ffdnispdb/templates/project_detail.html:26
+#: ffdnispdb/forms.py:131 ffdnispdb/templates/project_detail.html:26
 msgid "short name"
 msgid "short name"
 msgstr "nom court"
 msgstr "nom court"
 
 
-#: ffdnispdb/forms.py:86
+#: ffdnispdb/forms.py:131
 msgid "E.g. FDN"
 msgid "E.g. FDN"
 msgstr "E.g. FDN"
 msgstr "E.g. FDN"
 
 
-#: ffdnispdb/forms.py:88 ffdnispdb/templates/project_detail.html:30
+#: ffdnispdb/forms.py:133 ffdnispdb/templates/project_detail.html:30
 msgid "description"
 msgid "description"
 msgstr "description"
 msgstr "description"
 
 
-#: ffdnispdb/forms.py:88
+#: ffdnispdb/forms.py:133
 msgid "Short text describing the project"
 msgid "Short text describing the project"
 msgstr "Court texte décrivant le projet"
 msgstr "Court texte décrivant le projet"
 
 
-#: ffdnispdb/forms.py:89
+#: ffdnispdb/forms.py:134
 msgid "logo url"
 msgid "logo url"
 msgstr "url du logo"
 msgstr "url du logo"
 
 
-#: ffdnispdb/forms.py:90 ffdnispdb/templates/map_popup.html:12
+#: ffdnispdb/forms.py:135 ffdnispdb/templates/map_popup.html:12
 #: ffdnispdb/templates/project_detail.html:40
 #: ffdnispdb/templates/project_detail.html:40
 msgid "website"
 msgid "website"
 msgstr "site web"
 msgstr "site web"
 
 
-#: ffdnispdb/forms.py:93
+#: ffdnispdb/forms.py:138
 msgid "Additional websites that you host (e.g. wiki, etherpad...)"
 msgid "Additional websites that you host (e.g. wiki, etherpad...)"
 msgstr "Sites web additionnels que vous hébergez (e.g. wiki, etherpad...)"
 msgstr "Sites web additionnels que vous hébergez (e.g. wiki, etherpad...)"
 
 
-#: ffdnispdb/forms.py:94
+#: ffdnispdb/forms.py:139
 msgid "contact email"
 msgid "contact email"
 msgstr "email de contact"
 msgstr "email de contact"
 
 
-#: ffdnispdb/forms.py:95
+#: ffdnispdb/forms.py:140
 msgid "General contact email address"
 msgid "General contact email address"
 msgstr "Adresse email de contact généraliste"
 msgstr "Adresse email de contact généraliste"
 
 
-#: ffdnispdb/forms.py:96 ffdnispdb/templates/project_detail.html:54
+#: ffdnispdb/forms.py:141 ffdnispdb/templates/project_detail.html:54
 msgid "main mailing list"
 msgid "main mailing list"
 msgstr "liste de diffusion principale"
 msgstr "liste de diffusion principale"
 
 
-#: ffdnispdb/forms.py:97
+#: ffdnispdb/forms.py:142
 msgid "Address of your main mailing list"
 msgid "Address of your main mailing list"
 msgstr "Adresse de la liste de diffusion principale"
 msgstr "Adresse de la liste de diffusion principale"
 
 
-#: ffdnispdb/forms.py:98
+#: ffdnispdb/forms.py:143
 msgid "creation date"
 msgid "creation date"
 msgstr "date de création"
 msgstr "date de création"
 
 
-#: ffdnispdb/forms.py:98
+#: ffdnispdb/forms.py:143
 msgid "YYYY-mm-dd"
 msgid "YYYY-mm-dd"
 msgstr "AAAA-mm-jj"
 msgstr "AAAA-mm-jj"
 
 
-#: ffdnispdb/forms.py:99
+#: ffdnispdb/forms.py:144
 msgid "Date at which the legal structure for your project was created"
 msgid "Date at which the legal structure for your project was created"
 msgstr "Date de création de la structure légale de votre projet"
 msgstr "Date de création de la structure légale de votre projet"
 
 
-#: ffdnispdb/forms.py:100 ffdnispdb/templates/project_detail.html:80
+#: ffdnispdb/forms.py:145 ffdnispdb/templates/project_detail.html:80
 msgid "chatrooms"
 msgid "chatrooms"
 msgstr "salons de discussion"
 msgstr "salons de discussion"
 
 
-#: ffdnispdb/forms.py:101
+#: ffdnispdb/forms.py:146
 msgid ""
 msgid ""
 "In URI form, e.g. <code>irc://irc.isp.net/#isp</code> or <code>xmpp:isp@chat."
 "In URI form, e.g. <code>irc://irc.isp.net/#isp</code> or <code>xmpp:isp@chat."
 "isp.net?join</code>"
 "isp.net?join</code>"
@@ -173,70 +194,80 @@ msgstr ""
 "Sous la forme d'une URI, e.g. <code>irc://irc.isp.net/#isp</code> ou "
 "Sous la forme d'une URI, e.g. <code>irc://irc.isp.net/#isp</code> ou "
 "<code>xmpp:isp@chat.isp.net?join</code>"
 "<code>xmpp:isp@chat.isp.net?join</code>"
 
 
-#: ffdnispdb/forms.py:105
+#: ffdnispdb/forms.py:148
+msgid "Covered Areas"
+msgstr "Zones Couvertes"
+
+#: ffdnispdb/forms.py:150
 msgid "Descriptive name of the covered areas and technologies deployed"
 msgid "Descriptive name of the covered areas and technologies deployed"
 msgstr "Nom descriptif de la zone couverte et technologies déployées"
 msgstr "Nom descriptif de la zone couverte et technologies déployées"
 
 
-#: ffdnispdb/forms.py:106
+#: ffdnispdb/forms.py:151
 msgid "latitude"
 msgid "latitude"
 msgstr "latitude"
 msgstr "latitude"
 
 
-#: ffdnispdb/forms.py:107
+#: ffdnispdb/forms.py:152
 msgid ""
 msgid ""
 "Geographical coordinates of your registered office or usual meeting location."
 "Geographical coordinates of your registered office or usual meeting location."
 msgstr "Coordonées géographiques de votre siège ou lieu habituel de rencontre."
 msgstr "Coordonées géographiques de votre siège ou lieu habituel de rencontre."
 
 
-#: ffdnispdb/forms.py:108
+#: ffdnispdb/forms.py:153
 msgid "longitude"
 msgid "longitude"
 msgstr "longitude"
 msgstr "longitude"
 
 
-#: ffdnispdb/forms.py:109
+#: ffdnispdb/forms.py:154
 msgid "progress step"
 msgid "progress step"
 msgstr "étape de progression"
 msgstr "étape de progression"
 
 
-#: ffdnispdb/forms.py:110 ffdnispdb/templates/map_popup.html:18
+#: ffdnispdb/forms.py:155 ffdnispdb/templates/map_popup.html:18
 #: ffdnispdb/templates/project_detail.html:72
 #: ffdnispdb/templates/project_detail.html:72
 msgid "members"
 msgid "members"
 msgstr "membres"
 msgstr "membres"
 
 
-#: ffdnispdb/forms.py:111
+#: ffdnispdb/forms.py:156
 msgid "Number of members"
 msgid "Number of members"
 msgstr "Nombre de membres"
 msgstr "Nombre de membres"
 
 
-#: ffdnispdb/forms.py:112 ffdnispdb/templates/map_popup.html:21
+#: ffdnispdb/forms.py:157 ffdnispdb/templates/map_popup.html:21
 #: ffdnispdb/templates/project_detail.html:76
 #: ffdnispdb/templates/project_detail.html:76
 msgid "subscribers"
 msgid "subscribers"
 msgstr "abonnées"
 msgstr "abonnées"
 
 
-#: ffdnispdb/forms.py:113
+#: ffdnispdb/forms.py:158
 msgid "Number of subscribers to an internet access"
 msgid "Number of subscribers to an internet access"
 msgstr "Nombre d'abonnées à un accès à Internet"
 msgstr "Nombre d'abonnées à un accès à Internet"
 
 
-#: ffdnispdb/forms.py:115 ffdnispdb/forms.py:228
+#: ffdnispdb/forms.py:160 ffdnispdb/forms.py:289
 msgid "Email"
 msgid "Email"
 msgstr "Email"
 msgstr "Email"
 
 
-#: ffdnispdb/forms.py:116
+#: ffdnispdb/forms.py:161
 msgid "Technical contact, in case of problems with your submission"
 msgid "Technical contact, in case of problems with your submission"
 msgstr "Contact technique, en cas de problème"
 msgstr "Contact technique, en cas de problème"
 
 
-#: ffdnispdb/forms.py:128
+#: ffdnispdb/forms.py:173
 msgid "You must specify at least one area"
 msgid "You must specify at least one area"
 msgstr "Vous devez spécifier au moins une zone"
 msgstr "Vous devez spécifier au moins une zone"
 
 
-#: ffdnispdb/forms.py:209 ffdnispdb/forms.py:233
+#: ffdnispdb/forms.py:181
+#, python-format
+msgid "The size of all GeoJSON data combined must not exceed %(max_size)s"
+msgstr ""
+"La taille de toutes les données GeoJSON ne soit pas excéder %(max_size)s"
+
+#: ffdnispdb/forms.py:270 ffdnispdb/forms.py:294
 msgid "Invalid URL"
 msgid "Invalid URL"
 msgstr "URL invalide"
 msgstr "URL invalide"
 
 
-#: ffdnispdb/forms.py:225
+#: ffdnispdb/forms.py:286
 msgid "base url"
 msgid "base url"
 msgstr "url de base"
 msgstr "url de base"
 
 
-#: ffdnispdb/forms.py:225
+#: ffdnispdb/forms.py:286
 msgid "E.g. https://isp.com/"
 msgid "E.g. https://isp.com/"
 msgstr "E.g. https://isp.com/"
 msgstr "E.g. https://isp.com/"
 
 
-#: ffdnispdb/forms.py:226
+#: ffdnispdb/forms.py:287
 msgid ""
 msgid ""
 "A ressource implementing our JSON-Schema specification must exist at path /"
 "A ressource implementing our JSON-Schema specification must exist at path /"
 "isp.json"
 "isp.json"
@@ -244,31 +275,31 @@ msgstr ""
 "Une ressource implémentant notre spécification JSON-Schema doit exister au "
 "Une ressource implémentant notre spécification JSON-Schema doit exister au "
 "chemin /isp.json"
 "chemin /isp.json"
 
 
-#: ffdnispdb/forms.py:229
+#: ffdnispdb/forms.py:290
 msgid "Technical contact, in case of problems"
 msgid "Technical contact, in case of problems"
 msgstr "Contact technique, en cas de problèmes"
 msgstr "Contact technique, en cas de problèmes"
 
 
-#: ffdnispdb/forms.py:236
+#: ffdnispdb/forms.py:297
 msgid "Invalid URL (must be HTTP(S))"
 msgid "Invalid URL (must be HTTP(S))"
 msgstr "URL invalide (doit être HTTP(S))"
 msgstr "URL invalide (doit être HTTP(S))"
 
 
-#: ffdnispdb/forms.py:239
+#: ffdnispdb/forms.py:300
 msgid "This URL is already in our database"
 msgid "This URL is already in our database"
 msgstr "Cette URL est déjà dans notre base de données"
 msgstr "Cette URL est déjà dans notre base de données"
 
 
-#: ffdnispdb/forms.py:243
+#: ffdnispdb/forms.py:304
 msgid "Tech Email"
 msgid "Tech Email"
 msgstr "Email Technique"
 msgstr "Email Technique"
 
 
-#: ffdnispdb/forms.py:244
+#: ffdnispdb/forms.py:305
 msgid "The Technical contact you provided while registering"
 msgid "The Technical contact you provided while registering"
 msgstr "Le contact technique que vous avez fourni lors de l'enregistrement"
 msgstr "Le contact technique que vous avez fourni lors de l'enregistrement"
 
 
-#: ffdnispdb/views.py:163 ffdnispdb/views.py:177
+#: ffdnispdb/views.py:164 ffdnispdb/views.py:178
 msgid "Project modified"
 msgid "Project modified"
 msgstr "Projet modifié"
 msgstr "Projet modifié"
 
 
-#: ffdnispdb/views.py:212
+#: ffdnispdb/views.py:213
 msgid ""
 msgid ""
 "If you provided the correct email adress, you must will receive a message "
 "If you provided the correct email adress, you must will receive a message "
 "shortly (check your spam folder)"
 "shortly (check your spam folder)"
@@ -276,11 +307,11 @@ msgstr ""
 "Si vous avez fourni l'adresse correcte, vous allez recevoir un message sous "
 "Si vous avez fourni l'adresse correcte, vous allez recevoir un message sous "
 "peu (regardez dans votre dossier spam)"
 "peu (regardez dans votre dossier spam)"
 
 
-#: ffdnispdb/views.py:236 ffdnispdb/views.py:293
+#: ffdnispdb/views.py:237 ffdnispdb/views.py:295
 msgid "Project created"
 msgid "Project created"
 msgstr "Projet créé"
 msgstr "Projet créé"
 
 
-#: ffdnispdb/views.py:360
+#: ffdnispdb/views.py:362
 msgid "Automatic updates activated"
 msgid "Automatic updates activated"
 msgstr "Mises à jour automatiques activées"
 msgstr "Mises à jour automatiques activées"
 
 
@@ -364,6 +395,7 @@ msgstr "Valider"
 #: ffdnispdb/templates/gen_edit_token.html:14
 #: ffdnispdb/templates/gen_edit_token.html:14
 #: ffdnispdb/templates/project_form_generic.html:66
 #: ffdnispdb/templates/project_form_generic.html:66
 #: ffdnispdb/templates/project_json_form_generic.html:14
 #: ffdnispdb/templates/project_json_form_generic.html:14
+#: ffdnispdb/templates/site.js:76
 msgid "Cancel"
 msgid "Cancel"
 msgstr "Annuler"
 msgstr "Annuler"
 
 
@@ -511,6 +543,22 @@ msgstr "Réactivation des mises à jour de votre projet"
 msgid "No ISP matching your query was found :-("
 msgid "No ISP matching your query was found :-("
 msgstr "Aucun FAI corresponsant à votre requête n'a été trouvé :-("
 msgstr "Aucun FAI corresponsant à votre requête n'a été trouvé :-("
 
 
+#: ffdnispdb/templates/site.js:69
+msgid "GeoJSON Input"
+msgstr "Champ GeoJSON"
+
+#: ffdnispdb/templates/site.js:72
+msgid "Paste your GeoJSON here"
+msgstr "Collez votre GeoJSON ici"
+
+#: ffdnispdb/templates/site.js:77
+msgid "Done"
+msgstr "Fini"
+
+#: ffdnispdb/templates/site.js:141
+msgid "Find ISPs near you"
+msgstr "Trouvez des FAI proche de vous"
+
 #: ffdnispdb/templates/validator_generic.html:81
 #: ffdnispdb/templates/validator_generic.html:81
 msgid "Retry"
 msgid "Retry"
 msgstr "Réessayer"
 msgstr "Réessayer"

+ 21 - 1
ffdnispdb/views.py

@@ -3,7 +3,7 @@
 from flask import request, g, redirect, url_for, abort, \
 from flask import request, g, redirect, url_for, abort, \
     render_template, flash, json, session, Response, Markup, \
     render_template, flash, json, session, Response, Markup, \
     stream_with_context, current_app, Blueprint
     stream_with_context, current_app, Blueprint
-from flask.ext.babel import gettext as _
+from flask.ext.babel import gettext as _, get_locale
 from flask.ext.mail import Message
 from flask.ext.mail import Message
 import itsdangerous
 import itsdangerous
 import docutils.core
 import docutils.core
@@ -401,6 +401,22 @@ def humans():
     return Response(open(authors_file), mimetype='text/plain; charset=utf-8')
     return Response(open(authors_file), mimetype='text/plain; charset=utf-8')
 
 
 
 
+@ispdb.route('/site.js', methods=['GET'])
+def site_js():
+    l = get_locale()
+    js_i18n = cache.get('site_js_%s'%(l,))
+    if not js_i18n:
+        js_i18n = render_template('site.js')
+        cache.set('site_js_%s'%(l,), js_i18n, timeout=60*60)
+    r = Response(js_i18n, headers={
+        'Content-type': 'application/javascript',
+        'Cache-control': 'private, max-age=3600'
+    })
+    r.add_etag()
+    r.make_conditional(request)
+    return r
+
+
 #------
 #------
 # Filters
 # Filters
 
 
@@ -415,3 +431,7 @@ def step_to_label(step):
 def stepname(step):
 def stepname(step):
     return STEPS[step]
     return STEPS[step]
 
 
+@ispdb.app_template_filter('js_str')
+def json_filter(v):
+    return Markup(json.dumps(unicode(v)))
+

+ 1 - 0
requirements.txt

@@ -3,6 +3,7 @@ Flask-Babel==0.9
 Flask-SQLAlchemy==1.0
 Flask-SQLAlchemy==1.0
 Flask-WTF==0.9.1
 Flask-WTF==0.9.1
 Flask-Mail==0.9.0
 Flask-Mail==0.9.0
+Flask-Cache==0.12
 Jinja2==2.7.1
 Jinja2==2.7.1
 MarkupSafe==0.18
 MarkupSafe==0.18
 Werkzeug==0.9.3
 Werkzeug==0.9.3