Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea59abc

Browse files
committed
文章处理优化
1 parent 836b72e commit ea59abc

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

config/db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ CREATE TABLE IF NOT EXISTS `user_info` (
153153
`city` varchar(10) NOT NULL DEFAULT '' COMMENT '居住地',
154154
`company` varchar(63) NOT NULL DEFAULT '' COMMENT '公司',
155155
`github` varchar(31) NOT NULL DEFAULT '' COMMENT 'Github昵称',
156+
`gitea` varchar(31) NOT NULL DEFAULT '' COMMENT 'Gitea昵称',
156157
`weibo` varchar(31) NOT NULL DEFAULT '' COMMENT '微博昵称',
157158
`website` varchar(63) NOT NULL DEFAULT '' COMMENT '个人主页,博客',
158159
`monlog` varchar(140) NOT NULL DEFAULT '' COMMENT '个人状态,签名,独白',

logic/article.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,18 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
9494
return nil, err
9595
}
9696

97-
author, authorTxt := "", ""
97+
author := ""
9898
if rule.InUrl {
9999
index, err := strconv.Atoi(rule.Author)
100100
if err != nil {
101101
logger.Errorln("author rule is illegal:", rule.Author, "error:", err)
102102
return nil, err
103103
}
104104
author = urlPaths[index]
105-
authorTxt = author
106105
} else {
107-
if strings.HasPrefix(rule.Author, ".") || strings.HasPrefix(rule.Author, "#") {
108-
authorSelection := doc.Find(rule.Author)
109-
author, err = authorSelection.Html()
110-
if err != nil {
111-
logger.Errorln("goquery parse author error:", err)
112-
return nil, err
113-
}
114-
115-
author = strings.TrimSpace(author)
116-
authorTxt = strings.TrimSpace(authorSelection.Text())
106+
authorSelection := doc.Find(rule.Author)
107+
if authorSelection.Is(rule.Author) {
108+
author = strings.TrimSpace(authorSelection.Text())
117109
} else if strings.HasPrefix(rule.Author, "/") {
118110
// 正则表达式
119111
re, err := regexp.Compile(rule.Author[1:])
@@ -129,11 +121,9 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
129121
}
130122

131123
author = authorResult[1]
132-
authorTxt = author
133124
} else {
134125
// 某些个人博客,页面中没有作者的信息,因此,规则中 author 即为 作者
135126
author = rule.Author
136-
authorTxt = rule.Author
137127
}
138128
}
139129

@@ -222,7 +212,7 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
222212
Domain: domain,
223213
Name: rule.Name,
224214
Author: author,
225-
AuthorTxt: authorTxt,
215+
AuthorTxt: author,
226216
Title: title,
227217
Content: content,
228218
Txt: txt,
@@ -870,7 +860,7 @@ func (self ArticleLogic) setImgSrc(ctx context.Context, v string, imgDeny bool,
870860
if strings.HasPrefix(v, "//") {
871861
v = "https:" + v
872862
} else if !strings.HasPrefix(v, "http") {
873-
v = "http://" + domain + "/" + v
863+
v = "http://" + domain + v
874864
}
875865
path, err := DefaultUploader.TransferUrl(ctx, v)
876866
if err == nil {

template/common/my_info.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ <h3 class="title"><i class="glyphicon glyphicon-user"></i> 用户登录</h3>
9595
</div>
9696
<input class="btn btn-block btn-success btn-sm" data-disable-with="正在登录" name="commit" type="submit" value="登录" />
9797
<div class="sidebar-login-tip">
98-
<div>没有账号?<a href="">注册</a></div>
99-
<div><a href="">忘记密码?</a></div>
98+
<div>没有账号?<a href="/account/register">注册</a></div>
99+
<div><a href="/account/forgetpwd">忘记密码?</a></div>
100100
</div>
101101
<div class="sep10"></div>
102102
<div class="cut-line">

0 commit comments

Comments
 (0)