Skip to content

Commit fcb60f6

Browse files
committed
feat(webui): statically embed js/css assets
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent a10a952 commit fcb60f6

File tree

15 files changed

+1484
-11
lines changed

15 files changed

+1484
-11
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,3 +777,7 @@ docker-image-intel-xpu:
777777
.PHONY: swagger
778778
swagger:
779779
swag init -g core/http/app.go --output swagger
780+
781+
.PHONY: gen-assets
782+
gen-assets:
783+
$(GOCMD) run core/dependencies_manager/manager.go embedded/webui_static.yaml core/http/static/assets

core/dependencies_manager/manager.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
8+
"github.com/go-skynet/LocalAI/pkg/downloader"
9+
"github.com/go-skynet/LocalAI/pkg/utils"
10+
"gopkg.in/yaml.v3"
11+
)
12+
13+
type Asset struct {
14+
FileName string `yaml:"filename"`
15+
URL string `yaml:"url"`
16+
SHA string `yaml:"sha"`
17+
}
18+
19+
func main() {
20+
21+
// read the YAML file which contains a list of assets
22+
// and download them in the asset path
23+
assets := []Asset{}
24+
25+
assetFile := os.Args[1]
26+
destPath := os.Args[2]
27+
28+
// read the YAML file
29+
f, err := os.ReadFile(assetFile)
30+
if err != nil {
31+
panic(err)
32+
}
33+
// unmarshal the YAML data into a struct
34+
if err := yaml.Unmarshal(f, &assets); err != nil {
35+
panic(err)
36+
}
37+
38+
// download the assets
39+
for _, asset := range assets {
40+
if err := downloader.DownloadFile(asset.URL, filepath.Join(destPath, asset.FileName), asset.SHA, 1, 1, utils.DisplayDownloadFunction); err != nil {
41+
panic(err)
42+
}
43+
}
44+
45+
fmt.Println("Finished downloading assets")
46+
}

core/http/static/assets/alpine.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/http/static/assets/font1.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@font-face {
2+
font-family: 'Inter';
3+
font-style: normal;
4+
font-weight: 400;
5+
font-display: swap;
6+
src: url(https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfMZg.ttf) format('truetype');
7+
}
8+
@font-face {
9+
font-family: 'Inter';
10+
font-style: normal;
11+
font-weight: 600;
12+
font-display: swap;
13+
src: url(https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuGKYMZg.ttf) format('truetype');
14+
}
15+
@font-face {
16+
font-family: 'Inter';
17+
font-style: normal;
18+
font-weight: 700;
19+
font-display: swap;
20+
src: url(https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYMZg.ttf) format('truetype');
21+
}
22+
@font-face {
23+
font-family: 'Roboto';
24+
font-style: normal;
25+
font-weight: 400;
26+
font-display: swap;
27+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5Q.ttf) format('truetype');
28+
}
29+
@font-face {
30+
font-family: 'Roboto';
31+
font-style: normal;
32+
font-weight: 500;
33+
font-display: swap;
34+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9vAw.ttf) format('truetype');
35+
}

core/http/static/assets/font2.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@font-face {
2+
font-family: 'Roboto';
3+
font-style: normal;
4+
font-weight: 300;
5+
font-display: swap;
6+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fBBc9.ttf) format('truetype');
7+
}
8+
@font-face {
9+
font-family: 'Roboto';
10+
font-style: normal;
11+
font-weight: 400;
12+
font-display: swap;
13+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype');
14+
}
15+
@font-face {
16+
font-family: 'Roboto';
17+
font-style: normal;
18+
font-weight: 500;
19+
font-display: swap;
20+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fBBc9.ttf) format('truetype');
21+
}
22+
@font-face {
23+
font-family: 'Roboto';
24+
font-style: normal;
25+
font-weight: 700;
26+
font-display: swap;
27+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmWUlfBBc9.ttf) format('truetype');
28+
}
29+
@font-face {
30+
font-family: 'Roboto';
31+
font-style: normal;
32+
font-weight: 900;
33+
font-display: swap;
34+
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmYUtfBBc9.ttf) format('truetype');
35+
}

core/http/static/assets/fontawesome.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/http/static/assets/highlightjs.css

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)