diff --git a/config/config.go b/config/config.go index bfa1e5f..25b6030 100644 --- a/config/config.go +++ b/config/config.go @@ -25,7 +25,7 @@ type SmtpConfig struct { type Pop3Config struct { Ip4address net.IP Ip4port int - Domain string + Domain string MaxIdleSeconds int } @@ -35,6 +35,7 @@ type WebConfig struct { TemplateDir string TemplateCache bool PublicDir string + GreetingFile string } type DataStoreConfig struct { @@ -328,6 +329,13 @@ func parseWebConfig() error { } webConfig.PublicDir = str + option = "greeting.file" + str, err = Config.String(section, option) + if err != nil { + return fmt.Errorf("Failed to parse [%v]%v: '%v'", section, option, err) + } + webConfig.GreetingFile = str + return nil } diff --git a/etc/devel.conf b/etc/devel.conf index 2ce5c4b..56b5c04 100644 --- a/etc/devel.conf +++ b/etc/devel.conf @@ -81,6 +81,10 @@ template.cache=false # Path to the selected themes public (static) files public.dir=%(install.dir)s/themes/%(theme)s/public +# Path to the greeting HTML displayed on front page, can +# be moved out of installation dir for customization +greeting.file=%(install.dir)s/themes/greeting.html + ############################################################################# [datastore] diff --git a/etc/inbucket.conf b/etc/inbucket.conf index a6c9c81..2236f1c 100644 --- a/etc/inbucket.conf +++ b/etc/inbucket.conf @@ -81,6 +81,10 @@ template.cache=true # Path to the selected themes public (static) files public.dir=%(install.dir)s/themes/%(theme)s/public +# Path to the greeting HTML displayed on front page, can +# be moved out of installation dir for customization +greeting.file=%(install.dir)s/themes/greeting.html + ############################################################################# [datastore] diff --git a/etc/unix-sample.conf b/etc/unix-sample.conf index 17b7b9d..00061f8 100644 --- a/etc/unix-sample.conf +++ b/etc/unix-sample.conf @@ -81,6 +81,10 @@ template.cache=true # Path to the selected themes public (static) files public.dir=%(install.dir)s/themes/%(theme)s/public +# Path to the greeting HTML displayed on front page, can +# be moved out of installation dir for customization +greeting.file=%(install.dir)s/themes/greeting.html + ############################################################################# [datastore] diff --git a/etc/win-sample.conf b/etc/win-sample.conf index b0fcdcf..507336c 100644 --- a/etc/win-sample.conf +++ b/etc/win-sample.conf @@ -81,6 +81,10 @@ template.cache=true # Path to the selected themes public (static) files public.dir=%(install.dir)s\themes\%(theme)s\public +# Path to the greeting HTML displayed on front page, can +# be moved out of installation dir for customization +greeting.file=%(install.dir)s\themes\greeting.html + ############################################################################# [datastore] diff --git a/themes/greeting.html b/themes/greeting.html new file mode 100644 index 0000000..67f4794 --- /dev/null +++ b/themes/greeting.html @@ -0,0 +1,9 @@ +
Inbucket is an email testing service; it will accept email for any email +address and make it available to view without a password.
+ +To view email for a particular address, enter the username portion +of the address into the box on the upper right and click go.
+ +This message can be customized by editing greeting.html. Change the
+configuration option greeting.file if you'd like to move it
+outside of the Inbucket installation directory.
Inbucket is an email testing service; it will accept email for any email -address and make it available to view without a password.
- -To view email for a particular address, enter the username portion -of the address into the box on the upper right and click go.
-{{end}} - +{{define "content"}}{{.greeting}}{{end}} diff --git a/web/root_controller.go b/web/root_controller.go index f5df0de..aa410a1 100644 --- a/web/root_controller.go +++ b/web/root_controller.go @@ -3,12 +3,20 @@ package web import ( "fmt" "github.com/jhillyerd/inbucket/config" + "html/template" + "io/ioutil" "net/http" ) func RootIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) { + greeting, err := ioutil.ReadFile(config.GetWebConfig().GreetingFile) + if err != nil { + return fmt.Errorf("Failed to load greeting: %v", err) + } + return RenderTemplate("root/index.html", w, map[string]interface{}{ "ctx": ctx, + "greeting": template.HTML(string(greeting)), }) }