Skip to content

Commit

Permalink
fix: add Arabic font support and SVG upload
Browse files Browse the repository at this point in the history
  • Loading branch information
BasselArt committed Dec 31, 2024
1 parent f04f073 commit 0eb592a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions app/handlers/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}

Expand All @@ -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)
}

Expand Down
7 changes: 5 additions & 2 deletions app/pkg/web/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0eb592a

Please sign in to comment.