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

Skip to content

Commit b34118b

Browse files
committed
做必要的判断&tag加头像
1 parent 8a8d393 commit b34118b

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

config/db.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ CREATE TABLE IF NOT EXISTS `articles` (
310310
PRIMARY KEY (`id`),
311311
UNIQUE KEY (`url`),
312312
KEY (`top`),
313-
KEY (`author_txt`),
314313
KEY (`domain`),
315314
KEY (`ctime`)
316315
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '网络文章聚合表';

src/http/controller/index.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func (self IndexController) RegisterRoute(g *echo.Group) {
3333
}
3434

3535
func (IndexController) NewIndex(ctx echo.Context) error {
36+
if len(logic.WebsiteSetting.IndexNavs) == 0 {
37+
return render(ctx, "new_index.html", nil)
38+
}
39+
3640
tab := ctx.QueryParam("tab")
3741
if tab == "" {
3842
tab = GetFromCookie(ctx, "INDEX_TAB")

template/feed/tag.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<a href="/user/{{$user.Username}}"><img src="{{gravatar $user.Avatar $user.Email 48 $.is_https}}" class="avatar"></a>
2424
{{else}}
2525
<a href="javascript:">
26-
<img src="https://secure.gravatar.com/avatar/3bf6178897766ebadaa830073e87374d?s=48">
26+
<img class="noavatar" alt="" src="https://secure.gravatar.com/avatar/3bf6178897766ebadaa830073e87374d?s=48" data-objid="{{.Objid}}" data-objtype="{{.Objtype}}" data-author="{{.Author}}">
2727
</a>
2828
{{end}}
2929
</td>
@@ -92,10 +92,24 @@
9292
</div>
9393
{{end}}
9494
{{define "js"}}
95+
<script type="text/javascript" src="/static/js/libs/identicon.js"></script>
9596
<script type="text/javascript">
9697
// 需要加载的侧边栏
9798
SG.SIDE_BARS = [
9899
"/comments/recent",
99100
];
101+
102+
$(function() {
103+
$('.noavatar').each(function() {
104+
var objid = $(this).data('objid'),
105+
objtype = $(this).data('objtype'),
106+
author = $(this).data('author');
107+
// var hash = md5(objid+"-"+objtype);
108+
var hash = md5(author+"");
109+
var data = new Identicon(hash, {format: 'svg', size: 48}).toString();
110+
var imgData = 'data:image/svg+xml;base64,' + data;
111+
$(this).attr('src', imgData);
112+
});
113+
});
100114
</script>
101115
{{end}}

template/new_index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
objtype = $(this).data('objtype'),
318318
author = $(this).data('author');
319319
// var hash = md5(objid+"-"+objtype);
320-
var hash = md5(author);
320+
var hash = md5(author+"");
321321
var data = new Identicon(hash, {format: 'svg', size: 48}).toString();
322322
var imgData = 'data:image/svg+xml;base64,' + data;
323323
$(this).attr('src', imgData);

0 commit comments

Comments
 (0)