frontend.go 1.5 KB

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