subreddits: page has been moved
This commit is contained in:
parent
d5db5b81f9
commit
13eb3ddbb9
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/tigorlazuardi/redmage/pkg/errs"
|
||||
"github.com/tigorlazuardi/redmage/pkg/log"
|
||||
"github.com/tigorlazuardi/redmage/views"
|
||||
"github.com/tigorlazuardi/redmage/views/subredditsview/detailsview"
|
||||
"github.com/tigorlazuardi/redmage/views/subreddits/details"
|
||||
)
|
||||
|
||||
func (routes *Routes) PageSubredditsDetails(rw http.ResponseWriter, r *http.Request) {
|
||||
|
@ -20,7 +20,7 @@ func (routes *Routes) PageSubredditsDetails(rw http.ResponseWriter, r *http.Requ
|
|||
var params api.SubredditGetByNameImageParams
|
||||
params.FillFromQuery(r.URL.Query())
|
||||
|
||||
var data detailsview.Data
|
||||
var data details.Data
|
||||
data.FlashMessageSuccess = r.Header.Get("X-Flash-Message-Success")
|
||||
var err error
|
||||
data.Params = params
|
||||
|
@ -33,7 +33,7 @@ func (routes *Routes) PageSubredditsDetails(rw http.ResponseWriter, r *http.Requ
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
if err := detailsview.Detailsview(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render subreddit details page")
|
||||
}
|
||||
return
|
||||
|
@ -47,12 +47,12 @@ func (routes *Routes) PageSubredditsDetails(rw http.ResponseWriter, r *http.Requ
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
if err := detailsview.Detailsview(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render subreddit details page")
|
||||
}
|
||||
}
|
||||
|
||||
if err := detailsview.Detailsview(c, data).Render(ctx, rw); err != nil {
|
||||
if err := details.View(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render subreddit details page")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package detailsview
|
||||
package details
|
||||
|
||||
import "github.com/tigorlazuardi/redmage/views"
|
||||
import "github.com/tigorlazuardi/redmage/models"
|
||||
|
@ -18,7 +18,7 @@ type Data struct {
|
|||
FlashMessageSuccess string
|
||||
}
|
||||
|
||||
templ Detailsview(c *views.Context, data Data) {
|
||||
templ View(c *views.Context, data Data) {
|
||||
@components.Doctype() {
|
||||
if data.Subreddit != nil {
|
||||
@components.Head(c, components.HeadTitle(fmt.Sprintf("Subreddit - %s", data.Subreddit.Name)))
|
||||
|
@ -26,7 +26,7 @@ templ Detailsview(c *views.Context, data Data) {
|
|||
@components.Head(c, components.HeadTitle("Subreddit - 404 NOT FOUND"))
|
||||
}
|
||||
@components.Body(c) {
|
||||
@DetailsContent(c, data)
|
||||
@Content(c, data)
|
||||
@components.NotificationContainer() {
|
||||
if data.FlashMessageSuccess != "" {
|
||||
@components.SuccessNotification(data.FlashMessageSuccess)
|
||||
|
@ -36,7 +36,7 @@ templ Detailsview(c *views.Context, data Data) {
|
|||
}
|
||||
}
|
||||
|
||||
templ DetailsContent(c *views.Context, data Data) {
|
||||
templ Content(c *views.Context, data Data) {
|
||||
<main class="prose min-w-full">
|
||||
@components.Container() {
|
||||
if data.Error != "" {
|
Loading…
Reference in a new issue