diff --git a/app/LICENSE.txt b/app/LICENSE.txt new file mode 100644 index 0000000..ee09b94 --- /dev/null +++ b/app/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 PyQuest contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/css/base.css b/app/css/base.css index 023ecc5..dd4fb90 100644 --- a/app/css/base.css +++ b/app/css/base.css @@ -359,3 +359,91 @@ pre { .voices-message:empty { display: none; } + +/* Bandeau : ce que fait PyQuest, en une ligne sous le titre. */ +.app-tagline { + margin: 0; + color: var(--muted); + font-size: 0.8125rem; + line-height: 1.3; +} + +.brand > div { + min-width: 0; +} + +/* Pied de page : droits, contact, licence, à propos. */ +.app-footer { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 0.5rem 1.5rem; + margin-top: 2rem; + padding: 1rem; + border-top: 1px solid var(--border); + background: var(--surface); + color: var(--muted); + font-size: 0.875rem; +} + +.app-footer p { + margin: 0; +} + +.footer-links { + display: flex; + flex-wrap: wrap; + gap: 0.25rem 1.25rem; +} + +.app-footer a, +.link-button { + color: var(--link, var(--accent)); + text-decoration: underline; +} + +/* Bouton d'apparence de lien : vraie commande clavier, cible assez grande. */ +.link-button { + min-height: 2.75rem; + padding: 0 0.25rem; + background: none; + border: 0; + font: inherit; + cursor: pointer; +} + +.app-footer a { + display: inline-flex; + align-items: center; + min-height: 2.75rem; +} + +/* Panneau « À propos ». */ +.about-section h3 { + margin: 1.25rem 0 0.25rem; + font-size: 1.05rem; +} + +.about-section:first-child h3 { + margin-top: 0; +} + +.about-credits { + padding-left: 1.25rem; + font-size: 0.9rem; +} + +/* Le pied de page reste en bas de la fenêtre même quand le contenu est court. */ +#app-root { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +#notebook-region { + flex: 1; +} + +.app-footer { + align-items: center; +} diff --git a/app/index.html b/app/index.html index 0086a86..6be44bb 100644 --- a/app/index.html +++ b/app/index.html @@ -4,7 +4,8 @@ - PyQuest + PyQuest — apprendre Python par la pratique + @@ -22,7 +23,10 @@
-

PyQuest

+
+

PyQuest

+

+
diff --git a/app/js/i18n/en.json b/app/js/i18n/en.json index 7422a2c..e0ac695 100644 --- a/app/js/i18n/en.json +++ b/app/js/i18n/en.json @@ -145,5 +145,35 @@ "voices.download": "Download the voices for offline use", "voices.downloading": "Downloading: {done} of {total}…", "voices.done": "Voices downloaded: they will be read even without a connection.", - "voices.failed": "{failed} file(s) could not be downloaded. Try again with a connection." + "voices.failed": "{failed} file(s) could not be downloaded. Try again with a connection.", + "app.tagline": "Learn Python by doing, in your browser: no installation, even offline.", + "app.docTitle": "PyQuest — learn Python by doing", + "footer.copyright": "© {year} PyQuest", + "footer.license": "MIT licence", + "footer.about": "About and credits", + "about.title": "About PyQuest", + "about.what.title": "What is PyQuest?", + "about.what.text": "PyQuest teaches you Python by practising it: 15 levels, short explanations, guided exercises with hints, errors explained in plain language and a mission in every level. The Python you write is real Python, run right in your browser.", + "about.how.title": "How it works", + "about.how.1": "Everything happens in your browser: nothing to install, and the app works without a connection once loaded.", + "about.how.2": "Your progress (points, badges, day streak) stays on your device. You can save it to a file or, if your instance offers it, sync it between devices without creating an account.", + "about.how.3": "No ads, no analytics, no third-party service.", + "about.how.4": "Accessible: full keyboard use, light and dark themes, adjustable text size, sound and voice always switchable off.", + "about.license.title": "Licence", + "about.license.text": "© {year} PyQuest. Free software, released under the MIT licence: you may use, copy, modify and share it, as long as you keep the copyright notice and the licence text. It comes without warranty.", + "about.license.read": "Read the full text of the MIT licence", + "about.contact.title": "Contact", + "about.contact.text": "A question, a mistake, an idea for a level:", + "about.credits.title": "Credits", + "about.credits.intro": "PyQuest builds on free software and resources:", + "about.credit.python": "the Python language", + "about.credit.pyodide": "Python in the browser (WebAssembly)", + "about.credit.piper": "speech synthesis, used to produce the voices (build tool, not shipped)", + "about.credit.voice_fr": "data behind the French voice (University of Edinburgh)", + "about.credit.voice_en": "data behind the English voice", + "about.credit.font": "text font", + "about.credit.font_code": "code font", + "about.credit.yaml": "reading level files", + "about.credit.schema": "validating levels", + "about.credits.cc": "French voice: model trained on the SIWIS database (Honnet et al., University of Edinburgh), licence CC BY 4.0: https://creativecommons.org/licenses/by/4.0/. Sound effects are synthesised in your browser, without samples." } diff --git a/app/js/i18n/fr.json b/app/js/i18n/fr.json index 85ec462..7bef1dd 100644 --- a/app/js/i18n/fr.json +++ b/app/js/i18n/fr.json @@ -145,5 +145,35 @@ "voices.download": "Télécharger les voix pour le hors ligne", "voices.downloading": "Téléchargement : {done} sur {total}…", "voices.done": "Voix téléchargées : elles seront lues même sans connexion.", - "voices.failed": "{failed} fichier(s) n'ont pas pu être téléchargés. Réessaie avec une connexion." + "voices.failed": "{failed} fichier(s) n'ont pas pu être téléchargés. Réessaie avec une connexion.", + "app.tagline": "Apprendre Python par la pratique, dans ton navigateur : sans installation, même hors ligne.", + "app.docTitle": "PyQuest — apprendre Python par la pratique", + "footer.copyright": "© {year} PyQuest", + "footer.license": "Licence MIT", + "footer.about": "À propos et crédits", + "about.title": "À propos de PyQuest", + "about.what.title": "Qu'est-ce que PyQuest ?", + "about.what.text": "PyQuest t'apprend Python en le pratiquant : 15 niveaux, des explications courtes, des exercices guidés avec indices, des erreurs expliquées en langage simple et une mission à chaque niveau. Le Python que tu écris est du vrai Python, exécuté directement dans ton navigateur.", + "about.how.title": "Comment ça marche", + "about.how.1": "Tout se passe dans ton navigateur : rien à installer, et l'application fonctionne même sans connexion une fois chargée.", + "about.how.2": "Ta progression (points, badges, série de jours) reste sur ton appareil. Tu peux la sauvegarder dans un fichier ou, si ton instance le propose, la synchroniser entre appareils sans créer de compte.", + "about.how.3": "Aucune publicité, aucune statistique, aucun service tiers.", + "about.how.4": "Accessible : clavier complet, thèmes clair et sombre, taille du texte réglable, son et voix toujours désactivables.", + "about.license.title": "Licence", + "about.license.text": "© {year} PyQuest. Logiciel libre, distribué sous licence MIT : tu peux l'utiliser, le copier, le modifier et le partager, à condition de conserver la mention de droits et le texte de la licence. Il est fourni sans garantie.", + "about.license.read": "Lire le texte complet de la licence MIT", + "about.contact.title": "Contact", + "about.contact.text": "Une question, une erreur, une idée de niveau :", + "about.credits.title": "Crédits", + "about.credits.intro": "PyQuest repose sur des logiciels et des ressources libres :", + "about.credit.python": "le langage Python", + "about.credit.pyodide": "Python dans le navigateur (WebAssembly)", + "about.credit.piper": "synthèse vocale, utilisée pour fabriquer les voix (outil de construction, non embarqué)", + "about.credit.voice_fr": "données de la voix française (University of Edinburgh)", + "about.credit.voice_en": "données de la voix anglaise", + "about.credit.font": "police du texte", + "about.credit.font_code": "police du code", + "about.credit.yaml": "lecture des fichiers de niveaux", + "about.credit.schema": "validation des niveaux", + "about.credits.cc": "Voix française : modèle entraîné sur la base SIWIS (Honnet et al., University of Edinburgh), licence CC BY 4.0 : https://creativecommons.org/licenses/by/4.0/. Les effets sonores sont synthétisés dans ton navigateur, sans échantillon." } diff --git a/app/js/main.js b/app/js/main.js index 50f77bf..a5198b0 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -21,6 +21,7 @@ import { el } from './ui/dom.js'; import { CellManager } from './ui/CellManager.js'; import { NotebookView } from './ui/NotebookView.js'; import { ProgressMap } from './ui/ProgressMap.js'; +import { AboutPanel, COPYRIGHT_YEAR } from './ui/AboutPanel.js'; import { SettingsPanel } from './ui/SettingsPanel.js'; const LANGUAGES = ['fr', 'en']; @@ -72,6 +73,8 @@ class App { #map; #shelf; #panel; + #about; + #aboutDrawer; #levelsDrawer; #settingsDrawer; #levelIds = []; @@ -128,6 +131,7 @@ class App { this.#levelsDrawer.close(); this.#goTo(event.detail.id); }); + this.#about = new AboutPanel(this.#i18n); this.#panel = new SettingsPanel(this.#i18n); this.#panel.setSync(this.#sync.state); this.#panel.addEventListener('change', (event) => this.#onSettingChange(event.detail)); @@ -237,12 +241,28 @@ class App { trigger: document.getElementById('settings-toggle'), inertTargets: [appRoot], }); - region.append(...this.#levelsDrawer.elements, ...this.#settingsDrawer.elements); + this.#aboutDrawer = new Drawer({ + side: 'right', + title: '', + closeLabel: '', + content: this.#about.element, + trigger: document.getElementById('about-toggle'), + inertTargets: [appRoot], + }); + region.append(...this.#levelsDrawer.elements, ...this.#settingsDrawer.elements, ...this.#aboutDrawer.elements); this.#levelsDrawer.addEventListener('open', () => { this.#settingsDrawer.close({ restoreFocus: false }); + this.#aboutDrawer.close({ restoreFocus: false }); this.#map.scrollToCurrent(); }); - this.#settingsDrawer.addEventListener('open', () => this.#levelsDrawer.close({ restoreFocus: false })); + this.#settingsDrawer.addEventListener('open', () => { + this.#levelsDrawer.close({ restoreFocus: false }); + this.#aboutDrawer.close({ restoreFocus: false }); + }); + this.#aboutDrawer.addEventListener('open', () => { + this.#levelsDrawer.close({ restoreFocus: false }); + this.#settingsDrawer.close({ restoreFocus: false }); + }); } #bindLevelNav() { @@ -263,6 +283,11 @@ class App { #renderChrome() { const t = (key) => this.#i18n.t(key); document.getElementById('app-title').textContent = t('app.title'); + document.getElementById('app-tagline').textContent = t('app.tagline'); + document.title = t('app.docTitle'); + document.getElementById('footer-copyright').textContent = this.#i18n.t('footer.copyright', { year: COPYRIGHT_YEAR }); + document.getElementById('footer-license').textContent = t('footer.license'); + document.getElementById('about-toggle').textContent = t('footer.about'); document.getElementById('levels-toggle').replaceChildren(el('span', { 'aria-hidden': 'true', text: '☰ ' }), t('nav.levels')); document.getElementById('settings-toggle').replaceChildren(el('span', { 'aria-hidden': 'true', text: '⚙ ' }), t('nav.settings')); document.getElementById('level-prev').setAttribute('aria-label', t('nav.prev')); @@ -270,6 +295,9 @@ class App { document.getElementById('level-nav').setAttribute('aria-label', t('nav.label')); this.#levelsDrawer?.setTitle(t('progress.title')); this.#levelsDrawer?.setCloseLabel(t('nav.close')); + this.#aboutDrawer?.setTitle(t('about.title')); + this.#aboutDrawer?.setCloseLabel(t('nav.close')); + this.#about.render(); this.#settingsDrawer?.setTitle(t('settings.title')); this.#settingsDrawer?.setCloseLabel(t('nav.close')); this.#panel.render(this.#settings.settings); diff --git a/app/js/ui/AboutPanel.js b/app/js/ui/AboutPanel.js new file mode 100644 index 0000000..b99eb7c --- /dev/null +++ b/app/js/ui/AboutPanel.js @@ -0,0 +1,61 @@ +// « À propos » : ce qu'est PyQuest, comment ça marche, licence, contact et crédits (dont l'attribution CC BY 4.0 +// exigée par la voix française). Contenu construit sans HTML interprété ; textes dans les catalogues fr/en. + +import { el } from './dom.js'; + +export const CONTACT_EMAIL = 'dd@linuxtarn.org'; +export const COPYRIGHT_YEAR = 2026; + +// name, rôle (clé i18n), licence, adresse. Les noms et licences ne se traduisent pas. +const CREDITS = [ + { name: 'Python (CPython)', role: 'about.credit.python', license: 'PSF License', url: 'https://www.python.org/' }, + { name: 'Pyodide', role: 'about.credit.pyodide', license: 'MPL-2.0', url: 'https://pyodide.org/' }, + { name: 'Piper', role: 'about.credit.piper', license: 'GPL-3.0', url: 'https://github.com/OHF-Voice/piper1-gpl' }, + { name: 'SIWIS French Speech Synthesis Database', role: 'about.credit.voice_fr', license: 'CC BY 4.0', url: 'https://datashare.is.ed.ac.uk/handle/10283/2353' }, + { name: 'LJ Speech', role: 'about.credit.voice_en', license: 'Public domain', url: 'https://keithito.com/LJ-Speech-Dataset/' }, + { name: 'Atkinson Hyperlegible', role: 'about.credit.font', license: 'OFL 1.1', url: 'https://brailleinstitute.org/freefont' }, + { name: 'JetBrains Mono', role: 'about.credit.font_code', license: 'OFL 1.1', url: 'https://www.jetbrains.com/lp/mono/' }, + { name: 'js-yaml', role: 'about.credit.yaml', license: 'MIT', url: 'https://github.com/nodeca/js-yaml' }, + { name: '@cfworker/json-schema', role: 'about.credit.schema', license: 'MIT', url: 'https://github.com/cfworker/cfworker' }, +]; + +export class AboutPanel { + #i18n; + #root; + + /** @param {import('../i18n/i18n.js').I18n} i18n */ + constructor(i18n) { + this.#i18n = i18n; + this.#root = el('div', { class: 'about' }); + } + + get element() { + return this.#root; + } + + render() { + const t = (key, params) => this.#i18n.t(key, params); + const section = (titleKey, ...content) => el('section', { class: 'about-section' }, el('h3', { text: t(titleKey) }), ...content); + const externalLink = (url, text) => el('a', { href: url, target: '_blank', rel: 'noopener noreferrer', text }); + this.#root.replaceChildren( + section('about.what.title', el('p', { text: t('about.what.text') })), + section('about.how.title', el('ul', {}, ...[1, 2, 3, 4].map((n) => el('li', { text: t(`about.how.${n}`) })))), + section( + 'about.license.title', + el('p', { text: t('about.license.text', { year: COPYRIGHT_YEAR }) }), + el('p', {}, el('a', { href: 'LICENSE.txt', target: '_blank', rel: 'noopener', text: t('about.license.read') })), + ), + section('about.contact.title', el('p', {}, t('about.contact.text'), ' ', el('a', { href: `mailto:${CONTACT_EMAIL}`, text: CONTACT_EMAIL }))), + section( + 'about.credits.title', + el('p', { text: t('about.credits.intro') }), + el( + 'ul', + { class: 'about-credits' }, + ...CREDITS.map((credit) => el('li', {}, externalLink(credit.url, credit.name), ` — ${t(credit.role)} (${credit.license})`)), + ), + el('p', { class: 'hint', text: t('about.credits.cc') }), + ), + ); + } +} diff --git a/mkdocs.yml b/mkdocs.yml index 41e62cb..d83826b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,6 @@ # Documentation bilingue (fr par défaut, en). Sources : docs/site/fr et docs/site/en. Génération : make docs. site_name: PyQuest +copyright: "© 2026 PyQuest · dd@linuxtarn.org · MIT" site_description: Apprendre Python par la pratique, dans le navigateur / Learn Python by doing, in the browser docs_dir: docs/site site_dir: site diff --git a/tests/e2e/e2e.test.mjs b/tests/e2e/e2e.test.mjs index b38085c..256bd6f 100644 --- a/tests/e2e/e2e.test.mjs +++ b/tests/e2e/e2e.test.mjs @@ -242,7 +242,7 @@ test('voix hors ligne : télécharger les narrations Piper puis les écouter san const [, cached, total] = status.match(/(\d+) voix sur (\d+)/) ?? []; assert.ok(Number(total) > 40 && cached === total, `toutes les voix du français sont en cache : ${status}`); assert.equal(await group.getByRole('button', { name: 'Télécharger les voix pour le hors ligne' }).isDisabled(), true); - await page.locator('.drawer-right .drawer-close').click(); + await page.locator('.drawer-right.is-open .drawer-close').click(); await page.locator('.drawer-right.is-open').waitFor({ state: 'hidden' }); // Hors connexion : un niveau lointain se lit avec la voix Piper (fichier du cache), pas avec la synthèse système. @@ -259,6 +259,54 @@ test('voix hors ligne : télécharger les narrations Piper puis les écouter san assert.deepEqual(errors, []); }); +test('bandeau, pied de page et « À propos » : ce que fait PyQuest, droits, licence, contact, crédits', { skip, timeout: 120000 }, async () => { + const page = await (await browser.newContext({ locale: 'fr-FR' })).newPage(); + const errors = []; + page.on('pageerror', (error) => errors.push(error.message)); + await page.goto(base); + await page.waitForSelector('.explain', { timeout: 60000 }); + + // Le bandeau dit ce que fait l'application ; l'onglet aussi. + assert.match(await page.textContent('#app-tagline'), /Apprendre Python par la pratique, dans ton navigateur/); + assert.match(await page.title(), /PyQuest — apprendre Python/); + + // Pied de page : droits, contact, licence (texte complet servi), à propos. + const footer = page.locator('#app-footer'); + assert.match(await footer.textContent(), /© 2026 PyQuest/); + assert.equal(await footer.getByRole('link', { name: 'dd@linuxtarn.org' }).getAttribute('href'), 'mailto:dd@linuxtarn.org'); + const licenseLink = footer.getByRole('link', { name: 'Licence MIT' }); + const licenseResponse = await page.request.get(new URL(await licenseLink.getAttribute('href'), base).href); + assert.equal(licenseResponse.status(), 200); + assert.match(await licenseResponse.text(), /MIT License/); + + // « À propos et crédits » : panneau accessible, avec l'attribution de la voix française. + await footer.getByRole('button', { name: 'À propos et crédits' }).click(); + const drawer = page.locator('.drawer-right.is-open'); + await drawer.waitFor(); + assert.match(await drawer.textContent(), /À propos de PyQuest/); + assert.match(await drawer.textContent(), /Qu'est-ce que PyQuest \?/); + assert.match(await drawer.textContent(), /Licence MIT|licence MIT/); + assert.match(await drawer.textContent(), /SIWIS.*CC BY 4\.0/s); + assert.equal(await drawer.getByRole('link', { name: 'dd@linuxtarn.org' }).getAttribute('href'), 'mailto:dd@linuxtarn.org'); + for (const link of await drawer.locator('a[target=_blank]').all()) { + assert.match(await link.getAttribute('rel'), /noopener/); + } + assert.equal(await page.evaluate(() => document.getElementById('app-root').inert), true); + await page.keyboard.press('Escape'); + await drawer.waitFor({ state: 'hidden' }); + assert.equal(await page.evaluate(() => document.activeElement.id), 'about-toggle', 'le focus revient sur le bouton'); + + // En anglais : bandeau et pied de page suivent la langue. + await page.locator('#settings-toggle').click(); + await page.getByLabel('Langue').selectOption('en'); + await page.locator('.drawer-right.is-open .drawer-close').click(); + await page.waitForFunction(() => document.getElementById('app-tagline').textContent.startsWith('Learn Python')); + assert.match(await footer.textContent(), /MIT licence/); + await footer.getByRole('button', { name: 'About and credits' }).click(); + assert.match(await page.locator('.drawer-right.is-open').textContent(), /What is PyQuest\?/); + assert.deepEqual(errors, []); +}); + test('niveau 07 : boucle while avec plusieurs saisies successives dans l\'interface', { skip, timeout: 120000 }, async () => { const page = await (await browser.newContext()).newPage(); const errors = []; @@ -398,7 +446,7 @@ test('navigation : lien direct vers un niveau, tiroirs accessibles, précédent/ await page.locator('.drawer-right.is-open').waitFor(); for (let i = 0; i < 30; i++) await page.keyboard.press('Tab'); assert.equal(await page.evaluate(() => Boolean(document.activeElement.closest('.drawer-right'))), true, 'focus piégé'); - await page.locator('.drawer-right .drawer-close').click(); + await page.locator('.drawer-right.is-open .drawer-close').click(); await page.locator('.drawer-right.is-open').waitFor({ state: 'hidden' }); // Choisir un niveau dans le tiroir le ferme et l'ouvre. diff --git a/tests/js/about.test.mjs b/tests/js/about.test.mjs new file mode 100644 index 0000000..698db6a --- /dev/null +++ b/tests/js/about.test.mjs @@ -0,0 +1,36 @@ +import { test } from 'node:test'; +import assert from 'node:assert'; +import { readFileSync } from 'node:fs'; + +const read = (path) => readFileSync(new URL(`../../${path}`, import.meta.url), 'utf8'); + +test('la licence servie par l\'application est celle du dépôt', () => { + assert.equal(read('app/LICENSE.txt'), read('LICENSE')); + assert.match(read('LICENSE'), /MIT License/); +}); + +test('le texte « À propos » existe en français et en anglais, avec les mêmes clés', () => { + const fr = JSON.parse(read('app/js/i18n/fr.json')); + const en = JSON.parse(read('app/js/i18n/en.json')); + const aboutKeys = (catalog) => Object.keys(catalog).filter((key) => /^(about|footer)\.|^app\.(tagline|docTitle)$/.test(key)).sort(); + assert.deepEqual(aboutKeys(en), aboutKeys(fr)); + assert.ok(aboutKeys(fr).length > 25); + // L'attribution exigée par la licence CC BY 4.0 de la voix française figure dans les deux langues. + for (const catalog of [fr, en]) { + assert.match(catalog['about.credits.cc'], /SIWIS/); + assert.match(catalog['about.credits.cc'], /CC BY 4\.0/); + } +}); + +test('chaque crédit a un rôle traduit et le contact est celui du projet', async () => { + const source = read('app/js/ui/AboutPanel.js'); + const fr = JSON.parse(read('app/js/i18n/fr.json')); + const en = JSON.parse(read('app/js/i18n/en.json')); + const roles = [...source.matchAll(/role: '([^']+)'/g)].map((match) => match[1]); + assert.ok(roles.length >= 8); + for (const role of roles) { + assert.ok(fr[role] && en[role], `rôle sans traduction : ${role}`); + } + assert.match(source, /CONTACT_EMAIL = 'dd@linuxtarn\.org'/); + assert.match(read('app/index.html'), /mailto:dd@linuxtarn\.org/); +});