diff --git a/api.go b/api.go index b1ff9dd..a107aba 100644 --- a/api.go +++ b/api.go @@ -32,14 +32,19 @@ func init() { APIs["password"] = apiPassword // 删除文章 APIs["post-delete"] = apiPostDelete + // 添加文章 APIs["post-add"] = apiPostAdd - // 专题 + // 删除专题 APIs["serie-delete"] = apiSerieDelete + // 添加专题 APIs["serie-add"] = apiSerieAdd + // 专题排序 APIs["serie-sort"] = apiSerieSort - // xx箱 + // 删除草稿箱 APIs["draft-delete"] = apiDraftDelete + // 删除回收箱 APIs["trash-delete"] = apiTrashDelete + // 恢复回收箱 APIs["trash-recover"] = apiTrashRecover } diff --git a/back.go b/back.go index 920235b..fccef79 100644 --- a/back.go +++ b/back.go @@ -88,24 +88,6 @@ func HandleProfile(c *gin.Context) { c.HTML(http.StatusOK, "backLayout.html", h) } -// 插件 -func HandlePlugins(c *gin.Context) { - h := GetBack() - h["Console"] = true - h["Path"] = c.Request.URL.Path - h["Title"] = "插件管理 | " + Ei.BTitle - c.HTML(http.StatusOK, "backLayout.html", h) -} - -// 主题 -func HandleThemes(c *gin.Context) { - h := GetBack() - h["Console"] = true - h["Path"] = c.Request.URL.Path - h["Title"] = "主题管理 | " + Ei.BTitle - c.HTML(http.StatusOK, "backLayout.html", h) -} - // 写文章==>Write func HandlePost(c *gin.Context) { h := GetBack() diff --git a/front.go b/front.go index 93fec4d..fa01225 100644 --- a/front.go +++ b/front.go @@ -4,6 +4,7 @@ package main import ( "fmt" + "io/ioutil" "net/http" "regexp" "strconv" @@ -206,7 +207,33 @@ func HandleSitemap(c *gin.Context) { } // 服务端推送谷歌统计 -func HandleBeacon(c *gin.Context) {} +func HandleBeacon(c *gin.Context) { + ua := c.Request.UserAgent() + // TODO 过滤黑名单 + go func() { + req, err := http.NewRequest("POST", "https://www.google-analytics.com/collect", strings.NewReader(c.Request.URL.RawQuery)) + if err != nil { + logd.Error(err) + return + } + req.Header.Set("User-Agent", ua) + res, err := http.DefaultClient.Do(req) + if err != nil { + logd.Error(err) + return + } + defer res.Body.Close() + data, err := ioutil.ReadAll(res.Body) + if err != nil { + logd.Error(err) + return + } + if res.StatusCode/100 != 2 { + logd.Error(string(data)) + } + }() + c.String(http.StatusAccepted, "accepted") +} // 服务端获取评论详细 func HandleDisqus(c *gin.Context) { diff --git a/ping.go b/ping.go index 3b0a53f..045167d 100644 --- a/ping.go +++ b/ping.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "io/ioutil" "net/http" "net/url" @@ -36,5 +35,7 @@ func (f *Superfeedr) PingFunc(urls ...string) { logd.Error(err) return } - fmt.Println(string(data), res.StatusCode) + if res.StatusCode != 200 { + logd.Error(string(data)) + } } diff --git a/router.go b/router.go index 2dcd7af..0352cba 100644 --- a/router.go +++ b/router.go @@ -65,8 +65,6 @@ func init() { { // console auth.GET("/profile", HandleProfile) - auth.GET("/plugins", HandlePlugins) - auth.GET("/themes", HandleThemes) // write auth.GET("/write-post", HandlePost) // manage diff --git a/views/admin/backLayout.html b/views/admin/backLayout.html index a21a965..548a56f 100644 --- a/views/admin/backLayout.html +++ b/views/admin/backLayout.html @@ -30,8 +30,6 @@