Forum : page « Publier » (éditeur Markdown sûr, aperçu, brouillons)

- Bouton « Publier » dans l'en-tête (droit creer_sujet) ; /nouveau redirige vers /publier.
- /publier en pleine largeur : titre, station liée facultative, photos, « Me prévenir des
  réponses » (enregistré seulement), emplacement « Catégorie » marqué bientôt.
- markdown_sur.py : convertisseur maison (HTML échappé d'abord, liens http(s) seulement,
  titres, gras, italique, listes, code, paragraphes, tableaux pipe).
- posts.format ('texte' par défaut, 'md' depuis /publier) ; topics.station_liee et prevenir.
- Brouillons privés (table brouillons) : enregistrement auto ~1 s après la frappe
  (apercu.js), bouton sans JS, page « Mes brouillons », suppression à la publication.
- Tests : tests/test_publier.py ; tests existants mis à jour pour /publier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
Théo GastineletClaude Opus 5.5 a révisé 2026-11-06 00:39:45 +01:00
1 Parent 7b7be84fdf
révision c0d43e4e59
9 fichiers modifiés
+600 -30

Aucun fichier ne correspond à votre recherche

+18
Voir le fichier
@@ -111,6 +111,17 @@ CREATE TABLE IF NOT EXISTS lectures (
dernier_post INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, topic_id)
);
-- Brouillons de la page « Publier » : privés, un auteur ne voit que les siens ; supprimés à la publication.
CREATE TABLE IF NOT EXISTS brouillons (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
titre TEXT NOT NULL DEFAULT '',
corps TEXT NOT NULL DEFAULT '',
station TEXT NOT NULL DEFAULT '',
prevenir INTEGER NOT NULL DEFAULT 0,
maj TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_brouillons_user ON brouillons(user_id, maj);
CREATE UNIQUE INDEX IF NOT EXISTS idx_un_sujet_par_station ON topics(station) WHERE station IS NOT NULL AND status <> 'refuse';
"""
@@ -126,6 +137,13 @@ def connecter(chemin=":memory:"):
# migrations douces (colonnes ajoutées après la mise en ligne)
if "ancien_body" not in {r[1] for r in con.execute("PRAGMA table_info(posts)")}:
con.execute("ALTER TABLE posts ADD COLUMN ancien_body TEXT") # version d'avant l'unique modification
if "format" not in {r[1] for r in con.execute("PRAGMA table_info(posts)")}:
con.execute("ALTER TABLE posts ADD COLUMN format TEXT NOT NULL DEFAULT 'texte'") # 'texte' ou 'md' (page Publier)
cols = {r[1] for r in con.execute("PRAGMA table_info(topics)")}
if "station_liee" not in cols:
con.execute("ALTER TABLE topics ADD COLUMN station_liee TEXT") # station citée (facultatif), distincte du sujet de station
if "prevenir" not in cols:
con.execute("ALTER TABLE topics ADD COLUMN prevenir INTEGER NOT NULL DEFAULT 0") # « Me prévenir des réponses » (enregistré, pas encore d'envoi)
con.execute("INSERT OR IGNORE INTO users(hub_id, display_name) VALUES (?, ?)", (SYSTEME, "vercors.me"))
if con.execute("SELECT 1 FROM topics WHERE fixed=1").fetchone() is None:
sid = con.execute("SELECT id FROM users WHERE hub_id=?", (SYSTEME,)).fetchone()[0]