New attribute "disclaimer" on downloadable files
This commit is contained in:
parent
c28ad9533b
commit
bd19d31577
6 changed files with 80 additions and 22 deletions
|
@ -143,7 +143,27 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
|||
}
|
||||
}
|
||||
|
||||
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), getDestinationFilePath(path.Join(exercice.Path, "files", fname)), (*hash512).Sum(nil), digest_shown, size)
|
||||
paramsFiles, err := GetExerciceFilesParams(i, exercice)
|
||||
if err != nil {
|
||||
errs = append(errs, NewChallengeTxtError(exercice, 0, err))
|
||||
return
|
||||
}
|
||||
|
||||
disclaimer := ""
|
||||
if f, exists := paramsFiles[fname]; exists {
|
||||
// Call checks hooks
|
||||
for _, hk := range hooks.mdTextHooks {
|
||||
for _, err := range hk(f.Disclaimer, exceptions) {
|
||||
errs = append(errs, NewFileError(exercice, fname, err))
|
||||
}
|
||||
}
|
||||
|
||||
if disclaimer, err = ProcessMarkdown(i, fixnbsp(f.Disclaimer), exercice.Path); err != nil {
|
||||
errs = append(errs, NewFileError(exercice, fname, fmt.Errorf("error during markdown formating of disclaimer: %w", err)))
|
||||
}
|
||||
}
|
||||
|
||||
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), getDestinationFilePath(path.Join(exercice.Path, "files", fname)), (*hash512).Sum(nil), digest_shown, disclaimer, size)
|
||||
|
||||
// Call checks hooks
|
||||
for _, h := range hooks.fileHooks {
|
||||
|
@ -187,11 +207,23 @@ func SyncExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExce
|
|||
}
|
||||
|
||||
published := true
|
||||
disclaimer := ""
|
||||
if f, exists := paramsFiles[fname]; exists {
|
||||
published = !f.Hidden
|
||||
|
||||
// Call checks hooks
|
||||
for _, hk := range hooks.mdTextHooks {
|
||||
for _, err := range hk(f.Disclaimer, exceptions) {
|
||||
errs = append(errs, NewFileError(exercice, fname, err))
|
||||
}
|
||||
}
|
||||
|
||||
if disclaimer, err = ProcessMarkdown(i, fixnbsp(f.Disclaimer), exercice.Path); err != nil {
|
||||
errs = append(errs, NewFileError(exercice, fname, fmt.Errorf("error during markdown formating of disclaimer: %w", err)))
|
||||
}
|
||||
}
|
||||
|
||||
return exercice.ImportFile(filePath, origin, digests[fname], digest_shown, published)
|
||||
return exercice.ImportFile(filePath, origin, digests[fname], digest_shown, disclaimer, published)
|
||||
}); err != nil {
|
||||
errs = append(errs, NewFileError(exercice, fname, err))
|
||||
continue
|
||||
|
|
Reference in a new issue