start theme cup templates
This commit is contained in:
parent
1b6f3e6103
commit
f80c062099
11 changed files with 202 additions and 48 deletions
|
|
@ -452,35 +452,37 @@ func Signout(c *core.Context) *core.Response {
|
|||
// Show basic app login
|
||||
func AppLogin(c *core.Context) *core.Response {
|
||||
|
||||
// first, include all compoments
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: "Login form",
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Card title",
|
||||
CardBody: "Loerm ipsum at deim",
|
||||
},
|
||||
}
|
||||
|
||||
return c.Response.Template("login.html", tmplData)
|
||||
|
||||
}
|
||||
|
||||
// Show basic app sample
|
||||
func AppSample(c *core.Context) *core.Response {
|
||||
|
||||
title := "lorem"
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: title,
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Protected page",
|
||||
CardBody: "If you can see this page, your are loggedin",
|
||||
},
|
||||
}
|
||||
|
||||
//fmt.Printf("Outside cookie user is: %s", user.Email)
|
||||
|
||||
return c.Response.Template("app.html", tmplData)
|
||||
|
|
|
|||
|
|
@ -24,16 +24,22 @@ func WelcomeHome(c *core.Context) *core.Response {
|
|||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: "Welcome to Goffee",
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Golang Framework",
|
||||
CardBody: "Welcome to Goffee",
|
||||
},
|
||||
}
|
||||
|
||||
return c.Response.Template("basic.html", tmplData)
|
||||
return c.Response.Template("welcome.html", tmplData)
|
||||
|
||||
} else {
|
||||
message := "{\"message\": \"Welcome to Goffee\"}"
|
||||
return c.Response.Json(message)
|
||||
|
|
|
|||
|
|
@ -12,13 +12,16 @@ import (
|
|||
// Show basic template
|
||||
func Sample(c *core.Context) *core.Response {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: "Lorem ipsum inside",
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Framework Goffee",
|
||||
CardBody: "Powered by Golang",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
100
controllers/themedemo.go
Normal file
100
controllers/themedemo.go
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
|
||||
// Use of this source code is governed by MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"git.smarteching.com/goffee/core"
|
||||
"git.smarteching.com/goffee/core/template/components"
|
||||
)
|
||||
|
||||
// Show home page
|
||||
func Themedemo(c *core.Context) *core.Response {
|
||||
|
||||
// check if template engine is enabled
|
||||
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||
if TemplateEnableStr == "" {
|
||||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Card title",
|
||||
CardBody: "Loerm ipsum at deim",
|
||||
},
|
||||
}
|
||||
|
||||
return c.Response.Template("custom_theme_base.html", tmplData)
|
||||
|
||||
} else {
|
||||
|
||||
message := "{\"message\": \"Error, template not enabled\"}"
|
||||
return c.Response.Json(message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show form element page
|
||||
func Themeform(c *core.Context) *core.Response {
|
||||
|
||||
// check if template engine is enabled
|
||||
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||
if TemplateEnableStr == "" {
|
||||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
FormText components.FormInput
|
||||
FormEmail components.FormInput
|
||||
FormButton components.FormButton
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
FormText: components.FormInput{
|
||||
ID: "text",
|
||||
Label: "Name",
|
||||
Type: "text",
|
||||
Hint: "This is sample hint",
|
||||
Placeholder: "Enter your name",
|
||||
},
|
||||
FormEmail: components.FormInput{
|
||||
ID: "email",
|
||||
Label: "Email",
|
||||
Type: "email",
|
||||
Placeholder: "Enter your email address",
|
||||
},
|
||||
FormButton: components.FormButton{
|
||||
Text: "Login",
|
||||
IsSubmit: true,
|
||||
IsPrimary: true,
|
||||
},
|
||||
}
|
||||
return c.Response.Template("custom_theme_formpage.html", tmplData)
|
||||
|
||||
} else {
|
||||
|
||||
message := "{\"message\": \"Error, template not enabled\"}"
|
||||
return c.Response.Json(message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue