265 lines
8.2 KiB
Go
265 lines
8.2 KiB
Go
// Copyright (c) 2026 Jose Cely <me@jacs.guru>
|
|
// Use of this source code is governed by MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"html/template"
|
|
|
|
"git.smarteching.com/goffee/core"
|
|
)
|
|
|
|
// TablerDemo1 renders a Tabler-themed demo page
|
|
func TablerDemo1(c *core.Context) *core.Response {
|
|
|
|
// first, include compoment
|
|
type templateData struct {
|
|
Content template.HTML
|
|
}
|
|
// Build the template data
|
|
data := templateData{
|
|
// The main page content (rendered HTML)
|
|
Content: template.HTML("<h2>Hola mundo</h2>"),
|
|
}
|
|
|
|
return c.Response.Template("tabler_demo.html", data)
|
|
}
|
|
|
|
// TablerSingle renders a page using the single layout (centered page with logo)
|
|
func TablerSingle(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Tabler Single",
|
|
PageDescription: "A single centered page",
|
|
Content: template.HTML("<div class=\"card card-md\"><div class=\"card-body\"><h2 class=\"card-title text-center mb-4\">Login</h2><p class=\"text-secondary mb-4\">Enter your credentials to access your account.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_single.html", data)
|
|
}
|
|
|
|
// TablerDefault renders a page using the default layout (with navbar, page header, footer)
|
|
func TablerDefault(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Tabler Default",
|
|
PageDescription: "A default page layout",
|
|
Sidebar: false,
|
|
ShowTopbar: true,
|
|
PageHeader: "Default Page",
|
|
PagePretitle: "Overview",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
Content: template.HTML("<div class=\"card\"><div class=\"card-body\"><h3 class=\"card-title\">Content Area</h3><p>This is the main content area of the default page layout.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_default.html", data)
|
|
}
|
|
|
|
// TablerNavbar renders a page using the default layout (with navbar, navbarmenu, page header, footer)
|
|
func TablerNavbar(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Navbar Menu Demo",
|
|
PageDescription: "Sample page with navbar menu",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Navbar Menu Demo",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML("<div class=\"card\"><div class=\"card-body\"><h3 class=\"card-title\">Navbar Menu Example</h3><p>This page demonstrates the navbar menu component migrated from the Liquid template. The menu items (Dashboards, Layout, Help) are rendered from sample data.</p></div></div>"),
|
|
}
|
|
return c.Response.Template("tabler_default.html", data)
|
|
}
|
|
|
|
// TablerComponents renders a page with alerts, breadcrumbs, and toasts.
|
|
// Uses the composition pattern: embeds TablerPageData and adds Components.
|
|
func TablerComponents(c *core.Context) *core.Response {
|
|
type componentsPageData struct {
|
|
TablerPageData
|
|
Components FormtablerComponentsPage
|
|
}
|
|
data := componentsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "UI Components",
|
|
PageDescription: "Alerts, breadcrumbs and toasts demo",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Components",
|
|
PagePretitle: "UI Elements",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Components: SampleComponents(),
|
|
}
|
|
return c.Response.Template("tabler_components.html", data)
|
|
}
|
|
|
|
// TablerCards renders a page with card component demos.
|
|
// Uses the composition pattern: embeds TablerPageData and adds Cards.
|
|
func TablerCards(c *core.Context) *core.Response {
|
|
type cardsPageData struct {
|
|
TablerPageData
|
|
Cards []FormtablerCard
|
|
}
|
|
data := cardsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Cards",
|
|
PageDescription: "Card component demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Cards",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Cards: SampleCards(),
|
|
}
|
|
return c.Response.Template("tabler_cards.html", data)
|
|
}
|
|
|
|
// TablerFormElements renders a page with all 25 formtabler form components.
|
|
// Uses the composition pattern: embeds TablerPageData and adds
|
|
// a FormElements field containing all form component data.
|
|
func TablerFormElements(c *core.Context) *core.Response {
|
|
type formelementsPageData struct {
|
|
TablerPageData
|
|
FormElements FormtablerFormElementsPage
|
|
}
|
|
data := formelementsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Form Elements",
|
|
PageDescription: "Form element demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Form Elements",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
FormElements: SampleFormElements(),
|
|
}
|
|
return c.Response.Template("tabler_formelements.html", data)
|
|
}
|
|
|
|
// TablerTables renders a page with table components.
|
|
// Uses a page-specific struct that embeds TablerPageData and adds the Tables field.
|
|
// The template detects tables via hasField and renders them.
|
|
func TablerTables(c *core.Context) *core.Response {
|
|
type tablesPageData struct {
|
|
TablerPageData
|
|
Tables []TableComponent
|
|
}
|
|
data := tablesPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Tables",
|
|
PageDescription: "Table demo page",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Tables",
|
|
PagePretitle: "Components",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: template.HTML(""),
|
|
},
|
|
Tables: SampleTables(),
|
|
}
|
|
return c.Response.Template("tabler_tables.html", data)
|
|
}
|
|
|
|
// UserSignIn renders the sign-in page.
|
|
func UserSignIn(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Sign In",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_sign-in.html", data)
|
|
}
|
|
|
|
// UserSignUp renders the sign-up page.
|
|
func UserSignUp(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Sign Up",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_sign-up.html", data)
|
|
}
|
|
|
|
// UserForgot renders the forgot password page.
|
|
func UserForgot(c *core.Context) *core.Response {
|
|
type authPageData struct {
|
|
TablerPageData
|
|
}
|
|
data := authPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Forgot Password",
|
|
},
|
|
}
|
|
return c.Response.Template("apptabler_forgot.html", data)
|
|
}
|
|
|
|
// UserLock renders the account lock page.
|
|
func UserLock(c *core.Context) *core.Response {
|
|
type authLockPageData struct {
|
|
TablerPageData
|
|
PersonName string
|
|
}
|
|
data := authLockPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Account Locked",
|
|
},
|
|
PersonName: "Paweł Kuna",
|
|
}
|
|
return c.Response.Template("apptabler_auth-lock.html", data)
|
|
}
|
|
|
|
// UserSettings renders the user settings page.
|
|
func UserSettings(c *core.Context) *core.Response {
|
|
type userSettingsPageData struct {
|
|
TablerPageData
|
|
UserSettings FormtablerUserSettingsPage
|
|
}
|
|
data := userSettingsPageData{
|
|
TablerPageData: TablerPageData{
|
|
PageTitle: "Account Settings",
|
|
PageDescription: "User account settings",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
PageHeader: "Account Settings",
|
|
PagePretitle: "User Profile",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
NavbarMenu: SampleNavbarMenu(),
|
|
Content: nil,
|
|
},
|
|
UserSettings: SampleUserSettings(),
|
|
}
|
|
return c.Response.Template("apptabler_usersettings.html", data)
|
|
}
|
|
|
|
// TablerHome renders the homepage/dashboard layout
|
|
func TablerHome(c *core.Context) *core.Response {
|
|
data := TablerPageData{
|
|
PageTitle: "Dashboard",
|
|
PageDescription: "Dashboard home page",
|
|
PageHeader: "Dashboard",
|
|
PagePretitle: "Overview",
|
|
UserName: "Jane Doe",
|
|
UserRole: "Administrator",
|
|
ShowTopbar: true,
|
|
Sidebar: false,
|
|
}
|
|
return c.Response.Template("tabler_homepage.html", data)
|
|
}
|