mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Add customizable greeting to index page
Allow an organization to copy the greeting.html file out of the themes directory, customize it, then point the greeting.file config option at it so that it will survive Inbucket upgrades.
This commit is contained in:
@@ -25,7 +25,7 @@ type SmtpConfig struct {
|
|||||||
type Pop3Config struct {
|
type Pop3Config struct {
|
||||||
Ip4address net.IP
|
Ip4address net.IP
|
||||||
Ip4port int
|
Ip4port int
|
||||||
Domain string
|
Domain string
|
||||||
MaxIdleSeconds int
|
MaxIdleSeconds int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ type WebConfig struct {
|
|||||||
TemplateDir string
|
TemplateDir string
|
||||||
TemplateCache bool
|
TemplateCache bool
|
||||||
PublicDir string
|
PublicDir string
|
||||||
|
GreetingFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataStoreConfig struct {
|
type DataStoreConfig struct {
|
||||||
@@ -328,6 +329,13 @@ func parseWebConfig() error {
|
|||||||
}
|
}
|
||||||
webConfig.PublicDir = str
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ template.cache=false
|
|||||||
# Path to the selected themes public (static) files
|
# Path to the selected themes public (static) files
|
||||||
public.dir=%(install.dir)s/themes/%(theme)s/public
|
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]
|
[datastore]
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ template.cache=true
|
|||||||
# Path to the selected themes public (static) files
|
# Path to the selected themes public (static) files
|
||||||
public.dir=%(install.dir)s/themes/%(theme)s/public
|
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]
|
[datastore]
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ template.cache=true
|
|||||||
# Path to the selected themes public (static) files
|
# Path to the selected themes public (static) files
|
||||||
public.dir=%(install.dir)s/themes/%(theme)s/public
|
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]
|
[datastore]
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ template.cache=true
|
|||||||
# Path to the selected themes public (static) files
|
# Path to the selected themes public (static) files
|
||||||
public.dir=%(install.dir)s\themes\%(theme)s\public
|
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]
|
[datastore]
|
||||||
|
|
||||||
|
|||||||
9
themes/greeting.html
Normal file
9
themes/greeting.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<p>Inbucket is an email testing service; it will accept email for any email
|
||||||
|
address and make it available to view without a password.</p>
|
||||||
|
|
||||||
|
<p>To view email for a particular address, enter the username portion
|
||||||
|
of the address into the box on the upper right and click <em>go</em>.</p>
|
||||||
|
|
||||||
|
<p>This message can be customized by editing greeting.html. Change the
|
||||||
|
configuration option <code>greeting.file</code> if you'd like to move it
|
||||||
|
outside of the Inbucket installation directory.</p>
|
||||||
@@ -9,11 +9,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}{{.greeting}}{{end}}
|
||||||
<p>Inbucket is an email testing service; it will accept email for any email
|
|
||||||
address and make it available to view without a password.</p>
|
|
||||||
|
|
||||||
<p>To view email for a particular address, enter the username portion
|
|
||||||
of the address into the box on the upper right and click <em>go</em>.</p>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,20 @@ package web
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jhillyerd/inbucket/config"
|
"github.com/jhillyerd/inbucket/config"
|
||||||
|
"html/template"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RootIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
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{}{
|
return RenderTemplate("root/index.html", w, map[string]interface{}{
|
||||||
"ctx": ctx,
|
"ctx": ctx,
|
||||||
|
"greeting": template.HTML(string(greeting)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user