types.go (1604B)
1 package types 2 3 import ( 4 "path/filepath" 5 ) 6 7 type Config struct { 8 Community struct { 9 Name string `json:"name"` 10 ConductLink string `json:"conduct_url"` // optional 11 Language string `json:"language"` 12 } `json:"general"` 13 14 RSS struct { 15 Name string `json:"feed_name"` 16 Description string `json:"feed_description"` 17 URL string `json:"forum_url"` 18 } `json:"rss"` 19 20 Documents struct { 21 LogoPath string `json:"logo"` 22 AboutPath string `json:"about"` 23 RegisterRulesPath string `json:"rules"` 24 VerificationExplanationPath string `json:"verification_instructions"` 25 } `json:"documents"` 26 } 27 28 // Ensure that, at the very least, default paths exist for each expected document path. Does not overwrite previously set values. 29 func (c *Config) EnsureDefaultPaths() { 30 if c.Documents.AboutPath == "" { 31 c.Documents.AboutPath = filepath.Join("content", "about.md") 32 } 33 if c.Documents.RegisterRulesPath == "" { 34 c.Documents.RegisterRulesPath = filepath.Join("content", "rules.md") 35 } 36 if c.Documents.VerificationExplanationPath == "" { 37 c.Documents.VerificationExplanationPath = filepath.Join("content", "verification-instructions.md") 38 } 39 if c.Documents.LogoPath == "" { 40 c.Documents.LogoPath = filepath.Join("content", "logo.html") 41 } 42 } 43 44 /* 45 config structure: 46 ["general"] 47 name = "Merveilles" 48 conduct_link = "https://github.com/merveilles/Resources/blob/master/CONDUCT.md" 49 language = "English" 50 51 52 ["documents"] 53 logo = "./logo.svg" 54 about = "./about.md" 55 rules = "./rules.md" 56 verification_instructions = "./verification-instructions.md" 57 */