42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"blog/config"
|
||
|
"blog/models"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func Memos(w http.ResponseWriter, r *http.Request) {
|
||
|
if err := r.ParseForm(); err != nil {
|
||
|
http.Error(w, "参数解析错误", http.StatusInternalServerError)
|
||
|
}
|
||
|
fun := r.Form.Get("name")
|
||
|
log.Printf("R:%v,name:%s\n", r.Form, fun)
|
||
|
switch fun {
|
||
|
case "talk":
|
||
|
Template := models.Template.Talk
|
||
|
|
||
|
Template.WriteData(w, models.BuildViewData("Talk", map[string]interface{}{
|
||
|
"url": config.Cfg.MemosURL,
|
||
|
"user": config.Cfg.MemosUser,
|
||
|
"tag": config.Cfg.MemosTalkTag,
|
||
|
"author": config.Cfg.Author,
|
||
|
"qq": config.Cfg.Qq,
|
||
|
}))
|
||
|
case "album":
|
||
|
Template := models.Template.Album
|
||
|
tag := strings.Split(config.Cfg.MemosAlbumTag, ",")
|
||
|
Template.WriteData(w, models.BuildViewData("Album", map[string]interface{}{
|
||
|
"url": config.Cfg.MemosURL,
|
||
|
"user": config.Cfg.MemosUser,
|
||
|
"image": tag[0],
|
||
|
"video": tag[1],
|
||
|
}))
|
||
|
default:
|
||
|
http.Error(w, "无法解析页面请求"+fun, http.StatusInternalServerError)
|
||
|
}
|
||
|
|
||
|
}
|