mirror of
https://github.com/deunix-educ/PyQuest.git
synced 2026-11-25 08:19:44 +01:00
Online documentation at /docs/ for authors and administrators: built into dist, nginx auth_request (check-docs), editor and admin links, Docker/server_update integration
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ export class AuthorApp {
|
||||
#store;
|
||||
#catalogs;
|
||||
#root;
|
||||
#hasDocs = false; // documentation en ligne publiée par le serveur (/docs/)
|
||||
#account = null; // { username, csrf } si l'éditeur est protégé par une connexion (backend Django), sinon null
|
||||
#knownIds = [];
|
||||
#model = emptyLevelModel();
|
||||
@@ -66,6 +67,7 @@ export class AuthorApp {
|
||||
|
||||
async run() {
|
||||
this.#account = await this.#loadAccount();
|
||||
await this.#detectDocs();
|
||||
this.#knownIds = (await this.#lessons.listLevels()).map((level) => level.id);
|
||||
const draft = await this.#store.get(DRAFT_KEY).catch(() => undefined);
|
||||
if (draft) {
|
||||
@@ -97,6 +99,23 @@ export class AuthorApp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lien vers la documentation en ligne (/docs/), seulement si le serveur la publie : sinon (essai local sans
|
||||
* documentation) pas de lien mort. La vérification est faite une fois, à l'ouverture.
|
||||
*/
|
||||
async #detectDocs() {
|
||||
try {
|
||||
const response = await fetch(new URL('docs/', document.baseURI), { method: 'HEAD', cache: 'no-store', credentials: 'same-origin', redirect: 'manual' });
|
||||
this.#hasDocs = response.ok;
|
||||
} catch {
|
||||
this.#hasDocs = false;
|
||||
}
|
||||
}
|
||||
|
||||
#docsLink() {
|
||||
return this.#hasDocs ? el('a', { class: 'btn', id: 'author-docs', href: 'docs/', target: '_blank', rel: 'noopener', text: this.#t('author.toolbar.docs') }) : null;
|
||||
}
|
||||
|
||||
/** Formulaire de déconnexion (vrai POST protégé par CSRF : la page de connexion s'affiche ensuite). */
|
||||
#accountControl() {
|
||||
if (!this.#account) {
|
||||
@@ -152,6 +171,7 @@ export class AuthorApp {
|
||||
fileInput,
|
||||
el('button', { type: 'button', class: 'btn btn-primary', id: 'author-download', text: t('author.toolbar.download'), onclick: () => this.#download() }),
|
||||
languages,
|
||||
this.#docsLink(),
|
||||
el('a', { class: 'btn', href: './', text: t('author.toolbar.back') }),
|
||||
),
|
||||
this.#accountControl(),
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"author.kind.drawing_colors": "Drawing: colours used",
|
||||
"author.kind.drawing_colors.help": "Colours that must all appear, comma-separated: “red,blue”.",
|
||||
"lint.drawing_value_invalid": "Malformed drawing test value (see the test type help; colours: black, red, green, blue, orange, purple, gray).",
|
||||
"author.toolbar.docs": "Documentation (new tab)",
|
||||
"author.account.label": "Account",
|
||||
"author.account.signed_in": "Signed in: {name}",
|
||||
"author.account.logout": "Sign out"
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"author.kind.drawing_colors": "Dessin : couleurs utilisées",
|
||||
"author.kind.drawing_colors.help": "Couleurs qui doivent toutes apparaître, séparées par des virgules : « red,blue ».",
|
||||
"lint.drawing_value_invalid": "Valeur de test de dessin mal formée (voir l'aide du type de test ; couleurs : black, red, green, blue, orange, purple, gray).",
|
||||
"author.toolbar.docs": "Documentation (nouvel onglet)",
|
||||
"author.account.label": "Compte",
|
||||
"author.account.signed_in": "Connecté : {name}",
|
||||
"author.account.logout": "Se déconnecter"
|
||||
|
||||
Reference in New Issue
Block a user