sync: Parse resolution.md
This commit is contained in:
parent
0cc72712a4
commit
f8001653cd
4 changed files with 62 additions and 28 deletions
|
@ -190,14 +190,11 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
|
|||
}
|
||||
}
|
||||
|
||||
// Handle video
|
||||
// Handle resolutions
|
||||
resolutionFound := false
|
||||
|
||||
e.VideoURI = path.Join(epath, "resolution.mp4")
|
||||
if !i.exists(e.VideoURI) {
|
||||
if LogMissingResolution {
|
||||
log.Printf("%q: resolution.mp4: no video file found at %s", edir, e.VideoURI)
|
||||
} else {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: no video file found at %s", edir, e.VideoURI))
|
||||
}
|
||||
e.VideoURI = ""
|
||||
} else if size, err := getFileSize(i, e.VideoURI); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: ", edir, err))
|
||||
|
@ -205,6 +202,35 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
|
|||
} else if size == 0 {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: The file is empty!", edir))
|
||||
e.VideoURI = ""
|
||||
} else {
|
||||
resolutionFound = true
|
||||
}
|
||||
|
||||
writeup := path.Join(epath, "resolution.md")
|
||||
if !i.exists(writeup) {
|
||||
writeup = path.Join(epath, "resolution.txt")
|
||||
}
|
||||
|
||||
if i.exists(writeup) {
|
||||
if size, err := getFileSize(i, writeup); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.md: %s", edir, err.Error()))
|
||||
} else if size == 0 {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.md: The file is empty!", edir))
|
||||
} else if e.Resolution, err = getFileContent(i, writeup); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.md: %s", edir, err.Error()))
|
||||
} else if e.Resolution, err = ProcessMarkdown(i, e.Overview, epath); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: resolution.md: error during markdown processing: %s", edir, err.Error()))
|
||||
} else {
|
||||
resolutionFound = true
|
||||
}
|
||||
}
|
||||
|
||||
if !resolutionFound {
|
||||
if LogMissingResolution {
|
||||
log.Printf("%q: no resolution video or text file found in %s", edir, epath, epath)
|
||||
} else {
|
||||
errs = append(errs, fmt.Sprintf("%q: no resolution video or text file found in %s", edir, epath))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
Reference in a new issue