forked from jason/cpolis
Split up max value for img height and with into values for img and banner
This commit is contained in:
@@ -12,44 +12,48 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
AESKeyFile string
|
||||
ArticleDir string
|
||||
ConfigFile string
|
||||
DBName string
|
||||
Description string
|
||||
Domain string
|
||||
AtomFeed string
|
||||
FirebaseKey string
|
||||
GOBKeyFile string
|
||||
Link string
|
||||
LogFile string
|
||||
PDFDir string
|
||||
PicsDir string
|
||||
Port string
|
||||
Title string
|
||||
Version string
|
||||
WebDir string
|
||||
MaxImgHeight int
|
||||
MaxImgWidth int
|
||||
AESKeyFile string
|
||||
ArticleDir string
|
||||
ConfigFile string
|
||||
DBName string
|
||||
Description string
|
||||
Domain string
|
||||
AtomFeed string
|
||||
FirebaseKey string
|
||||
GOBKeyFile string
|
||||
Link string
|
||||
LogFile string
|
||||
PDFDir string
|
||||
PicsDir string
|
||||
Port string
|
||||
Title string
|
||||
Version string
|
||||
WebDir string
|
||||
MaxBannerHeight int
|
||||
MaxBannerWidth int
|
||||
MaxImgHeight int
|
||||
MaxImgWidth int
|
||||
}
|
||||
|
||||
func newConfig() *Config {
|
||||
return &Config{
|
||||
AESKeyFile: "/var/www/cpolis/aes.key",
|
||||
ArticleDir: "/var/www/cpolis/articles",
|
||||
ConfigFile: "/etc/cpolis/config.toml",
|
||||
DBName: "cpolis",
|
||||
AtomFeed: "/var/www/cpolis/cpolis.atom",
|
||||
FirebaseKey: "/var/www/cpolis/serviceAccountKey.json",
|
||||
GOBKeyFile: "/var/www/cpolis/gob.key",
|
||||
LogFile: "/var/log/cpolis.log",
|
||||
MaxImgHeight: 1080,
|
||||
MaxImgWidth: 1920,
|
||||
PDFDir: "/var/www/cpolis/pdfs",
|
||||
PicsDir: "/var/www/cpolis/pics",
|
||||
Port: ":8080",
|
||||
Version: "v0.13.0",
|
||||
WebDir: "/var/www/cpolis/web",
|
||||
AESKeyFile: "/var/www/cpolis/aes.key",
|
||||
ArticleDir: "/var/www/cpolis/articles",
|
||||
ConfigFile: "/etc/cpolis/config.toml",
|
||||
DBName: "cpolis",
|
||||
AtomFeed: "/var/www/cpolis/cpolis.atom",
|
||||
FirebaseKey: "/var/www/cpolis/serviceAccountKey.json",
|
||||
GOBKeyFile: "/var/www/cpolis/gob.key",
|
||||
LogFile: "/var/log/cpolis.log",
|
||||
MaxBannerHeight: 1080,
|
||||
MaxBannerWidth: 1920,
|
||||
MaxImgHeight: 1080,
|
||||
MaxImgWidth: 1920,
|
||||
PDFDir: "/var/www/cpolis/pdfs",
|
||||
PicsDir: "/var/www/cpolis/pics",
|
||||
Port: ":8080",
|
||||
Version: "v0.13.0",
|
||||
WebDir: "/var/www/cpolis/web",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +123,10 @@ func (c *Config) handleCliArgs() error {
|
||||
flag.StringVar(&c.PicsDir, "pics", c.PicsDir, "pictures directory")
|
||||
flag.StringVar(&c.Title, "title", c.Title, "channel title")
|
||||
flag.StringVar(&c.WebDir, "web", c.WebDir, "web directory")
|
||||
flag.IntVar(&c.MaxImgHeight, "height", c.MaxImgHeight, "maximum image height")
|
||||
flag.IntVar(&c.MaxImgWidth, "width", c.MaxImgWidth, "maximum image width")
|
||||
flag.IntVar(&c.MaxBannerHeight, "banner-height", c.MaxBannerHeight, "maximum banner height")
|
||||
flag.IntVar(&c.MaxBannerWidth, "banner-width", c.MaxBannerWidth, "maximum banner width")
|
||||
flag.IntVar(&c.MaxImgHeight, "img-height", c.MaxImgHeight, "maximum image height")
|
||||
flag.IntVar(&c.MaxImgWidth, "img-width", c.MaxImgWidth, "maximum image width")
|
||||
flag.IntVar(&port, "port", port, "port")
|
||||
flag.Parse()
|
||||
|
||||
@@ -217,6 +223,14 @@ func (c *Config) setupConfig(cliConfig *Config) error {
|
||||
return fmt.Errorf("error setting up file: %v", err)
|
||||
}
|
||||
|
||||
if cliConfig.MaxBannerHeight != defaultConfig.MaxBannerHeight {
|
||||
c.MaxBannerHeight = cliConfig.MaxBannerHeight
|
||||
}
|
||||
|
||||
if cliConfig.MaxBannerWidth != defaultConfig.MaxBannerWidth {
|
||||
c.MaxBannerWidth = cliConfig.MaxBannerWidth
|
||||
}
|
||||
|
||||
if cliConfig.MaxImgHeight != defaultConfig.MaxImgHeight {
|
||||
c.MaxImgHeight = cliConfig.MaxImgHeight
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user