From b2a679c25da42c4665059965830858da4f0ec238 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 15 Sep 2015 18:59:14 -0700 Subject: PLT-93 cleaing up client side configs --- utils/config.go | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'utils/config.go') diff --git a/utils/config.go b/utils/config.go index a1d282c29..eb78cd08a 100644 --- a/utils/config.go +++ b/utils/config.go @@ -4,10 +4,13 @@ package utils import ( - l4g "code.google.com/p/log4go" "encoding/json" + "fmt" "os" "path/filepath" + "strconv" + + l4g "code.google.com/p/log4go" ) const ( @@ -109,15 +112,15 @@ type PrivacySettings struct { ShowFullName bool } +type ClientSettings struct { + SegmentDeveloperKey string + GoogleDeveloperKey string +} + type TeamSettings struct { MaxUsersPerTeam int AllowPublicLink bool AllowValetDefault bool - TermsLink string - PrivacyLink string - AboutLink string - HelpLink string - ReportProblemLink string TourLink string DefaultThemeColor string DisableTeamCreation bool @@ -133,6 +136,7 @@ type Config struct { EmailSettings EmailSettings RateLimitSettings RateLimitSettings PrivacySettings PrivacySettings + ClientSettings ClientSettings TeamSettings TeamSettings SSOSettings map[string]SSOSetting } @@ -147,6 +151,8 @@ func (o *Config) ToJson() string { } var Cfg *Config = &Config{} +var CfgLastModified int64 = 0 +var ClientProperties map[string]string = map[string]string{} var SanitizeOptions map[string]bool = map[string]bool{} func FindConfigFile(fileName string) string { @@ -242,22 +248,46 @@ func LoadConfig(fileName string) { panic("Error decoding config file=" + fileName + ", err=" + err.Error()) } + if info, err := file.Stat(); err != nil { + panic("Error getting config info file=" + fileName + ", err=" + err.Error()) + } else { + CfgLastModified = info.ModTime().Unix() + } + configureLog(&config.LogSettings) Cfg = &config - SanitizeOptions = getSanitizeOptions() + SanitizeOptions = getSanitizeOptions(Cfg) + ClientProperties = getClientProperties(Cfg) } -func getSanitizeOptions() map[string]bool { +func getSanitizeOptions(c *Config) map[string]bool { options := map[string]bool{} - options["fullname"] = Cfg.PrivacySettings.ShowFullName - options["email"] = Cfg.PrivacySettings.ShowEmailAddress - options["skypeid"] = Cfg.PrivacySettings.ShowSkypeId - options["phonenumber"] = Cfg.PrivacySettings.ShowPhoneNumber + options["fullname"] = c.PrivacySettings.ShowFullName + options["email"] = c.PrivacySettings.ShowEmailAddress + options["skypeid"] = c.PrivacySettings.ShowSkypeId + options["phonenumber"] = c.PrivacySettings.ShowPhoneNumber return options } +func getClientProperties(c *Config) map[string]string { + props := make(map[string]string) + + props["Version"] = c.ServiceSettings.Version + props["SiteName"] = c.ServiceSettings.SiteName + props["ByPassEmail"] = strconv.FormatBool(c.EmailSettings.ByPassEmail) + props["ShowEmailAddress"] = strconv.FormatBool(c.PrivacySettings.ShowEmailAddress) + props["AllowPublicLink"] = strconv.FormatBool(c.TeamSettings.AllowPublicLink) + props["SegmentDeveloperKey"] = c.ClientSettings.SegmentDeveloperKey + props["GoogleDeveloperKey"] = c.ClientSettings.GoogleDeveloperKey + props["AnalyticsUrl"] = c.ServiceSettings.AnalyticsUrl + props["ProfileHeight"] = fmt.Sprintf("%v", c.ImageSettings.ProfileHeight) + props["ProfileWidth"] = fmt.Sprintf("%v", c.ImageSettings.ProfileWidth) + + return props +} + func IsS3Configured() bool { if Cfg.AWSSettings.S3AccessKeyId == "" || Cfg.AWSSettings.S3SecretAccessKey == "" || Cfg.AWSSettings.S3Region == "" || Cfg.AWSSettings.S3Bucket == "" { return false -- cgit v1.2.3-1-g7c22 From 5e2f701e6c6c8bfa87b2913100365b45264470c3 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 15 Sep 2015 19:09:50 -0700 Subject: Removing old config stuff --- utils/config.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils/config.go') diff --git a/utils/config.go b/utils/config.go index eb78cd08a..9f66e9f37 100644 --- a/utils/config.go +++ b/utils/config.go @@ -282,8 +282,10 @@ func getClientProperties(c *Config) map[string]string { props["SegmentDeveloperKey"] = c.ClientSettings.SegmentDeveloperKey props["GoogleDeveloperKey"] = c.ClientSettings.GoogleDeveloperKey props["AnalyticsUrl"] = c.ServiceSettings.AnalyticsUrl + props["ByPassEmail"] = strconv.FormatBool(c.EmailSettings.ByPassEmail) props["ProfileHeight"] = fmt.Sprintf("%v", c.ImageSettings.ProfileHeight) props["ProfileWidth"] = fmt.Sprintf("%v", c.ImageSettings.ProfileWidth) + props["ProfileWidth"] = fmt.Sprintf("%v", c.ImageSettings.ProfileWidth) return props } -- cgit v1.2.3-1-g7c22