Commit 307e23d1 authored by rgaudin's avatar rgaudin
Browse files

Fixed #330: added Nomad Android App content feature

parent 6ece3c4a
2.1.1 2.1.1
* Fixed an issue when downloading small files too fast * Fixed an issue when downloading small files too fast
* Added new content offer: Nomad Education Android APK
* Updated Kiwix to version 3.0.1-6
2.1.0 2.1.0
......
...@@ -33,11 +33,12 @@ language_name: "English" ...@@ -33,11 +33,12 @@ language_name: "English"
# versions # versions
qemu_kernel_version: "4.10.0" qemu_kernel_version: "4.10.0"
kernel_version: "4.14.34" kernel_version: "4.14.34"
kiwix_version: "3.0.1" kiwix_version: "3.0.1-6"
kalite_version: "0.17.4" kalite_version: "0.17.4"
edupi_version: "1.4.10" edupi_version: "1.4.10"
python3_version: "3.5" python3_version: "3.5"
php_version: "7.3" php_version: "7.3"
nomad_version: "2.7.0"
# Apps path # Apps path
venvs_root: /home/{{ username }}/venvs venvs_root: /home/{{ username }}/venvs
...@@ -53,6 +54,7 @@ wikifundi_root: "/var/www/wikifundi" ...@@ -53,6 +54,7 @@ wikifundi_root: "/var/www/wikifundi"
mediawiki_root: "{{ wikifundi_root }}/w" mediawiki_root: "{{ wikifundi_root }}/w"
parsoid_root: "{{ mediawiki_root }}/parsoid" parsoid_root: "{{ mediawiki_root }}/parsoid"
common_static_path: "/var/www/static" common_static_path: "/var/www/static"
nomad_root: "/var/www/nomad"
# Domain names # Domain names
kiwix_server_name: kiwix.{{ hostname }} kiwix_server_name: kiwix.{{ hostname }}
...@@ -60,6 +62,7 @@ kalite_server_name: khanacademy.{{ hostname }} ...@@ -60,6 +62,7 @@ kalite_server_name: khanacademy.{{ hostname }}
aflatoun_server_name: aflatoun.{{ hostname }} aflatoun_server_name: aflatoun.{{ hostname }}
edupi_server_name: edupi.{{ hostname }} edupi_server_name: edupi.{{ hostname }}
wikifundi_server_name: wikifundi.{{ hostname }} wikifundi_server_name: wikifundi.{{ hostname }}
nomad_server_name: nomad.{{ hostname }}
time_server_name: time.{{ hostname }} time_server_name: time.{{ hostname }}
kiwix_fqdn: kiwix.{{ fqdn }} kiwix_fqdn: kiwix.{{ fqdn }}
...@@ -67,6 +70,7 @@ kalite_fqdn: khanacademy.{{ fqdn }} ...@@ -67,6 +70,7 @@ kalite_fqdn: khanacademy.{{ fqdn }}
aflatoun_fqdn: aflatoun.{{ fqdn }} aflatoun_fqdn: aflatoun.{{ fqdn }}
edupi_fqdn: edupi.{{ fqdn }} edupi_fqdn: edupi.{{ fqdn }}
wikifundi_fqdn: wikifundi.{{ fqdn }} wikifundi_fqdn: wikifundi.{{ fqdn }}
nomad_fqdn: nomad.{{ fqdn }}
time_fqdn: time.{{ fqdn }} time_fqdn: time.{{ fqdn }}
# content & features # content & features
...@@ -87,3 +91,4 @@ kalite_videos_prefix: "{{ data_path }}/kalite_videos_" ...@@ -87,3 +91,4 @@ kalite_videos_prefix: "{{ data_path }}/kalite_videos_"
zim_path: "{{ data_path }}/packages" zim_path: "{{ data_path }}/packages"
wikifundi_langpack_prefix: "{{ data_path }}/wikifundi_langpack_" wikifundi_langpack_prefix: "{{ data_path }}/wikifundi_langpack_"
edupi_resources_path: "{{ data_path }}/edupi_resources" edupi_resources_path: "{{ data_path }}/edupi_resources"
nomad_content_path: "{{ data_path }}/nomad"
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
- role: captive_portal - role: captive_portal
# content setup (install, dependencies) # content setup (install, dependencies)
- role: nomad_setup
when: ansible_local.config.nomad|bool
- role: wikifundi_setup - role: wikifundi_setup
when: ansible_local.config.wikifundi_languages | length when: ansible_local.config.wikifundi_languages | length
......
...@@ -15,4 +15,9 @@ html[dir='rtl'] .card { ...@@ -15,4 +15,9 @@ html[dir='rtl'] .card {
background-size: 48px; background-size: 48px;
} }
.card.nomad {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAvCAYAAAClgknJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54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isie_nopic { background-image: url("http://library.kiwix.org/wikipedia_fr_tunisie_novid_2018-10/-/favicon"); } .card.zim_wikipedia_fr_tunisie_nopic { background-image: url("http://library.kiwix.org/wikipedia_fr_tunisie_novid_2018-10/-/favicon"); }
...@@ -862,7 +862,6 @@ html[dir='rtl'] .search input[type='submit'] { ...@@ -862,7 +862,6 @@ html[dir='rtl'] .search input[type='submit'] {
width: 50%; width: 50%;
} }
header { header {
margin-top: 20px;
flex-direction : column; flex-direction : column;
-webkit-flex-direction: column; -webkit-flex-direction: column;
-webkit-align-items: center; -webkit-align-items: center;
......
---
- name: Ensure directory exists
file:
path: "{{ nomad_root }}"
state: directory
owner: root
group: root
mode: 0755
tags: ['master', 'reconfigure']
- name: Ensure APK directory exists
file:
path: "{{ nomad_content_path }}"
state: directory
tags: ['master', 'reconfigure', 'content']
- name: install nginx vhost
template:
src: nginx.vhost.j2
dest: /etc/nginx/sites-available/nomad
mode: 0644
tags: ['master', 'rename', 'reconfigure']
- name: enable nomad vhost
file:
src: /etc/nginx/sites-available/nomad
dest: /etc/nginx/sites-enabled/nomad
state: link
force: yes
notify: restart nginx
tags: ['master', 'reconfigure']
- name: Copy static files
copy:
src: static
dest: "{{ nomad_root }}/"
tags: ['master', 'reconfigure']
- name: copy page
template:
src: index.html.j2
dest: "{{ nomad_root }}/index.html"
mode: 0644
tags: ['master', 'reconfigure']
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Nomad Education</title>
<link rel="icon" href="/static/favicon.png">
<link rel="stylesheet" href="/hotspot-static/font-awesome/css/font-awesome.min.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="/hotspot-static/purecss/pure-css-grids-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" type="text/css" href="/hotspot-static/purecss/pure-css-grids-min.css">
<!--<![endif]-->
<link rel="stylesheet" type="text/css" href="/hotspot-static/main.css" />
<link rel="stylesheet" type="text/css" href="/hotspot-static/branding/style.css" />
<style type="text/css">
.global-page-header {
background: linear-gradient(to bottom,#f38649 0%,#c15843 100%);
background-size: auto;
background-size: 100% 100%;
position: relative;
color: #fff;
}
.center {
text-align: center;
}
.app-icon {
float: right;
max-width: 100px;
}
.button {
background-color: #f38649;
}
ol, ul { list-style: decimal; }
header {
margin-bottom: 0;
}
</style>
</head>
<body class="">
<header class="global-page-header">
<section><a href="http://{{ fqdn }}/" title="retour à {{ project_name }}"><h1><img src="/static/logo_baseline.png"></img></h1></a></section>
</header>
<div class="content">
<p class="center"><a href="/download/ecoles_numeriques.apk" class="button">Télécharger l'appli Android <strong>Écoles Numériques</strong> v{{ nomad_version }}</a></p>
<div class="row">
<div class="col half">
<h2>Qu'est ce que c'est ?</h2>
<p><em>Écoles Numériques</em> est une application Android (pour téléphone ou tablette) réalisée par <em>Nomad Education</em>.</p>
<p>Cette application propose <strong>des Quizz et des mini-cours</strong> dans <u>toutes les matères</u>, du CP au CM2.</p>
<p>Pratique pour réviser en s'amusant !</p>
</div>
<div class="col half">
<img src="/static/screen-app.png"></img>
</div>
</div>
<h2>Comment l'utiliser ?</h2>
<img class="app-icon" src="/static/app-icon.png"></img>
<p>L'utilisation est particulièrement simple ; lancez l'installation sur votre appereil Android puis :</p>
<ol>
<li>Choisissez votre niveau du CP (1<sup>ère</sup> année) au CM2 (5<sup>ème</sup> année)</li>
<li>Choisissez une matière</li>
<li>Choisissez un sujet</li>
</ol>
<h2>Comment l'installer ?</h2>
<p>Concrairement aux autres contenus de <em>{{ project_name }}</em>, cet outil ne s'utilise pas en ligne mais doit être installé sur votre appareil Android (tablette ou téléphone).</p>
<ol>
<li>Cliquez sur le bouton de téléchargement en haut de cette page pour télécharger le fichier d'installation (fichier APK).</li>
<li>Lancez-le ensuite depuis votre navigateur s'il vous le propose ou depuis l'application <em>Fichiers</em> de votre appareil. Dans ce cas, il se trouvera dans le dossier <em>Téléchargements</em>.</li>
<li>En le lançant, suivez les instructions d'installation affichées à l'écran.</li>
<li>C'est fini, l'application <em>Écoles Numériques</em> est désormais accessible à coté des autres applications.</li>
</ol>
</div>
</body>
</html>
server {
listen 80;
server_name {{ nomad_fqdn }} {{ hostname }};
root {{ nomad_root }};
location /download/ { alias {{ nomad_content_path }}/; }
location /hotspot-static/ { alias {{ common_static_path }}/; expires 1y; }
location /502.html { internal; root /var/www; }
error_page 502 /502.html;
}
...@@ -107,5 +107,13 @@ ...@@ -107,5 +107,13 @@
"checksum": "ab155d0c66d3fde43ec7c99b28ef72a03c304e9f9dab1e0ca75332c7cb202ff5", "checksum": "ab155d0c66d3fde43ec7c99b28ef72a03c304e9f9dab1e0ca75332c7cb202ff5",
"archive_size": 22402590720, "archive_size": 22402590720,
"expanded_size": 26901218918 "expanded_size": 26901218918
},
"nomad_apk": {
"url": "{mirror}/other/nomad/nomadeducation-ecoles.apk",
"name": "ecoles_numeriques.apk",
"folder_name": null,
"checksum": "0b12025c5b49adc79547e6946b296e9db638df6900355aba0c910569b73bb893",
"archive_size": 37652894,
"expanded_size": 37652894
} }
} }
...@@ -102,6 +102,7 @@ def run_for_image(machine, root_partition_size, disk_size): ...@@ -102,6 +102,7 @@ def run_for_image(machine, root_partition_size, disk_size):
wifi_pwd="", wifi_pwd="",
edupi=True, edupi=True,
edupi_resources=None, edupi_resources=None,
nomad=True,
wikifundi_languages=["en", "fr"], wikifundi_languages=["en", "fr"],
aflatoun_languages=["en", "fr"], aflatoun_languages=["en", "fr"],
kalite_languages=["en", "fr", "es"], kalite_languages=["en", "fr", "es"],
...@@ -122,6 +123,7 @@ def build_extra_vars( ...@@ -122,6 +123,7 @@ def build_extra_vars(
wifi_pwd, wifi_pwd,
edupi, edupi,
edupi_resources, edupi_resources,
nomad,
wikifundi_languages, wikifundi_languages,
aflatoun_languages, aflatoun_languages,
kalite_languages, kalite_languages,
...@@ -149,6 +151,7 @@ def build_extra_vars( ...@@ -149,6 +151,7 @@ def build_extra_vars(
"aflatoun_languages": aflatoun_languages, "aflatoun_languages": aflatoun_languages,
"edupi": edupi, "edupi": edupi,
"edupi_has_resources": bool(edupi_resources), "edupi_has_resources": bool(edupi_resources),
"nomad": nomad,
"packages": packages, "packages": packages,
"custom_branding_path": "/tmp", "custom_branding_path": "/tmp",
"admin_account": "admin", "admin_account": "admin",
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# vim: ai ts=4 sts=4 et sw=4 nu # vim: ai ts=4 sts=4 et sw=4 nu
import os import os
import re
import json import json
import shutil import shutil
import itertools import itertools
...@@ -80,6 +79,7 @@ def get_remote_content(url): ...@@ -80,6 +79,7 @@ def get_remote_content(url):
def get_collection( def get_collection(
edupi=False, edupi=False,
edupi_resources=None, edupi_resources=None,
nomad=False,
packages=[], packages=[],
kalite_languages=[], kalite_languages=[],
wikifundi_languages=[], wikifundi_languages=[],
...@@ -116,6 +116,11 @@ def get_collection( ...@@ -116,6 +116,11 @@ def get_collection(
) )
) )
if nomad:
collection.append(
("NomadEducation", get_nomad_contents, run_nomad_actions, {"enable": nomad})
)
if len(packages): if len(packages):
collection.append( collection.append(
( (
...@@ -171,6 +176,11 @@ def get_edupi_contents(enable=False, resources_path=None): ...@@ -171,6 +176,11 @@ def get_edupi_contents(enable=False, resources_path=None):
return [get_alien_content(resources_path)] if resources_path else [] return [get_alien_content(resources_path)] if resources_path else []
def get_nomad_contents(enable=False):
""" nomad: only contains one APK """
return [get_content("nomad_apk")]
def get_kalite_contents(languages=[]): def get_kalite_contents(languages=[]):
""" kalite: medium lang packs and huge tarball of videos for each lang """ """ kalite: medium lang packs and huge tarball of videos for each lang """
...@@ -277,6 +287,22 @@ def run_edupi_actions( ...@@ -277,6 +287,22 @@ def run_edupi_actions(
) )
def run_nomad_actions(cache_folder, mount_point, logger, enable=False):
""" copy downloaded APK """
if not enable:
return
nomad_apk = get_content("nomad_apk")
nomad_folder = os.path.join(mount_point, "nomad")
os.makedirs(nomad_folder, exist_ok=True)
copy(
content=nomad_apk,
cache_folder=cache_folder,
final_path=os.path.join(nomad_folder, nomad_apk["name"]),
logger=logger,
)
def run_kalite_actions(cache_folder, mount_point, logger, languages=[]): def run_kalite_actions(cache_folder, mount_point, logger, languages=[]):
""" kalite: copy lang packs (ZIP) as-is and extract videos """ """ kalite: copy lang packs (ZIP) as-is and extract videos """
if not len(languages): if not len(languages):
...@@ -396,7 +422,7 @@ def get_collection_download_size_using_cache(collection, cache_folder): ...@@ -396,7 +422,7 @@ def get_collection_download_size_using_cache(collection, cache_folder):
) )
def get_expanded_size(collection): def get_expanded_size(collection, add_margin=True):
""" sum of extracted sizes of all collection with 10%|2GB margin """ """ sum of extracted sizes of all collection with 10%|2GB margin """
total_size = sum( total_size = sum(
[ [
...@@ -408,7 +434,7 @@ def get_expanded_size(collection): ...@@ -408,7 +434,7 @@ def get_expanded_size(collection):
) )
# add a 2% margin ; make sure it's at least 2GB # add a 2% margin ; make sure it's at least 2GB
margin = max([2 * ONE_GiB, total_size * 0.02]) margin = max([2 * ONE_GiB, total_size * 0.02]) if add_margin else 0
return total_size + margin return total_size + margin
......
...@@ -74,6 +74,27 @@ def generate_homepage(logger, options): ...@@ -74,6 +74,27 @@ def generate_homepage(logger, options):
} }
) )
if options["nomad"]:
edupi_fqdn = "nomad.{fqdn}".format(fqdn=fqdn)
if options["language"] == "fr":
title = "Écoles Numériques Android"
category = "Accès"
description = "Accès à l'application Android de Nomad Education"
else:
title = "Android Digital Schools"
category = "Access"
description = "Access to the Nomad Education Android App"
cards.append(
{
"url": "http://{}".format(edupi_fqdn),
"css_class": "nomad",
"category_class": "access",
"category": category,
"title": title,
"description": description,
}
)
if options["wikifundi_languages"]: if options["wikifundi_languages"]:
wikifundi_fqdn = "wikifundi.{fqdn}".format(fqdn=fqdn) wikifundi_fqdn = "wikifundi.{fqdn}".format(fqdn=fqdn)
if "fr" in options["wikifundi_languages"]: if "fr" in options["wikifundi_languages"]:
......
...@@ -125,7 +125,7 @@ def set_config(config, args): ...@@ -125,7 +125,7 @@ def set_config(config, args):
setif(arg_key, value) setif(arg_key, value)
# bool contents (switch) # bool contents (switch)
for key in ("edupi", "aflatoun"): for key in ("edupi", "aflatoun", "nomad"):
if config["content"].get(key) is not None: if config["content"].get(key) is not None:
vl = "yes" if config["content"][key] in ("yes", True) else "no" vl = "yes" if config["content"][key] in ("yes", True) else "no"
setif(key, vl) setif(key, vl)
...@@ -155,6 +155,7 @@ defaults = { ...@@ -155,6 +155,7 @@ defaults = {
"build_dir": ".", "build_dir": ".",
"catalog": False, "catalog": False,
"edupi": "no", "edupi": "no",
"nomad": "no",
"aflatoun": "no", "aflatoun": "no",
"kalite": [], "kalite": [],
"wikifundi": [], "wikifundi": [],
...@@ -177,6 +178,7 @@ parser.add_argument( ...@@ -177,6 +178,7 @@ parser.add_argument(
"--wikifundi", help="install wikifundi", choices=["fr", "en"], nargs="+" "--wikifundi", help="install wikifundi", choices=["fr", "en"], nargs="+"
) )
parser.add_argument("--edupi", help="install edupi", choices=["yes", "no"]) parser.add_argument("--edupi", help="install edupi", choices=["yes", "no"])
parser.add_argument("--nomad", help="install Nomad Education", choices=["yes", "no"])
parser.add_argument( parser.add_argument(
"--edupi-resources", help="Zipped folder of resources to init EduPi with" "--edupi-resources", help="Zipped folder of resources to init EduPi with"
) )
...@@ -303,6 +305,7 @@ for name in keys: ...@@ -303,6 +305,7 @@ for name in keys:
collection = get_collection( collection = get_collection(
edupi=args.edupi == "yes", edupi=args.edupi == "yes",
edupi_resources=args.edupi_resources, edupi_resources=args.edupi_resources,
nomad=args.nomad == "yes",
packages=args.zim_install, packages=args.zim_install,
kalite_languages=args.kalite, kalite_languages=args.kalite,
wikifundi_languages=args.wikifundi, wikifundi_languages=args.wikifundi,
...@@ -374,6 +377,7 @@ try: ...@@ -374,6 +377,7 @@ try:
aflatoun=args.aflatoun == "yes", aflatoun=args.aflatoun == "yes",
edupi=args.edupi == "yes", edupi=args.edupi == "yes",
edupi_resources=args.edupi_resources, edupi_resources=args.edupi_resources,
nomad=args.nomad == "yes",
zim_install=args.zim_install, zim_install=args.zim_install,
size=args.output_size, size=args.output_size,
logger=logger, logger=logger,
......
...@@ -472,7 +472,7 @@ class Application: ...@@ -472,7 +472,7 @@ class Application:
def get_project_size(name, lang): def get_project_size(name, lang):
langs = ["fr", "en"] if name == "aflatoun" else [lang] langs = ["fr", "en"] if name == "aflatoun" else [lang]
return get_expanded_size( return get_expanded_size(
get_collection(**{"{}_languages".format(name): langs}) get_collection(**{"{}_languages".format(name): langs}), add_margin=False
) )
# kalite # kalite
...@@ -523,6 +523,19 @@ class Application: ...@@ -523,6 +523,19 @@ class Application:
"file-set", lambda _: self.update_free_space() "file-set", lambda _: self.update_free_space()
) )
# nomad
self.component.nomad_switch.connect(
"notify::active", lambda switch, state: self.update_free_space()
)
self.component.nomad_label.set_label(
"{} ({})".format(
self.component.nomad_label.get_label(),
human_readable_size(
get_expanded_size(get_collection(nomad=True), add_margin=False)
),
)
)
self.refresh_disk_list() self.refresh_disk_list()
self.reset_config() # will calculate free space self.reset_config() # will calculate free space
...@@ -721,7 +734,7 @@ class Application: ...@@ -721,7 +734,7 @@ class Application:
for lang, button in getattr(self, "iter_{}_check_button".format(key))(): for lang, button in getattr(self, "iter_{}_check_button".format(key))():
button.set_active(False) button.set_active(False)
for key in ("edupi", "aflatoun"): for key in ("edupi", "aflatoun", "nomad"):
getattr(self.component, "{}_switch".format(key)).set_active(False) getattr(self.component, "{}_switch".format(key)).set_active(False)
# edupi resources # edupi resources
...@@ -1537,7 +1550,7 @@ class Application: ...@@ -1537,7 +1550,7 @@ class Application:
button.set_active(lang in config["content"][key]) button.set_active(lang in config["content"][key])
# boolean contents (switches) # boolean contents (switches)
for key in ("edupi", "aflatoun"): for key in ("edupi", "aflatoun", "nomad"):
if config["content"].get(key) is not None: if config["content"].get(key) is not None:
getattr(self.component, "{}_switch".format(key)).set_active( getattr(self.component, "{}_switch".format(key)).set_active(
config["content"][key] config["content"][key]
...@@ -1668,6 +1681,7 @@ class Application: ...@@ -1668,6 +1681,7 @@ class Application:
("aflatoun", self.component.aflatoun_switch.get_active()), ("aflatoun", self.component.aflatoun_switch.get_active()),
("edupi", self.component.edupi_switch.get_active()), ("edupi", self.component.edupi_switch.get_active()),
("edupi_resources", edupi_resources), ("edupi_resources", edupi_resources),
("nomad", self.component.nomad_switch.get_active()),
] ]
),