Embed static files used by Subsonic API

This commit is contained in:
Deluan 2020-01-24 21:35:19 -05:00
parent f63b1703e6
commit 49f59fe9f4
8 changed files with 337 additions and 8 deletions

View file

Before

Width:  |  Height:  |  Size: 264 KiB

After

Width:  |  Height:  |  Size: 264 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 709 KiB

After

Width:  |  Height:  |  Size: 709 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Before After
Before After

View file

@ -37,6 +37,10 @@ setup: Jamstash-master
go mod download go mod download
@(cd ./ui && npm ci) @(cd ./ui && npm ci)
.PHONY: static
static:
cd static && go-bindata -fs -prefix "static" -nocompress -ignore="\\\*.go" -pkg static .
Jamstash-master: Jamstash-master:
wget -N https://github.com/tsquillario/Jamstash/archive/master.zip wget -N https://github.com/tsquillario/Jamstash/archive/master.zip
unzip -o master.zip unzip -o master.zip

View file

@ -94,9 +94,9 @@ and login with this temporary password.
<p align="center"> <p align="center">
<p float="left"> <p float="left">
<img width="300" src="https://raw.githubusercontent.com/deluan/navidrome/master/static/screenshot-login-mobile.png"> <img width="300" src="https://raw.githubusercontent.com/deluan/navidrome/master/.github/screenshots/screenshot-login-mobile.png">
<img width="300" src="https://raw.githubusercontent.com/deluan/navidrome/master/static/screenshot-mobile.png"> <img width="300" src="https://raw.githubusercontent.com/deluan/navidrome/master/.github/screenshots/screenshot-mobile.png">
<img width="600"src="https://raw.githubusercontent.com/deluan/navidrome/master/static/screenshot-desktop.png"> <img width="600"src="https://raw.githubusercontent.com/deluan/navidrome/master/.github/screenshots/screenshot-desktop.png">
</p> </p>
</p> </p>

View file

@ -13,6 +13,7 @@ import (
"strings" "strings"
"github.com/deluan/navidrome/model" "github.com/deluan/navidrome/model"
"github.com/deluan/navidrome/static"
"github.com/dhowden/tag" "github.com/dhowden/tag"
"github.com/nfnt/resize" "github.com/nfnt/resize"
) )
@ -61,8 +62,7 @@ func (c *cover) Get(ctx context.Context, id string, size int, out io.Writer) err
if err != model.ErrNotFound { if err != model.ErrNotFound {
reader, err = readFromTag(path) reader, err = readFromTag(path)
} else { } else {
var f *os.File f, err := static.AssetFile().Open("default_cover.jpg")
f, err = os.Open("static/default_cover.jpg")
if err == nil { if err == nil {
defer f.Close() defer f.Close()
reader = f reader = f

View file

@ -3,12 +3,12 @@ package subsonic
import ( import (
"io" "io"
"net/http" "net/http"
"os"
"github.com/deluan/navidrome/engine" "github.com/deluan/navidrome/engine"
"github.com/deluan/navidrome/log" "github.com/deluan/navidrome/log"
"github.com/deluan/navidrome/model" "github.com/deluan/navidrome/model"
"github.com/deluan/navidrome/server/subsonic/responses" "github.com/deluan/navidrome/server/subsonic/responses"
"github.com/deluan/navidrome/static"
) )
type MediaRetrievalController struct { type MediaRetrievalController struct {
@ -20,8 +20,7 @@ func NewMediaRetrievalController(cover engine.Cover) *MediaRetrievalController {
} }
func (c *MediaRetrievalController) GetAvatar(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) { func (c *MediaRetrievalController) GetAvatar(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
var f *os.File f, err := static.AssetFile().Open("itunes.png")
f, err := os.Open("static/itunes.png")
if err != nil { if err != nil {
log.Error(r, "Image not found", err) log.Error(r, "Image not found", err)
return nil, NewError(responses.ErrorDataNotFound, "Avatar image not found") return nil, NewError(responses.ErrorDataNotFound, "Avatar image not found")

326
static/bindata.go Normal file

File diff suppressed because one or more lines are too long