Browse Source

feat: rename embed file

pull/120/head
Aldino Kemal 2 years ago
parent
commit
98f6075c13
  1. 12
      src/cmd/root.go
  2. 6
      src/main.go
  3. 2
      src/views/index.html

12
src/cmd/root.go

@ -27,8 +27,8 @@ import (
) )
var ( var (
EmbedViews embed.FS
EmbedViewsComponent embed.FS
EmbedIndex embed.FS
EmbedViews embed.FS
) )
// rootCmd represents the base command when called without any subcommands // rootCmd represents the base command when called without any subcommands
@ -61,7 +61,7 @@ func runRest(_ *cobra.Command, _ []string) {
log.Fatalln(err) log.Fatalln(err)
} }
engine := html.NewFileSystem(http.FS(EmbedViews), ".html")
engine := html.NewFileSystem(http.FS(EmbedIndex), ".html")
engine.AddFunc("isEnableBasicAuth", func(token any) bool { engine.AddFunc("isEnableBasicAuth", func(token any) bool {
return token != nil return token != nil
}) })
@ -71,7 +71,7 @@ func runRest(_ *cobra.Command, _ []string) {
}) })
app.Static("/statics", "./statics") app.Static("/statics", "./statics")
app.Use("/components", filesystem.New(filesystem.Config{ app.Use("/components", filesystem.New(filesystem.Config{
Root: http.FS(EmbedViewsComponent),
Root: http.FS(EmbedViews),
PathPrefix: "views/components", PathPrefix: "views/components",
Browse: true, Browse: true,
})) }))
@ -141,9 +141,9 @@ func runRest(_ *cobra.Command, _ []string) {
} }
// Execute adds all child commands to the root command and sets flags appropriately. // Execute adds all child commands to the root command and sets flags appropriately.
func Execute(embedViews embed.FS, embedViewsComponent embed.FS) {
func Execute(embedIndex embed.FS, embedViews embed.FS) {
EmbedIndex = embedIndex
EmbedViews = embedViews EmbedViews = embedViews
EmbedViewsComponent = embedViewsComponent
if err := rootCmd.Execute(); err != nil { if err := rootCmd.Execute(); err != nil {
os.Exit(1) os.Exit(1)
} }

6
src/main.go

@ -6,11 +6,11 @@ import (
) )
//go:embed views/index.html //go:embed views/index.html
var embedViews embed.FS
var embedIndex embed.FS
//go:embed views //go:embed views
var embedViewsComponent embed.FS
var embedViews embed.FS
func main() { func main() {
cmd.Execute(embedViews, embedViewsComponent)
cmd.Execute(embedIndex, embedViews)
} }

2
src/views/index.html

@ -12,7 +12,7 @@
<script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.11.4/js/dataTables.semanticui.min.js"></script> <script src="https://cdn.datatables.net/1.11.4/js/dataTables.semanticui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.8/semantic.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.8/semantic.min.js"></script>
<script src="https://unpkg.com/vue@3"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3.4.21/vue.cjs.js"></script>
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script> <script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
<title>Whatsapp API Multi Device {{ .AppVersion }}</title> <title>Whatsapp API Multi Device {{ .AppVersion }}</title>

Loading…
Cancel
Save