mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
Add service worker to cache feed icons
This commit is contained in:
parent
c926498d3d
commit
6aa02680d8
8 changed files with 94 additions and 35 deletions
72
generate.go
72
generate.go
|
@ -96,23 +96,33 @@ func concat(files []string) string {
|
|||
return b.String()
|
||||
}
|
||||
|
||||
func generateJSBundle(bundleFile string, srcFiles []string) {
|
||||
var b strings.Builder
|
||||
b.WriteString("(function() {'use strict';")
|
||||
b.WriteString(concat(srcFiles))
|
||||
b.WriteString("})();")
|
||||
|
||||
func generateJSBundle(bundleFile string, bundleFiles map[string][]string, prefixes, suffixes map[string]string) {
|
||||
bundle := NewBundle("static", "Javascripts")
|
||||
m := minify.New()
|
||||
m.AddFunc("text/javascript", js.Minify)
|
||||
|
||||
output, err := m.String("text/javascript", b.String())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
for name, srcFiles := range bundleFiles {
|
||||
var b strings.Builder
|
||||
|
||||
if prefix, found := prefixes[name]; found {
|
||||
b.WriteString(prefix)
|
||||
}
|
||||
|
||||
b.WriteString(concat(srcFiles))
|
||||
|
||||
if suffix, found := suffixes[name]; found {
|
||||
b.WriteString(suffix)
|
||||
}
|
||||
|
||||
minifiedData, err := m.String("text/javascript", b.String())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
bundle.Files[name] = minifiedData
|
||||
bundle.Checksums[name] = checksum([]byte(minifiedData))
|
||||
}
|
||||
|
||||
bundle := NewBundle("static", "Javascript")
|
||||
bundle.Files["app"] = output
|
||||
bundle.Checksums["app"] = checksum([]byte(output))
|
||||
bundle.Write(bundleFile)
|
||||
}
|
||||
|
||||
|
@ -165,20 +175,30 @@ func generateBundle(bundleFile, pkg, mapName string, srcFiles []string) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
generateJSBundle("ui/static/js.go", []string{
|
||||
"ui/static/js/dom_helper.js",
|
||||
"ui/static/js/touch_handler.js",
|
||||
"ui/static/js/keyboard_handler.js",
|
||||
"ui/static/js/mouse_handler.js",
|
||||
"ui/static/js/form_handler.js",
|
||||
"ui/static/js/request_builder.js",
|
||||
"ui/static/js/unread_counter_handler.js",
|
||||
"ui/static/js/entry_handler.js",
|
||||
"ui/static/js/confirm_handler.js",
|
||||
"ui/static/js/menu_handler.js",
|
||||
"ui/static/js/modal_handler.js",
|
||||
"ui/static/js/nav_handler.js",
|
||||
"ui/static/js/bootstrap.js",
|
||||
generateJSBundle("ui/static/js.go", map[string][]string{
|
||||
"app": []string{
|
||||
"ui/static/js/dom_helper.js",
|
||||
"ui/static/js/touch_handler.js",
|
||||
"ui/static/js/keyboard_handler.js",
|
||||
"ui/static/js/mouse_handler.js",
|
||||
"ui/static/js/form_handler.js",
|
||||
"ui/static/js/request_builder.js",
|
||||
"ui/static/js/unread_counter_handler.js",
|
||||
"ui/static/js/entry_handler.js",
|
||||
"ui/static/js/confirm_handler.js",
|
||||
"ui/static/js/menu_handler.js",
|
||||
"ui/static/js/modal_handler.js",
|
||||
"ui/static/js/nav_handler.js",
|
||||
"ui/static/js/bootstrap.js",
|
||||
},
|
||||
"sw": []string{
|
||||
"ui/static/js/sw.js",
|
||||
},
|
||||
}, map[string]string{
|
||||
"app": "(function(){'use strict';",
|
||||
"sw": "'use strict';",
|
||||
}, map[string]string{
|
||||
"app": "})();",
|
||||
})
|
||||
|
||||
generateCSSBundle("ui/static/css.go", map[string][]string{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue