forked from jason/cpolis
Switch to atom feed
This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
||||
DBName string
|
||||
Description string
|
||||
Domain string
|
||||
AtomFeed string
|
||||
FirebaseKey string
|
||||
KeyFile string
|
||||
Link string
|
||||
@@ -36,6 +37,7 @@ func newConfig() *Config {
|
||||
ArticleDir: "/var/www/cpolis/articles",
|
||||
ConfigFile: "/etc/cpolis/config.toml",
|
||||
DBName: "cpolis",
|
||||
AtomFeed: "/var/www/cpolis/cpolis.atom",
|
||||
FirebaseKey: "/var/www/cpolis/serviceAccountKey.json",
|
||||
KeyFile: "/var/www/cpolis/cpolis.key",
|
||||
LogFile: "/var/log/cpolis.log",
|
||||
@@ -101,6 +103,7 @@ func (c *Config) handleCliArgs() error {
|
||||
var err error
|
||||
|
||||
flag.StringVar(&c.ArticleDir, "articles", c.ArticleDir, "articles directory")
|
||||
flag.StringVar(&c.AtomFeed, "feed", c.AtomFeed, "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")
|
||||
@@ -163,6 +166,18 @@ func (c *Config) setupConfig(cliConfig *Config) error {
|
||||
if cliConfig.Domain != defaultConfig.Domain {
|
||||
c.Domain = cliConfig.Domain
|
||||
}
|
||||
domainStrings := strings.Split(c.Domain, "/")
|
||||
if domainStrings[0] != "http:" && domainStrings[0] != "https:" {
|
||||
c.Domain = "https://" + c.Domain
|
||||
}
|
||||
|
||||
if cliConfig.AtomFeed != defaultConfig.AtomFeed {
|
||||
c.AtomFeed = cliConfig.AtomFeed
|
||||
}
|
||||
c.AtomFeed, err = mkFile(c.AtomFeed, 0644, 0744)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error setting up file: %v", err)
|
||||
}
|
||||
|
||||
if cliConfig.FirebaseKey != defaultConfig.FirebaseKey {
|
||||
c.FirebaseKey = cliConfig.FirebaseKey
|
||||
|
||||
Reference in New Issue
Block a user