From dbcc5d8a972f4f169e9e2c0636450555a06152b9 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 24 Aug 2018 21:51:50 -0700 Subject: Use canonical imports --- generate.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'generate.go') diff --git a/generate.go b/generate.go index cba64e3..7136cc3 100644 --- a/generate.go +++ b/generate.go @@ -24,7 +24,7 @@ import ( const tpl = `// Code generated by go generate; DO NOT EDIT. -package {{ .Package }} +package {{ .Package }} // import "miniflux.app/{{ .ImportPath }}" var {{ .Map }} = map[string]string{ {{ range $constant, $content := .Files }}` + "\t" + `"{{ $constant }}": ` + "`{{ $content }}`" + `, @@ -38,9 +38,11 @@ var {{ .Map }}Checksums = map[string]string{ var bundleTpl = template.Must(template.New("").Parse(tpl)) type Bundle struct { - Package, Map string - Files map[string]string - Checksums map[string]string + Package string + Map string + ImportPath string + Files map[string]string + Checksums map[string]string } func (b *Bundle) Write(filename string) { @@ -53,12 +55,13 @@ func (b *Bundle) Write(filename string) { bundleTpl.Execute(f, b) } -func NewBundle(pkg, mapName string) *Bundle { +func NewBundle(pkg, mapName, importPath string) *Bundle { return &Bundle{ - Package: pkg, - Map: mapName, - Files: make(map[string]string), - Checksums: make(map[string]string), + Package: pkg, + Map: mapName, + ImportPath: importPath, + Files: make(map[string]string), + Checksums: make(map[string]string), } } @@ -97,7 +100,7 @@ func concat(files []string) string { } func generateJSBundle(bundleFile string, bundleFiles map[string][]string, prefixes, suffixes map[string]string) { - bundle := NewBundle("static", "Javascripts") + bundle := NewBundle("static", "Javascripts", "ui/static") m := minify.New() m.AddFunc("text/javascript", js.Minify) @@ -127,7 +130,7 @@ func generateJSBundle(bundleFile string, bundleFiles map[string][]string, prefix } func generateCSSBundle(bundleFile string, themes map[string][]string) { - bundle := NewBundle("static", "Stylesheets") + bundle := NewBundle("static", "Stylesheets", "ui/static") m := minify.New() m.AddFunc("text/css", css.Minify) @@ -146,7 +149,7 @@ func generateCSSBundle(bundleFile string, themes map[string][]string) { } func generateBinaryBundle(bundleFile string, srcFiles []string) { - bundle := NewBundle("static", "Binaries") + bundle := NewBundle("static", "Binaries", "ui/static") for _, srcFile := range srcFiles { data := readFile(srcFile) @@ -161,7 +164,7 @@ func generateBinaryBundle(bundleFile string, srcFiles []string) { } func generateBundle(bundleFile, pkg, mapName string, srcFiles []string) { - bundle := NewBundle(pkg, mapName) + bundle := NewBundle(pkg, mapName, pkg) for _, srcFile := range srcFiles { data := readFile(srcFile) -- cgit v1.2.3