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

Skip to content

Commit 43edab3

Browse files
committed
1. 激活前,可以修改邮箱;
2. 广告位统一处理;
1 parent b0eaca2 commit 43edab3

File tree

15 files changed

+402
-810
lines changed

15 files changed

+402
-810
lines changed

src/http/controller/index.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ type IndexController struct{}
2727

2828
// 注册路由
2929
func (self IndexController) RegisterRoute(g *echo.Group) {
30-
g.GET("/", self.NewIndex)
30+
g.GET("/", self.Index)
3131
g.GET("/wr", self.WrapUrl)
3232
g.GET("/pkgdoc", self.Pkgdoc)
3333
g.GET("/markdown", self.Markdown)
3434
}
3535

36-
func (IndexController) NewIndex(ctx echo.Context) error {
36+
func (IndexController) Index(ctx echo.Context) error {
3737
if len(logic.WebsiteSetting.IndexNavs) == 0 {
38-
return render(ctx, "new_index.html", nil)
38+
return render(ctx, "index.html", nil)
3939
}
4040

4141
tab := ctx.QueryParam("tab")
@@ -51,11 +51,11 @@ func (IndexController) NewIndex(ctx echo.Context) error {
5151
SetCookie(ctx, "INDEX_TAB", data["tab"].(string))
5252
data["all_nodes"] = logic.GenNodes()
5353

54-
return render(ctx, "new_index.html", data)
54+
return render(ctx, "index.html", data)
5555
}
5656

5757
// Index 首页
58-
func (IndexController) Index(ctx echo.Context) error {
58+
func (IndexController) OldIndex(ctx echo.Context) error {
5959
num := 10
6060
paginator := logic.NewPaginatorWithPerPage(1, num)
6161
topicsList := make([]map[string]interface{}, num)

src/http/middleware/login.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func NeedLogin() echo.MiddlewareFunc {
7575
if !ok || user.Status != model.UserStatusAudit {
7676
method := ctx.Request().Method()
7777
if util.IsAjax(ctx) {
78-
return ctx.JSON(http.StatusForbidden, `{"ok":0,"error":"403 Forbidden"}`)
78+
if !strings.HasPrefix(ctx.Path(), "/account") {
79+
return ctx.JSON(http.StatusForbidden, `{"ok":0,"error":"403 Forbidden"}`)
80+
}
7981
} else {
8082
if method == "POST" {
8183
return ctx.HTML(http.StatusForbidden, `403 Forbidden`)

src/logic/ad.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (AdLogic) FindAll(ctx context.Context, path string) map[string]*model.Adver
2323
objLog := GetLogger(ctx)
2424

2525
pageAds := make([]*model.PageAd, 0)
26-
err := MasterDB.Where("path=? AND is_online=1", path).Find(&pageAds)
26+
err := MasterDB.Where("(path=? OR path=?) AND is_online=1", path, "*").Find(&pageAds)
2727
if err != nil {
2828
objLog.Errorln("AdLogic FindAll PageAd error:", err)
2929
return nil

src/logic/user.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"math/rand"
1313
"model"
1414
"net/url"
15+
"strings"
1516
"time"
1617
"util"
1718

@@ -114,7 +115,12 @@ func (self UserLogic) Update(ctx context.Context, me *model.Me, form url.Values)
114115
_, err = MasterDB.Id(me.Uid).Cols(cols).Update(user)
115116
if err != nil {
116117
objLog.Errorf("更新用户 【%d】 信息失败:%s", me.Uid, err)
117-
errMsg = "对不起,服务器内部错误,请稍后再试!"
118+
if strings.Contains(err.Error(), "Error 1062: Duplicate entry") {
119+
// TODO:被恶意注册?
120+
errMsg = "该邮箱地址被其他账号注册了"
121+
} else {
122+
errMsg = "对不起,服务器内部错误,请稍后再试!"
123+
}
118124
return
119125
}
120126

template/articles/detail.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ <h1 id="title" data-id="{{.article.Id}}">
316316
{{end}}
317317
{{end}}
318318

319+
{{if .pos_ad.right2}}
320+
{{if eq .pos_ad.right2.AdType 1}}
321+
{{noescape .pos_ad.right2.Code}}
322+
{{end}}
323+
{{end}}
324+
319325
<script>
320326
var baiduImagePlus = {
321327
noLogo:true,

template/articles/list.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
100100

101101
{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"一周阅读排行","objtype":1,"limit":10,"rank_type":"week"}`)}}
102102

103+
{{if .pos_ad.right2}}
104+
<div class="box_white sidebar" id="ad-right2">
105+
{{if eq .pos_ad.right2.AdType 0}}
106+
{{noescape .pos_ad.right2.Code}}
107+
{{end}}
108+
</div>
109+
{{end}}
110+
103111
</div>
104112

105113
</div>

template/common/my_info.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,12 @@ <h3 class="title"><i class="glyphicon glyphicon-user"></i> 用户登录</h3>
107107
</div>
108108
</div>
109109
</div>
110+
{{end}}
111+
112+
{{if and .pos_ad.below_me (not .pos_ad.right1)}}
113+
<div class="box_white sidebar" id="ad-below_me">
114+
{{if eq .pos_ad.below_me.AdType 0}}
115+
{{noescape .pos_ad.below_me.Code}}
116+
{{end}}
117+
</div>
110118
{{end}}

0 commit comments

Comments
 (0)