frontend.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package frontend
  2. import (
  3. "database/sql"
  4. _ "github.com/go-sql-driver/mysql"
  5. "golang-fave/engine/wrapper"
  6. utils "golang-fave/engine/wrapper/utils"
  7. )
  8. // --- Demo
  9. type MenuItem struct {
  10. Name string
  11. Link string
  12. Active bool
  13. }
  14. type TmplData struct {
  15. MetaTitle string
  16. MetaKeywords string
  17. MetaDescription string
  18. MenuItems []MenuItem
  19. }
  20. // --------
  21. type Frontend struct {
  22. wrapper *wrapper.Wrapper
  23. db *sql.DB
  24. user *utils.MySql_user
  25. urls *[]string
  26. }
  27. func New(wrapper *wrapper.Wrapper, db *sql.DB, url_args *[]string) *Frontend {
  28. return &Frontend{wrapper, db, nil, url_args}
  29. }
  30. func (this *Frontend) Run() bool {
  31. // --- Demo
  32. if this.wrapper.R.URL.Path == "/" {
  33. return this.wrapper.TmplFrontEnd("index", TmplData{
  34. MetaTitle: "Meta Title",
  35. MetaKeywords: "Meta Keywords",
  36. MetaDescription: "Meta Description",
  37. MenuItems: []MenuItem{
  38. {Name: "Home", Link: "/", Active: true},
  39. {Name: "Item 1", Link: "/#1", Active: false},
  40. {Name: "Item 2", Link: "/#2", Active: false},
  41. {Name: "Item 3", Link: "/#3", Active: false},
  42. },
  43. })
  44. }
  45. // --------
  46. return false
  47. }