diff --git a/config/main.go b/config/main.go index 8381c6e..41a6c8b 100644 --- a/config/main.go +++ b/config/main.go @@ -14,6 +14,7 @@ import ( type Config struct { userConfig systemConfig + memosConfig } // diff --git a/config/memos.go b/config/memos.go new file mode 100644 index 0000000..12f4346 --- /dev/null +++ b/config/memos.go @@ -0,0 +1,8 @@ +package config + +type memosConfig struct { + MemosUser string `json:"memos_user"` + MemosURL string `json:"memos_url"` + MemosAlbumTag string `json:"memos_album_tag"` + MemosTalkTag string `json:"memos_talk_tag"` +} diff --git a/config/user.go b/config/user.go index 6f0d511..f69f311 100644 --- a/config/user.go +++ b/config/user.go @@ -5,6 +5,8 @@ type userConfig struct { Author string `json:"author"` + Qq string `json:"qq"` + Icp string `json:"icp"` TimeLayout string `json:"timeLayout"` diff --git a/controller/album.go b/controller/album.go new file mode 100644 index 0000000..65469bf --- /dev/null +++ b/controller/album.go @@ -0,0 +1,23 @@ +package controller + +import ( + "blog/config" + "blog/models" + "net/http" +) + +func Album(w http.ResponseWriter, r *http.Request) { + + PhotoTemplate := models.Template.Album + + if err := r.ParseForm(); err != nil { + PhotoTemplate.WriteError(w, err) + } + + PhotoTemplate.WriteData(w, models.BuildViewData("Album", map[string]interface{}{ + "memos_url": config.Cfg.MemosURL, + "memos_user": config.Cfg.MemosUser, + "memos_tag": config.Cfg.MemosAlbumTag, + })) + +} diff --git a/controller/talk.go b/controller/talk.go new file mode 100644 index 0000000..7fe1dcd --- /dev/null +++ b/controller/talk.go @@ -0,0 +1,25 @@ +package controller + +import ( + "blog/config" + "blog/models" + "net/http" +) + +func Talk(w http.ResponseWriter, r *http.Request) { + + TalkTemplate := models.Template.Talk + + if err := r.ParseForm(); err != nil { + TalkTemplate.WriteError(w, err) + } + + TalkTemplate.WriteData(w, models.BuildViewData("Talk", map[string]interface{}{ + "memos_url": config.Cfg.MemosURL, + "memos_user": config.Cfg.MemosUser, + "memos_tag": config.Cfg.MemosTalkTag, + "author": config.Cfg.Author, + "qq": config.Cfg.Qq, + })) + +} diff --git a/models/html_template.go b/models/html_template.go index ce773b5..aafa492 100644 --- a/models/html_template.go +++ b/models/html_template.go @@ -12,6 +12,8 @@ type TemplatePointer struct { } type HtmlTemplate struct { + Talk TemplatePointer + Album TemplatePointer Article TemplatePointer Categories TemplatePointer Dashboard TemplatePointer @@ -48,7 +50,7 @@ func initHtmlTemplate(viewDir string) (HtmlTemplate, error) { var htmlTemplate HtmlTemplate tp, err := readHtmlTemplate( - []string{"index", "extraNav", "dashboard", "categories", "article"}, + []string{"index", "extraNav", "dashboard", "categories", "article", "album", "talk"}, viewDir) if err != nil { return htmlTemplate, err @@ -59,6 +61,8 @@ func initHtmlTemplate(viewDir string) (HtmlTemplate, error) { htmlTemplate.Dashboard = tp[2] htmlTemplate.Categories = tp[3] htmlTemplate.Article = tp[4] + htmlTemplate.Album = tp[5] + htmlTemplate.Talk = tp[6] return htmlTemplate, nil } diff --git a/routes/main.go b/routes/main.go index 4186762..ff3e703 100644 --- a/routes/main.go +++ b/routes/main.go @@ -13,6 +13,8 @@ func InitRoute() { http.HandleFunc("/categories", controller.Category) http.HandleFunc("/article", controller.Article) http.HandleFunc("/extra-nav", controller.ExtraNav) + http.HandleFunc("/album", controller.Album) + http.HandleFunc("/talk", controller.Talk) http.HandleFunc(config.Cfg.GitHookUrl, controller.GithubHook) http.HandleFunc(config.Cfg.Dashboard, controller.Dashboard) diff --git a/themes/blog/album.html b/themes/blog/album.html new file mode 100644 index 0000000..338e28b --- /dev/null +++ b/themes/blog/album.html @@ -0,0 +1,77 @@ +{{template "header" .}} +
- {{ .Title }} -
+ + + + + + + + +{{template "footer" .}} diff --git a/themes/blog/layouts/head.html b/themes/blog/layouts/head.html index b1030bd..19208a2 100644 --- a/themes/blog/layouts/head.html +++ b/themes/blog/layouts/head.html @@ -60,6 +60,12 @@