Édition de la page d'accueil directement depuis YunoHost
- api.php : backend PHP de l'éditeur sur my_webapp (brouillon, publier, rétablir), réservé aux comptes listés dans .editors.json (EDITORS dans .env), identité lue dans l'en-tête YNH_USER du SSO, protection CSRF. - preview.py répond aux mêmes routes api.php?action=..., l'éditeur n'a plus qu'un seul chemin de code ; Exporter n'existe qu'en local. - Aperçu en direct dans l'éditeur (iframe + postMessage). - Lien « Éditer la page d'accueil » dans le footer pour les éditeurs. - Catalogue en ligne via /yunohost/portalapi/me. - favicon.js : icône d'onglet = logo de l'app défini dans YunoHost. - make deploy garde la config.json du serveur ; make deploy-config l'écrase après confirmation. DEPLOY_SSH permet de déployer via root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d42141eb9f
commit
a01d03aa09
14 files changed
+612
-48
No files matched your search
@@ -18,10 +18,22 @@ REMOTE_PORT=22
|
||||
# mettre le chemin absolu /var/www/... — voir le README).
|
||||
REMOTE_PATH=/www/
|
||||
|
||||
# Alternative au compte SFTP de l'app : deployer via un compte SSH root
|
||||
# (ex. "root@mondomaine.exemple" ou un alias de ~/.ssh/config). Les fichiers
|
||||
# vont alors dans /var/www/<REMOTE_USER><REMOTE_PATH> et sont rendus a
|
||||
# REMOTE_USER. Si renseigne, REMOTE_PASSWORD est ignore.
|
||||
DEPLOY_SSH=
|
||||
|
||||
# Mot de passe du compte REMOTE_USER (celui défini à l'installation de
|
||||
# l'app). Laisse vide pour que ssh/scp le demande à chaque fois.
|
||||
REMOTE_PASSWORD=
|
||||
|
||||
# --- Edition en ligne (editor.html servi par YunoHost, via api.php) ---
|
||||
# Comptes YunoHost autorises a modifier la page d'accueil depuis le serveur
|
||||
# (lien "Editer la page d'accueil" en bas de page). Separes par des espaces
|
||||
# ou des virgules. Necessite PHP active sur l'app my_webapp.
|
||||
EDITORS=
|
||||
|
||||
# --- Synchronisation des apps (make sync) ---
|
||||
# Utilisateur et hôte SSH ayant accès en lecture à la configuration YunoHost
|
||||
# (root, ou un utilisateur avec sudo -- voir le README pour les limites).
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
include .env
|
||||
PORT ?= 8000
|
||||
|
||||
.PHONY: help install config demo serve sync fetch export deploy
|
||||
.PHONY: help install config demo serve sync fetch export deploy deploy-config
|
||||
|
||||
help:
|
||||
@echo "Cibles disponibles :"
|
||||
@@ -13,7 +13,8 @@ help:
|
||||
@echo " make sync - recupere dans src/config.json les apps YunoHost manquantes"
|
||||
@echo " make fetch - recupere src/config.json depuis le serveur (config actuellement deployee)"
|
||||
@echo " make export - copie src/ vers output/ (equivalent au bouton Exporter)"
|
||||
@echo " make deploy - envoie output/ sur le serveur YunoHost"
|
||||
@echo " make deploy - envoie output/ sur le serveur YunoHost (garde la config.json du serveur)"
|
||||
@echo " make deploy-config - idem, mais ECRASE la config.json du serveur par la locale"
|
||||
|
||||
install:
|
||||
sudo apt-get update
|
||||
@@ -55,6 +56,11 @@ export:
|
||||
deploy:
|
||||
scripts/deploy.sh
|
||||
|
||||
deploy-config:
|
||||
@printf "Ecraser la config.json du serveur (modifs faites en ligne perdues) ? [o/N] "; \
|
||||
read ans; case "$$ans" in o|O|oui|y|Y) ;; *) echo "Annule."; exit 1;; esac
|
||||
DEPLOY_CONFIG=1 scripts/deploy.sh
|
||||
|
||||
fetch:
|
||||
scp akbar:/var/www/$(REMOTE_USER)/www/config.json src/config.json
|
||||
@echo "Config de la HomePage téléchargée depuis le serveur"
|
||||
@@ -15,7 +15,8 @@ aussi local et ignoré par git — voir plus bas comment le renseigner.
|
||||
|
||||
```
|
||||
src/ sources de la page (index.html, style.css, app.js)
|
||||
et de l'éditeur visuel (editor.html/css/js)
|
||||
et de l'éditeur visuel (editor.html/css/js, + api.php pour
|
||||
l'utiliser directement sur YunoHost)
|
||||
+ config.json (tes données, ignoré par git — voir ci-dessous)
|
||||
+ config.example.json (exemple versionné, point de départ)
|
||||
+ config.demo.json / catalog.demo.json (données de démo,
|
||||
@@ -98,8 +99,11 @@ make serve
|
||||
- Le bouton **Rétablir l'original** abandonne le brouillon et revient à
|
||||
la dernière version enregistrée.
|
||||
- Le bouton **Exporter** enregistre puis copie les fichiers déployables
|
||||
(`index.html`, `style.css`, `app.js`, `config.json`) dans `output/` —
|
||||
c'est ce dossier, pas `src/`, qui est envoyé sur le serveur.
|
||||
(page, éditeur, `api.php`, `config.json`) dans `output/` — c'est ce
|
||||
dossier, pas `src/`, qui est envoyé sur le serveur. Ce bouton n'existe
|
||||
qu'en local.
|
||||
- Le bouton **Aperçu** affiche/masque, en bas de l'éditeur, la page
|
||||
finale mise à jour en direct à chaque modification.
|
||||
- **`http://localhost:8000/`** — aperçu de la page finale (celle de
|
||||
`src/`), avec rechargement automatique dès qu'un fichier change. Tant
|
||||
qu'un brouillon existe, l'aperçu l'affiche à la place de `config.json`.
|
||||
@@ -107,6 +111,39 @@ make serve
|
||||
Cette partie ne nécessite aucune information sur ton serveur : tout est
|
||||
local.
|
||||
|
||||
## Éditer directement depuis YunoHost
|
||||
|
||||
Une fois déployé, l'éditeur fonctionne aussi en ligne : le lien **Éditer la
|
||||
page d'accueil** apparaît en bas de la page (après « Éditer mon profil »)
|
||||
pour les comptes autorisés. Les modifications partent dans un brouillon
|
||||
(visible seulement dans l'aperçu de l'éditeur) et le bouton **Publier**
|
||||
remplace `config.json` sur le serveur : la page est à jour immédiatement,
|
||||
sans `make export`/`make deploy`.
|
||||
|
||||
Prérequis :
|
||||
- **PHP activé** sur l'app Custom Webapp (`my_webapp`) — choisi à
|
||||
l'installation ou dans son panneau de configuration. C'est `api.php` qui
|
||||
reçoit les modifications (même contrat que `scripts/preview.py` en local).
|
||||
- L'icône de l'onglet reprend automatiquement le logo défini pour l'app
|
||||
dans l'admin YunoHost (`favicon.js`). Pour en forcer une autre :
|
||||
`"favicon": "https://..."` dans la section `portal` de `config.json`.
|
||||
- **`EDITORS`** renseigné dans `.env` (comptes YunoHost séparés par des
|
||||
espaces ou des virgules). `make deploy` en génère `.editors.json` sur le
|
||||
serveur. Les autres utilisateurs ne voient pas le lien et `api.php`
|
||||
refuse leurs requêtes.
|
||||
- L'app ne doit **pas** être publique (visiteurs) : l'identité vient de
|
||||
l'en-tête `YNH_USER` injecté par le SSO YunoHost.
|
||||
|
||||
Côté serveur, le brouillon (`.config.draft.json`) et la liste des éditeurs
|
||||
(`.editors.json`) commencent par un point : nginx refuse de les servir,
|
||||
seul PHP les lit. Le catalogue de l'éditeur vient alors de
|
||||
`/yunohost/portalapi/me` (apps visibles par l'utilisateur connecté), au
|
||||
lieu de la connexion SSH root utilisée en local.
|
||||
|
||||
⚠️ Comme la config peut maintenant changer en ligne, `make deploy`
|
||||
**n'envoie plus `config.json`** (voir plus bas). Pour repartir de la
|
||||
version en ligne avant de travailler en local : `make fetch`.
|
||||
|
||||
## Récupérer automatiquement les apps installées sur YunoHost
|
||||
|
||||
```bash
|
||||
@@ -185,10 +222,16 @@ Le déploiement se fait toujours à partir de `output/`, jamais de `src/`
|
||||
directement :
|
||||
|
||||
```bash
|
||||
make export # (ou le bouton Exporter de l'éditeur) : src/ -> output/
|
||||
make deploy # envoie output/ sur le serveur
|
||||
make export # (ou le bouton Exporter de l'éditeur) : src/ -> output/
|
||||
make deploy # envoie output/ sur le serveur, SAUF config.json
|
||||
make deploy-config # idem, mais écrase config.json du serveur (confirmation demandée)
|
||||
```
|
||||
|
||||
`make deploy` met à jour la page, l'éditeur, `api.php` et la liste des
|
||||
éditeurs, mais garde la `config.json` du serveur, pour ne jamais écraser
|
||||
ce qui a été modifié en ligne. Pour pousser ta config locale à la place,
|
||||
utilise `make deploy-config` (ou `DEPLOY_CONFIG=1 scripts/deploy.sh`).
|
||||
|
||||
### Configurer `.env`
|
||||
|
||||
```bash
|
||||
@@ -208,6 +251,9 @@ REMOTE_PORT=22
|
||||
REMOTE_PATH=/www/
|
||||
REMOTE_PASSWORD=le-mot-de-passe-ici
|
||||
|
||||
# Edition en ligne (comptes autorises)
|
||||
EDITORS=moncompte
|
||||
|
||||
# Synchronisation des apps (make sync)
|
||||
SYNC_SSH_USER=root
|
||||
SYNC_SSH_HOST=tondomaine.exemple
|
||||
@@ -230,6 +276,14 @@ en général un compte **SFTP uniquement**, chrooté dans son propre dossier
|
||||
(`/var/www/<REMOTE_USER>`), donc `/www/` et pas
|
||||
`/var/www/<REMOTE_USER>/www/`.
|
||||
|
||||
### Déployer via root (alternative)
|
||||
|
||||
Si tu as déjà un accès SSH root au serveur (clé ou alias dans
|
||||
`~/.ssh/config`), renseigne `DEPLOY_SSH=root@tondomaine` (ou l'alias) dans
|
||||
`.env` : `make deploy` copie alors dans `/var/www/<REMOTE_USER>/www/` et
|
||||
rend les fichiers au compte de l'app (indispensable pour que l'éditeur en
|
||||
ligne puisse réécrire `config.json`).
|
||||
|
||||
### Authentification par clé SSH (alternative)
|
||||
|
||||
Pour ne plus dépendre du mot de passe pour le déploiement :
|
||||
|
||||
+56
-7
@@ -37,7 +37,7 @@ REMOTE_PATH="${REMOTE_PATH:-/www/}"
|
||||
|
||||
SCP="scp"
|
||||
|
||||
if [ -n "${REMOTE_PASSWORD:-}" ]; then
|
||||
if [ -n "${REMOTE_PASSWORD:-}" ] && [ -z "${DEPLOY_SSH:-}" ]; then
|
||||
if ! command -v sshpass > /dev/null 2>&1; then
|
||||
echo "REMOTE_PASSWORD est defini dans .env mais sshpass n'est pas installe (apt install sshpass)." >&2
|
||||
exit 1
|
||||
@@ -45,9 +45,58 @@ if [ -n "${REMOTE_PASSWORD:-}" ]; then
|
||||
SCP="sshpass -p ${REMOTE_PASSWORD} scp"
|
||||
fi
|
||||
|
||||
${SCP} -P "${REMOTE_PORT}" \
|
||||
"${OUTPUT_DIR}/index.html" \
|
||||
"${OUTPUT_DIR}/style.css" \
|
||||
"${OUTPUT_DIR}/app.js" \
|
||||
"${OUTPUT_DIR}/config.json" \
|
||||
"${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}"
|
||||
for f in editor.html editor.css editor.js api.php favicon.js; do
|
||||
if [ ! -f "${OUTPUT_DIR}/$f" ]; then
|
||||
echo "output/$f manquant : relance 'make export'." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
FILES="index.html style.css app.js editor.html editor.css editor.js api.php favicon.js"
|
||||
|
||||
# Liste des comptes YunoHost autorises a modifier la page en ligne
|
||||
# (EDITORS dans .env, separes par des espaces ou des virgules). Le fichier
|
||||
# commence par un point : nginx refuse de le servir, seul api.php le lit.
|
||||
EDITORS_LIST="$(printf '%s' "${EDITORS:-}" | tr ',' ' ')"
|
||||
if [ -n "$(printf '%s' "$EDITORS_LIST" | tr -d ' ')" ]; then
|
||||
json="["
|
||||
sep=""
|
||||
for u in $EDITORS_LIST; do
|
||||
case "$u" in
|
||||
*[!a-z0-9._-]*) echo "Nom d'utilisateur invalide dans EDITORS : $u" >&2; exit 1 ;;
|
||||
esac
|
||||
json="${json}${sep}\"${u}\""
|
||||
sep=", "
|
||||
done
|
||||
printf '%s]\n' "$json" > "${OUTPUT_DIR}/.editors.json"
|
||||
FILES="$FILES .editors.json"
|
||||
else
|
||||
echo "EDITORS vide dans .env : liste des editeurs non envoyee (personne ne pourra editer en ligne si elle n'existe pas deja)." >&2
|
||||
fi
|
||||
|
||||
# config.json n'est envoye que sur demande explicite (make deploy-config) :
|
||||
# sinon on garderait le risque d'ecraser les modifications faites en ligne
|
||||
# depuis l'editeur. Pour recuperer la version du serveur : make fetch.
|
||||
if [ "${DEPLOY_CONFIG:-0}" = "1" ]; then
|
||||
FILES="$FILES config.json"
|
||||
echo "config.json locale envoyee : elle REMPLACE celle du serveur."
|
||||
else
|
||||
echo "config.json du serveur conservee (make deploy-config pour l'ecraser)."
|
||||
fi
|
||||
|
||||
set --
|
||||
for f in $FILES; do
|
||||
set -- "$@" "${OUTPUT_DIR}/$f"
|
||||
done
|
||||
|
||||
if [ -n "${DEPLOY_SSH:-}" ]; then
|
||||
# Via un compte root (ex. root@mondomaine ou un alias SSH) : chemin absolu du serveur,
|
||||
# puis les fichiers sont rendus au compte de l'app pour que PHP (qui tourne
|
||||
# sous ce compte) puisse reecrire config.json et le brouillon.
|
||||
REMOTE_DIR="/var/www/${REMOTE_USER}/$(printf '%s' "$REMOTE_PATH" | sed 's#^/##')"
|
||||
scp "$@" "${DEPLOY_SSH}:${REMOTE_DIR}"
|
||||
ssh "${DEPLOY_SSH}" "cd '${REMOTE_DIR}' && chown '${REMOTE_USER}:${REMOTE_USER}' ${FILES} && chmod 664 ${FILES} && { [ ! -f .editors.json ] || chmod 640 .editors.json; }"
|
||||
else
|
||||
${SCP} -P "${REMOTE_PORT}" "$@" "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}"
|
||||
fi
|
||||
echo "Deploye : $FILES"
|
||||
+4
-1
@@ -10,7 +10,10 @@ SRC_DIR="$PROJECT_ROOT/src"
|
||||
OUTPUT_DIR="$PROJECT_ROOT/output"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
cp "$SRC_DIR/index.html" "$SRC_DIR/style.css" "$SRC_DIR/app.js" "$SRC_DIR/config.json" "$OUTPUT_DIR/"
|
||||
# Meme liste que EXPORTED_FILES dans scripts/preview.py.
|
||||
for f in index.html style.css app.js config.json editor.html editor.css editor.js api.php favicon.js; do
|
||||
cp "$SRC_DIR/$f" "$OUTPUT_DIR/"
|
||||
done
|
||||
|
||||
echo "Exporte vers $OUTPUT_DIR :"
|
||||
ls "$OUTPUT_DIR"
|
||||
+37
-12
@@ -9,6 +9,7 @@ import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import urllib.parse
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
@@ -28,7 +29,12 @@ CONFIG_PATH = SRC_DIR / "config.json"
|
||||
DRAFT_PATH = SRC_DIR / "config.draft.json"
|
||||
|
||||
WATCHED_FILES = ["index.html", "style.css", "app.js", "config.json", "config.draft.json"]
|
||||
EXPORTED_FILES = ["index.html", "style.css", "app.js", "config.json"]
|
||||
# config.json est exporte aussi, mais deploy.sh ne l'envoie que sur demande
|
||||
# (make deploy-config) pour ne pas ecraser les modifs faites en ligne.
|
||||
EXPORTED_FILES = [
|
||||
"index.html", "style.css", "app.js", "config.json",
|
||||
"editor.html", "editor.css", "editor.js", "api.php", "favicon.js",
|
||||
]
|
||||
|
||||
RELOAD_SNIPPET = b"""
|
||||
<script>
|
||||
@@ -81,20 +87,27 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
|
||||
self.wfile.write(body)
|
||||
return
|
||||
|
||||
if self.path == "/__catalog":
|
||||
self._send_catalog()
|
||||
route, action = self._route()
|
||||
if route == "/api.php":
|
||||
if action == "whoami":
|
||||
self._send_json({"user": "local", "canEdit": True, "local": True})
|
||||
elif action == "catalog":
|
||||
self._send_catalog()
|
||||
elif action == "config":
|
||||
draft = DRAFT_PATH.exists()
|
||||
self._send_file(DRAFT_PATH if draft else CONFIG_PATH, draft)
|
||||
elif action == "original":
|
||||
self._send_file(CONFIG_PATH, False)
|
||||
else:
|
||||
self.send_error(404)
|
||||
return
|
||||
|
||||
route = self.path.split("?", 1)[0]
|
||||
# En local, l'apercu affiche le brouillon tant qu'il existe.
|
||||
if route == "/config.json":
|
||||
draft = DRAFT_PATH.exists()
|
||||
self._send_file(DRAFT_PATH if draft else CONFIG_PATH, draft)
|
||||
return
|
||||
|
||||
if route == "/__original":
|
||||
self._send_file(CONFIG_PATH, False)
|
||||
return
|
||||
|
||||
if self.path in ("/", "/index.html"):
|
||||
try:
|
||||
html = (SRC_DIR / "index.html").read_bytes()
|
||||
@@ -111,11 +124,16 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
|
||||
super().do_GET()
|
||||
|
||||
def do_POST(self):
|
||||
if self.path in ("/__save", "/__draft"):
|
||||
route, action = self._route()
|
||||
if route != "/api.php":
|
||||
self.send_error(404)
|
||||
return
|
||||
|
||||
if action in ("save", "draft"):
|
||||
data = self._read_json_body()
|
||||
if data is None:
|
||||
return
|
||||
if self.path == "/__save":
|
||||
if action == "save":
|
||||
self._write_json(CONFIG_PATH, data)
|
||||
DRAFT_PATH.unlink(missing_ok=True)
|
||||
else:
|
||||
@@ -123,12 +141,13 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
|
||||
self._send_json({"ok": True})
|
||||
return
|
||||
|
||||
if self.path == "/__discard":
|
||||
if action == "discard":
|
||||
DRAFT_PATH.unlink(missing_ok=True)
|
||||
self._send_json({"ok": True})
|
||||
return
|
||||
|
||||
if self.path == "/__export":
|
||||
# Uniquement en local : sur le serveur, "Enregistrer" publie directement.
|
||||
if action == "export":
|
||||
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
copied = []
|
||||
for name in EXPORTED_FILES:
|
||||
@@ -141,6 +160,12 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
|
||||
|
||||
self.send_error(404)
|
||||
|
||||
def _route(self):
|
||||
"""Renvoie (chemin, action) ; action = parametre ?action= d'api.php."""
|
||||
parsed = urllib.parse.urlsplit(self.path)
|
||||
action = urllib.parse.parse_qs(parsed.query).get("action", [""])[0]
|
||||
return parsed.path, action
|
||||
|
||||
def _send_catalog(self):
|
||||
if os.environ.get("HOMEPAGE_DEMO"):
|
||||
try:
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
// Backend de l'editeur quand la page est servie par YunoHost (my_webapp avec
|
||||
// PHP). Meme contrat que scripts/preview.py en local : api.php?action=...
|
||||
//
|
||||
// GET whoami -> { user, canEdit, local }
|
||||
// GET config -> brouillon s'il existe, sinon config.json
|
||||
// (en-tete X-Homepage-Draft: 1|0)
|
||||
// GET original -> config.json
|
||||
// GET catalog -> { portal: true } : le navigateur interroge lui-meme
|
||||
// /yunohost/portalapi/me (pas d'acces root ici)
|
||||
// POST draft -> ecrit le brouillon
|
||||
// POST save -> ecrit config.json et supprime le brouillon
|
||||
// POST discard -> supprime le brouillon
|
||||
//
|
||||
// Securite :
|
||||
// - l'utilisateur vient de l'en-tete YNH_USER, injecte par SSOwat (qui
|
||||
// efface d'abord tout en-tete ynh_* envoye par le client) ;
|
||||
// - seuls les comptes listes dans .editors.json peuvent modifier. Ce
|
||||
// fichier et le brouillon commencent par un point : nginx refuse de les
|
||||
// servir, seul PHP les lit ;
|
||||
// - chaque POST doit porter l'en-tete X-Homepage-Editor (impossible a
|
||||
// envoyer depuis un autre site sans preflight CORS) et, si le navigateur
|
||||
// envoie Origin, celui-ci doit etre ce domaine.
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
const CONFIG_FILE = __DIR__ . '/config.json';
|
||||
const DRAFT_FILE = __DIR__ . '/.config.draft.json';
|
||||
const EDITORS_FILE = __DIR__ . '/.editors.json';
|
||||
const MAX_BODY = 1024 * 1024;
|
||||
|
||||
header('Cache-Control: no-store');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
function reply(int $status, array $payload): void
|
||||
{
|
||||
http_response_code($status);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
function current_user(): string
|
||||
{
|
||||
return trim((string)($_SERVER['HTTP_YNH_USER'] ?? ''));
|
||||
}
|
||||
|
||||
function can_edit(string $user): bool
|
||||
{
|
||||
if ($user === '' || !is_readable(EDITORS_FILE)) {
|
||||
return false;
|
||||
}
|
||||
$editors = json_decode((string)file_get_contents(EDITORS_FILE), true);
|
||||
return is_array($editors) && in_array($user, $editors, true);
|
||||
}
|
||||
|
||||
function send_config_file(string $path, bool $isDraft): void
|
||||
{
|
||||
$body = @file_get_contents($path);
|
||||
if ($body === false) {
|
||||
reply(404, ['error' => basename($path) . ' introuvable']);
|
||||
}
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('X-Homepage-Draft: ' . ($isDraft ? '1' : '0'));
|
||||
echo $body;
|
||||
exit;
|
||||
}
|
||||
|
||||
function read_json_body(): array
|
||||
{
|
||||
$raw = file_get_contents('php://input', false, null, 0, MAX_BODY + 1);
|
||||
if ($raw === false || strlen($raw) > MAX_BODY) {
|
||||
reply(413, ['error' => 'Configuration trop volumineuse']);
|
||||
}
|
||||
$data = json_decode($raw, true);
|
||||
if (!is_array($data) || !isset($data['groups']) || !is_array($data['groups'])) {
|
||||
reply(400, ['error' => 'JSON invalide']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function write_json_atomic(string $path, array $data): void
|
||||
{
|
||||
$json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
$tmp = $path . '.tmp';
|
||||
if ($json === false || file_put_contents($tmp, $json . "\n", LOCK_EX) === false || !rename($tmp, $path)) {
|
||||
@unlink($tmp);
|
||||
reply(500, ['error' => 'Écriture impossible : ' . basename($path)]);
|
||||
}
|
||||
}
|
||||
|
||||
function check_csrf(): void
|
||||
{
|
||||
if (($_SERVER['HTTP_X_HOMEPAGE_EDITOR'] ?? '') !== '1') {
|
||||
reply(403, ['error' => 'En-tête X-Homepage-Editor manquant']);
|
||||
}
|
||||
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
||||
if ($origin !== '') {
|
||||
$parts = parse_url($origin);
|
||||
$originHost = ($parts['host'] ?? '') . (isset($parts['port']) ? ':' . $parts['port'] : '');
|
||||
}
|
||||
if ($origin !== '' && strcasecmp($originHost, (string)($_SERVER['HTTP_HOST'] ?? '')) !== 0) {
|
||||
reply(403, ['error' => 'Origine refusée']);
|
||||
}
|
||||
}
|
||||
|
||||
$action = (string)($_GET['action'] ?? '');
|
||||
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
||||
$user = current_user();
|
||||
$allowed = can_edit($user);
|
||||
|
||||
if ($action === 'whoami') {
|
||||
reply(200, ['user' => $user, 'canEdit' => $allowed, 'local' => false]);
|
||||
}
|
||||
|
||||
if (!$allowed) {
|
||||
reply(403, ['error' => $user === ''
|
||||
? 'Non connecté via le SSO YunoHost'
|
||||
: "« $user » n'est pas autorisé à modifier la page d'accueil (.editors.json)"]);
|
||||
}
|
||||
|
||||
if ($method === 'GET') {
|
||||
switch ($action) {
|
||||
case 'config':
|
||||
$isDraft = is_file(DRAFT_FILE);
|
||||
send_config_file($isDraft ? DRAFT_FILE : CONFIG_FILE, $isDraft);
|
||||
case 'original':
|
||||
send_config_file(CONFIG_FILE, false);
|
||||
case 'catalog':
|
||||
reply(200, ['portal' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($method === 'POST') {
|
||||
check_csrf();
|
||||
switch ($action) {
|
||||
case 'draft':
|
||||
write_json_atomic(DRAFT_FILE, read_json_body());
|
||||
reply(200, ['ok' => true]);
|
||||
case 'save':
|
||||
write_json_atomic(CONFIG_FILE, read_json_body());
|
||||
@unlink(DRAFT_FILE);
|
||||
reply(200, ['ok' => true]);
|
||||
case 'discard':
|
||||
@unlink(DRAFT_FILE);
|
||||
reply(200, ['ok' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
reply(404, ['error' => "Action inconnue : $action"]);
|
||||
+50
-3
@@ -1,4 +1,7 @@
|
||||
const COLLAPSE_STORAGE_KEY = "yunohost-portal-collapsed-groups";
|
||||
// Page affichee dans l'apercu de l'editeur (editor.html) : la config arrive
|
||||
// par postMessage et les liens ne doivent pas quitter l'apercu.
|
||||
const IS_PREVIEW = window.parent !== window && new URLSearchParams(window.location.search).has("preview");
|
||||
|
||||
function loadCollapsedState() {
|
||||
try {
|
||||
@@ -110,14 +113,20 @@ function render(config) {
|
||||
document.getElementById("edit-profile").href = config.portal.editProfileUrl || "#";
|
||||
document.getElementById("footer-doc").href = config.portal.documentationUrl || "#";
|
||||
document.getElementById("footer-support").href = config.portal.supportUrl || "#";
|
||||
// Icone d'onglet forcee dans config.json ; sinon favicon.js reprend le
|
||||
// logo de l'app defini dans YunoHost.
|
||||
if (config.portal.favicon && window.homepageSetFavicon) {
|
||||
window.homepageFaviconOverride = true;
|
||||
window.homepageSetFavicon(config.portal.favicon);
|
||||
}
|
||||
|
||||
const logoutUrl = config.portal.logoutUrl || "/yunohost/portalapi/logout";
|
||||
document.getElementById("logout-btn").addEventListener("click", (e) => {
|
||||
document.getElementById("logout-btn").onclick = (e) => {
|
||||
e.preventDefault();
|
||||
fetch(logoutUrl, { credentials: "same-origin" }).finally(() => {
|
||||
window.location.href = "/yunohost/sso/";
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const app = document.getElementById("app");
|
||||
app.innerHTML = "";
|
||||
@@ -150,11 +159,49 @@ function render(config) {
|
||||
}
|
||||
}
|
||||
|
||||
fetch("config.json")
|
||||
// Le lien "Editer la page d'accueil" n'apparait que pour les comptes
|
||||
// autorises (api.php / .editors.json). Si PHP n'est pas actif, la requete
|
||||
// echoue silencieusement et le lien reste cache.
|
||||
function showEditLinkIfAllowed() {
|
||||
if (IS_PREVIEW) return;
|
||||
fetch("api.php?action=whoami", { credentials: "same-origin", cache: "no-store" })
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((me) => {
|
||||
if (me && me.canEdit) document.getElementById("footer-edit-home").hidden = false;
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
if (IS_PREVIEW) {
|
||||
// Dans l'apercu : liens ouverts dans un nouvel onglet, deconnexion inactive.
|
||||
document.addEventListener("click", (e) => {
|
||||
const a = e.target.closest("a");
|
||||
if (!a) return;
|
||||
if (a.id === "logout-btn") {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return;
|
||||
}
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener";
|
||||
}, true);
|
||||
|
||||
window.addEventListener("message", (e) => {
|
||||
if (e.origin !== window.location.origin || e.source !== window.parent) return;
|
||||
if (e.data && e.data.type === "homepage-config") render(e.data.config);
|
||||
});
|
||||
}
|
||||
|
||||
fetch("config.json", { cache: "no-cache" })
|
||||
.then((r) => r.json())
|
||||
.then(render)
|
||||
.catch((err) => {
|
||||
document.getElementById("app").textContent =
|
||||
"Erreur de chargement de la configuration (config.json).";
|
||||
console.error(err);
|
||||
})
|
||||
.finally(() => {
|
||||
if (IS_PREVIEW) window.parent.postMessage({ type: "homepage-preview-ready" }, window.location.origin);
|
||||
});
|
||||
|
||||
showEditLinkIfAllowed();
|
||||
@@ -412,3 +412,53 @@ body {
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* --- Apercu en direct (iframe en bas d'ecran) --- */
|
||||
.preview-drawer {
|
||||
display: none;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: 45vh;
|
||||
flex-direction: column;
|
||||
border-top: 2px solid var(--purple);
|
||||
background: var(--bg);
|
||||
z-index: 20;
|
||||
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
body[data-preview="open"] .preview-drawer { display: flex; }
|
||||
body[data-preview="open"] #editor-root { padding-bottom: 46vh; }
|
||||
#preview-toggle[aria-pressed="true"] { background: var(--purple); color: #fff; }
|
||||
|
||||
.preview-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 6px 16px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
background: var(--panel-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.preview-bar a { color: var(--purple); text-decoration: none; white-space: nowrap; }
|
||||
|
||||
#preview-frame {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.access-denied {
|
||||
max-width: 560px;
|
||||
margin: 64px auto;
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
background: var(--panel-bg);
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
[hidden] { display: none !important; }
|
||||
+11
-1
@@ -5,13 +5,15 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Éditeur du portail</title>
|
||||
<link rel="stylesheet" href="editor.css" />
|
||||
<script src="favicon.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="editor-topbar">
|
||||
<h1>Éditeur du portail</h1>
|
||||
<div class="editor-actions">
|
||||
<span id="status" class="status"></span>
|
||||
<a href="/" target="_blank" class="btn btn-outline">Aperçu ↗</a>
|
||||
<a href="./" class="btn btn-outline" title="Revenir à la page d'accueil">← Accueil</a>
|
||||
<button id="preview-toggle" class="btn btn-outline" aria-pressed="true" title="Afficher/masquer l'aperçu en direct">Aperçu</button>
|
||||
<button id="revert-btn" class="btn btn-outline" disabled title="Abandonner le brouillon et revenir à la dernière version enregistrée">Rétablir l'original</button>
|
||||
<button id="save-btn" class="btn btn-outline">Enregistrer</button>
|
||||
<button id="export-btn" class="btn btn-primary">Exporter</button>
|
||||
@@ -20,6 +22,14 @@
|
||||
|
||||
<main id="editor-root"></main>
|
||||
|
||||
<aside class="preview-drawer" aria-label="Aperçu en direct">
|
||||
<div class="preview-bar">
|
||||
<span>Aperçu en direct — non publié tant que tu n'as pas cliqué sur Publier/Enregistrer</span>
|
||||
<a href="./" target="_blank" rel="noopener">Ouvrir la page ↗</a>
|
||||
</div>
|
||||
<iframe id="preview-frame" title="Aperçu de la page d'accueil"></iframe>
|
||||
</aside>
|
||||
|
||||
<script src="editor.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+122
-17
@@ -1,8 +1,20 @@
|
||||
let state = null;
|
||||
let dirty = false;
|
||||
let dragSource = null; // { appId }, { groupId } or { catalogApp } currently being dragged
|
||||
let catalog = []; // toutes les apps installees sur YunoHost (voir /__catalog)
|
||||
let catalog = []; // toutes les apps installees sur YunoHost (voir api.php?action=catalog)
|
||||
let catalogError = null;
|
||||
let env = { user: "", canEdit: false, local: false }; // voir api.php?action=whoami
|
||||
|
||||
// Meme contrat en local (scripts/preview.py) et sur YunoHost (api.php).
|
||||
function api(action) {
|
||||
return `api.php?action=${action}`;
|
||||
}
|
||||
|
||||
function apiPost(action, body, extra = {}) {
|
||||
const headers = { "X-Homepage-Editor": "1" };
|
||||
if (body !== undefined) headers["Content-Type"] = "application/json";
|
||||
return fetch(api(action), { method: "POST", headers, body, credentials: "same-origin", ...extra });
|
||||
}
|
||||
|
||||
const PALETTE = [
|
||||
"#1db9c3", "#ff5a1f", "#2094f3", "#ffc230", "#00a651", "#e6721a",
|
||||
@@ -47,7 +59,7 @@ function writeDraft() {
|
||||
draftTimer = null;
|
||||
const body = JSON.stringify(state, null, 2);
|
||||
draftWrite = draftWrite
|
||||
.then(() => fetch("/__draft", { method: "POST", headers: { "Content-Type": "application/json" }, body }))
|
||||
.then(() => apiPost("draft", body))
|
||||
.then((res) => { if (!res.ok) throw new Error(res.statusText); })
|
||||
.catch((err) => {
|
||||
setStatus("Erreur d'écriture du brouillon", "error");
|
||||
@@ -537,12 +549,37 @@ function render() {
|
||||
ungroupedSection.appendChild(ungroupedGrid);
|
||||
|
||||
center.appendChild(ungroupedSection);
|
||||
pushPreview();
|
||||
}
|
||||
|
||||
// Sur le serveur, PHP n'a pas acces au fichier root du portail : on demande
|
||||
// au portail YunoHost les apps visibles par l'utilisateur connecte, au meme
|
||||
// format que /etc/yunohost/portal/<domaine>.json (cf. yunohost_sync.py).
|
||||
async function fetchPortalCatalog() {
|
||||
const res = await fetch("/yunohost/portalapi/me", { credentials: "same-origin", cache: "no-store" });
|
||||
if (!res.ok) throw new Error(`portalapi/me : HTTP ${res.status}`);
|
||||
const me = await res.json();
|
||||
const ownPath = new URL(".", window.location.href).pathname.replace(/\/+$/, "");
|
||||
const apps = [];
|
||||
Object.entries(me.apps || {}).forEach(([permKey, info]) => {
|
||||
if (!permKey.endsWith(".main") || !info.url) return;
|
||||
let url = info.url.startsWith("http") ? info.url : `https://${info.url}`;
|
||||
if (!url.endsWith("/")) url += "/";
|
||||
if (ownPath && new URL(url).pathname.replace(/\/+$/, "") === ownPath) return; // cette page elle-meme
|
||||
const name = info.label || permKey.slice(0, -".main".length);
|
||||
const app = { id: permKey.slice(0, -".main".length), name, url, color: colorOf(name), initials: initialsOf(name) };
|
||||
if (info.logo) app.icon = info.logo.startsWith("http") ? info.logo : `${window.location.origin}${info.logo}`;
|
||||
apps.push(app);
|
||||
});
|
||||
apps.sort((a, b) => a.name.localeCompare(b.name, "fr", { sensitivity: "base" }));
|
||||
return { apps };
|
||||
}
|
||||
|
||||
async function loadCatalog() {
|
||||
try {
|
||||
const res = await fetch("/__catalog", { cache: "no-store" });
|
||||
const data = await res.json();
|
||||
const res = await fetch(api("catalog"), { cache: "no-store" });
|
||||
let data = await res.json();
|
||||
if (data.portal) data = await fetchPortalCatalog();
|
||||
if (data.error) {
|
||||
catalog = [];
|
||||
catalogError = data.error;
|
||||
@@ -552,13 +589,42 @@ async function loadCatalog() {
|
||||
}
|
||||
} catch (err) {
|
||||
catalog = [];
|
||||
catalogError = "Catalogue indisponible (aperçu local requis).";
|
||||
catalogError = "Catalogue YunoHost indisponible.";
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
function showAccessDenied(message) {
|
||||
document.querySelector(".editor-actions").hidden = true;
|
||||
const root = document.getElementById("editor-root");
|
||||
root.innerHTML = "";
|
||||
const box = document.createElement("p");
|
||||
box.className = "access-denied";
|
||||
box.textContent = message;
|
||||
root.appendChild(box);
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const res = await fetch("config.json", { cache: "no-store" });
|
||||
try {
|
||||
env = await (await fetch(api("whoami"), { cache: "no-store" })).json();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
showAccessDenied("Impossible de joindre le backend de l'éditeur (api.php). PHP est-il activé sur l'app ?");
|
||||
return;
|
||||
}
|
||||
if (!env.canEdit) {
|
||||
showAccessDenied(env.user
|
||||
? `« ${env.user} » n'est pas autorisé à modifier la page d'accueil.`
|
||||
: "Connecte-toi au portail YunoHost pour modifier la page d'accueil.");
|
||||
return;
|
||||
}
|
||||
// Exporter n'a de sens qu'en local ; en ligne, Enregistrer publie directement.
|
||||
document.getElementById("export-btn").hidden = !env.local;
|
||||
document.getElementById("save-btn").textContent = env.local ? "Enregistrer" : "Publier";
|
||||
document.getElementById("save-btn").className = env.local ? "btn btn-outline" : "btn btn-primary";
|
||||
|
||||
const res = await fetch(api("config"), { cache: "no-store" });
|
||||
if (!res.ok) throw new Error(await res.text());
|
||||
state = await res.json();
|
||||
setDirty(res.headers.get("X-Homepage-Draft") === "1");
|
||||
await loadCatalog();
|
||||
@@ -570,9 +636,9 @@ async function revert() {
|
||||
cancelPendingDraft();
|
||||
try {
|
||||
await draftWrite;
|
||||
const res = await fetch("/__discard", { method: "POST" });
|
||||
const res = await apiPost("discard");
|
||||
if (!res.ok) throw new Error(await res.text());
|
||||
const orig = await fetch("/__original", { cache: "no-store" });
|
||||
const orig = await fetch(api("original"), { cache: "no-store" });
|
||||
state = await orig.json();
|
||||
setDirty(false);
|
||||
render();
|
||||
@@ -588,14 +654,10 @@ async function save() {
|
||||
cancelPendingDraft();
|
||||
await draftWrite;
|
||||
try {
|
||||
const res = await fetch("/__save", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(state, null, 2),
|
||||
});
|
||||
const res = await apiPost("save", JSON.stringify(state, null, 2));
|
||||
if (!res.ok) throw new Error(await res.text());
|
||||
setDirty(false);
|
||||
setStatus("Enregistré ✓", "saved");
|
||||
setStatus(env.local ? "Enregistré ✓" : "Publié ✓", "saved");
|
||||
setTimeout(() => setStatus(""), 2000);
|
||||
} catch (err) {
|
||||
setStatus("Erreur d'enregistrement", "error");
|
||||
@@ -606,7 +668,7 @@ async function save() {
|
||||
async function exportToOutput() {
|
||||
await save();
|
||||
try {
|
||||
const res = await fetch("/__export", { method: "POST" });
|
||||
const res = await apiPost("export");
|
||||
if (!res.ok) throw new Error(await res.text());
|
||||
setStatus("Exporté vers output/ ✓", "saved");
|
||||
setTimeout(() => setStatus(""), 2500);
|
||||
@@ -625,7 +687,50 @@ document.getElementById("revert-btn").addEventListener("click", revert);
|
||||
window.addEventListener("pagehide", () => {
|
||||
if (!draftTimer) return;
|
||||
cancelPendingDraft();
|
||||
navigator.sendBeacon("/__draft", new Blob([JSON.stringify(state)], { type: "application/json" }));
|
||||
apiPost("draft", JSON.stringify(state), { keepalive: true });
|
||||
});
|
||||
|
||||
load();
|
||||
// --- Apercu en direct -------------------------------------------------------
|
||||
// index.html charge dans une iframe ; a chaque rendu, l'editeur lui envoie
|
||||
// l'etat courant (postMessage) et app.js le re-affiche sans aller-retour
|
||||
// serveur. L'iframe signale "ready" a chaque chargement pour recevoir l'etat.
|
||||
const PREVIEW_STORAGE_KEY = "homepage-editor-preview-open";
|
||||
|
||||
function previewFrame() {
|
||||
return document.getElementById("preview-frame");
|
||||
}
|
||||
|
||||
function pushPreview() {
|
||||
const frame = previewFrame();
|
||||
if (!state || !frame || !frame.contentWindow || document.body.dataset.preview !== "open") return;
|
||||
frame.contentWindow.postMessage({ type: "homepage-config", config: state }, window.location.origin);
|
||||
}
|
||||
|
||||
function setPreviewOpen(open) {
|
||||
document.body.dataset.preview = open ? "open" : "closed";
|
||||
document.getElementById("preview-toggle").setAttribute("aria-pressed", String(open));
|
||||
const frame = previewFrame();
|
||||
if (open && !frame.src) frame.src = "index.html?preview=1";
|
||||
else pushPreview();
|
||||
try { localStorage.setItem(PREVIEW_STORAGE_KEY, open ? "1" : "0"); } catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
window.addEventListener("message", (e) => {
|
||||
if (e.origin !== window.location.origin || e.source !== previewFrame().contentWindow) return;
|
||||
if (e.data && e.data.type === "homepage-preview-ready") pushPreview();
|
||||
});
|
||||
|
||||
document.getElementById("preview-toggle").addEventListener("click", () => {
|
||||
setPreviewOpen(document.body.dataset.preview !== "open");
|
||||
});
|
||||
|
||||
(function initPreview() {
|
||||
let open = true;
|
||||
try { open = localStorage.getItem(PREVIEW_STORAGE_KEY) !== "0"; } catch (e) { /* ignore */ }
|
||||
setPreviewOpen(open);
|
||||
})();
|
||||
|
||||
load().catch((err) => {
|
||||
setStatus("Erreur de chargement de la configuration", "error");
|
||||
console.error(err);
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
// Icone de l'onglet : reprend le logo defini pour cette app dans l'admin
|
||||
// YunoHost (Applications > Home Page > logo), lu via /yunohost/portalapi/me.
|
||||
// Le dernier logo connu est garde dans le navigateur pour s'afficher tout de
|
||||
// suite au chargement suivant. "portal.favicon" dans config.json, s'il est
|
||||
// renseigne, a la priorite (voir app.js).
|
||||
(function () {
|
||||
const STORAGE_KEY = "homepage-favicon";
|
||||
|
||||
function setFavicon(href) {
|
||||
if (!href) return;
|
||||
let link = document.querySelector('link[rel="icon"]');
|
||||
if (!link) {
|
||||
link = document.createElement("link");
|
||||
link.rel = "icon";
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
if (link.href !== href) link.href = href;
|
||||
}
|
||||
|
||||
function remember(href) {
|
||||
try { localStorage.setItem(STORAGE_KEY, href); } catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
function trimSlash(path) {
|
||||
return path.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
// Chemin de l'app = dossier de la page courante (ex. /home pour /home/editor.html).
|
||||
const ownPath = trimSlash(new URL(".", window.location.href).pathname);
|
||||
const ownKey = (window.location.host + ownPath).toLowerCase();
|
||||
|
||||
try { setFavicon(localStorage.getItem(STORAGE_KEY)); } catch (e) { /* ignore */ }
|
||||
|
||||
window.homepageSetFavicon = function (href) {
|
||||
setFavicon(href);
|
||||
remember(href);
|
||||
};
|
||||
|
||||
fetch("/yunohost/portalapi/me", { credentials: "same-origin", cache: "no-store" })
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((me) => {
|
||||
if (!me || !me.apps || window.homepageFaviconOverride) return;
|
||||
const self = Object.values(me.apps).find((info) => {
|
||||
const url = trimSlash((info.url || "").replace(/^https?:\/\//, "")).toLowerCase();
|
||||
return url === ownKey;
|
||||
});
|
||||
if (self && self.logo) window.homepageSetFavicon(new URL(self.logo, window.location.origin).href);
|
||||
})
|
||||
.catch(() => { /* hors YunoHost (apercu local) : pas de portail */ });
|
||||
})();
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Portail</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="favicon.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
@@ -58,6 +59,7 @@
|
||||
|
||||
<footer class="footer">
|
||||
<a href="#" id="footer-edit-profile">Éditer mon profil</a>
|
||||
<a href="editor.html" id="footer-edit-home" hidden>Éditer la page d'accueil</a>
|
||||
<a href="#" id="footer-doc">Documentation</a>
|
||||
<a href="#" id="footer-support">Support</a>
|
||||
<a href="#" id="footer-admin">Administration</a>
|
||||
|
||||
@@ -228,6 +228,7 @@ main#app {
|
||||
font-size: 13px;
|
||||
}
|
||||
.footer a:hover { text-decoration: underline; }
|
||||
.footer a[hidden] { display: none; }
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.topbar {
|
||||
|
||||
Reference in new issue
Block a user