mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
perf(static): minimize the SVG
Since tdewolff/minify supports SVG minimization, let's make use of it. As we need to keep the license in the SVG because we're nice netizens, we can at least use SPDX identifiers instead of using it verbatim. This does save a couple of kB.
This commit is contained in:
parent
485baf9654
commit
68984da332
5 changed files with 41 additions and 72 deletions
|
@ -16,19 +16,13 @@ import (
|
|||
|
||||
func (h *handler) showAppIcon(w http.ResponseWriter, r *http.Request) {
|
||||
filename := request.RouteStringParam(r, "filename")
|
||||
etag, err := static.GetBinaryFileChecksum(filename)
|
||||
if err != nil {
|
||||
value, ok := static.BinaryBundles[filename]
|
||||
if !ok {
|
||||
html.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
response.New(w, r).WithCaching(etag, 72*time.Hour, func(b *response.Builder) {
|
||||
blob, err := static.LoadBinaryFile(filename)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
response.New(w, r).WithCaching(value.Checksum, 72*time.Hour, func(b *response.Builder) {
|
||||
switch filepath.Ext(filename) {
|
||||
case ".png":
|
||||
b.WithoutCompression()
|
||||
|
@ -36,8 +30,7 @@ func (h *handler) showAppIcon(w http.ResponseWriter, r *http.Request) {
|
|||
case ".svg":
|
||||
b.WithHeader("Content-Type", "image/svg+xml")
|
||||
}
|
||||
|
||||
b.WithBody(blob)
|
||||
b.WithBody(value.Data)
|
||||
b.Write()
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue