Skip to content

Commit 953a839

Browse files
committed
增加文字小广告功能
1 parent 0dc0b41 commit 953a839

File tree

8 files changed

+73
-10
lines changed

8 files changed

+73
-10
lines changed

change.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@
2121
- [ ] 增加电子书下载管控,是否必须登录才能下载电子书
2222
- [ ] 发布队列
2323

24-
## V2.4 升级日志
24+
## v2.2 升级日志
25+
26+
- [ ] 书籍信息设置页,支持增加文字广告功能
27+
- [ ] 申请成为作者的功能(提交自己GitHub、gitee和博客等相关内容)
28+
- [ ] 增加实体书功能(广告)
29+
- [ ] 增加网络课程推广功能(广告)
30+
- [ ] 增加 wiki 功能
31+
- [ ] 增加博客(文章)系统功能
32+
- [ ] ElasticSearch支持搜索博客、wiki和实体书
33+
- [ ] 增加程序员工具箱功能(长期工作)
34+
35+
## V2.1 升级日志
2536

2637
- [x] 解决 2.0 版本,初始化管理员失败(密码长度修改导致)的问题
2738
- [x] html转json实现,以兼容各种小程序和uni-app的富文本组件`rich-text`对内容的渲染
@@ -167,8 +178,8 @@ sudo docker run -it -p 9300:9300 -p 9200:9200 -v /Users/TruthHun/elasticsearch/d
167178
## V1.3 开发升级预告
168179
- [x] 新增:用户阅读记录和阅读进度
169180
- [x] 新增:阅读书签功能,以便读者标记阅读位置
170-
- [x] 新增:书籍详情页和文档内容页增加分享功能(由于百度分享等现有分享代码不支持`https`,所以使用本地化百度分享源码解决方案 https://github.com/hrwhisper/baiduShare
171-
- [x] 新增:使用KaTeX( https://github.com/Khan/KaTeX ),扩展对数学公式的支持
181+
- [x] 新增:书籍详情页和文档内容页增加分享功能(由于百度分享等现有分享代码不支持`https`,所以使用本地化百度分享源码解决方案 <https://github.com/hrwhisper/baiduShare>
182+
- [x] 新增:使用KaTeX( <https://github.com/Khan/KaTeX> ),扩展对数学公式的支持
172183
- [x] 优化:更新HTML转markdown工具[html2md](https://github.com/TruthHun/html2md),强化转化效果
173184
- [x] 修复:文档内URL链接大小写问题优化 [issue#20](https://github.com/TruthHun/BookStack/issues/20)
174185
- [x] 修复:友链唯一索引问题(默认的字段varchar类型长度(255)过长,导致部分MySQL数据库无法生成唯一索引)
@@ -203,7 +214,7 @@ FIX:
203214
- [x] 一键拉取项目,支持任何来源的zip压缩的markdown项目的拉取
204215
- [x] 无刷新加载上下篇阅读文档,优化阅读体验
205216
- [x] 移除SEO等Go文件中硬编码的"bookstack.cn"的域名(因为BookStack,一开始是打算自用的,所以当时写死了)
206-
- [x] 登录和注册验证码优化(使用Beego自带的验证码体系:https://github.com/astaxie/beego/tree/master/utils/captcha)
217+
- [x] 登录和注册验证码优化(使用Beego自带的验证码体系:<https://github.com/astaxie/beego/tree/master/utils/captcha)>
207218
- [x] 支持本地化存储(改动了很多地方,具体改动,请`git log`查看)。在app.conf中增加了`store_type`配置项,以扩展存储类型,目前扩展的存储类型有本地存储(`local`)和阿里云OSS存储(`oss`),更多存储类型(`七牛云存储(qiniu)、腾讯云存储(cos)、百度云存储(bos)、又拍云存储(upyun)`)持续开发中.
208219
- [x] 分页优化
209220
- [x] 解决角色名称有时不显示的问题

controllers/BookController.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ func (this *BookController) SaveBook() {
231231
book.Author = this.GetString("author")
232232
book.AuthorURL = this.GetString("author_url")
233233
book.Lang = this.GetString("lang")
234+
book.AdTitle = this.GetString("ad_title")
235+
book.AdLink = this.GetString("ad_link")
234236

235237
if err := book.Update(); err != nil {
236238
this.JsonResult(6006, "保存失败")

models/book.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ type Book struct {
6363
Score int `orm:"column(score);default(40)" json:"score"` // 文档项目评分,默认40,即4.0星
6464
CntScore int // 评分人数
6565
CntComment int // 评论人数
66-
Author string `orm:"size(50)"` //原作者,即来源
67-
AuthorURL string `orm:"column(author_url)"` //原作者链接,即来源链接
66+
Author string `orm:"size(50)"` //原作者,即来源
67+
AuthorURL string `orm:"column(author_url)"` //原作者链接,即来源链接
68+
AdTitle string `orm:"default()"` // 文字广告标题
69+
AdLink string `orm:"default();size(512)"` // 文字广告链接
6870
Lang string `orm:"size(10);index;default(zh)"`
6971
}
7072

@@ -542,6 +544,8 @@ func (book *Book) ToBookResult() (m *BookResult) {
542544
m.CntComment = book.CntComment
543545
m.Author = book.Author
544546
m.AuthorURL = book.AuthorURL
547+
m.AdTitle = book.AdTitle
548+
m.AdLink = book.AdLink
545549
m.Lang = book.Lang
546550

547551
if book.Theme == "" {

models/book_result.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type BookResult struct {
4646
IsDisplayComment bool `json:"is_display_comment"`
4747
Author string `json:"author"`
4848
AuthorURL string `json:"author_url"`
49+
AdTitle string `json:"ad_title"`
50+
AdLink string `json:"ad_link"`
4951
Lang string `json:"lang"`
5052
}
5153

models/category.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ type Category struct {
2323
Cnt int `json:"cnt"` //分类下的文档项目统计
2424
Sort int `json:"sort"` //排序
2525
Status bool `json:"status"` //分类状态,true表示显示,否则表示隐藏
26+
//PrintBookCount int `orm:"default(0)" json:"print_book_count"`
27+
//WikiCount int `orm:"default(0)" json:"wiki_count"`
28+
//ArticleCount int `orm:"default(0)" json:"article_count"`
2629
}
2730

2831
func NewCategory() *Category {

models/print_book.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package models
2+
3+
type PrintBook struct {
4+
Id int `json:"id"`
5+
Cover string `json:"cover"`
6+
Title string `json:"title"`
7+
Keywords string `json:"keywords"`
8+
Description string `json:"description"`
9+
Author string `json:"author"`
10+
Publish string `json:"publish"` //出版社
11+
Lang string `json:"lang"` //语种
12+
Page int `json:"page"` //页数
13+
View int `json:"view"`
14+
Support int `json:"support"`
15+
ShopLinks []struct {
16+
Name string `json:"name"`
17+
Href string `json:"href"`
18+
} `orm:"-" json:"shop_links"`
19+
ShopLinksJSON string `orm:"type(text)"`
20+
Content string `json:"content" orm:"type(longtext)"` // markdown content
21+
}

views/book/setting.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@
121121
</div>
122122
</div>
123123

124+
<div class="form-group">
125+
<label>文字广告</label>
126+
<div class="input-group">
127+
<span class="input-group-btn">
128+
<button class="btn btn-default" type="button">广告标题</button>
129+
</span>
130+
<input type="text" placeholder="选填" value="{{.Model.AdTitle}}" name="ad_title" id="author" class="form-control">
131+
<span class="input-group-btn">
132+
<button class="btn btn-default" style="border-left: 0px;border-right: 0px;border-radius: 0px;" type="button">广告链接</button>
133+
</span>
134+
<input type="text" placeholder="选填" value="{{.Model.AdLink}}" name="ad_link" id="author_url" class="form-control">
135+
</div>
136+
<p class="text help-block">文字广告,可以放原作者的打赏和赞助二维码链接,也可以放开源书籍的购买链接以支持作者</p>
137+
</div>
138+
124139
<div class="form-group">
125140
<label>分类 (<span class="text-muted">支持选择多个分类</span>)</label>
126141
{{range $idx,$cate:=$.Cates}}
@@ -141,12 +156,12 @@
141156
<div class="form-group">
142157
<label>描述</label>
143158
<textarea rows="3" class="form-control" name="description" style="height: 90px" placeholder="项目描述">{{.Model.Description}}</textarea>
144-
<p class="text">描述信息不超过500个字符,支持Markdown语法</p>
159+
<p class="text help-block">描述信息不超过500个字符,支持Markdown语法</p>
145160
</div>
146161
<div class="form-group">
147162
<label>标签</label>
148163
<input type="text" class="form-control" name="label" placeholder="项目标签" value="{{.Model.Label}}">
149-
<p class="text">最多允许添加10个标签,多个标签请用“,”分割</p>
164+
<p class="text help-block">最多允许添加10个标签,多个标签请用“,”分割</p>
150165
</div>
151166
{{if eq .Model.PrivatelyOwned 1}}
152167
<div class="form-group">

views/document/default_read.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
li.L1, li.L3, li.L5, li.L7, li.L9{background-color: transparent;}
2626
.editormd-preview-container pre.prettyprint, .editormd-html-preview pre.prettyprint{border-color: transparent;}
2727
body{-webkit-overflow-scrolling:touch;}
28+
.alink,.alink a{color: #888 !important;}
29+
.alink:hover,.alink a:hover{color: red !important;}
2830
</style>
2931
</head>
3032
<body>
@@ -46,7 +48,6 @@
4648
{{end}}
4749
<a title="下载" href="javascript:" data-toggle="modal" data-target="#ModalDownload" class="btn btn-light"><i class="fa fa-cloud-download"></i> 下载</a>
4850

49-
5051
<a href="{{urlfor "RecordController.List" ":book_id" .Model.BookId}}" rel="nofollow" class="btn btn-link showModalHistory"><i class="fa fa-clock-o"></i> 阅读记录</a>
5152
<span class="dropdown">
5253
<button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
@@ -89,8 +90,12 @@ <h1 id="article-title">{{.Title}}</h1>
8990
</div>
9091
<div class="article-content">
9192
<div class="help-block article-info" style="padding-bottom: 20px;">
93+
{{if .Model.AdTitle}}
94+
<span class="alink tooltips" title="{{.Model.AdTitle}}"><i class="fa fa-angle-right"></i> <a target="_blank" rel="nofollow" href="{{.Model.AdLink}}">{{.Model.AdTitle}}</a> <i class="fa fa-angle-left"></i> </span>
95+
{{end}}
96+
9297
{{if .Model.Author}}
93-
<span><i class="fa fa-user-o"></i> <a target="_blank" title="来源" href="{{.Model.AuthorURL}}">来源: {{.Model.Author}}</a></span>
98+
<span><i class="fa fa-user-o"></i> <a target="_blank" title="来源" href="{{.Model.AuthorURL}}">来源 {{.Model.Author}}</a></span>
9499
{{end}}
95100
<span><i class="fa fa-eye"></i> 浏览 <i class="read-count">{{.View}}</i></span>
96101
<span class="hidden-xs"><a href="#" data-target="#ModalQRcode" data-toggle="modal"><i class="fa fa-qrcode"></i> 扫码</a></span>

0 commit comments

Comments
 (0)