frontend.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package main
  2. import (
  3. "html/template"
  4. "golang-fave/engine/wrapper"
  5. )
  6. type TmplMenuItem struct {
  7. Name string
  8. Link string
  9. }
  10. type TmplData struct {
  11. PathSysIcoFav string
  12. PathSysCssBootstrap string
  13. PathSysJsJquery string
  14. PathSysJsPopper string
  15. PathSysJsBootstrap string
  16. MetaTitle string
  17. MetaKeywords string
  18. MetaDescription string
  19. MenuItems []TmplMenuItem
  20. SomeHtml template.HTML
  21. }
  22. func handleFrontEnd(e *wrapper.Wrapper) bool {
  23. tmpl, err := template.ParseFiles(
  24. e.DirVhostHome+"/template"+"/index.html",
  25. e.DirVhostHome+"/template"+"/header.html",
  26. e.DirVhostHome+"/template"+"/footer.html",
  27. )
  28. if err != nil {
  29. e.PrintTmplPageError(err)
  30. return true
  31. }
  32. tmpl.Execute(*e.W, TmplData{
  33. PathSysIcoFav: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/fave.ico",
  34. PathSysCssBootstrap: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/bootstrap.css",
  35. PathSysJsJquery: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/jquery.js",
  36. PathSysJsPopper: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/popper.js",
  37. PathSysJsBootstrap: e.R.URL.Scheme + "://" + e.R.Host + "/assets/sys/bootstrap.js",
  38. MetaTitle: "Meta Title",
  39. MetaKeywords: "Meta Keywords",
  40. MetaDescription: "Meta Description",
  41. MenuItems: []TmplMenuItem{
  42. {Name: "Menu Item 1", Link: "/#1"},
  43. {Name: "Menu Item 2", Link: "/#2"},
  44. },
  45. SomeHtml: template.HTML("<div class=\"some-class\">DIV</div>"),
  46. })
  47. return true
  48. }