Browse Source

Split front-end template data funcs, http data

Vova Tkach 6 years ago
parent
commit
01a1f2c567

+ 28 - 0
engine/fetdata/content.go

@@ -0,0 +1,28 @@
+package fetdata
+
+import (
+	"html/template"
+
+	"golang-fave/utils"
+)
+
+func (this *FERData) Name() string {
+	if this.Wrap.CurrModule == "index" {
+		return this.DataRow.(*utils.MySql_page).A_name
+	}
+	return ""
+}
+
+func (this *FERData) Alias() string {
+	if this.Wrap.CurrModule == "index" {
+		return this.DataRow.(*utils.MySql_page).A_alias
+	}
+	return ""
+}
+
+func (this *FERData) Content() template.HTML {
+	if this.Wrap.CurrModule == "index" {
+		return template.HTML(this.DataRow.(*utils.MySql_page).A_content)
+	}
+	return template.HTML("")
+}

+ 0 - 44
engine/fetdata/fetdata.go

@@ -1,8 +1,6 @@
 package fetdata
 
 import (
-	"html/template"
-
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -28,45 +26,3 @@ func (this *FERData) init() *FERData {
 	}
 	return this
 }
-
-func (this *FERData) MetaTitle() string {
-	if this.Wrap.CurrModule == "index" {
-		return this.DataRow.(*utils.MySql_page).A_meta_title
-	}
-	return ""
-}
-
-func (this *FERData) MetaKeywords() string {
-	if this.Wrap.CurrModule == "index" {
-		return this.DataRow.(*utils.MySql_page).A_meta_keywords
-	}
-	return ""
-}
-
-func (this *FERData) MetaDescription() string {
-	if this.Wrap.CurrModule == "index" {
-		return this.DataRow.(*utils.MySql_page).A_meta_description
-	}
-	return ""
-}
-
-func (this *FERData) Name() string {
-	if this.Wrap.CurrModule == "index" {
-		return this.DataRow.(*utils.MySql_page).A_name
-	}
-	return ""
-}
-
-func (this *FERData) Alias() string {
-	if this.Wrap.CurrModule == "index" {
-		return this.DataRow.(*utils.MySql_page).A_alias
-	}
-	return ""
-}
-
-func (this *FERData) Content() template.HTML {
-	if this.Wrap.CurrModule == "index" {
-		return template.HTML(this.DataRow.(*utils.MySql_page).A_content)
-	}
-	return template.HTML("")
-}

+ 17 - 0
engine/fetdata/http.go

@@ -0,0 +1,17 @@
+package fetdata
+
+import (
+	"golang-fave/utils"
+)
+
+func (this *FERData) RequestURI() string {
+	return this.Wrap.R.RequestURI
+}
+
+func (this *FERData) RequestURL() string {
+	return this.Wrap.R.URL.Path
+}
+
+func (this *FERData) RequestGET() string {
+	return utils.ExtractGetParams(this.Wrap.R.RequestURI)
+}

+ 26 - 0
engine/fetdata/meta_data.go

@@ -0,0 +1,26 @@
+package fetdata
+
+import (
+	"golang-fave/utils"
+)
+
+func (this *FERData) MetaTitle() string {
+	if this.Wrap.CurrModule == "index" {
+		return this.DataRow.(*utils.MySql_page).A_meta_title
+	}
+	return ""
+}
+
+func (this *FERData) MetaKeywords() string {
+	if this.Wrap.CurrModule == "index" {
+		return this.DataRow.(*utils.MySql_page).A_meta_keywords
+	}
+	return ""
+}
+
+func (this *FERData) MetaDescription() string {
+	if this.Wrap.CurrModule == "index" {
+		return this.DataRow.(*utils.MySql_page).A_meta_description
+	}
+	return ""
+}

+ 13 - 1
hosts/localhost/template/header.html

@@ -34,4 +34,16 @@
 				</div>
 			</nav>
 		</header>
-		<main role="main" class="pt-2">
+		<main role="main" class="pt-2">
+			<div class="container some-text pt-3">
+				<h2>MetaData</h2>
+				<div><b>MetaTitle:</b> {{$.Data.MetaTitle}}</div>
+				<div><b>MetaKeywords:</b> {{$.Data.MetaKeywords}}</div>
+				<div><b>MetaDescription:</b> {{$.Data.MetaDescription}}</div>
+			</div>
+			<div class="container some-text pt-3">
+				<h2>Http</h2>
+				<div><b>RequestURI:</b> {{$.Data.RequestURI}}</div>
+				<div><b>RequestURL:</b> {{$.Data.RequestURL}}</div>
+				<div><b>RequestGET:</b> {{$.Data.RequestGET}}</div>
+			</div>