module_blog.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package modules
  2. import (
  3. //"html"
  4. "golang-fave/assets"
  5. "golang-fave/consts"
  6. //"golang-fave/engine/builder"
  7. "golang-fave/engine/wrapper"
  8. //"golang-fave/utils"
  9. )
  10. func (this *Modules) RegisterModule_Blog() *Module {
  11. return this.newModule(MInfo{
  12. WantDB: true,
  13. Mount: "blog",
  14. Name: "Blog",
  15. Order: 1,
  16. System: false,
  17. Icon: assets.SysSvgIconPage,
  18. Sub: &[]MISub{
  19. {Mount: "default", Name: "List of posts", Show: true, Icon: assets.SysSvgIconList},
  20. {Mount: "add", Name: "Add new post", Show: true, Icon: assets.SysSvgIconPlus},
  21. {Mount: "modify", Name: "Modify post", Show: false},
  22. {Mount: "cats", Name: "List of categories", Show: true, Icon: assets.SysSvgIconList},
  23. {Mount: "cats-add", Name: "Add new category", Show: true, Icon: assets.SysSvgIconPlus},
  24. {Mount: "cats-modify", Name: "Modify category", Show: false},
  25. },
  26. }, nil, func(wrap *wrapper.Wrapper) (string, string, string) {
  27. content := ""
  28. sidebar := ""
  29. if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" {
  30. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  31. {Name: "List of posts"},
  32. })
  33. //
  34. } else if wrap.CurrSubModule == "cats" {
  35. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  36. {Name: "List of categories"},
  37. })
  38. //
  39. } else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" {
  40. if wrap.CurrSubModule == "add" {
  41. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  42. {Name: "Add new post"},
  43. })
  44. } else {
  45. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  46. {Name: "Modify post"},
  47. })
  48. }
  49. //
  50. } else if wrap.CurrSubModule == "cats-add" || wrap.CurrSubModule == "cats-modify" {
  51. if wrap.CurrSubModule == "cats-add" {
  52. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  53. {Name: "Add new category"},
  54. })
  55. } else {
  56. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  57. {Name: "Modify category"},
  58. })
  59. }
  60. //
  61. }
  62. return this.getSidebarModules(wrap), content, sidebar
  63. })
  64. }