Browse Source

Return demo content, return mysql driver

Vova Tkach 6 years ago
parent
commit
3a2fa75d69
3 changed files with 34 additions and 1 deletions
  1. 2 0
      engine/actions/action_mysql.go
  2. 1 0
      engine/backend/backend.go
  3. 31 1
      engine/frontend/frontend.go

+ 2 - 0
engine/actions/action_mysql.go

@@ -2,6 +2,8 @@ package actions
 
 import (
 	"database/sql"
+	_ "github.com/go-sql-driver/mysql"
+
 	"fmt"
 	"strconv"
 

+ 1 - 0
engine/backend/backend.go

@@ -2,6 +2,7 @@ package backend
 
 import (
 	"database/sql"
+	_ "github.com/go-sql-driver/mysql"
 
 	"golang-fave/engine/wrapper"
 

+ 31 - 1
engine/frontend/frontend.go

@@ -2,10 +2,27 @@ package frontend
 
 import (
 	"database/sql"
+	_ "github.com/go-sql-driver/mysql"
 
 	"golang-fave/engine/wrapper"
 )
 
+// --- Demo
+type MenuItem struct {
+	Name   string
+	Link   string
+	Active bool
+}
+
+type TmplData struct {
+	MetaTitle       string
+	MetaKeywords    string
+	MetaDescription string
+	MenuItems       []MenuItem
+}
+
+// --------
+
 type Frontend struct {
 	wrapper *wrapper.Wrapper
 	db      *sql.DB
@@ -16,9 +33,22 @@ func New(wrapper *wrapper.Wrapper, db *sql.DB) *Frontend {
 }
 
 func (this *Frontend) Run() bool {
+	// --- Demo
 	if this.wrapper.R.URL.Path == "/" {
-		return this.wrapper.TmplFrontEnd("index", nil)
+		return this.wrapper.TmplFrontEnd("index", TmplData{
+			MetaTitle:       "Meta Title",
+			MetaKeywords:    "Meta Keywords",
+			MetaDescription: "Meta Description",
+
+			MenuItems: []MenuItem{
+				{Name: "Home", Link: "/", Active: true},
+				{Name: "Item 1", Link: "/#1", Active: false},
+				{Name: "Item 2", Link: "/#2", Active: false},
+				{Name: "Item 3", Link: "/#3", Active: false},
+			},
+		})
 	}
+	// --------
 
 	return false
 }