Compare commits

..

11 Commits

Author SHA1 Message Date
henry.chen
7c938bf024 chore(release): 2.2.10 2023-12-22 14:12:15 +08:00
henry.chen
65fcc69efa chore: bump all gorm & driver version 2023-12-22 14:10:36 +08:00
henry.chen
d06bab72a5 chore: bump gin swagger version to v1.6.0 2023-12-22 14:03:57 +08:00
henry.chen
95900eec1a chore: rm http header: Expect-CT 2023-12-07 09:55:30 +08:00
henry.chen
dfae78891d chore: update ad config 2023-12-01 13:46:29 +08:00
henry.chen
c515e33e2c chore(release): 2.2.9 2023-09-25 18:14:51 +08:00
henry.chen
5b12dd625b chore: update config 2023-09-25 18:14:41 +08:00
henry.chen
9b918caccd fix: google analytics not work, supported ga4 measurement protocol 2023-09-25 18:12:57 +08:00
Deepzz
2be53379e1 Update writing.md 2023-09-13 10:49:51 +08:00
Deepzz
944e27c58a Update app.yml 2023-09-13 10:45:56 +08:00
Deepzz
92baf970bc Update docker-compose.yml 2023-07-12 17:33:18 +08:00
12 changed files with 2804 additions and 160 deletions

View File

@@ -2,6 +2,15 @@
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. 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.
### [2.2.10](https://github.com/eiblog/eiblog/compare/v2.2.9...v2.2.10) (2023-12-22)
### [2.2.9](https://github.com/eiblog/eiblog/compare/v2.2.8...v2.2.9) (2023-09-25)
### Bug Fixes
* google analytics not work, supported ga4 measurement protocol ([9b918ca](https://github.com/eiblog/eiblog/commit/9b918caccd9fd7faff7d253693e075ccd0150c17))
### [2.2.8](https://github.com/eiblog/eiblog/compare/v2.2.7...v2.2.8) (2023-07-12) ### [2.2.8](https://github.com/eiblog/eiblog/compare/v2.2.7...v2.2.8) (2023-07-12)

View File

@@ -2,7 +2,7 @@ appname: eiblog
database: database:
driver: sqlite driver: sqlite
source: ./db.sqlite source: ./db.sqlite
eshost: eshost: # http://elasticsearch:9200
eiblogapp: eiblogapp:
mode: mode:
name: cmd-eiblog name: cmd-eiblog
@@ -28,11 +28,10 @@ eiblogapp:
publickey: wdSgxRm9rdGAlLKFcFdToBe3GT4SibmV7Y8EjJQ0r4GWXeKtxpopMAeIeoI2dTEg publickey: wdSgxRm9rdGAlLKFcFdToBe3GT4SibmV7Y8EjJQ0r4GWXeKtxpopMAeIeoI2dTEg
accesstoken: 50023908f39f4607957e909b495326af accesstoken: 50023908f39f4607957e909b495326af
google: # 谷歌分析 google: # 谷歌分析
url: https://www.google-analytics.com/collect url: https://www.google-analytics.com/g/collect
tid: UA-xxxxxx-1 tid: G-xxxxxxxxxx
v: "1" v: "2"
t: pageview adsense: <script async src="https://pagead2.googlesyndication.com/xxx" crossorigin="anonymous"></script>
adsense: <script data-ad-client="ca-pub-5384494508691406" async src=""></script>
qiniu: # 七牛OSS qiniu: # 七牛OSS
bucket: eiblog bucket: eiblog
domain: st.deepzz.com domain: st.deepzz.com

View File

@@ -27,6 +27,7 @@ services:
restart: always restart: always
backup: backup:
image: deepzz0/backup:latest image: deepzz0/backup:latest
#command: ./backend --restore true
volumes: volumes:
- ${PWD}/conf:/app/conf - ${PWD}/conf:/app/conf
links: links:

View File

@@ -34,7 +34,7 @@
![article-description](./img/article-description.png) ![article-description](./img/article-description.png)
### 图片懒加载 ### 图片懒加载
博客系统提供图片懒加载功能浏览到某个位置图片才会加载以此来提高页面加载速度。我们可根据需要是否使用。当然由此带来的坏处就是rss不能够正确加载图片。后续看是否解决这个问题或朋友提PR。 博客系统提供图片懒加载功能(浏览到某个位置,图片才会加载),以此来提高页面加载速度。我们可根据需要是否使用。~~当然由此带来的坏处就是rss不能够正确加载图片。后续看是否解决这个问题或朋友提PR。~~,已解决。
首先看下图片的`markdown`标准写法: 首先看下图片的`markdown`标准写法:
``` ```

View File

@@ -78,9 +78,6 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location ^~ /admin/ { location ^~ /admin/ {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
# https://imququ.com/post/web-security-and-response-header.html#toc-1
# 期望CT: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT
add_header Expect-CT "max-age=180";
add_header Cache-Control no-cache; add_header Cache-Control no-cache;
add_header X-Frame-Options SAMEORIGIN; add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
@@ -93,9 +90,6 @@ server {
location / { location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
# https://imququ.com/post/web-security-and-response-header.html#toc-1
# 期望CT: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT
add_header Expect-CT "max-age=180";
add_header Cache-Control no-cache; add_header Cache-Control no-cache;
# 内容安全策略: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP # 内容安全策略: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https:; media-src https:; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self'; frame-src https://disqus.com"; add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https:; media-src https:; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self'; frame-src https://disqus.com";

21
go.mod
View File

@@ -4,20 +4,21 @@ go 1.15
require ( require (
github.com/eiblog/blackfriday v0.0.0-20161010144836-c0ec111761ae github.com/eiblog/blackfriday v0.0.0-20161010144836-c0ec111761ae
github.com/gin-contrib/sessions v0.0.3 github.com/gin-contrib/sessions v0.0.5
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1
github.com/lib/pq v1.10.1 github.com/lib/pq v1.10.9
github.com/qiniu/go-sdk/v7 v7.11.0 github.com/qiniu/go-sdk/v7 v7.11.0
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.2 github.com/sirupsen/logrus v1.9.3
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.3.3 github.com/swaggo/gin-swagger v1.3.3
github.com/swaggo/swag v1.7.4 github.com/swaggo/swag v1.7.4
go.mongodb.org/mongo-driver v1.5.1 go.mongodb.org/mongo-driver v1.11.4
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/clickhouse v0.1.0 gorm.io/driver/clickhouse v0.6.0
gorm.io/driver/mysql v1.0.6 gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.0.8 gorm.io/driver/postgres v1.5.4
gorm.io/driver/sqlite v1.1.4 gorm.io/driver/sqlite v1.5.4
gorm.io/driver/sqlserver v1.0.7 gorm.io/driver/sqlserver v1.5.2
gorm.io/gorm v1.21.9 gorm.io/gorm v1.25.5
) )

2885
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -69,7 +69,6 @@ type Google struct {
URL string `yaml:"url"` URL string `yaml:"url"`
Tid string `yaml:"tid"` Tid string `yaml:"tid"`
V string `yaml:"v"` V string `yaml:"v"`
T string `yaml:"t"`
AdSense string `yaml:"adsense"` AdSense string `yaml:"adsense"`
} }

View File

@@ -5,8 +5,8 @@ import (
_ "github.com/eiblog/eiblog/pkg/core/backup/docs" // docs _ "github.com/eiblog/eiblog/pkg/core/backup/docs" // docs
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
) )
// RegisterRoutes register routes // RegisterRoutes register routes

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
htemplate "html/template" htemplate "html/template"
"io/ioutil" "io/ioutil"
"math/rand"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@@ -335,27 +336,34 @@ func handleDisqusCreate(c *gin.Context) {
} }
// handleBeaconPage 服务端推送谷歌统计 // handleBeaconPage 服务端推送谷歌统计
// https://www.thyngster.com/ga4-measurement-protocol-cheatsheet/
func handleBeaconPage(c *gin.Context) { func handleBeaconPage(c *gin.Context) {
ua := c.Request.UserAgent() ua := c.Request.UserAgent()
vals := c.Request.URL.Query() vals := c.Request.URL.Query()
vals.Set("v", config.Conf.EiBlogApp.Google.V) vals.Set("v", config.Conf.EiBlogApp.Google.V)
vals.Set("tid", config.Conf.EiBlogApp.Google.Tid) vals.Set("tid", config.Conf.EiBlogApp.Google.Tid)
vals.Set("t", config.Conf.EiBlogApp.Google.T)
cookie, _ := c.Cookie("u") cookie, _ := c.Cookie("u")
vals.Set("cid", cookie) vals.Set("cid", cookie)
vals.Set("dl", c.Request.Referer()) vals.Set("dl", c.Request.Referer()) // document location
vals.Set("uip", c.ClientIP()) vals.Set("en", "page_view") // event name
vals.Set("sct", "1") // Session Count
vals.Set("seg", "1") // Session Engagment
vals.Set("_uip", c.ClientIP()) // user ip
vals.Set("_p", fmt.Sprint(201226219+rand.Intn(499999999))) // random page load hash
vals.Set("_ee", "1") // external event
go func() { go func() {
req, err := http.NewRequest("POST", config.Conf.EiBlogApp.Google.URL, url := config.Conf.EiBlogApp.Google.URL + "?" + vals.Encode()
strings.NewReader(vals.Encode())) req, err := http.NewRequest("POST", url, nil)
if err != nil { if err != nil {
logrus.Error("HandleBeaconPage.NewRequest: ", err) logrus.Error("HandleBeaconPage.NewRequest: ", err)
return return
} }
req.Header.Set("User-Agent", ua) req.Header.Set("User-Agent", ua)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") req.Header.Set("Sec-Ch-Ua", c.GetHeader("Sec-Ch-Ua"))
req.Header.Set("Sec-Ch-Ua-Platform", c.GetHeader("Sec-Ch-Ua-Platform"))
req.Header.Set("Sec-Ch-Ua-Mobile", c.GetHeader("Sec-Ch-Ua-Mobile"))
res, err := http.DefaultClient.Do(req) res, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
logrus.Error("HandleBeaconPage.Do: ", err) logrus.Error("HandleBeaconPage.Do: ", err)

View File

@@ -5,8 +5,8 @@ import (
_ "github.com/eiblog/eiblog/pkg/core/eiblog/docs" // docs _ "github.com/eiblog/eiblog/pkg/core/eiblog/docs" // docs
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
) )
// RegisterRoutes register routes // RegisterRoutes register routes

View File

@@ -1,3 +1,3 @@
{{define "ana_js"}} {{define "ana_js"}}
!function(e,n,o){var t=e.screen,a=encodeURIComponent,r=["dt="+a(n.title),"dr="+a(n.referrer),"ul="+(o.language||o.browserLanguage),"sd="+t.colorDepth+"-bit","sr="+t.width+"x"+t.height,"_="+ +new Date],i="?"+r.join("&");e.__beacon_img=new Image,e.__beacon_img.src="/beacon.html"+i}(window,document,navigator,location); !function(e,n,o){var t=e.screen,a=encodeURIComponent,r=["dt="+a(n.title),"dr="+a(n.referrer),"ul="+(o.language||o.browserLanguage).toLowerCase(),"sd="+t.colorDepth+"-bit","sr="+t.width+"x"+t.height,"_="+ +new Date],i="?"+r.join("&");e.__beacon_img=new Image,e.__beacon_img.src="/beacon.html"+i}(window,document,navigator,location);
{{end}} {{end}}