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

Skip to content

Commit e4ff191

Browse files
committed
add ad
1 parent d07146c commit e4ff191

File tree

7 files changed

+94
-6
lines changed

7 files changed

+94
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ welcome.png
5151
/env.ini
5252
ssl
5353
bin
54+
55+
*.code-workspace

cmd/studygolang/graceful_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows && !plan9
12
// +build !windows,!plan9
23

34
package main

http/controller/install_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// http://studygolang.com
55
// Author: polaris [email protected]
66

7+
//go:build !windows && !plan9
78
// +build !windows,!plan9
89

910
package controller

template/articles/list.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<li><a href="/">首页</a></li>
88
<li class="active">文章</li>
99
</ol>
10-
{{range .articles}}
10+
{{range $i, $article := .articles}}
1111
<article class="article box_white">
1212
<div class="row">
1313
{{if .Cover}}
@@ -70,7 +70,17 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
7070
</div>
7171
</div>
7272
</article>
73-
{{else}}
73+
74+
{{if eq (mod $i 6) 3}}
75+
{{if $.pos_ad.feed}}
76+
<article class="article box_white">
77+
{{if eq $.pos_ad.feed.AdType 0}}
78+
{{noescape $.pos_ad.feed.Code}}
79+
{{end}}
80+
</article>
81+
{{end}}
82+
{{end}}
83+
7484
<article class="article box_white">
7585
<div class="row">暂无博文,<a class="btn btn-default btn-sm" href="/articles/new">撰写文章</a></div>
7686
</article>
@@ -88,8 +98,6 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
8898
<div class="sep20"></div>
8999
{{include "common/my_info.html" .}}
90100

91-
{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"今日阅读排行","objtype":1,"limit":10,"rank_type":"today"}`)}}
92-
93101
{{if .pos_ad.right1}}
94102
<div class="box_white sidebar" id="ad-right1">
95103
{{if eq .pos_ad.right1.AdType 0}}
@@ -98,6 +106,8 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
98106
</div>
99107
{{end}}
100108

109+
{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"今日阅读排行","objtype":1,"limit":10,"rank_type":"today"}`)}}
110+
101111
{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"一周阅读排行","objtype":1,"limit":10,"rank_type":"week"}`)}}
102112

103113
{{if .pos_ad.right2}}
@@ -126,4 +136,4 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
126136
{{end}}
127137
{{end}}
128138

129-
{{end}}
139+
{{end}}

template/index.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@
110110
</div>
111111
{{end}}
112112

113+
{{end}}
114+
{{else if eq (mod $i 10) 4}}
115+
{{if $.pos_ad.feed}}
116+
117+
{{if eq $.pos_ad.feed.AdType 0}}
118+
{{noescape $.pos_ad.feed.Code}}
119+
{{else}}
120+
<div id="ad-banner">
121+
</div>
122+
{{end}}
123+
113124
{{end}}
114125
{{end}}
115126
{{end}}
@@ -167,6 +178,17 @@
167178
</div>
168179
{{end}}
169180
{{end}}
181+
{{else if eq (mod $i 10) 4}}
182+
{{if $.pos_ad.feed}}
183+
184+
{{if eq $.pos_ad.feed.AdType 0}}
185+
{{noescape $.pos_ad.feed.Code}}
186+
{{else}}
187+
<div id="ad-banner">
188+
</div>
189+
{{end}}
190+
191+
{{end}}
170192
{{end}}
171193
{{end}}
172194

@@ -241,6 +263,17 @@
241263
</div>
242264
{{end}}
243265
{{end}}
266+
{{else if eq (mod $i 10) 4}}
267+
{{if $.pos_ad.feed}}
268+
269+
{{if eq $.pos_ad.feed.AdType 0}}
270+
{{noescape $.pos_ad.feed.Code}}
271+
{{else}}
272+
<div id="ad-banner">
273+
</div>
274+
{{end}}
275+
276+
{{end}}
244277
{{end}}
245278
{{end}}
246279

@@ -331,6 +364,17 @@
331364
</div>
332365
{{end}}
333366
{{end}}
367+
{{else if eq (mod $i 10) 4}}
368+
{{if $.pos_ad.feed}}
369+
370+
{{if eq $.pos_ad.feed.AdType 0}}
371+
{{noescape $.pos_ad.feed.Code}}
372+
{{else}}
373+
<div id="ad-banner">
374+
</div>
375+
{{end}}
376+
377+
{{end}}
334378
{{end}}
335379
{{end}}
336380

@@ -381,6 +425,17 @@
381425
</div>
382426
{{end}}
383427
{{end}}
428+
{{else if eq (mod $i 10) 4}}
429+
{{if $.pos_ad.feed}}
430+
431+
{{if eq $.pos_ad.feed.AdType 0}}
432+
{{noescape $.pos_ad.feed.Code}}
433+
{{else}}
434+
<div id="ad-banner">
435+
</div>
436+
{{end}}
437+
438+
{{end}}
384439
{{end}}
385440
{{end}}
386441

template/resources/index.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
<div class="resources">
2121
{{with $root := .}}
22-
{{range .resources}}
22+
{{range $i, $resource := .resources}}
2323
<div class="resource">
2424
<div class="rinfo">
2525
<a class="avatar pull-right" href="/user/{{.user.Username}}"><img src="{{gravatar .user.Avatar .user.Email 48 $root.is_https}}" alt="{{.user.Username}}"></a>
@@ -40,6 +40,17 @@
4040
</p>
4141
</div>
4242
</div>
43+
44+
{{if eq (mod $i 10) 3}}
45+
{{if $.pos_ad.feed}}
46+
<div>
47+
{{if eq $.pos_ad.feed.AdType 0}}
48+
{{noescape $.pos_ad.feed.Code}}
49+
{{end}}
50+
</div>
51+
{{end}}
52+
{{end}}
53+
4354
{{else}}
4455
<p class="text-center">该分类暂时没有任何资源</p>
4556
{{end}}

template/topics/common_list.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
{{end}}
4747
</div>
4848
{{end}}
49+
{{else if eq (mod $i 10) 4}}
50+
{{if $.pos_ad.feed}}
51+
<div>
52+
{{if eq $.pos_ad.feed.AdType 0}}
53+
{{noescape $.pos_ad.feed.Code}}
54+
{{end}}
55+
</div>
56+
{{end}}
4957
{{end}}
5058
{{end}}
5159
{{else}}

0 commit comments

Comments
 (0)