This commit is contained in:
deepzz0
2016-10-12 00:29:56 +08:00
parent f3dfe46e7f
commit c24fa8bb22
6 changed files with 38 additions and 27 deletions

9
api.go
View File

@@ -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
}

18
back.go
View File

@@ -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()

View File

@@ -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) {

View File

@@ -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))
}
}

View File

@@ -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

View File

@@ -30,8 +30,6 @@
</li>
<ul class="child">
<li {{if eq .Path "/admin/profile"}}class="focus" {{end}}><a target="_self" href="/admin/profile">个人设置</a></li>
<li {{if eq .Path "/admin/plugins"}}class="focus" {{end}}><a target="_self" href="/admin/plugins">插件</a></li>
<li class="last {{if eq .Path "/admin/themes"}}focus{{end}}"><a target="_self" href="/admin/themes">外观</a></li>
</ul>
</ul>
<ul class="root {{if .Post}}focus{{end}}">