|
@@ -9,6 +9,7 @@ import (
|
9
|
9
|
|
10
|
10
|
"gogs.gildas.ch/gildas/movies"
|
11
|
11
|
"gogs.gildas.ch/gildas/movies/omdb"
|
|
12
|
+ "gopkg.in/russross/blackfriday.v2"
|
12
|
13
|
)
|
13
|
14
|
|
14
|
15
|
func Router(c *movies.Collection) http.HandlerFunc {
|
|
@@ -156,15 +157,9 @@ func List(c *movies.Collection) http.HandlerFunc {
|
156
|
157
|
}
|
157
|
158
|
|
158
|
159
|
if r.Method == "POST" {
|
159
|
|
- updated, err := movies.UnmarshalList([]byte(r.FormValue("list_json")))
|
160
|
|
- if err != nil {
|
161
|
|
- errs = append(errs, err)
|
162
|
|
- } else if listID != updated.ID {
|
163
|
|
- errs = append(errs, fmt.Errorf("you cannot change the imdb id."))
|
164
|
|
- } else {
|
165
|
|
- l = updated
|
166
|
|
- c.UpdateList(updated)
|
167
|
|
- }
|
|
160
|
+ l.Title = r.FormValue("title")
|
|
161
|
+ l.Description = r.FormValue("description")
|
|
162
|
+ c.UpdateList(l)
|
168
|
163
|
}
|
169
|
164
|
|
170
|
165
|
b, err := json.MarshalIndent(l, "", " ")
|
|
@@ -173,7 +168,11 @@ func List(c *movies.Collection) http.HandlerFunc {
|
173
|
168
|
}
|
174
|
169
|
|
175
|
170
|
t.Execute(w, map[string]interface{}{
|
176
|
|
- "List": l,
|
|
171
|
+ "List": l,
|
|
172
|
+ "Description": template.HTML(
|
|
173
|
+ blackfriday.Run(
|
|
174
|
+ []byte(strings.ReplaceAll(l.Description, "\r\n", "\n")),
|
|
175
|
+ blackfriday.WithExtensions(blackfriday.CommonExtensions))),
|
177
|
176
|
"ListJSON": string(b),
|
178
|
177
|
"Errors": errs,
|
179
|
178
|
})
|