now using propper URL redirects, media path now created if not found, now checking for templates directory
This commit is contained in:
parent
0431580dd6
commit
78aa6bea18
13
comics.go
13
comics.go
|
@ -1,9 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
"fmt"
|
||||
"flag"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
"math/rand"
|
||||
|
@ -90,6 +92,17 @@ func (o * Options) Parse() error {
|
|||
|
||||
flag.Parse()
|
||||
|
||||
if _, err := os.Stat(o.TemplatesPath); errors.Is(err, os.ErrNotExist) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(o.MediaPath); errors.Is(err, os.ErrNotExist) {
|
||||
err := os.Mkdir(o.MediaPath, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -114,14 +114,14 @@ func managerRemoveView(w http.ResponseWriter, r * http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("http://%s:%d", options.Address, options.Port), http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func managerPublishView(w http.ResponseWriter, r * http.Request) {
|
||||
var err error
|
||||
|
||||
if r.Method == "GET" {
|
||||
http.Redirect(w, r, fmt.Sprintf("http://%s:%d", options.Address, options.Port), http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
if r.Method != "POST" {
|
||||
|
@ -162,7 +162,7 @@ func managerPublishView(w http.ResponseWriter, r * http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("http://%s:%d", options.Address, options.Port), http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func managerEditView(w http.ResponseWriter, r * http.Request) {
|
||||
|
|
Loading…
Reference in New Issue