diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-08-24 21:51:50 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-08-24 21:56:39 -0700 |
commit | dbcc5d8a972f4f169e9e2c0636450555a06152b9 (patch) | |
tree | 00d7ed89efc2ffdbfa4c602ba66b0c156d48cb0d /generate.go | |
parent | 7f2612d9a67ccb97a9cee8c330b7445f11497d01 (diff) |
Use canonical imports
Diffstat (limited to 'generate.go')
-rw-r--r-- | generate.go | 29 |
1 files changed, 16 insertions, 13 deletions
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) |