Skip to content

Commit

Permalink
使用 dnspod 来获取 favicon,提高用户体验(替换掉 google 的)
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Dec 14, 2015
1 parent 536e467 commit 526dcef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"html/template"
"strings"
"time"

"github.com/gorilla/sessions"
Expand Down Expand Up @@ -410,6 +411,10 @@ type Site struct {
CategoryId bson.ObjectId
}

func (s *Site) TrimUrlHttpPrefix() string {
return strings.TrimPrefix(s.Url, "http://")
}

// 文章分类
type ArticleCategory struct {
Id_ bson.ObjectId `bson:"_id"`
Expand Down
2 changes: 1 addition & 1 deletion templates/site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4><small>{{.Name}}</small></h4>
<dl class="site">
{{range $sites}}
<dt id="site-{{.Id_.Hex}}">
<img src="https://plus.google.com/_/favicon?domain={{.Url}}"><a href="{{.Url}}" target="_blank">{{.Title}}</a>
<img src="http://statics.dnspod.cn/proxy_favicon/_/favicon?domain={{.TrimUrlHttpPrefix}}"><a href="{{.Url}}" target="_blank">{{.Title}}</a>
{{if $.username}}
{{if .CanEdit $.username $.db}}
<a class="btn btn-xs btn-info pull-right" href="/site/{{.Id_.Hex}}/edit" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
Expand Down

0 comments on commit 526dcef

Please sign in to comment.