-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_blog.go
42 lines (37 loc) · 1.11 KB
/
route_blog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"html/template"
"net/http"
"github.com/gorilla/mux"
. "github.com/logrusorgru/aurora"
)
func Blog(w http.ResponseWriter, r *http.Request) {
fmt.Println(Gray(8-1, "Starting Blog..."))
templates := template.Must(
template.ParseFiles(
"templates/OUT_navbar.html",
"templates/OUT_head.html",
"templates/OUT_footer.html",
"templates/OUT_subscribe.html",
"templates/blog/blog_home.html"))
templates.ExecuteTemplate(w, "layout", nil)
}
func RouteBlogArticle(w http.ResponseWriter, r *http.Request) {
fmt.Println(Gray(8-1, "Starting RouteBlogArticle..."))
article := mux.Vars(r)["article"]
article_full_path := fmt.Sprintf("templates/blog/%s.html", article)
templates := template.Must(
template.ParseFiles(
"templates/OUT_navbar.html",
"templates/OUT_head.html",
"templates/OUT_footer.html",
"templates/OUT_subscribe.html",
article_full_path))
templates.ExecuteTemplate(w, "layout", nil)
}
func BlogSubscribe(w http.ResponseWriter, r *http.Request) {
fmt.Println(Gray(8-1, "Starting BlogSubscribe..."))
email := r.FormValue("email")
InsertSubscriberByEmail(email)
}