fic: Can overwrite authors for each exercice

This commit is contained in:
nemunaire 2023-06-14 21:04:56 +02:00
commit 28ad0fa791
5 changed files with 23 additions and 11 deletions

View file

@ -613,7 +613,7 @@ func createExercice(c *gin.Context) {
}
}
exercice, err := theme.AddExercice(ue.Title, ue.Image, ue.WIP, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI, ue.Resolution, ue.SeeAlso, ue.Finished)
exercice, err := theme.AddExercice(ue.Title, ue.Authors, ue.Image, ue.WIP, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI, ue.Resolution, ue.SeeAlso, ue.Finished)
if err != nil {
log.Println("Unable to createExercice:", err.Error())
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during exercice creation."})

View file

@ -1717,7 +1717,7 @@ angular.module("FICApp")
}
});
$scope.exercices = Exercice.query();
$scope.fields = ["title", "urlid", "disabled", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "image", "resolution", "issue", "issuekind", "wip"];
$scope.fields = ["title", "urlid", "authors", "disabled", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "image", "resolution", "issue", "issuekind", "wip"];
$scope.inSync = false;
$scope.syncExo = function() {

View file

@ -139,6 +139,15 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
e.URLId = fic.ToURLid(e.Title)
e.Title = fixnbsp(e.Title)
if i.Exists(path.Join(epath, "AUTHORS.txt")) {
if authors, err := getAuthors(i, epath); err != nil {
errs = append(errs, NewExerciceError(e, fmt.Errorf("unable to get AUTHORS.txt: %w", err)))
} else {
// Format authors
e.Authors = strings.Join(authors, ", ")
}
}
// Texts to format using Markdown
if i.Exists(path.Join(epath, "overview.txt")) {
e.Overview, err = GetFileContent(i, path.Join(epath, "overview.txt"))