mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
chore: update html
This commit is contained in:
6
pkg/cache/cache.go
vendored
6
pkg/cache/cache.go
vendored
@@ -234,8 +234,8 @@ func (c *Cache) rebuildArticle(article *model.Article, needSort bool) {
|
||||
}
|
||||
}
|
||||
// series
|
||||
for i, series := range c.Series {
|
||||
if series.ID == article.SeriesID {
|
||||
for i, serie := range c.Series {
|
||||
if serie.ID == article.SerieID {
|
||||
c.Series[i].Articles = append(c.Series[i].Articles, article)
|
||||
if needSort {
|
||||
sort.Sort(c.Series[i].Articles)
|
||||
@@ -291,7 +291,7 @@ func (c *Cache) regeneratePages() {
|
||||
case pageArchive:
|
||||
sort.Sort(c.Archives)
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(c.Blogger.ArchiveSay + "\n")
|
||||
buf.WriteString(c.Blogger.ArchivesSay + "\n")
|
||||
var (
|
||||
currentYear string
|
||||
gt12Month = len(Ei.Archives) > 12
|
||||
|
||||
34
pkg/cache/store/mongodb.go
vendored
34
pkg/cache/store/mongodb.go
vendored
@@ -25,7 +25,7 @@ const (
|
||||
collectionArticle = "article"
|
||||
collectionBlogger = "blogger"
|
||||
collectionCounter = "counter"
|
||||
collectionSeries = "series"
|
||||
collectionSerie = "serie"
|
||||
|
||||
counterNameSerie = "serie"
|
||||
counterNameArticle = "article"
|
||||
@@ -69,7 +69,7 @@ func (db *mongodb) Init(source string) (Store, error) {
|
||||
Keys: bson.D{bson.E{Key: "slug", Value: 1}},
|
||||
Options: options.Index().SetUnique(true).SetSparse(true),
|
||||
}
|
||||
db.Database(mongoDBName).Collection(collectionSeries).
|
||||
db.Database(mongoDBName).Collection(collectionSerie).
|
||||
Indexes().
|
||||
CreateOne(context.Background(), indexModel)
|
||||
return db, nil
|
||||
@@ -149,29 +149,29 @@ func (db *mongodb) UpdateAccount(ctx context.Context, name string,
|
||||
return err
|
||||
}
|
||||
|
||||
// InsertSeries 创建专题
|
||||
func (db *mongodb) InsertSeries(ctx context.Context, series *model.Series) error {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSeries)
|
||||
// InsertSerie 创建专题
|
||||
func (db *mongodb) InsertSerie(ctx context.Context, serie *model.Serie) error {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSerie)
|
||||
|
||||
series.ID = db.nextValue(ctx, counterNameSerie)
|
||||
_, err := collection.InsertOne(ctx, series)
|
||||
serie.ID = db.nextValue(ctx, counterNameSerie)
|
||||
_, err := collection.InsertOne(ctx, serie)
|
||||
return err
|
||||
}
|
||||
|
||||
// RemoveSeries 删除专题
|
||||
func (db *mongodb) RemoveSeries(ctx context.Context, id int) error {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSeries)
|
||||
// RemoveSerie 删除专题
|
||||
func (db *mongodb) RemoveSerie(ctx context.Context, id int) error {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSerie)
|
||||
|
||||
filter := bson.M{"id": id}
|
||||
_, err := collection.DeleteOne(ctx, filter)
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateSeries 更新专题
|
||||
func (db *mongodb) UpdateSeries(ctx context.Context, id int,
|
||||
// UpdateSerie 更新专题
|
||||
func (db *mongodb) UpdateSerie(ctx context.Context, id int,
|
||||
fields map[string]interface{}) error {
|
||||
|
||||
collection := db.Database(mongoDBName).Collection(collectionSeries)
|
||||
collection := db.Database(mongoDBName).Collection(collectionSerie)
|
||||
|
||||
filter := bson.M{"id": id}
|
||||
params := bson.M{}
|
||||
@@ -183,9 +183,9 @@ func (db *mongodb) UpdateSeries(ctx context.Context, id int,
|
||||
return err
|
||||
}
|
||||
|
||||
// LoadAllSeries 查询所有专题
|
||||
func (db *mongodb) LoadAllSeries(ctx context.Context) (model.SortedSeries, error) {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSeries)
|
||||
// LoadAllSerie 查询所有专题
|
||||
func (db *mongodb) LoadAllSerie(ctx context.Context) (model.SortedSeries, error) {
|
||||
collection := db.Database(mongoDBName).Collection(collectionSerie)
|
||||
|
||||
filter := bson.M{}
|
||||
cur, err := collection.Find(ctx, filter)
|
||||
@@ -196,7 +196,7 @@ func (db *mongodb) LoadAllSeries(ctx context.Context) (model.SortedSeries, error
|
||||
|
||||
var series model.SortedSeries
|
||||
for cur.Next(ctx) {
|
||||
obj := model.Series{}
|
||||
obj := model.Serie{}
|
||||
err = cur.Decode(&obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
16
pkg/cache/store/store.go
vendored
16
pkg/cache/store/store.go
vendored
@@ -27,14 +27,14 @@ type Store interface {
|
||||
// UpdateAccount 更新账户
|
||||
UpdateAccount(ctx context.Context, name string, fields map[string]interface{}) error
|
||||
|
||||
// InsertSeries 创建专题
|
||||
InsertSeries(ctx context.Context, series *model.Series) error
|
||||
// RemoveSeries 删除专题
|
||||
RemoveSeries(ctx context.Context, id int) error
|
||||
// UpdateSeries 更新专题
|
||||
UpdateSeries(ctx context.Context, id int, fields map[string]interface{}) error
|
||||
// LoadAllSeries 读取所有专题
|
||||
LoadAllSeries(ctx context.Context) (model.SortedSeries, error)
|
||||
// InsertSerie 创建专题
|
||||
InsertSerie(ctx context.Context, series *model.Serie) error
|
||||
// RemoveSerie 删除专题
|
||||
RemoveSerie(ctx context.Context, id int) error
|
||||
// UpdateSerie 更新专题
|
||||
UpdateSerie(ctx context.Context, id int, fields map[string]interface{}) error
|
||||
// LoadAllSerie 读取所有专题
|
||||
LoadAllSerie(ctx context.Context) (model.SortedSeries, error)
|
||||
|
||||
// InsertArticle 创建文章
|
||||
InsertArticle(ctx context.Context, article *model.Article) error
|
||||
|
||||
@@ -101,9 +101,9 @@ func handleArticlePage(c *gin.Context) {
|
||||
} else {
|
||||
params["Days"] = int(time.Now().Sub(article.CreatedAt).Hours()) / 24
|
||||
}
|
||||
if article.SeriesID > 0 {
|
||||
if article.SerieID > 0 {
|
||||
for _, series := range cache.Ei.Series {
|
||||
if series.ID == article.SeriesID {
|
||||
if series.ID == article.SerieID {
|
||||
params["Serie"] = series
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ import "time"
|
||||
|
||||
// Article 文章
|
||||
type Article struct {
|
||||
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
|
||||
Author string `gorm:"column:author;not null" bson:"author"` // 作者名
|
||||
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 文章缩略名
|
||||
Title string `gorm:"column:title;not null" bson:"title"` // 标题
|
||||
Count int `gorm:"column:count;not null" bson:"count"` // 评论数量
|
||||
Content string `gorm:"column:content;not null" bson:"content"` // markdown内容
|
||||
SeriesID int `gorm:"column:series_id;not null" bson:"series_id"` // 专题ID
|
||||
Tags string `gorm:"column:tags;not null" bson:"tags"` // tag,以逗号隔开
|
||||
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
|
||||
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
|
||||
Author string `gorm:"column:author;not null" bson:"author"` // 作者名
|
||||
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 文章缩略名
|
||||
Title string `gorm:"column:title;not null" bson:"title"` // 标题
|
||||
Count int `gorm:"column:count;not null" bson:"count"` // 评论数量
|
||||
Content string `gorm:"column:content;not null" bson:"content"` // markdown内容
|
||||
SerieID int `gorm:"column:serie_id;not null" bson:"serie_id"` // 专题ID
|
||||
Tags string `gorm:"column:tags;not null" bson:"tags"` // tag,以逗号隔开
|
||||
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
|
||||
|
||||
DeletedAt time.Time `gorm:"column:deleted_at;default:null" bson:"deleted_at"` // 删除时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:now()" bson:"updated_at"` // 更新时间
|
||||
|
||||
@@ -9,6 +9,6 @@ type Blogger struct {
|
||||
BTitle string `gorm:"column:b_title;not null" bson:"b_title"` // 底部title
|
||||
Copyright string `gorm:"column:copyright;not null" bson:"copyright"` // 版权声明
|
||||
|
||||
SeriesSay string `gorm:"column:series_say;not null" bson:"series_say"` // 专题说明
|
||||
ArchiveSay string `gorm:"column:archive_say;not null" bson:"archive_say"` // 归档说明
|
||||
SeriesSay string `gorm:"column:series_say;not null" bson:"series_say"` // 专题说明
|
||||
ArchivesSay string `gorm:"column:archives_say;not null" bson:"archives_say"` // 归档说明
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Series 专题
|
||||
type Series struct {
|
||||
// Serie 专题
|
||||
type Serie struct {
|
||||
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
|
||||
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 缩略名
|
||||
Name string `gorm:"column:name;not null" bson:"name"` // 专题名
|
||||
@@ -15,7 +15,7 @@ type Series struct {
|
||||
}
|
||||
|
||||
// SortedSeries 排序后专题
|
||||
type SortedSeries []*Series
|
||||
type SortedSeries []*Serie
|
||||
|
||||
// Len 长度
|
||||
func (s SortedSeries) Len() int { return len(s) }
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
<td><a href="/admin/write-post?cid={{.ID}}">{{.Title}}</a></td>
|
||||
<td>{{.Author}}</td>
|
||||
<td>{{if gt .SerieID 0}}专题ID:{{.SerieID}}{{else}}--{{end}}</td>
|
||||
<td>{{dateformat .CreateTime "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .UpdateTime "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .CreatedAt "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .UpdatedAt "2006/01/02 15:04"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<section class="typecho-post-option" role="application">
|
||||
<label for="date" class="typecho-label">发布日期</label>
|
||||
<p>
|
||||
<input class="typecho-date w-100" type="text" name="date" id="date" {{with .Edit}}value="{{dateformat .CreateTime "2006-01-02 15:04"}}"{{end}} />
|
||||
<input class="typecho-date w-100" type="text" name="date" id="date" {{with .Edit}}value="{{dateformat .CreatedAt "2006-01-02 15:04"}}"{{end}} />
|
||||
</p>
|
||||
</section>
|
||||
<section class="typecho-post-option category-option">
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
</td>
|
||||
<td>{{.Author}}</td>
|
||||
<td>{{if gt .SerieID 0}}专题ID:{{.SerieID}}{{else}}--{{end}}</td>
|
||||
<td>{{dateformat .CreateTime "06/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .UpdateTime "06/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .CreatedAt "06/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .UpdatedAt "06/01/02 15:04"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</p>
|
||||
<h2>{{.BlogName}}</h2>
|
||||
<p>{{.SubTitle}}</p>
|
||||
<p>最后登录: {{dateformat .LoginTime "2006/01/02 15:04"}}</p>
|
||||
<p>最后登录: {{dateformat .LoginAt "2006/01/02 15:04"}}</p>
|
||||
</div>
|
||||
<div class="col-mb-12 col-tb-6 col-tb-offset-1 typecho-content-panel" role="form">
|
||||
<section>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<a href="/admin/add-serie?mid={{.ID}}">{{.Name}}</a>
|
||||
<a target="_blank" href="/series.html#toc-{{.ID}}" title="浏览 {{.Name}}"><i class="i-exlink"></i></a>
|
||||
</td>
|
||||
<td>{{dateformat .CreateTime "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .CreatedAt "2006/01/02 15:04"}}</td>
|
||||
<td><a class="balloon-button left size-50" href="#">{{len .Articles}}</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
<td>{{.Title}}</td>
|
||||
<td>{{.Author}}</td>
|
||||
<td>{{if gt .SerieID 0}}专题ID:{{.SerieID}}{{else}}--{{end}}</td>
|
||||
<td>{{dateformat .CreateTime "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .DeleteTime "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .CreatedAt "2006/01/02 15:04"}}</td>
|
||||
<td>{{dateformat .DeletedAt "2006/01/02 15:04"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user