Browse Source

Migration for new template files

Vova Tkach 5 years ago
parent
commit
95fb5eb1df

+ 22 - 22
hosts/localhost/template/cached-block-1.html

@@ -1,23 +1,23 @@
-{{if not (eq $.Data.Module "404")}}
-	{{if eq $.Data.Module "index"}}
-		{{$.Data.Page.Name}}
-	{{else if or (eq $.Data.Module "blog") (eq $.Data.Module "blog-post") (eq $.Data.Module "blog-category")}}
-		{{if eq $.Data.Module "blog-category"}}
-			Posts of category "{{$.Data.Blog.Category.Name}}" | Blog
-		{{else if eq $.Data.Module "blog-post"}}
-			{{$.Data.Blog.Post.Name}} | Blog
-		{{else}}
-			Latest posts | Blog
-		{{end}}
-	{{else if or (eq $.Data.Module "shop") (eq $.Data.Module "shop-product") (eq $.Data.Module "shop-category")}}
-		{{if eq $.Data.Module "shop-category"}}
-			Products of category "{{$.Data.Shop.Category.Name}}" | Shop
-		{{else if eq $.Data.Module "shop-product"}}
-			{{$.Data.Shop.Product.Name}} | Shop
-		{{else}}
-			Latest products | Shop
-		{{end}}
-	{{end}}
-{{else}}
-	Error 404
+{{if not (eq $.Data.Module "404")}}
+	{{if eq $.Data.Module "index"}}
+		{{$.Data.Page.Name}}
+	{{else if or (eq $.Data.Module "blog") (eq $.Data.Module "blog-post") (eq $.Data.Module "blog-category")}}
+		{{if eq $.Data.Module "blog-category"}}
+			Posts of category "{{$.Data.Blog.Category.Name}}" | Blog
+		{{else if eq $.Data.Module "blog-post"}}
+			{{$.Data.Blog.Post.Name}} | Blog
+		{{else}}
+			Latest posts | Blog
+		{{end}}
+	{{else if or (eq $.Data.Module "shop") (eq $.Data.Module "shop-product") (eq $.Data.Module "shop-category")}}
+		{{if eq $.Data.Module "shop-category"}}
+			Products of category "{{$.Data.Shop.Category.Name}}" | Shop
+		{{else if eq $.Data.Module "shop-product"}}
+			{{$.Data.Shop.Product.Name}} | Shop
+		{{else}}
+			Latest products | Shop
+		{{end}}
+	{{end}}
+{{else}}
+	Error 404
 {{end}}

+ 1 - 1
modules/module_index_act_mysql_setup.go

@@ -465,7 +465,7 @@ func (this *Modules) RegisterAction_IndexMysqlSetup() *Action {
 			return
 		}
 		if _, err = tx.Exec(
-			`INSERT INTO settings (name, value) VALUES ('database_version', '000000008');`,
+			`INSERT INTO settings (name, value) VALUES ('database_version', '000000009');`,
 		); err != nil {
 			tx.Rollback()
 			wrap.MsgError(err.Error())

+ 1 - 0
support/migrate/000000001.go

@@ -14,4 +14,5 @@ var Migrations = map[string]func(*sqlw.DB, string) error{
 	"000000006": Migrate_000000006,
 	"000000007": Migrate_000000007,
 	"000000008": Migrate_000000008,
+	"000000009": Migrate_000000009,
 }

+ 33 - 0
support/migrate/000000009.go

@@ -0,0 +1,33 @@
+package migrate
+
+import (
+	"io/ioutil"
+	"os"
+
+	ThemeFiles "golang-fave/assets/template"
+	"golang-fave/engine/sqlw"
+)
+
+func Migrate_000000009(db *sqlw.DB, host string) error {
+	if err := ioutil.WriteFile(host+string(os.PathSeparator)+"/template/cached-block-1.html", ThemeFiles.AllData["cached-block-1.html"], 0664); err != nil {
+		return err
+	}
+
+	if err := ioutil.WriteFile(host+string(os.PathSeparator)+"/template/cached-block-2.html", ThemeFiles.AllData["cached-block-2.html"], 0664); err != nil {
+		return err
+	}
+
+	if err := ioutil.WriteFile(host+string(os.PathSeparator)+"/template/cached-block-3.html", ThemeFiles.AllData["cached-block-3.html"], 0664); err != nil {
+		return err
+	}
+
+	if err := ioutil.WriteFile(host+string(os.PathSeparator)+"/template/cached-block-4.html", ThemeFiles.AllData["cached-block-4.html"], 0664); err != nil {
+		return err
+	}
+
+	if err := ioutil.WriteFile(host+string(os.PathSeparator)+"/template/cached-block-5.html", ThemeFiles.AllData["cached-block-5.html"], 0664); err != nil {
+		return err
+	}
+
+	return nil
+}