Templates are working, just empty

This commit is contained in:
2017-10-05 00:08:07 +02:00
parent 525fbb4f94
commit 8c8aad3312
9 changed files with 133 additions and 27 deletions
+6 -3
View File
@@ -2,6 +2,7 @@ package viewmodel
import (
"fmt"
"strings"
"git.aiterp.net/AiteRP/aitestory/server"
"git.aiterp.net/gisle/wrouter/auth"
@@ -9,6 +10,7 @@ import (
// Base is the basic information used to render the page
type Base struct {
UserID string
UserName string
UserRole string
UserLoggedIn bool
@@ -16,11 +18,12 @@ type Base struct {
}
// InitBase initializes the base of the viewmodel
func (base *Base) InitBase(user *auth.User, viewTitle string) {
func (base *Base) setupBase(user *auth.User, viewTitle string) {
if user != nil {
base.UserName = user.ID
base.UserID = user.ID
base.UserName = strings.SplitN(user.ID, ":", 2)[1]
base.UserRole = user.Data["role"]
base.UserLoggedIn = false
base.UserLoggedIn = true
}
base.ViewTitle = fmt.Sprintf("%s - %s", viewTitle, server.Main.Config.View.Title)
+21
View File
@@ -0,0 +1,21 @@
package viewmodel
import (
"git.aiterp.net/AiteRP/aitestory/model"
"git.aiterp.net/gisle/wrouter/auth"
)
// PageList is a view model for rendering the front page
type PageList struct {
Base
Headers []model.Header
Category string
ActiveTags []model.Tag
FavoriteTags []model.Tag
}
// Setup sets up the page model and the base, and should
// be run after the details have been filled in.
func (pl *PageList) Setup(user *auth.User) {
pl.setupBase(user, "Index")
}