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 ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
......@@ -26,51 +26,29 @@ msgstr "connecté"
msgid "Offline"
msgstr "hors-ligne"
#: portal/templates/portal.html:3
#: portal/templates/portal.html:4
#, python-format
msgid "Entering “<em>%(hotspot_name)s</em>"
msgstr "Connection à «<em>%(hotspot_name)s</em>»"
msgid "Welcome to <em>%(project_name)s</em> Hotspot."
msgstr "Bienvenue sur le Hotspot <em>%(project_name)s</em>."
#: portal/templates/portal.html:6
#, python-format
msgid "<em>%(project_name)s</em> is a free-to-use, content-enabled box."
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:5
msgid "Access your content via: "
msgstr "Accèdez aux contenus via :"
#: portal/templates/portal.html:8
#, python-format
msgid ""
"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:5
msgid "Copy to clipboard"
msgstr "Copier l'adresse"
#: 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 ""
"You will then be prompted with this page <strong>after every "
"15mn</strong> of inactivity."
"<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."
msgstr ""
"Cette page vous sera alors présenté <strong>après 15mn</strong> "
"d'inactivité."
"<strong>Vous devez <u>manuellement</u> (utilisez le copier-coller) aller "
"à</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 ""
"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 "
......@@ -81,33 +59,19 @@ msgstr ""
"en simplement une nouvelle sur un site non-sécurisé et enregistrez-vous à"
" nouveau."
#: portal/templates/portal.html:15
msgid "Action Required!"
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
#: portal/templates/portal.html:13
#, python-format
msgid ""
"Open your Web browser copy-paste or type this address there then click "
"bellow."
"You will be disconnected after %(interval)smn of inactivity: use this "
"address to reconnect."
msgstr ""
"Ouvrez votre navigateur Web et collez ou saisissez cette adresse ; puis "
"cliquez ci-dessous."
"Vous serez déconnecté après %(interval)smn"
" d'innactivité. Utilisez cette adresse pour"
" vous reconnecter."
#: portal/templates/portal.html:20
msgid "Agree to register and close"
msgstr "OK pour continuer"
#: portal/templates/portal.html:16
msgid "Agree and register"
msgstr "S'enregistrer"
#: portal/templates/registered.html:3
#, python-format
......@@ -134,14 +98,14 @@ msgstr ""
"text=\"http://%(fqdn)s/\">%(fqdn)s</button> en suivant les instructions "
"précédentes."
#: portal/templates/registered.html:11
#: portal/templates/registered.html:10
#, python-format
msgid "You're now ready to access <em>%(project_name)s's content</em>."
msgstr ""
"Vous êtes désormais prêt à accèder aux <em>contenus de "
"%(project_name)s</em>."
#: portal/templates/registered.html:12
#: portal/templates/registered.html:11
#, python-format
msgid "Go to %(fqdn)s"
msgstr "Aller à %(fqdn)s"
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -25,73 +25,41 @@ msgstr ""
msgid "Offline"
msgstr ""
#: portal/templates/portal.html:3
#: portal/templates/portal.html:4
#, python-format
msgid "Entering “<em>%(hotspot_name)s</em>"
msgid "Welcome to <em>%(project_name)s</em> Hotspot."
msgstr ""
#: portal/templates/portal.html:6
#, python-format
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:"
#: portal/templates/portal.html:5
msgid "Access your content via: "
msgstr ""
#: portal/templates/portal.html:8
#, python-format
msgid ""
"Access to this box's content is done <strong>solely via "
"<em>http://%(fqdn)s/</em></strong>."
#: portal/templates/portal.html:5
msgid "Copy to clipboard"
msgstr ""
#: 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 ""
"You will then be prompted with this page <strong>after every "
"15mn</strong> of inactivity."
"<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."
msgstr ""
#: portal/templates/portal.html:11
#: portal/templates/portal.html:12
msgid ""
"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."
msgstr ""
#: portal/templates/portal.html:15
msgid "Action Required!"
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
#: portal/templates/portal.html:13
#, python-format
msgid ""
"Open your Web browser copy-paste or type this address there then click "
"bellow."
"You will be disconnected after %(interval)smn of inactivity: use this "
"address to reconnect."
msgstr ""
#: portal/templates/portal.html:20
msgid "Agree to register and close"
#: portal/templates/portal.html:16
msgid "Agree and register"
msgstr ""
#: portal/templates/registered.html:3
......@@ -113,12 +81,12 @@ msgid ""
"text=\"http://%(fqdn)s/\">%(fqdn)s</button> as instructed earlier."
msgstr ""
#: portal/templates/registered.html:11
#: portal/templates/registered.html:10
#, python-format
msgid "You're now ready to access <em>%(project_name)s's content</em>."
msgstr ""
#: portal/templates/registered.html:12
#: portal/templates/registered.html:11
#, python-format
msgid "Go to %(fqdn)s"
msgstr ""
......
......@@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" href="/hotspot-static/main.css" />
<link rel="stylesheet" type="text/css" href="/hotspot-static/branding/style.css" />
<script src="/hotspot-static/clipboard.min.js"></script>
<style type="text/css">ul { list-style-type: initial; padding-left: 1em; }</style>
</head>
<body class="">
<header>
......@@ -27,9 +28,6 @@
<span class="boxid">{{ project_name }}!</span>
</section>
</header>
<ul class="messages">
{% block intro %}{% endblock %}
</ul>
<div class="content">
{% block content %}{% endblock %}
</div>
......
{% 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 %}
<h2>{% trans %}<em>{{ project_name }}</em> is a free-to-use, content-enabled box.{% endtrans %}</h2>
<p class="underline">{% trans %}Please, keep the following in mind:{% endtrans %}</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 />
<h2>{% trans %}Welcome to <em>{{ project_name }}</em> Hotspot.{% endtrans %}</h2>
<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>
{% if action_required %}
<h2>{% trans %}Action Required!{% endtrans %}</h2>
<p>{% trans %}After you click the button bellow, <strong>you need to <u>manually</u> go to</strong>:{% endtrans %}</p>
<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>
<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>
<hr />
{% 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 %}
{% 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 %}
<h2>{% trans %}You're all set!{% endtrans %}</h2>
{% if action_required %}
......
......@@ -32,6 +32,7 @@ import platform
import subprocess
import flask
import werkzeug
from flask import Flask, request, render_template
from flask_babel import Babel
......@@ -45,6 +46,7 @@ from portal.utils import (
is_ubuntu_request,
is_firefox_request,
is_microsoft_request,
REGISTRATION_TIMEOUT,
is_microsoft_ncsi_request,
)
from portal.database import User
......@@ -64,7 +66,16 @@ app.jinja_env.filters["colored_status"] = colored_status
@babel.localeselector
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():
......@@ -73,6 +84,7 @@ def get_branding_context():
"hotspot_name": os.getenv("HOTSPOT_NAME", "default"),
"fqdn": os.getenv("FQDN", "default.hotspot"),
"internet_status": "online" if has_internet() else "offline",
"interval": REGISTRATION_TIMEOUT / 60,
}
......@@ -232,6 +244,15 @@ def entrypoint(u_path):
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")
def register():
""" 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