wp-go/internal/theme/twentyfifteen/twentyfifteen.go

65 lines
1.4 KiB
Go
Raw Normal View History

2023-02-09 12:49:33 +00:00
package twentyfifteen
import (
2023-02-10 13:23:30 +00:00
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
2023-02-09 12:49:33 +00:00
"github.com/fthvgb1/wp-go/internal/plugins"
"github.com/fthvgb1/wp-go/internal/theme/common"
)
const ThemeName = "twentyfifteen"
type indexHandle struct {
*common.IndexHandle
2023-02-09 12:49:33 +00:00
}
func newIndexHandle(iHandle *common.IndexHandle) *indexHandle {
return &indexHandle{iHandle}
}
type detailHandle struct {
*common.DetailHandle
}
func newDetailHandle(dHandle *common.DetailHandle) *detailHandle {
return &detailHandle{DetailHandle: dHandle}
}
func Hook(h *common.Handle) {
h.WidgetAreaData()
h.GetPassword()
2023-02-10 13:23:30 +00:00
if h.Scene == constraints.Detail {
newDetailHandle(common.NewDetailHandle(h)).Detail()
2023-02-09 12:49:33 +00:00
return
}
newIndexHandle(common.NewIndexHandle(h)).Index()
2023-02-09 12:49:33 +00:00
}
func (i *indexHandle) Index() {
i.Templ = "twentyfifteen/posts/index.gohtml"
2023-02-09 12:49:33 +00:00
err := i.BuildIndexData(common.NewIndexParams(i.C))
if err != nil {
i.C.HTML(i.Code, i.Templ, i.GinH)
return
2023-02-09 12:49:33 +00:00
}
i.ExecPostsPlugin()
i.PageEle = plugins.TwentyFifteenPagination()
i.Pagination()
i.C.HTML(i.Code, i.Templ, i.GinH)
2023-02-09 12:49:33 +00:00
}
func (d *detailHandle) Detail() {
d.Templ = "twentyfifteen/posts/detail.gohtml"
2023-02-09 12:49:33 +00:00
err := d.BuildDetailData()
if err != nil {
d.Stats = constraints.Error404
d.C.HTML(d.Code, d.Templ, d.GinH)
return
}
d.PasswordProject()
d.CommentRender = plugins.CommentRender()
d.RenderComment()
d.C.HTML(d.Code, d.Templ, d.GinH)
2023-02-09 12:49:33 +00:00
}