Strictly require title for issue
This commit is contained in:
parent
2743899b65
commit
4bd255a7c4
@ -30,6 +30,14 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
||||
return
|
||||
}
|
||||
|
||||
title := r.PostFormValue("issue-title")
|
||||
if len(title) == 0 {
|
||||
err = fmt.Errorf("error: no title for issue specified")
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if session.Values["issue-image"] == nil {
|
||||
err := "error: Image required"
|
||||
log.Println(err)
|
||||
@ -55,14 +63,11 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
||||
return
|
||||
}
|
||||
|
||||
imgSize := imgInfo.Size()
|
||||
mimeType := mime.TypeByExtension(filepath.Ext(imgAbsName))
|
||||
|
||||
article := &b.Article{
|
||||
Title: r.PostFormValue("issue-title"),
|
||||
Title: title,
|
||||
EncURL: fmt.Sprint(c.Domain, "/image/serve/", imgFileName),
|
||||
EncLength: int(imgSize),
|
||||
EncType: mimeType,
|
||||
EncLength: int(imgInfo.Size()),
|
||||
EncType: mime.TypeByExtension(filepath.Ext(imgAbsName)),
|
||||
Published: true,
|
||||
Rejected: false,
|
||||
Created: time.Now(),
|
||||
|
@ -18,7 +18,7 @@
|
||||
<div>
|
||||
<h3>Titelseite</h3>
|
||||
<div class="grid grid-cols-2 gap-4 items-center">
|
||||
<input class="h-full" name="issue-title" placeholder="Titel" type="text" />
|
||||
<input class="h-full" name="issue-title" placeholder="Titel" required type="text" />
|
||||
<label class="btn text-center" for="image-upload">Bild hochladen</label>
|
||||
<input class="hidden" id="image-upload" name="issue-image" type="file" required
|
||||
hx-post="/issue/upload-image" />
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
<footer class="text-center text-gray-500 my-8">
|
||||
<p>© 2024 Jason Streifling. Alle Rechte vorbehalten.</p>
|
||||
<p>v0.11.0 - <strong>Alpha: Änderungen und Fehler möglich.</strong></p>
|
||||
<p>v0.11.0 - <strong>Alpha: Drastische Änderungen und Fehler vorbehalten.</strong></p>
|
||||
</footer>
|
||||
|
||||
<script src="https://unpkg.com/htmx.org@2.0.2"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user