diff --git a/admin/sync/README.md b/admin/sync/README.md index 6b974898..8aaf5dba 100644 --- a/admin/sync/README.md +++ b/admin/sync/README.md @@ -35,7 +35,7 @@ Tous les textes doivent utiliser l'encodage UTF8. + `label = "Intitulé de la réponse"` : (facultatif, par défaut identique à `value`) ; - `[[hint]]` : paramètres pour un indice : * `filename = "toto.txt"` : (mutuellement exclusif avec `content`) nom du fichier tel qu'il apparaît dans le dossier `hints` ; - * `content = "Contenu de l'indice"` : (mutuellement exclusif avec `filename`) contenu de l'indice affiché ; + * `content = "Contenu de l'indice"` : (mutuellement exclusif avec `filename`) contenu de l'indice affiché, en markdown ; * `cost = 10` : (facultatif, par défaut 1/4 des gains du challenge) coût de l'indice ; * `title = "Foo Bar"` : (facultatif, par défaut "Astuce $id") titre de l'astuce dans l'interface ; + `links.txt` : webographie publiée avec les solutions @@ -214,5 +214,5 @@ Exemple `DIGESTS.txt` {#exemple-digeststxt} --- title: Format des répertoires pour la synchronisation author: FIC team 2019 -date: "Dernière mise à jour du document : 12 mai 2018" +date: "Dernière mise à jour du document : 17 août 2018" --- diff --git a/admin/sync/exercice_hints.go b/admin/sync/exercice_hints.go index c95fb1f0..b1590a43 100644 --- a/admin/sync/exercice_hints.go +++ b/admin/sync/exercice_hints.go @@ -12,6 +12,7 @@ import ( "srs.epita.fr/fic-server/libfic" + "gopkg.in/russross/blackfriday.v2" _ "golang.org/x/crypto/blake2b" ) @@ -69,12 +70,11 @@ func SyncExerciceHints(i Importer, exercice fic.Exercice) (errs []string) { hint.Content = s } } - } - - // At this point, filename should have been replaced by Content if filled, so let's ensure that - if hint.Content == "" { + } else if hint.Content == "" { errs = append(errs, fmt.Sprintf("%q: challenge.txt: hint %s (%d): content and filename can't be empty at the same time", path.Base(exercice.Path), hint.Title, n+1)) continue + } else { + hint.Content = string(blackfriday.Run([]byte(hint.Content))) } // Import hint diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go index ed8669e3..81d3265f 100644 --- a/admin/sync/exercices.go +++ b/admin/sync/exercices.go @@ -7,6 +7,7 @@ import ( "strconv" "srs.epita.fr/fic-server/libfic" + "gopkg.in/russross/blackfriday.v2" ) // getExercices returns all exercice directories existing in a given theme, considering the given Importer. @@ -83,6 +84,10 @@ func SyncExercices(i Importer, theme fic.Theme) []string { videoURI = "" } + // Markdown pre-formating + statement = string(blackfriday.Run([]byte(statement))) + overview = string(blackfriday.Run([]byte(overview))) + if e, err := theme.GetExerciceByTitle(ename); err != nil { if ex, err := theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Path, edir), statement, overview, nil, gain, videoURI); err != nil { errs = append(errs, fmt.Sprintf("%q: error on exercice add: %s", edir, err)) diff --git a/admin/sync/themes.go b/admin/sync/themes.go index 87a0f932..b76952ec 100644 --- a/admin/sync/themes.go +++ b/admin/sync/themes.go @@ -7,6 +7,7 @@ import ( "srs.epita.fr/fic-server/libfic" "github.com/julienschmidt/httprouter" + "gopkg.in/russross/blackfriday.v2" ) // getThemes returns all theme directories in the base directory. @@ -67,8 +68,12 @@ func SyncThemes(i Importer) []string { } } + // Format authors authors_str := strings.Join(authors, ", ") + // Format overview (markdown) + intro = string(blackfriday.Run([]byte(intro))) + if theme.Name != tname || theme.Authors != authors_str || theme.Intro != intro { theme.Name = tname theme.Authors = authors_str