mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-21 13:42:26 +08:00
adjust the code
This commit is contained in:
6
api.go
6
api.go
@@ -89,7 +89,9 @@ func apiBlog(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := UpdateAccountField(mgo.M{"$set": mgo.M{"blogger.blogname": bn, "blogger.btitle": bt, "blogger.beian": ba, "blogger.subtitle": st, "blogger.seriessay": ss, "blogger.archivessay": as}})
|
err := UpdateAccountField(mgo.M{"$set": mgo.M{"blogger.blogname": bn,
|
||||||
|
"blogger.btitle": bt, "blogger.beian": ba, "blogger.subtitle": st,
|
||||||
|
"blogger.seriessay": ss, "blogger.archivessay": as}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responseNotice(c, NOTICE_NOTICE, err.Error(), "")
|
responseNotice(c, NOTICE_NOTICE, err.Error(), "")
|
||||||
return
|
return
|
||||||
@@ -335,7 +337,7 @@ func apiSerieAdd(c *gin.Context) {
|
|||||||
responseNotice(c, NOTICE_SUCCESS, "操作成功", "")
|
responseNotice(c, NOTICE_SUCCESS, "操作成功", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暂未启用
|
// NOTE 暂未启用
|
||||||
func apiSerieSort(c *gin.Context) {
|
func apiSerieSort(c *gin.Context) {
|
||||||
err := c.Request.ParseForm()
|
err := c.Request.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
3
front.go
3
front.go
@@ -379,7 +379,8 @@ func HandleDisqus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 发表评论
|
// 发表评论
|
||||||
// [thread:[5279901489] parent:[] identifier:[post-troubleshooting-https] next:[] author_name:[你好] author_email:[chenqijing2@163.com] message:[fdsfdsf]]
|
// [thread:[5279901489] parent:[] identifier:[post-troubleshooting-https]
|
||||||
|
// next:[] author_name:[你好] author_email:[chenqijing2@163.com] message:[fdsfdsf]]
|
||||||
type DisqusCreate struct {
|
type DisqusCreate struct {
|
||||||
ErrNo int `json:"errno"`
|
ErrNo int `json:"errno"`
|
||||||
ErrMsg string `json:"errmsg"`
|
ErrMsg string `json:"errmsg"`
|
||||||
|
|||||||
3
ping.go
3
ping.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -64,7 +65,7 @@ func (p *pingRPC) PingFunc(slug string) {
|
|||||||
if len(setting.Conf.PingRPCs) == 0 {
|
if len(setting.Conf.PingRPCs) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.Params.Param[1].Value = "https://" + setting.Conf.Mode.Domain + "/post/" + slug + ".html"
|
p.Params.Param[1].Value = fmt.Sprintf("https://%s/post/%s.html", setting.Conf.Mode.Domain, slug)
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
buf.WriteString(xml.Header)
|
buf.WriteString(xml.Header)
|
||||||
enc := xml.NewEncoder(buf)
|
enc := xml.NewEncoder(buf)
|
||||||
|
|||||||
29
qiniu.go
29
qiniu.go
@@ -11,18 +11,6 @@ import (
|
|||||||
"github.com/qiniu/api.v7/storage"
|
"github.com/qiniu/api.v7/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
type bucket struct {
|
|
||||||
name string
|
|
||||||
domain string
|
|
||||||
accessKey string
|
|
||||||
secretKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutRet struct {
|
|
||||||
Hash string `json:"hash"`
|
|
||||||
Key string `json:"key"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
func onProgress(fsize, uploaded int64) {
|
func onProgress(fsize, uploaded int64) {
|
||||||
d := int(float64(uploaded) / float64(fsize) * 100)
|
d := int(float64(uploaded) / float64(fsize) * 100)
|
||||||
@@ -40,10 +28,6 @@ func FileUpload(name string, size int64, data io.Reader) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
key := getKey(name)
|
key := getKey(name)
|
||||||
if key == "" {
|
|
||||||
return "", errors.New("不支持的文件类型")
|
|
||||||
}
|
|
||||||
|
|
||||||
mac := qbox.NewMac(setting.Conf.Qiniu.AccessKey, setting.Conf.Qiniu.SecretKey)
|
mac := qbox.NewMac(setting.Conf.Qiniu.AccessKey, setting.Conf.Qiniu.SecretKey)
|
||||||
// 设置上传的策略
|
// 设置上传的策略
|
||||||
putPolicy := &storage.PutPolicy{
|
putPolicy := &storage.PutPolicy{
|
||||||
@@ -62,7 +46,8 @@ func FileUpload(name string, size int64, data io.Reader) (string, error) {
|
|||||||
// uploader
|
// uploader
|
||||||
uploader := storage.NewFormUploader(cfg)
|
uploader := storage.NewFormUploader(cfg)
|
||||||
ret := new(storage.PutRet)
|
ret := new(storage.PutRet)
|
||||||
putExtra := &storage.PutExtra{OnProgress: onProgress}
|
putExtra := &storage.PutExtra{}
|
||||||
|
|
||||||
err := uploader.Put(nil, ret, upToken, key, data, size, putExtra)
|
err := uploader.Put(nil, ret, upToken, key, data, size, putExtra)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -75,9 +60,6 @@ func FileUpload(name string, size int64, data io.Reader) (string, error) {
|
|||||||
// 删除文件
|
// 删除文件
|
||||||
func FileDelete(name string) error {
|
func FileDelete(name string) error {
|
||||||
key := getKey(name)
|
key := getKey(name)
|
||||||
if key == "" {
|
|
||||||
return errors.New("不支持的文件类型")
|
|
||||||
}
|
|
||||||
|
|
||||||
mac := qbox.NewMac(setting.Conf.Qiniu.AccessKey, setting.Conf.Qiniu.SecretKey)
|
mac := qbox.NewMac(setting.Conf.Qiniu.AccessKey, setting.Conf.Qiniu.SecretKey)
|
||||||
// 上传配置
|
// 上传配置
|
||||||
@@ -104,9 +86,12 @@ func getKey(name string) string {
|
|||||||
key = "blog/img/" + name
|
key = "blog/img/" + name
|
||||||
case ".mov", ".mp4":
|
case ".mov", ".mp4":
|
||||||
key = "blog/video/" + name
|
key = "blog/video/" + name
|
||||||
case ".go", ".js", ".css", ".cpp", ".php", ".rb", ".java", ".py", ".sql", ".lua", ".html", ".sh", ".xml", ".cs":
|
case ".go", ".js", ".css", ".cpp", ".php", ".rb",
|
||||||
|
".java", ".py", ".sql", ".lua", ".html",
|
||||||
|
".sh", ".xml", ".cs":
|
||||||
key = "blog/code/" + name
|
key = "blog/code/" + name
|
||||||
case ".txt", ".md", ".ini", ".yaml", ".yml", ".doc", ".ppt", ".pdf":
|
case ".txt", ".md", ".ini", ".yaml", ".yml",
|
||||||
|
".doc", ".ppt", ".pdf":
|
||||||
key = "blog/document/" + name
|
key = "blog/document/" + name
|
||||||
case ".zip", ".rar", ".tar", ".gz":
|
case ".zip", ".rar", ".tar", ".gz":
|
||||||
key = "blog/archive/" + name
|
key = "blog/archive/" + name
|
||||||
|
|||||||
Reference in New Issue
Block a user