module_blog.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. {Sep: true, Show: true},
  23. {Mount: "cats", Name: "List of categories", Show: true, Icon: assets.SysSvgIconList},
  24. {Mount: "cats-add", Name: "Add new category", Show: true, Icon: assets.SysSvgIconPlus},
  25. {Mount: "cats-modify", Name: "Modify category", Show: false},
  26. },
  27. }, nil, func(wrap *wrapper.Wrapper) (string, string, string) {
  28. content := ""
  29. sidebar := ""
  30. if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" {
  31. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  32. {Name: "List of posts"},
  33. })
  34. //
  35. } else if wrap.CurrSubModule == "cats" {
  36. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  37. {Name: "List of categories"},
  38. })
  39. content += builder.DataTable(
  40. wrap,
  41. "blog_cats",
  42. "id",
  43. "DESC",
  44. &[]builder.DataTableRow{
  45. {
  46. DBField: "id",
  47. NameInTable: "Id",
  48. },
  49. {
  50. DBField: "name",
  51. NameInTable: "Name",
  52. },
  53. {
  54. DBField: "alias",
  55. NameInTable: "Alias",
  56. },
  57. },
  58. nil,
  59. "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/",
  60. nil,
  61. nil,
  62. )
  63. } else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" {
  64. if wrap.CurrSubModule == "add" {
  65. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  66. {Name: "Add new post"},
  67. })
  68. } else {
  69. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  70. {Name: "Modify post"},
  71. })
  72. }
  73. //
  74. } else if wrap.CurrSubModule == "cats-add" || wrap.CurrSubModule == "cats-modify" {
  75. if wrap.CurrSubModule == "cats-add" {
  76. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  77. {Name: "Add new category"},
  78. })
  79. } else {
  80. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  81. {Name: "Modify category"},
  82. })
  83. }
  84. //
  85. }
  86. return this.getSidebarModules(wrap), content, sidebar
  87. })
  88. }