diff --git a/Dockerfile b/Dockerfile index 7ce93c14b..b6c42dd9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ COPY go.mod go.sum ./ RUN go mod download COPY . ./ -RUN go mod tidy ARG COMMITHASH RUN COMMITHASH=${COMMITHASH} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server diff --git a/app/handlers/images.go b/app/handlers/images.go index c7d9af4b1..63e7a9d45 100644 --- a/app/handlers/images.go +++ b/app/handlers/images.go @@ -20,7 +20,6 @@ import ( "github.com/getfider/fider/app/pkg/log" "github.com/getfider/fider/app/pkg/web" "github.com/goenning/imagic" - "github.com/pkg/errors" ) // LetterAvatar returns a letter gravatar picture based on given name @@ -183,24 +182,23 @@ func Favicon() web.HandlerFunc { bytes = q.Result.Content contentType = q.Result.ContentType } else { - //bytes, err = os.ReadFile(env.Path("favicon.png")) - bytes, err = os.ReadFile(env.Path("public/assets/images/fav.png")) + bytes, err = os.ReadFile(env.Path("favicon.png")) contentType = "image/png" if err != nil { - log.Error(c, errors.Wrap(err, "failed to read favicon file")) return c.Failure(err) } } size, err := c.QueryParamAsInt("size") if err != nil { - size = 64 // Default size if not provided or invalid + return c.BadRequest(web.Map{}) } - size = between(size, 50, 1000) + size = between(size, 50, 200) opts := []imagic.ImageOperation{} if size > 0 { + opts = append(opts, imagic.Padding(size*10/100)) opts = append(opts, imagic.Resize(size)) } @@ -210,7 +208,6 @@ func Favicon() web.HandlerFunc { bytes, err = imagic.Apply(bytes, opts...) if err != nil { - log.Error(c, errors.Wrap(err, "failed to process favicon image")) return c.Failure(err) } diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.go index faf8dc998..32634989f 100644 --- a/app/pkg/web/renderer.go +++ b/app/pkg/web/renderer.go @@ -176,8 +176,11 @@ func (r *Renderer) Render(w io.Writer, statusCode int, props Props, ctx *Context r.chunkedAssets[pageChunkName], } - // Always use the local favicon file - private["favicon"] = AssetsURL(ctx, "/static/favicon") + if tenant == nil || tenant.LogoBlobKey == "" { + private["favicon"] = AssetsURL(ctx, "/static/favicon") + } else { + private["favicon"] = AssetsURL(ctx, "/static/favicon/%s", tenant.LogoBlobKey) + } private["currentURL"] = ctx.Request.URL.String() if canonicalURL := ctx.Value("Canonical-URL"); canonicalURL != nil {