Fix StaticURL in gemini
This commit is contained in:
parent
2ca44b60d4
commit
0d420f70d8
@ -126,6 +126,7 @@ func main() {
|
|||||||
gmiParams.Logger = logger.WithNamespace("gmi")
|
gmiParams.Logger = logger.WithNamespace("gmi")
|
||||||
gmiParams.PostStore = postStore
|
gmiParams.PostStore = postStore
|
||||||
gmiParams.PostAssetStore = postAssetStore
|
gmiParams.PostAssetStore = postAssetStore
|
||||||
|
gmiParams.HTTPPublicURL = httpParams.PublicURL
|
||||||
|
|
||||||
logger.Info(ctx, "starting gmi api")
|
logger.Info(ctx, "starting gmi api")
|
||||||
gmiAPI, err := gmi.New(gmiParams)
|
gmiAPI, err := gmi.New(gmiParams)
|
||||||
|
@ -30,6 +30,8 @@ type Params struct {
|
|||||||
PublicURL *url.URL
|
PublicURL *url.URL
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
CertificatesPath string
|
CertificatesPath string
|
||||||
|
|
||||||
|
HTTPPublicURL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupCfg implement the cfg.Cfger interface.
|
// SetupCfg implement the cfg.Cfger interface.
|
||||||
|
@ -33,8 +33,9 @@ type rendererGetPostSeriesNextPreviousRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type renderer struct {
|
type renderer struct {
|
||||||
url *url.URL
|
url *url.URL
|
||||||
postStore post.Store
|
postStore post.Store
|
||||||
|
httpPublicURL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r renderer) GetPosts(page, count int) (rendererGetPostsRes, error) {
|
func (r renderer) GetPosts(page, count int) (rendererGetPostsRes, error) {
|
||||||
@ -98,7 +99,9 @@ func (r renderer) PostBody(p post.StoredPost) (string, error) {
|
|||||||
return filepath.Join("/posts", id)
|
return filepath.Join("/posts", id)
|
||||||
},
|
},
|
||||||
StaticURL: func(path string) string {
|
StaticURL: func(path string) string {
|
||||||
return filepath.Join("/static", path)
|
httpPublicURL := *r.httpPublicURL
|
||||||
|
httpPublicURL.Path = filepath.Join(httpPublicURL.Path, "/static", path)
|
||||||
|
return httpPublicURL.String()
|
||||||
},
|
},
|
||||||
Image: func(args ...string) (string, error) {
|
Image: func(args ...string) (string, error) {
|
||||||
|
|
||||||
@ -207,8 +210,9 @@ func (a *api) tplHandler() (gemini.Handler, error) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
err := tpl.Execute(buf, renderer{
|
err := tpl.Execute(buf, renderer{
|
||||||
url: r.URL,
|
url: r.URL,
|
||||||
postStore: a.params.PostStore,
|
postStore: a.params.PostStore,
|
||||||
|
httpPublicURL: a.params.HTTPPublicURL,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user