Commit 97dd3f60 authored by rgaudin's avatar rgaudin
Browse files

Fixed #331: simplified portal web page

- better language detection (dropping regional specifier)
- added /fake-register for rendering test
- updated french translation
- using a variable for disconnect interval
parent fa9e6873
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-10-07 10:52+0000\n" "POT-Creation-Date: 2019-10-14 10:24+0000\n"
"PO-Revision-Date: 2019-10-07 09:38+0000\n" "PO-Revision-Date: 2019-10-07 09:38+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n" "Language: fr\n"
...@@ -26,51 +26,29 @@ msgstr "connecté" ...@@ -26,51 +26,29 @@ msgstr "connecté"
msgid "Offline" msgid "Offline"
msgstr "hors-ligne" msgstr "hors-ligne"
#: portal/templates/portal.html:3 #: portal/templates/portal.html:4
#, python-format #, python-format
msgid "Entering “<em>%(hotspot_name)s</em>" msgid "Welcome to <em>%(project_name)s</em> Hotspot."
msgstr "Connection à «<em>%(hotspot_name)s</em>»" msgstr "Bienvenue sur le Hotspot <em>%(project_name)s</em>."
#: portal/templates/portal.html:6 #: portal/templates/portal.html:5
#, python-format msgid "Access your content via: "
msgid "<em>%(project_name)s</em> is a free-to-use, content-enabled box." msgstr "Accèdez aux contenus via :"
msgstr "<em>%(project_name)s</em> est une ressource de contenus libres d'accès"
#: portal/templates/portal.html:7
msgid "Please, keep the following in mind:"
msgstr "Merci de vous rappeler des points suivants :"
#: portal/templates/portal.html:8 #: portal/templates/portal.html:5
#, python-format msgid "Copy to clipboard"
msgid "" msgstr "Copier l'adresse"
"Access to this box's content is done <strong>solely via "
"<em>http://%(fqdn)s/</em></strong>."
msgstr ""
"L'accès à ces contenus ne se fait <strong>qu'à travers "
"<em>http://%(fqdn)s/</em></strong>."
#: portal/templates/portal.html:8 #: portal/templates/portal.html:8
msgid "Remember-it !"
msgstr "Souvenez-vous en !"
#: portal/templates/portal.html:9
#, python-format
msgid ""
"This box may also provide access to Internet (currently "
"%(colored_status)s)"
msgstr ""
"Cette ressource pourrait fournir un accès"
" à Internet (actuellement %(colored_status)s)."
#: portal/templates/portal.html:10
msgid "" msgid ""
"You will then be prompted with this page <strong>after every " "<strong>You need to <u>manually</u> go to</strong> (use copy-paste) that "
"15mn</strong> of inactivity." "address as clicking on the button bellow might close this web page."
msgstr "" msgstr ""
"Cette page vous sera alors présenté <strong>après 15mn</strong> " "<strong>Vous devez <u>manuellement</u> (utilisez le copier-coller) aller "
"d'inactivité." "à</strong> cette addresse car après avoir cliqué sur le bouton ci-"
"dessous, cette page risque de se fermer."
#: portal/templates/portal.html:11 #: portal/templates/portal.html:12
msgid "" msgid ""
"When browsing a secure website, your browser might display a <em>Security" "When browsing a secure website, your browser might display a <em>Security"
" Warning</em> instead of displaying this page. Just open a new page onto " " Warning</em> instead of displaying this page. Just open a new page onto "
...@@ -81,33 +59,19 @@ msgstr "" ...@@ -81,33 +59,19 @@ msgstr ""
"en simplement une nouvelle sur un site non-sécurisé et enregistrez-vous à" "en simplement une nouvelle sur un site non-sécurisé et enregistrez-vous à"
" nouveau." " nouveau."
#: portal/templates/portal.html:15 #: portal/templates/portal.html:13
msgid "Action Required!" #, python-format
msgstr "Action requise !"
#: portal/templates/portal.html:16
msgid ""
"After you click the button bellow, <strong>you need to <u>manually</u> go"
" to</strong>:"
msgstr ""
"Après avoir cliqué sur le bouton ci-dessous, <strong>vous devrez "
"<u>manuellement</u> aller à</strong> :"
#: portal/templates/portal.html:17
msgid "Copy to clipboard"
msgstr "Copier l'adresse"
#: portal/templates/portal.html:18
msgid "" msgid ""
"Open your Web browser copy-paste or type this address there then click " "You will be disconnected after %(interval)smn of inactivity: use this "
"bellow." "address to reconnect."
msgstr "" msgstr ""
"Ouvrez votre navigateur Web et collez ou saisissez cette adresse ; puis " "Vous serez déconnecté après %(interval)smn"
"cliquez ci-dessous." " d'innactivité. Utilisez cette adresse pour"
" vous reconnecter."
#: portal/templates/portal.html:20 #: portal/templates/portal.html:16
msgid "Agree to register and close" msgid "Agree and register"
msgstr "OK pour continuer" msgstr "S'enregistrer"
#: portal/templates/registered.html:3 #: portal/templates/registered.html:3
#, python-format #, python-format
...@@ -134,14 +98,14 @@ msgstr "" ...@@ -134,14 +98,14 @@ msgstr ""
"text=\"http://%(fqdn)s/\">%(fqdn)s</button> en suivant les instructions " "text=\"http://%(fqdn)s/\">%(fqdn)s</button> en suivant les instructions "
"précédentes." "précédentes."
#: portal/templates/registered.html:11 #: portal/templates/registered.html:10
#, python-format #, python-format
msgid "You're now ready to access <em>%(project_name)s's content</em>." msgid "You're now ready to access <em>%(project_name)s's content</em>."
msgstr "" msgstr ""
"Vous êtes désormais prêt à accèder aux <em>contenus de " "Vous êtes désormais prêt à accèder aux <em>contenus de "
"%(project_name)s</em>." "%(project_name)s</em>."
#: portal/templates/registered.html:12 #: portal/templates/registered.html:11
#, python-format #, python-format
msgid "Go to %(fqdn)s" msgid "Go to %(fqdn)s"
msgstr "Aller à %(fqdn)s" msgstr "Aller à %(fqdn)s"
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-10-07 10:52+0000\n" "POT-Creation-Date: 2019-10-14 10:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -25,73 +25,41 @@ msgstr "" ...@@ -25,73 +25,41 @@ msgstr ""
msgid "Offline" msgid "Offline"
msgstr "" msgstr ""
#: portal/templates/portal.html:3 #: portal/templates/portal.html:4
#, python-format #, python-format
msgid "Entering “<em>%(hotspot_name)s</em>" msgid "Welcome to <em>%(project_name)s</em> Hotspot."
msgstr "" msgstr ""
#: portal/templates/portal.html:6 #: portal/templates/portal.html:5
#, python-format msgid "Access your content via: "
msgid "<em>%(project_name)s</em> is a free-to-use, content-enabled box."
msgstr ""
#: portal/templates/portal.html:7
msgid "Please, keep the following in mind:"
msgstr "" msgstr ""
#: portal/templates/portal.html:8 #: portal/templates/portal.html:5
#, python-format msgid "Copy to clipboard"
msgid ""
"Access to this box's content is done <strong>solely via "
"<em>http://%(fqdn)s/</em></strong>."
msgstr "" msgstr ""
#: portal/templates/portal.html:8 #: portal/templates/portal.html:8
msgid "Remember-it !"
msgstr ""
#: portal/templates/portal.html:9
#, python-format
msgid ""
"This box may also provide access to Internet (currently "
"%(colored_status)s)"
msgstr ""
#: portal/templates/portal.html:10
msgid "" msgid ""
"You will then be prompted with this page <strong>after every " "<strong>You need to <u>manually</u> go to</strong> (use copy-paste) that "
"15mn</strong> of inactivity." "address as clicking on the button bellow might close this web page."
msgstr "" msgstr ""
#: portal/templates/portal.html:11 #: portal/templates/portal.html:12
msgid "" msgid ""
"When browsing a secure website, your browser might display a <em>Security" "When browsing a secure website, your browser might display a <em>Security"
" Warning</em> instead of displaying this page. Just open a new page onto " " Warning</em> instead of displaying this page. Just open a new page onto "
"a non-secure website to register again." "a non-secure website to register again."
msgstr "" msgstr ""
#: portal/templates/portal.html:15 #: portal/templates/portal.html:13
msgid "Action Required!" #, python-format
msgstr ""
#: portal/templates/portal.html:16
msgid ""
"After you click the button bellow, <strong>you need to <u>manually</u> go"
" to</strong>:"
msgstr ""
#: portal/templates/portal.html:17
msgid "Copy to clipboard"
msgstr ""
#: portal/templates/portal.html:18
msgid "" msgid ""
"Open your Web browser copy-paste or type this address there then click " "You will be disconnected after %(interval)smn of inactivity: use this "
"bellow." "address to reconnect."
msgstr "" msgstr ""
#: portal/templates/portal.html:20 #: portal/templates/portal.html:16
msgid "Agree to register and close" msgid "Agree and register"
msgstr "" msgstr ""
#: portal/templates/registered.html:3 #: portal/templates/registered.html:3
...@@ -113,12 +81,12 @@ msgid "" ...@@ -113,12 +81,12 @@ msgid ""
"text=\"http://%(fqdn)s/\">%(fqdn)s</button> as instructed earlier." "text=\"http://%(fqdn)s/\">%(fqdn)s</button> as instructed earlier."
msgstr "" msgstr ""
#: portal/templates/registered.html:11 #: portal/templates/registered.html:10
#, python-format #, python-format
msgid "You're now ready to access <em>%(project_name)s's content</em>." msgid "You're now ready to access <em>%(project_name)s's content</em>."
msgstr "" msgstr ""
#: portal/templates/registered.html:12 #: portal/templates/registered.html:11
#, python-format #, python-format
msgid "Go to %(fqdn)s" msgid "Go to %(fqdn)s"
msgstr "" msgstr ""
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" href="/hotspot-static/main.css" /> <link rel="stylesheet" type="text/css" href="/hotspot-static/main.css" />
<link rel="stylesheet" type="text/css" href="/hotspot-static/branding/style.css" /> <link rel="stylesheet" type="text/css" href="/hotspot-static/branding/style.css" />
<script src="/hotspot-static/clipboard.min.js"></script> <script src="/hotspot-static/clipboard.min.js"></script>
<style type="text/css">ul { list-style-type: initial; padding-left: 1em; }</style>
</head> </head>
<body class=""> <body class="">
<header> <header>
...@@ -27,9 +28,6 @@ ...@@ -27,9 +28,6 @@
<span class="boxid">{{ project_name }}!</span> <span class="boxid">{{ project_name }}!</span>
</section> </section>
</header> </header>
<ul class="messages">
{% block intro %}{% endblock %}
</ul>
<div class="content"> <div class="content">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
......
{% extends "base.html" %} {% extends "base.html" %}
{% block intro %}<li class="info">{% trans %}Entering “<em>{{ hotspot_name }}</em>”{% endtrans %} (<a href="http://{{ fqdn }}/">{{ fqdn }}</a>)</li>{% endblock %}
{% block content %} {% block content %}
<h2>{% trans %}<em>{{ project_name }}</em> is a free-to-use, content-enabled box.{% endtrans %}</h2> <h2>{% trans %}Welcome to <em>{{ project_name }}</em> Hotspot.{% endtrans %}</h2>
<p class="underline">{% trans %}Please, keep the following in mind:{% endtrans %}</p> <p>{% trans %}Access your content via: {% endtrans %} <code>http://{{ fqdn }}/</code> <button class="clipboard button button-sm neutral" data-clipboard-text="http://{{ fqdn }}/">{% trans %}Copy to clipboard{% endtrans %}</button></p>
<ul><li>{% trans %}Access to this box's content is done <strong>solely via <em>http://{{ fqdn }}/</em></strong>.{% endtrans %} <span class="underline">{% trans %}Remember-it !{% endtrans %}</li>
<li>{% trans colored_status=internet_status|colored_status|safe %}This box may also provide access to Internet (currently {{ colored_status }}){% endtrans %}</li>
<li>{% trans %}You will then be prompted with this page <strong>after every 15mn</strong> of inactivity.{% endtrans %}</li>
<li>{% trans %}When browsing a secure website, your browser might display a <em>Security Warning</em> instead of displaying this page. Just open a new page onto a non-secure website to register again.{% endtrans %}</li>
</ul>
<hr />
{% if action_required %} {% if action_required %}
<h2>{% trans %}Action Required!{% endtrans %}</h2> <p>{% trans %}<strong>You need to <u>manually</u> go to</strong> (use copy-paste) that address as clicking on the button bellow might close this web page.{% endtrans %}</p>
<p>{% trans %}After you click the button bellow, <strong>you need to <u>manually</u> go to</strong>:{% endtrans %}</p> <hr />
<p><code>http://{{ fqdn }}/</code> <button class="clipboard button neutral" data-clipboard-text="http://{{ fqdn }}/">{% trans %}Copy to clipboard{% endtrans %}</button></p>
<p>{% trans %}Open your Web browser copy-paste or type this address there then click bellow.{% endtrans %}</p>
{% endif %} {% endif %}
<p><a class="button" href="/hotspot-register">{% trans %}Agree to register and close{% endtrans %}</a></p> <ul>
<li>{% trans %}When browsing a secure website, your browser might display a <em>Security Warning</em> instead of displaying this page. Just open a new page onto a non-secure website to register again.{% endtrans %}</li>
<li>{% trans interval=interval|int %}You will be disconnected after {{ interval }}mn of inactivity: use this address to reconnect.{% endtrans %}</li>
</ul>
<p><a class="button" href="/hotspot-register">{% trans %}Agree and register{% endtrans %}</a></p>
{% endblock %} {% endblock %}
{% extends "base.html" %} {% extends "base.html" %}
{% block intro %}<li class="success">{% trans %}Registered to “<em>{{ hotspot_name }}</em>” (<a href="http://{{ fqdn }}/">{{ fqdn }}</a>){% endtrans %}</li>{% endblock %}
{% block content %} {% block content %}
<h2>{% trans %}You're all set!{% endtrans %}</h2> <h2>{% trans %}You're all set!{% endtrans %}</h2>
{% if action_required %} {% if action_required %}
......
...@@ -32,6 +32,7 @@ import platform ...@@ -32,6 +32,7 @@ import platform
import subprocess import subprocess
import flask import flask
import werkzeug
from flask import Flask, request, render_template from flask import Flask, request, render_template
from flask_babel import Babel from flask_babel import Babel
...@@ -45,6 +46,7 @@ from portal.utils import ( ...@@ -45,6 +46,7 @@ from portal.utils import (
is_ubuntu_request, is_ubuntu_request,
is_firefox_request, is_firefox_request,
is_microsoft_request, is_microsoft_request,
REGISTRATION_TIMEOUT,
is_microsoft_ncsi_request, is_microsoft_ncsi_request,
) )
from portal.database import User from portal.database import User
...@@ -64,7 +66,16 @@ app.jinja_env.filters["colored_status"] = colored_status ...@@ -64,7 +66,16 @@ app.jinja_env.filters["colored_status"] = colored_status
@babel.localeselector @babel.localeselector
def get_locale(): def get_locale():
return request.accept_languages.best_match(["fr", "en"]) """ select locale from HTTP Accept-Languages header value
Dropping regional specifier as we handle offer bare-language translations """
supported_languages = ["fr", "en"]
try:
return werkzeug.datastructures.LanguageAccept(
[(al[0].split("-", 1)[0], al[1]) for al in request.accept_languages]
).best_match(supported_languages)
except Exception:
return supported_languages[-1]
def get_branding_context(): def get_branding_context():
...@@ -73,6 +84,7 @@ def get_branding_context(): ...@@ -73,6 +84,7 @@ def get_branding_context():
"hotspot_name": os.getenv("HOTSPOT_NAME", "default"), "hotspot_name": os.getenv("HOTSPOT_NAME", "default"),
"fqdn": os.getenv("FQDN", "default.hotspot"), "fqdn": os.getenv("FQDN", "default.hotspot"),
"internet_status": "online" if has_internet() else "offline", "internet_status": "online" if has_internet() else "offline",
"interval": REGISTRATION_TIMEOUT / 60,
} }
...@@ -232,6 +244,15 @@ def entrypoint(u_path): ...@@ -232,6 +244,15 @@ def entrypoint(u_path):
return render_template("portal.html", **context) return render_template("portal.html", **context)
@app.route("/fake-register")
def fake_register():
""" just display registered page """
user = create_user(request)
context = {"user": user, "action_required": not user.is_apple}
context.update(get_branding_context())
return render_template("registered.html", **context)
@app.route("/hotspot-register") @app.route("/hotspot-register")
def register(): def register():
""" record that user passed portal and should be considered online and informed """ """ record that user passed portal and should be considered online and informed """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment