diff --git a/cmd/fake-smtp/template/blocks/base.html.tmpl b/cmd/fake-smtp/template/blocks/base.html.tmpl
index 343bd13..c9f6ff9 100644
--- a/cmd/fake-smtp/template/blocks/base.html.tmpl
+++ b/cmd/fake-smtp/template/blocks/base.html.tmpl
@@ -6,10 +6,10 @@
{{block "title" . -}}{{- end}}
{{- block "head_style" . -}}
-
+
{{end}}
{{- block "head_script" . -}}
-
+
{{end}}
diff --git a/cmd/fake-smtp/template/blocks/header.html.tmpl b/cmd/fake-smtp/template/blocks/header.html.tmpl
index f5dd99a..ae95018 100644
--- a/cmd/fake-smtp/template/blocks/header.html.tmpl
+++ b/cmd/fake-smtp/template/blocks/header.html.tmpl
@@ -2,7 +2,7 @@
@@ -44,7 +45,7 @@
data-controller="iframe"
data-action="load->iframe#onLoad"
style="width:100%;{{if not .Email.HTML}}display:none;{{end}}"
- src="{{ .Email.ID }}/html">
+ src="{{ .BaseURL }}/emails/{{ .Email.ID }}/html">
{{ .Email.Text }}
diff --git a/cmd/fake-smtp/template/layouts/inbox.html.tmpl b/cmd/fake-smtp/template/layouts/inbox.html.tmpl
index 4e4a3e9..a4305ad 100644
--- a/cmd/fake-smtp/template/layouts/inbox.html.tmpl
+++ b/cmd/fake-smtp/template/layouts/inbox.html.tmpl
@@ -24,10 +24,11 @@
+ {{ $baseURL := .BaseURL }}
{{range .Emails}}
+ data-inbox-entry-link="{{ $baseURL }}/emails/{{ .ID }}">
{{ .Subject }} |
{{range .From}}
@@ -44,7 +45,7 @@
|
|
diff --git a/internal/config/config.go b/internal/config/config.go
index 45c1b55..49cf0ed 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -22,6 +22,7 @@ type HTTPConfig struct {
Address string `yaml:"address" env:"FAKESMTP_HTTP_ADDRESS"`
TemplateDir string `yaml:"templateDir" env:"FAKESMTP_HTTP_TEMPLATEDIR"`
PublicDir string `yaml:"publicDir" env:"FAKESMTP_HTTP_PUBLICDIR"`
+ BaseURL string `yaml:"baseUrl" env:"FAKESMTP_HTTP_BASEURL"`
}
type SMTPConfig struct {
diff --git a/internal/route/helper.go b/internal/route/helper.go
index 84c9314..950a11b 100644
--- a/internal/route/helper.go
+++ b/internal/route/helper.go
@@ -5,9 +5,11 @@ import (
"strconv"
"time"
+ "forge.cadoles.com/wpetit/fake-smtp/internal/config"
"forge.cadoles.com/wpetit/fake-smtp/internal/query"
"github.com/pkg/errors"
"gitlab.com/wpetit/goweb/middleware/container"
+ "gitlab.com/wpetit/goweb/service"
"gitlab.com/wpetit/goweb/service/template"
)
@@ -15,8 +17,8 @@ func extendTemplateData(w http.ResponseWriter, r *http.Request, data template.Da
ctn := container.Must(r.Context())
data, err := template.Extend(data,
template.WithBuildInfo(w, r, ctn),
+ withBaseURL(ctn),
)
-
if err != nil {
panic(errors.Wrap(err, "could not extend template data"))
}
@@ -104,3 +106,16 @@ func createInboxQueryFromRequest(r *http.Request) (*query.GetInboxRequest, error
return inboxRequest, nil
}
+
+func withBaseURL(ctn *service.Container) template.DataExtFunc {
+ return func(data template.Data) (template.Data, error) {
+ conf, err := config.From(ctn)
+ if err != nil {
+ return nil, errors.WithStack(err)
+ }
+
+ data["BaseURL"] = conf.HTTP.BaseURL
+
+ return data, nil
+ }
+}