diff --git a/cmd/backend/config.go b/cmd/backend/config.go index fdda506..b56e315 100644 --- a/cmd/backend/config.go +++ b/cmd/backend/config.go @@ -18,7 +18,7 @@ type Config struct { DBName string Description string Domain string - AtomFeed string + AtomFile string FirebaseKey string GOBKeyFile string Link string @@ -39,7 +39,7 @@ func newConfig() *Config { return &Config{ AESKeyFile: "/var/www/cpolis/aes.key", ArticleDir: "/var/www/cpolis/articles", - AtomFeed: "/var/www/cpolis/cpolis.atom", + AtomFile: "/var/www/cpolis/cpolis.atom", ConfigFile: "/etc/cpolis/config.toml", DBName: "cpolis", FirebaseKey: "/var/www/cpolis/serviceAccountKey.json", @@ -110,7 +110,7 @@ func (c *Config) handleCliArgs() error { flag.StringVar(&c.AESKeyFile, "aes", c.AESKeyFile, "aes key file") flag.StringVar(&c.ArticleDir, "articles", c.ArticleDir, "articles directory") - flag.StringVar(&c.AtomFeed, "feed", c.AtomFeed, "atom feed file") + flag.StringVar(&c.AtomFile, "feed", c.AtomFile, "atom feed file") flag.StringVar(&c.ConfigFile, "config", c.ConfigFile, "config file") flag.StringVar(&c.DBName, "db", c.DBName, "DB name") flag.StringVar(&c.Description, "desc", c.Description, "channel description") @@ -187,10 +187,10 @@ func (c *Config) setupConfig(cliConfig *Config) error { c.Domain = "https://" + c.Domain } - if cliConfig.AtomFeed != defaultConfig.AtomFeed { - c.AtomFeed = cliConfig.AtomFeed + if cliConfig.AtomFile != defaultConfig.AtomFile { + c.AtomFile = cliConfig.AtomFile } - c.AtomFeed, err = mkFile(c.AtomFeed, 0644, 0744) + c.AtomFile, err = mkFile(c.AtomFile, 0644, 0744) if err != nil { return fmt.Errorf("error setting up file: %v", err) } diff --git a/cmd/calls/atom.go b/cmd/calls/atom.go index 7d57463..6110d4f 100644 --- a/cmd/calls/atom.go +++ b/cmd/calls/atom.go @@ -14,7 +14,7 @@ func ServeAtomFeed(c *b.Config) http.HandlerFunc { return } - absFilepath, err := filepath.Abs(c.AtomFeed) + absFilepath, err := filepath.Abs(c.AtomFile) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index 616a56f..864bfd6 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -469,7 +469,7 @@ func PublishArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { + if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -704,7 +704,7 @@ func DeleteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { + if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/cmd/frontend/images.go b/cmd/frontend/images.go index cec9984..921c768 100644 --- a/cmd/frontend/images.go +++ b/cmd/frontend/images.go @@ -17,12 +17,6 @@ func UploadImage(c *b.Config, s *b.CookieStore) http.HandlerFunc { return } - if err := r.ParseMultipartForm(10 << 20); err != nil { - log.Println(err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - file, _, err := r.FormFile("article-image") if err != nil { log.Println(err) diff --git a/cmd/frontend/issues.go b/cmd/frontend/issues.go index efa1ba8..4aefb63 100644 --- a/cmd/frontend/issues.go +++ b/cmd/frontend/issues.go @@ -97,7 +97,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { + if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/cmd/frontend/pdf.go b/cmd/frontend/pdf.go index 5d25554..eda5820 100644 --- a/cmd/frontend/pdf.go +++ b/cmd/frontend/pdf.go @@ -18,12 +18,6 @@ func UploadPDF(c *b.Config, s *b.CookieStore) http.HandlerFunc { return } - if err := r.ParseMultipartForm(10 << 20); err != nil { - log.Println(err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - file, _, err := r.FormFile("pdf-upload") if err != nil { log.Println(err)