Merge branch 'devel'

This commit is contained in:
Jason Streifling 2024-10-28 18:02:56 +01:00
commit e4e43d1a83
6 changed files with 10 additions and 22 deletions

View File

@ -18,7 +18,7 @@ type Config struct {
DBName string DBName string
Description string Description string
Domain string Domain string
AtomFeed string AtomFile string
FirebaseKey string FirebaseKey string
GOBKeyFile string GOBKeyFile string
Link string Link string
@ -39,7 +39,7 @@ func newConfig() *Config {
return &Config{ return &Config{
AESKeyFile: "/var/www/cpolis/aes.key", AESKeyFile: "/var/www/cpolis/aes.key",
ArticleDir: "/var/www/cpolis/articles", ArticleDir: "/var/www/cpolis/articles",
AtomFeed: "/var/www/cpolis/cpolis.atom", AtomFile: "/var/www/cpolis/cpolis.atom",
ConfigFile: "/etc/cpolis/config.toml", ConfigFile: "/etc/cpolis/config.toml",
DBName: "cpolis", DBName: "cpolis",
FirebaseKey: "/var/www/cpolis/serviceAccountKey.json", 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.AESKeyFile, "aes", c.AESKeyFile, "aes key file")
flag.StringVar(&c.ArticleDir, "articles", c.ArticleDir, "articles directory") 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.ConfigFile, "config", c.ConfigFile, "config file")
flag.StringVar(&c.DBName, "db", c.DBName, "DB name") flag.StringVar(&c.DBName, "db", c.DBName, "DB name")
flag.StringVar(&c.Description, "desc", c.Description, "channel description") 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 c.Domain = "https://" + c.Domain
} }
if cliConfig.AtomFeed != defaultConfig.AtomFeed { if cliConfig.AtomFile != defaultConfig.AtomFile {
c.AtomFeed = cliConfig.AtomFeed c.AtomFile = cliConfig.AtomFile
} }
c.AtomFeed, err = mkFile(c.AtomFeed, 0644, 0744) c.AtomFile, err = mkFile(c.AtomFile, 0644, 0744)
if err != nil { if err != nil {
return fmt.Errorf("error setting up file: %v", err) return fmt.Errorf("error setting up file: %v", err)
} }

View File

@ -14,7 +14,7 @@ func ServeAtomFeed(c *b.Config) http.HandlerFunc {
return return
} }
absFilepath, err := filepath.Abs(c.AtomFeed) absFilepath, err := filepath.Abs(c.AtomFile)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -469,7 +469,7 @@ func PublishArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil {
log.Println(err) log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return 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) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil {
log.Println(err) log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return

View File

@ -17,12 +17,6 @@ func UploadImage(c *b.Config, s *b.CookieStore) http.HandlerFunc {
return 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") file, _, err := r.FormFile("article-image")
if err != nil { if err != nil {
log.Println(err) log.Println(err)

View File

@ -97,7 +97,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
if err = b.SaveAtomFeed(c.AtomFeed, feed); err != nil { if err = b.SaveAtomFeed(c.AtomFile, feed); err != nil {
log.Println(err) log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return

View File

@ -18,12 +18,6 @@ func UploadPDF(c *b.Config, s *b.CookieStore) http.HandlerFunc {
return 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") file, _, err := r.FormFile("pdf-upload")
if err != nil { if err != nil {
log.Println(err) log.Println(err)