mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
chore: remove some filed in app.yml
This commit is contained in:
@@ -22,14 +22,11 @@ eiblogapp:
|
|||||||
descprefix: "Desc:" # 文章描述前缀
|
descprefix: "Desc:" # 文章描述前缀
|
||||||
identifier: <!--more--> # 截取预览标识
|
identifier: <!--more--> # 截取预览标识
|
||||||
length: 400 # 自动截取预览, 字符数
|
length: 400 # 自动截取预览, 字符数
|
||||||
trash: -48 # 回收箱保留48小时
|
|
||||||
clean: 1 # 定时清理回收箱,每 %d 小时
|
|
||||||
timezone: Asia/Shanghai # 时区
|
timezone: Asia/Shanghai # 时区
|
||||||
disqus: # 评论相关
|
disqus: # 评论相关
|
||||||
shortname: xxxxxx
|
shortname: xxxxxx
|
||||||
publickey: wdSgxRm9rdGAlLKFcFdToBe3GT4SibmV7Y8EjJQ0r4GWXeKtxpopMAeIeoI2dTEg
|
publickey: wdSgxRm9rdGAlLKFcFdToBe3GT4SibmV7Y8EjJQ0r4GWXeKtxpopMAeIeoI2dTEg
|
||||||
accesstoken: 50023908f39f4607957e909b495326af
|
accesstoken: 50023908f39f4607957e909b495326af
|
||||||
interval: 5 # 获取评论数量间隔h
|
|
||||||
google:
|
google:
|
||||||
url: https://www.google-analytics.com/collect
|
url: https://www.google-analytics.com/collect
|
||||||
tid: UA-xxxxxx-1
|
tid: UA-xxxxxx-1
|
||||||
|
|||||||
15
pkg/cache/cache.go
vendored
15
pkg/cache/cache.go
vendored
@@ -86,7 +86,8 @@ func (c *Cache) AddArticle(article *model.Article) error {
|
|||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
// store
|
// store
|
||||||
err := c.InsertArticle(context.Background(), article)
|
err := c.InsertArticle(context.Background(), article,
|
||||||
|
config.Conf.EiBlogApp.General.StartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -417,7 +418,8 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Slug: "about",
|
Slug: "about",
|
||||||
CreatedAt: time.Time{},
|
CreatedAt: time.Time{},
|
||||||
}
|
}
|
||||||
err = c.InsertArticle(context.Background(), about)
|
err = c.InsertArticle(context.Background(), about,
|
||||||
|
config.Conf.EiBlogApp.General.StartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -430,7 +432,8 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Slug: "blogroll",
|
Slug: "blogroll",
|
||||||
CreatedAt: time.Time{}.AddDate(0, 0, 7),
|
CreatedAt: time.Time{}.AddDate(0, 0, 7),
|
||||||
}
|
}
|
||||||
err = c.InsertArticle(context.Background(), blogroll)
|
err = c.InsertArticle(context.Background(), blogroll,
|
||||||
|
config.Conf.EiBlogApp.General.StartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -552,8 +555,7 @@ func (c *Cache) regeneratePages() {
|
|||||||
|
|
||||||
// timerClean 定时清理文章
|
// timerClean 定时清理文章
|
||||||
func (c *Cache) timerClean() {
|
func (c *Cache) timerClean() {
|
||||||
dur := time.Duration(config.Conf.EiBlogApp.General.Clean)
|
ticker := time.NewTicker(time.Hour)
|
||||||
ticker := time.NewTicker(dur * time.Hour)
|
|
||||||
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
err := c.CleanArticles(context.Background())
|
err := c.CleanArticles(context.Background())
|
||||||
@@ -565,8 +567,7 @@ func (c *Cache) timerClean() {
|
|||||||
|
|
||||||
// timerDisqus disqus定时操作
|
// timerDisqus disqus定时操作
|
||||||
func (c *Cache) timerDisqus() {
|
func (c *Cache) timerDisqus() {
|
||||||
dur := time.Duration(config.Conf.EiBlogApp.Disqus.Interval)
|
ticker := time.NewTicker(5 * time.Hour)
|
||||||
ticker := time.NewTicker(dur * time.Hour)
|
|
||||||
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
err := internal.PostsCount(c.ArticlesMap)
|
err := internal.PostsCount(c.ArticlesMap)
|
||||||
|
|||||||
12
pkg/cache/store/mongodb.go
vendored
12
pkg/cache/store/mongodb.go
vendored
@@ -6,7 +6,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eiblog/eiblog/pkg/config"
|
|
||||||
"github.com/eiblog/eiblog/pkg/model"
|
"github.com/eiblog/eiblog/pkg/model"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@@ -35,7 +34,7 @@ type mongodb struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init init mongodb client
|
// Init init mongodb client
|
||||||
func (db *mongodb) Init(source string) (Store, error) {
|
func (db *mongodb) Init(name, source string) (Store, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@@ -117,7 +116,7 @@ func (db *mongodb) LoadInsertAccount(ctx context.Context,
|
|||||||
|
|
||||||
collection := db.Database(mongoDBName).Collection(collectionAccount)
|
collection := db.Database(mongoDBName).Collection(collectionAccount)
|
||||||
|
|
||||||
filter := bson.M{"username": config.Conf.EiBlogApp.Account.Username}
|
filter := bson.M{"username": acct.Username}
|
||||||
result := collection.FindOne(ctx, filter)
|
result := collection.FindOne(ctx, filter)
|
||||||
err = result.Err()
|
err = result.Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -207,11 +206,11 @@ func (db *mongodb) LoadAllSerie(ctx context.Context) (model.SortedSeries, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InsertArticle 创建文章
|
// InsertArticle 创建文章
|
||||||
func (db *mongodb) InsertArticle(ctx context.Context, article *model.Article) error {
|
func (db *mongodb) InsertArticle(ctx context.Context, article *model.Article, startID int) error {
|
||||||
// 可手动分配ID或者分配ID, 占位至起始id
|
// 可手动分配ID或者分配ID, 占位至起始id
|
||||||
for article.ID == 0 {
|
for article.ID == 0 {
|
||||||
id := db.nextValue(ctx, counterNameArticle)
|
id := db.nextValue(ctx, counterNameArticle)
|
||||||
if id < config.Conf.EiBlogApp.General.StartID {
|
if id < startID {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
article.ID = id
|
article.ID = id
|
||||||
@@ -236,7 +235,8 @@ func (db *mongodb) RemoveArticle(ctx context.Context, id int) error {
|
|||||||
func (db *mongodb) CleanArticles(ctx context.Context) error {
|
func (db *mongodb) CleanArticles(ctx context.Context) error {
|
||||||
collection := db.Database(mongoDBName).Collection(collectionArticle)
|
collection := db.Database(mongoDBName).Collection(collectionArticle)
|
||||||
|
|
||||||
exp := time.Now().Add(time.Duration(config.Conf.EiBlogApp.General.Trash) * time.Hour)
|
// 超过两天自动删除
|
||||||
|
exp := time.Now().Add(-48 * time.Hour)
|
||||||
filter := bson.M{"deleted_at": bson.M{"$gt": time.Time{}, "$lt": exp}}
|
filter := bson.M{"deleted_at": bson.M{"$gt": time.Time{}, "$lt": exp}}
|
||||||
_, err := collection.DeleteMany(ctx, filter)
|
_, err := collection.DeleteMany(ctx, filter)
|
||||||
return err
|
return err
|
||||||
|
|||||||
80
pkg/cache/store/rdbms.go
vendored
Normal file
80
pkg/cache/store/rdbms.go
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
// Package store provides ...
|
||||||
|
package store
|
||||||
|
|
||||||
|
type rdbms struct{}
|
||||||
|
|
||||||
|
// // Init 数据库初始化, 建表, 加索引操作等
|
||||||
|
// func (db *rdbms) Init(source string) (Store, error) {
|
||||||
|
// gorm.
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // LoadInsertBlogger 读取或创建博客
|
||||||
|
// func (db *rdbms) LoadInsertBlogger(ctx context.Context, blogger *model.Blogger) (bool, error) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // UpdateBlogger 更新博客
|
||||||
|
// func (db *rdbms) UpdateBlogger(ctx context.Context, fields map[string]interface{}) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // LoadInsertAccount 读取或创建账户
|
||||||
|
// func (db *rdbms) LoadInsertAccount(ctx context.Context, acct *model.Account) (bool, error) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // UpdateAccount 更新账户
|
||||||
|
// func (db *rdbms) UpdateAccount(ctx context.Context, name string, fields map[string]interface{}) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // InsertSerie 创建专题
|
||||||
|
// func (db *rdbms) InsertSerie(ctx context.Context, series *model.Serie) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // RemoveSerie 删除专题
|
||||||
|
// func (db *rdbms) RemoveSerie(ctx context.Context, id int) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // UpdateSerie 更新专题
|
||||||
|
// func (db *rdbms) UpdateSerie(ctx context.Context, id int, fields map[string]interface{}) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // LoadAllSerie 读取所有专题
|
||||||
|
// func (db *rdbms) LoadAllSerie(ctx context.Context) (model.SortedSeries, error) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // InsertArticle 创建文章
|
||||||
|
// func (db *rdbms) InsertArticle(ctx context.Context, article *model.Article) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // RemoveArticle 硬删除文章
|
||||||
|
// func (db *rdbms) RemoveArticle(ctx context.Context, id int) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // CleanArticles 清理回收站文章
|
||||||
|
// func (db *rdbms) CleanArticles(ctx context.Context) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // UpdateArticle 更新文章
|
||||||
|
// func (db *rdbms) UpdateArticle(ctx context.Context, id int, fields map[string]interface{}) error {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // LoadArticle 查找文章
|
||||||
|
// func (db *rdbms) LoadArticle(ctx context.Context, id int) (*model.Article, error) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // LoadArticleList 查找文章列表
|
||||||
|
// func (db *rdbms) LoadArticleList(ctx context.Context, search SearchArticles) (model.SortedArticles, int, error) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
6
pkg/cache/store/store.go
vendored
6
pkg/cache/store/store.go
vendored
@@ -52,7 +52,7 @@ type Store interface {
|
|||||||
LoadAllSerie(ctx context.Context) (model.SortedSeries, error)
|
LoadAllSerie(ctx context.Context) (model.SortedSeries, error)
|
||||||
|
|
||||||
// InsertArticle 创建文章
|
// InsertArticle 创建文章
|
||||||
InsertArticle(ctx context.Context, article *model.Article) error
|
InsertArticle(ctx context.Context, article *model.Article, startID int) error
|
||||||
// RemoveArticle 硬删除文章
|
// RemoveArticle 硬删除文章
|
||||||
RemoveArticle(ctx context.Context, id int) error
|
RemoveArticle(ctx context.Context, id int) error
|
||||||
// CleanArticles 清理回收站文章
|
// CleanArticles 清理回收站文章
|
||||||
@@ -68,7 +68,7 @@ type Store interface {
|
|||||||
// Driver 存储驱动
|
// Driver 存储驱动
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
// Init 数据库初始化, 建表, 加索引操作等
|
// Init 数据库初始化, 建表, 加索引操作等
|
||||||
Init(source string) (Store, error)
|
Init(name, source string) (Store, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register 注册驱动
|
// Register 注册驱动
|
||||||
@@ -106,5 +106,5 @@ func NewStore(name string, source string) (Store, error) {
|
|||||||
return nil, fmt.Errorf("store: unknown driver %q (forgotten import?)", name)
|
return nil, fmt.Errorf("store: unknown driver %q (forgotten import?)", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return driver.Init(source)
|
return driver.Init(name, source)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ type General struct {
|
|||||||
DescPrefix string `yaml:"descprefix"` // 文章描述前缀
|
DescPrefix string `yaml:"descprefix"` // 文章描述前缀
|
||||||
Identifier string `yaml:"identifier"` // 文章截取标识
|
Identifier string `yaml:"identifier"` // 文章截取标识
|
||||||
Length int `yaml:"length"` // 文章预览长度
|
Length int `yaml:"length"` // 文章预览长度
|
||||||
Trash int `yaml:"trash"` // 回收箱文章保留时间
|
|
||||||
Clean int `yaml:"clean"` // 清理回收箱频率
|
|
||||||
Timezone string `yaml:"timezone"` // 时区
|
Timezone string `yaml:"timezone"` // 时区
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +54,6 @@ type Disqus struct {
|
|||||||
ShortName string `yaml:"shortname"`
|
ShortName string `yaml:"shortname"`
|
||||||
PublicKey string `yaml:"publickey"`
|
PublicKey string `yaml:"publickey"`
|
||||||
AccessToken string `yaml:"accesstoken"`
|
AccessToken string `yaml:"accesstoken"`
|
||||||
Interval int `yaml:"interval"` // 获取评论数量间隔
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twitter card
|
// Twitter card
|
||||||
|
|||||||
Reference in New Issue
Block a user