mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
fix article list error
This commit is contained in:
24
api.go
24
api.go
@@ -194,14 +194,13 @@ func apiPostAdd(c *gin.Context) {
|
||||
if tag != "" {
|
||||
tags = strings.Split(tag, ",")
|
||||
}
|
||||
t := CheckDate(date)
|
||||
serieid := CheckSerieID(serie)
|
||||
publish = CheckPublish(do)
|
||||
artc := &Article{
|
||||
Title: title,
|
||||
Content: text,
|
||||
Slug: slug,
|
||||
CreateTime: t,
|
||||
CreateTime: CheckDate(date),
|
||||
IsDraft: !publish,
|
||||
Author: Ei.Username,
|
||||
SerieID: serieid,
|
||||
@@ -222,16 +221,20 @@ func apiPostAdd(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
artc.ID = int32(cid)
|
||||
if CheckBool(c.PostForm("update")) {
|
||||
artc.UpdateTime = time.Now()
|
||||
}
|
||||
i, a := GetArticle(artc.ID)
|
||||
if a != nil {
|
||||
artc.IsDraft = false
|
||||
artc.Count = a.Count
|
||||
artc.UpdateTime = a.UpdateTime
|
||||
Ei.Articles = append(Ei.Articles[0:i], Ei.Articles[i+1:]...)
|
||||
DelFromLinkedList(a)
|
||||
ManageTagsArticle(a, false, DELETE)
|
||||
ManageSeriesArticle(a, false, DELETE)
|
||||
ManageArchivesArticle(a, false, DELETE)
|
||||
delete(Ei.MapArticles, a.Slug)
|
||||
a = nil
|
||||
}
|
||||
if update != "" {
|
||||
if CheckBool(update) {
|
||||
artc.UpdateTime = time.Now()
|
||||
}
|
||||
err = UpdateArticle(bson.M{"id": artc.ID}, artc)
|
||||
@@ -240,15 +243,6 @@ func apiPostAdd(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if !artc.IsDraft {
|
||||
if a != nil {
|
||||
Ei.Articles = append(Ei.Articles[0:i], Ei.Articles[i+1:]...)
|
||||
DelFromLinkedList(a)
|
||||
ManageTagsArticle(a, false, DELETE)
|
||||
ManageSeriesArticle(a, false, DELETE)
|
||||
ManageArchivesArticle(a, false, DELETE)
|
||||
delete(Ei.MapArticles, a.Slug)
|
||||
a = nil
|
||||
}
|
||||
Ei.MapArticles[artc.Slug] = artc
|
||||
Ei.Articles = append(Ei.Articles, artc)
|
||||
sort.Sort(Ei.Articles)
|
||||
|
||||
4
back.go
4
back.go
@@ -61,7 +61,7 @@ func HandleLoginPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if Ei.Username != user || !VerifyPasswd(Ei.Password, user, pwd) {
|
||||
logd.Print("账号或密码错误", user, pwd)
|
||||
logd.Printf("账号或密码错误 %s, %s", user, pwd)
|
||||
c.Redirect(http.StatusFound, "/admin/login")
|
||||
return
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func HandlePost(c *gin.Context) {
|
||||
h["Edit"] = artc
|
||||
}
|
||||
}
|
||||
if h["Title"] == "" {
|
||||
if h["Title"] == nil {
|
||||
h["Title"] = "撰写文章 | " + Ei.BTitle
|
||||
}
|
||||
h["Path"] = c.Request.URL.Path
|
||||
|
||||
@@ -3,7 +3,7 @@ runmode: prod
|
||||
# 回收箱保留48小时
|
||||
trash: -48
|
||||
# 定时清理回收箱,%d小时
|
||||
clean: 12
|
||||
clean: 1
|
||||
# 首页展示文章数量
|
||||
pagenum: 10
|
||||
# 管理界面
|
||||
|
||||
13
db.go
13
db.go
@@ -73,7 +73,17 @@ func init() {
|
||||
ms.Close()
|
||||
ms, c = db.Connect(DB, COLLECTION_ARTICLE)
|
||||
index = mgo.Index{
|
||||
Key: []string{"id", "slug"},
|
||||
Key: []string{"id"},
|
||||
Unique: true,
|
||||
DropDups: true,
|
||||
Background: true,
|
||||
Sparse: true,
|
||||
}
|
||||
if err := c.EnsureIndex(index); err != nil {
|
||||
logd.Fatal(err)
|
||||
}
|
||||
index = mgo.Index{
|
||||
Key: []string{"slug"},
|
||||
Unique: true,
|
||||
DropDups: true,
|
||||
Background: true,
|
||||
@@ -461,6 +471,7 @@ func AddToLinkedList(id int32) {
|
||||
artc.Prev = Ei.Articles[i-1]
|
||||
if Ei.Articles[i-1].Next != nil {
|
||||
artc.Next = Ei.Articles[i-1].Next
|
||||
Ei.Articles[i-1].Next.Prev = artc
|
||||
}
|
||||
Ei.Articles[i-1].Next = artc
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
个人邮箱</label>
|
||||
<input id="info-0-1" name="email" type="text" class="text" value="{{.Email}}" />
|
||||
<p class="description">
|
||||
用于发送告警邮件及其它通知, 建议填写, 如: example#163.com.</p>
|
||||
用于发送告警邮件及其它通知, 建议填写, 如: example@163.com.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="typecho-option">
|
||||
|
||||
Reference in New Issue
Block a user