mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-10 00:22:27 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30ebf76eda | ||
|
|
f5c0bcdb99 | ||
|
|
4b53da3801 | ||
|
|
1bdfb6abea | ||
|
|
33f47d8f3a | ||
|
|
080c992a92 |
56
CHANGELOG.md
56
CHANGELOG.md
@@ -1,10 +1,21 @@
|
|||||||
# Eiblog Changelog
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [1.4.9](https://github.com/eiblog/eiblog/compare/v1.4.8...v1.4.9) (2019-12-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **disqus:** connect reset by peer ([1bdfb6a](https://github.com/eiblog/eiblog/commit/1bdfb6a))
|
||||||
|
|
||||||
|
### v1.4.4 (2018-05-07)
|
||||||
|
|
||||||
## v1.4.4 (2018-05-07)
|
|
||||||
* 修复基础评论分钟数计算错误
|
* 修复基础评论分钟数计算错误
|
||||||
* let's encrypt v2证书内嵌ct,故移除有关ct内容
|
* let's encrypt v2证书内嵌ct,故移除有关ct内容
|
||||||
|
|
||||||
## v1.4.3 (2018-02-09)
|
### v1.4.3 (2018-02-09)
|
||||||
|
|
||||||
* 修复博客初始化后,about 页面不能够评论 #6
|
* 修复博客初始化后,about 页面不能够评论 #6
|
||||||
* 修复编辑专题,按钮显示“添加专题”错误
|
* 修复编辑专题,按钮显示“添加专题”错误
|
||||||
* 优化“添加文章”从同步改为异步推送:feed,es,disqus。速度显著提升
|
* 优化“添加文章”从同步改为异步推送:feed,es,disqus。速度显著提升
|
||||||
@@ -12,10 +23,12 @@
|
|||||||
* docker-compose.yml mongodb 去掉端口映射,防止用户将端口暴露至外网
|
* docker-compose.yml mongodb 去掉端口映射,防止用户将端口暴露至外网
|
||||||
* session key 每次重启随机生成等一些细节的修复
|
* session key 每次重启随机生成等一些细节的修复
|
||||||
|
|
||||||
## v1.4.2 (2018-01-25)
|
### v1.4.2 (2018-01-25)
|
||||||
|
|
||||||
* fix archive page bug
|
* fix archive page bug
|
||||||
|
|
||||||
## v1.4.1 (2018-01-14)
|
### v1.4.1 (2018-01-14)
|
||||||
|
|
||||||
* 修复创建新文章,disqus 不收录bug
|
* 修复创建新文章,disqus 不收录bug
|
||||||
* 修复创建新文章,归档页面不刷新bug
|
* 修复创建新文章,归档页面不刷新bug
|
||||||
* 修复能够删除关于页面和友情链接页面bug
|
* 修复能够删除关于页面和友情链接页面bug
|
||||||
@@ -24,29 +37,35 @@
|
|||||||
* 添加当月数大于12,归档页面使用年份归档
|
* 添加当月数大于12,归档页面使用年份归档
|
||||||
* 优化代码逻辑
|
* 优化代码逻辑
|
||||||
|
|
||||||
## v1.4.0 (2018-01-01)
|
### v1.4.0 (2018-01-01)
|
||||||
|
|
||||||
* fix 搜索页面 bug
|
* fix 搜索页面 bug
|
||||||
* CGO_ENABLED=0 关闭 cgo
|
* CGO_ENABLED=0 关闭 cgo
|
||||||
* 更新Makefile ct log 服务器
|
* 更新Makefile ct log 服务器
|
||||||
* 数据库数据终于可以备份了
|
* 数据库数据终于可以备份了
|
||||||
|
|
||||||
## v1.3.4 (2017-11-29)
|
### v1.3.4 (2017-11-29)
|
||||||
|
|
||||||
* fix page:admin/write-post autocomplete tag
|
* fix page:admin/write-post autocomplete tag
|
||||||
|
|
||||||
## v1.3.3 (2017-11-27)
|
### v1.3.3 (2017-11-27)
|
||||||
|
|
||||||
* fix docker image: exec user process caused "no such file or directory"
|
* fix docker image: exec user process caused "no such file or directory"
|
||||||
|
|
||||||
## v1.3.2 (2017-11-17)
|
### v1.3.2 (2017-11-17)
|
||||||
|
|
||||||
* 修复文章自动保存引起的发布文章不成功的bug
|
* 修复文章自动保存引起的发布文章不成功的bug
|
||||||
|
|
||||||
## v1.3.1 (2017-11-05)
|
### v1.3.1 (2017-11-05)
|
||||||
|
|
||||||
* 修复调整 关于、友情链接 创建时间出现文章乱序
|
* 修复调整 关于、友情链接 创建时间出现文章乱序
|
||||||
* 修复评论时间计算错误
|
* 修复评论时间计算错误
|
||||||
* 调整acme文件验证路径
|
* 调整acme文件验证路径
|
||||||
* 更改七牛SDK包为github包。
|
* 更改七牛SDK包为github包。
|
||||||
* 调整七牛配置文件名称,app.yml: kodo -> qiniu,name -> bucket,请提高静态文件版本 staticversion
|
* 调整七牛配置文件名称,app.yml: kodo -> qiniu,name -> bucket,请提高静态文件版本 staticversion
|
||||||
|
|
||||||
## v1.3.0 (2017-07-13)
|
### v1.3.0 (2017-07-13)
|
||||||
|
|
||||||
* 更改 app.yml 配置项,将大部分配置归在 general 常规配置下。注意,部署时请先更新 app.yml。
|
* 更改 app.yml 配置项,将大部分配置归在 general 常规配置下。注意,部署时请先更新 app.yml。
|
||||||
* 静态文件采用动态渲染,即用户不再需要管理 view、static 目录。
|
* 静态文件采用动态渲染,即用户不再需要管理 view、static 目录。
|
||||||
* 通过 acme.sh 使用双证书啦,可到 Makefile 查看相关信息。
|
* 通过 acme.sh 使用双证书啦,可到 Makefile 查看相关信息。
|
||||||
@@ -54,28 +73,33 @@
|
|||||||
* 开启配置项 enablehttps, 将自动重定向 http 到 https 啦。
|
* 开启配置项 enablehttps, 将自动重定向 http 到 https 啦。
|
||||||
* disqus.js 文件由配置指定,请看 app.yml 下的 disqus 相关配置。
|
* disqus.js 文件由配置指定,请看 app.yml 下的 disqus 相关配置。
|
||||||
|
|
||||||
## v1.2.0 (2017-06-14)
|
### v1.2.0 (2017-06-14)
|
||||||
|
|
||||||
* 更新评论功能,基础评论 0 回复也可评论了。
|
* 更新评论功能,基础评论 0 回复也可评论了。
|
||||||
* disqus.js 文件由博主自行更新。
|
* disqus.js 文件由博主自行更新。
|
||||||
* 更正描述 README.md 描述错误 [#4f996](https://github.com/eiblog/eiblog/commit/4f9965b6bdefe087dd0805c1840afcb2752cd155)。
|
* 更正描述 README.md 描述错误 [#4f996](https://github.com/eiblog/eiblog/commit/4f9965b6bdefe087dd0805c1840afcb2752cd155)。
|
||||||
* docker 镜像版本化。
|
* docker 镜像版本化。
|
||||||
|
|
||||||
## v1.1.3 (2017-05-12)
|
### v1.1.3 (2017-05-12)
|
||||||
|
|
||||||
* 更新 disqus_78bca4.js 到 disqus_921d24.js,具体请参考 docs/install.md
|
* 更新 disqus_78bca4.js 到 disqus_921d24.js,具体请参考 docs/install.md
|
||||||
* 更新 vendor
|
* 更新 vendor
|
||||||
|
|
||||||
## v1.1.2 (2017-03-08)
|
### v1.1.2 (2017-03-08)
|
||||||
|
|
||||||
* 解决添加文章描述错误的bug
|
* 解决添加文章描述错误的bug
|
||||||
* 添加vendor目录
|
* 添加vendor目录
|
||||||
* 添加文档docs目录
|
* 添加文档docs目录
|
||||||
* 删除多余注释
|
* 删除多余注释
|
||||||
|
|
||||||
## v1.1.1 (2017-02-07)
|
### v1.1.1 (2017-02-07)
|
||||||
|
|
||||||
* 添加文章描述功能。
|
* 添加文章描述功能。
|
||||||
* 修复评论`jQuery`文件引用错误。
|
* 修复评论`jQuery`文件引用错误。
|
||||||
* 修复`.travis.yml`描述错误。
|
* 修复`.travis.yml`描述错误。
|
||||||
|
|
||||||
## v1.0.0 (2016-01-09)
|
### v1.0.0 (2016-01-09)
|
||||||
|
|
||||||
首次发布版本
|
首次发布版本
|
||||||
|
|
||||||
* 全站`HTTPS`设计,安全、极速。
|
* 全站`HTTPS`设计,安全、极速。
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ disqus:
|
|||||||
postcreate: https://disqus.com/api/3.0/posts/create.json
|
postcreate: https://disqus.com/api/3.0/posts/create.json
|
||||||
postapprove: https://disqus.com/api/3.0/posts/approve.json
|
postapprove: https://disqus.com/api/3.0/posts/approve.json
|
||||||
threadcreate: https://disqus.com/api/3.0/threads/create.json
|
threadcreate: https://disqus.com/api/3.0/threads/create.json
|
||||||
# disqus.js 文件名
|
|
||||||
embed: disqus_7d3cf2.js
|
|
||||||
# 获取评论数量间隔
|
# 获取评论数量间隔
|
||||||
interval: 5
|
interval: 5
|
||||||
# 谷歌统计
|
# 谷歌统计
|
||||||
|
|||||||
109
disqus.go
109
disqus.go
@@ -3,10 +3,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -58,7 +60,7 @@ func PostsCount() error {
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
resp, err := http.Get(setting.Conf.Disqus.PostsCount + "?" + vals.Encode())
|
resp, err := Get(setting.Conf.Disqus.PostsCount + "?" + vals.Encode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -128,7 +130,7 @@ func PostsList(slug, cursor string) (*postsListResp, error) {
|
|||||||
vals.Set("cursor", cursor)
|
vals.Set("cursor", cursor)
|
||||||
vals.Set("limit", "50")
|
vals.Set("limit", "50")
|
||||||
|
|
||||||
resp, err := http.Get(setting.Conf.Disqus.PostsList + "?" + vals.Encode())
|
resp, err := Get(setting.Conf.Disqus.PostsList + "?" + vals.Encode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -181,12 +183,8 @@ func PostCreate(pc *PostComment) (*postCreateResp, error) {
|
|||||||
vals.Set("author_name", pc.AuthorName)
|
vals.Set("author_name", pc.AuthorName)
|
||||||
// vals.Set("state", "approved")
|
// vals.Set("state", "approved")
|
||||||
|
|
||||||
request, err := http.NewRequest("POST", setting.Conf.Disqus.PostCreate, strings.NewReader(vals.Encode()))
|
header := http.Header{"Referer": {"https://disqus.com"}}
|
||||||
if err != nil {
|
resp, err := PostWithHeader(setting.Conf.Disqus.PostCreate, vals, header)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
request.Header.Set("Referer", "https://disqus.com")
|
|
||||||
resp, err := http.DefaultClient.Do(request)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -225,12 +223,8 @@ func PostApprove(post string) error {
|
|||||||
vals.Set("access_token", setting.Conf.Disqus.AccessToken)
|
vals.Set("access_token", setting.Conf.Disqus.AccessToken)
|
||||||
vals.Set("post", post)
|
vals.Set("post", post)
|
||||||
|
|
||||||
request, err := http.NewRequest("POST", setting.Conf.Disqus.PostApprove, strings.NewReader(vals.Encode()))
|
header := http.Header{"Referer": {"https://disqus.com"}}
|
||||||
if err != nil {
|
resp, err := PostWithHeader(setting.Conf.Disqus.PostApprove, vals, header)
|
||||||
return err
|
|
||||||
}
|
|
||||||
request.Header.Set("Referer", "https://disqus.com")
|
|
||||||
resp, err := http.DefaultClient.Do(request)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -276,7 +270,7 @@ func ThreadCreate(artc *Article) error {
|
|||||||
urlPath := fmt.Sprintf("https://%s/post/%s.html", setting.Conf.Mode.Domain, artc.Slug)
|
urlPath := fmt.Sprintf("https://%s/post/%s.html", setting.Conf.Mode.Domain, artc.Slug)
|
||||||
vals.Set("url", urlPath)
|
vals.Set("url", urlPath)
|
||||||
|
|
||||||
resp, err := http.PostForm(setting.Conf.Disqus.ThreadCreate, vals)
|
resp, err := PostForm(setting.Conf.Disqus.ThreadCreate, vals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -299,3 +293,88 @@ func ThreadCreate(artc *Article) error {
|
|||||||
artc.Thread = result.Response.Id
|
artc.Thread = result.Response.Id
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////// HTTP 请求 /////////////////////////////
|
||||||
|
|
||||||
|
var httpClient = &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
DialContext: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
DualStack: true,
|
||||||
|
}).DialContext,
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRequest(method, rawurl string, vals url.Values) (*http.Request, error) {
|
||||||
|
u, err := url.Parse(rawurl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
host := u.Host
|
||||||
|
// 获取主机IP
|
||||||
|
ips, err := net.LookupHost(u.Host)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(ips) == 0 {
|
||||||
|
return nil, errors.New("not found ip: " + u.Host)
|
||||||
|
}
|
||||||
|
// 设置ServerName
|
||||||
|
httpClient.Transport.(*http.Transport).TLSClientConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
|
u.Host = ips[0]
|
||||||
|
// 创建HTTP Request
|
||||||
|
var req *http.Request
|
||||||
|
if vals != nil {
|
||||||
|
req, err = http.NewRequest(method, u.String(), strings.NewReader(vals.Encode()))
|
||||||
|
} else {
|
||||||
|
req, err = http.NewRequest(method, u.String(), nil)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 改变Host
|
||||||
|
req.Host = host
|
||||||
|
return req, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get HTTP Get请求
|
||||||
|
func Get(rawurl string) (*http.Response, error) {
|
||||||
|
req, err := newRequest(http.MethodGet, rawurl, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 发起请求
|
||||||
|
return httpClient.Do(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostForm HTTP Post请求
|
||||||
|
func PostForm(rawurl string, vals url.Values) (*http.Response, error) {
|
||||||
|
req, err := newRequest(http.MethodPost, rawurl, vals)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
// 发起请求
|
||||||
|
return httpClient.Do(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostWithHeader HTTP Post请求,自定义Header
|
||||||
|
func PostWithHeader(rawurl string, vals url.Values, header http.Header) (*http.Response, error) {
|
||||||
|
req, err := newRequest(http.MethodPost, rawurl, vals)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// set header
|
||||||
|
req.Header = header
|
||||||
|
// 发起请求
|
||||||
|
return httpClient.Do(req)
|
||||||
|
}
|
||||||
|
|||||||
@@ -86,14 +86,13 @@ $ docker run -d --name eisearch \
|
|||||||
#### 文件准备
|
#### 文件准备
|
||||||
博主是一个有强迫症的人,一些文件的路径我使用了固定的路径,请大家见谅。假如你的 cdn 域名为 `st.example.com`,你需要确定这些文件已经在你的 cdn 中,它们路径分别是:
|
博主是一个有强迫症的人,一些文件的路径我使用了固定的路径,请大家见谅。假如你的 cdn 域名为 `st.example.com`,你需要确定这些文件已经在你的 cdn 中,它们路径分别是:
|
||||||
|
|
||||||
| 文件 | 地址 | 描述 |
|
| 文件 | 地址 | 描述 |
|
||||||
| ------------------ | ---------------------------------------- | ---------------------------------------- |
|
| ------------------ | -------------------------------------------- | ------------------------------------------------------------ |
|
||||||
| favicon.ico | st.example.com/static/img/favicon.ico | cdn 中的文件名为 `static/img/favicon.ico`。你也可以复制 favicon.ico 到 static 文件夹下,通过 example.com/favicon.ico 也是能够访问到。docker 用户可能需要重新打包镜像。 |
|
| favicon.ico | st.example.com/static/img/favicon.ico | cdn 中的文件名为 `static/img/favicon.ico`。你也可以复制 favicon.ico 到 static 文件夹下,通过 example.com/favicon.ico 也是能够访问到。docker 用户可能需要重新打包镜像。 |
|
||||||
| bg04.jpg | st.example.com/static/img/bg04.jpg | 首页左侧的大背景图,需要更名请到 views/st_blog.css 修改。 |
|
| bg04.jpg | st.example.com/static/img/bg04.jpg | 首页左侧的大背景图,需要更名请到 views/st_blog.css 修改。 |
|
||||||
| avatar.png | st.example.com/static/img/avatar.png | 头像 |
|
| avatar.png | st.example.com/static/img/avatar.png | 头像 |
|
||||||
| blank.gif | st.example.com/static/img/blank.gif | 空白图片,[下载](https://st.deepzz.com/static/img/blank.gif) |
|
| blank.gif | st.example.com/static/img/blank.gif | 空白图片,[下载](https://st.deepzz.com/static/img/blank.gif) |
|
||||||
| default_avatar.png | st.example.com/static/img/default_avatar.png | disqus 默认图片,[下载](https://st.deepzz.com/static/img/default_avatar.png) |
|
| default_avatar.png | st.example.com/static/img/default_avatar.png | disqus 默认图片,[下载](https://st.deepzz.com/static/img/default_avatar.png) |
|
||||||
| disqus.js | st.example.com/static/js/disqus_xxx.js | disqus 文件,你可以通过 https://short_name.disqus.com/embed.js 下载你的专属文件,并上传到七牛。更新配置文件 app.yml。 |
|
|
||||||
|
|
||||||
> 注意,cdn 提到的文件下载,请复制链接进行下载,因为博主使用了防盗链功能,还有:
|
> 注意,cdn 提到的文件下载,请复制链接进行下载,因为博主使用了防盗链功能,还有:
|
||||||
1、每次修改 app.yml 文件(如:更换 cdn 域名或更新头像),如果你不知道是否应该提高 staticversion 一个版本,那么最好提高一个 +1。
|
1、每次修改 app.yml 文件(如:更换 cdn 域名或更新头像),如果你不知道是否应该提高 staticversion 一个版本,那么最好提高一个 +1。
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ type Config struct {
|
|||||||
PostCreate string
|
PostCreate string
|
||||||
PostApprove string
|
PostApprove string
|
||||||
ThreadCreate string
|
ThreadCreate string
|
||||||
Embed string
|
|
||||||
Interval int
|
Interval int
|
||||||
}
|
}
|
||||||
Google struct { // 谷歌统计
|
Google struct { // 谷歌统计
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user