Skip to content

Commit 0e27912

Browse files
committed
merge video
2 parents d4f14d7 + bb90dd0 commit 0e27912

38 files changed

+1459
-227
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ output
4747
virtualroot
4848
docker
4949
license.cert
50-
index
50+
index
51+
index/

change.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@
3131
- [ ] 友链交换入口
3232
- [ ] 程序员网址导航
3333

34+
## v2.10 升级日志
35+
- [x] 支持音频和视频上传
36+
- [x] 如果开启了OSS云存储,则将音视频上传上去的同时将音视频设置为私有
37+
- [x] 支持音频和视频播放管理
38+
- [x] 管理后台,恢复和优化附件管理功能
39+
- [x] 如果管理员或者用户是书籍项目所有人,则音视频链接支持直链播放,否则对音视频链接进行一定的防盗链处理
40+
- [x] 优化程序内的 `cmd` 执行
41+
- [x] 内容阅读页面音频视频播放功能
42+
- [x] 音频和视频播放倍速控制
43+
- [x] 视频画中画播放
44+
- [x] 禁止音频和视频直接下载
45+
- [x] 增加和升级API,使小程序和APP支持音频和视频播放,以及图片放大预览
46+
- [x] 小程序/APP返回的音视频内容进行加密
47+
- [x] 优化`html2json`仓库,解析`HTML`内容,使小程序支持音频和视频播放功能,以及图片放大预览功能
48+
- [x] BookStack 依赖检测,以便程序可以正常使用完整功能进行工作,检测项:chrome、puppeteer、git、calibre
49+
3450
## v2.9 升级日志
3551
- [x] 对无权限创建书籍书籍的用户,隐藏创建书籍入口
3652
- [x] 优化首页分类索引高亮显示,并增加`回到顶部`功能

commands/command.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
var (
2626
ConfigurationFile = "./conf/app.conf"
27-
WorkingDirectory = "./"
2827
LogFile = "./logs"
2928
)
3029

@@ -226,49 +225,40 @@ func RegisterFunction() {
226225

227226
func ResolveCommand(args []string) {
228227
flagSet := flag.NewFlagSet("MinDoc command: ", flag.ExitOnError)
229-
flagSet.StringVar(&ConfigurationFile, "config", "", "MinDoc configuration file.")
230-
flagSet.StringVar(&WorkingDirectory, "dir", "", "MinDoc working directory.")
231-
flagSet.StringVar(&LogFile, "log", "", "MinDoc log file path.")
228+
flagSet.StringVar(&ConfigurationFile, "config", "", "BookStack configuration file.")
229+
flagSet.StringVar(&LogFile, "log", "", "BookStack log file path.")
232230

233231
flagSet.Parse(args)
234232

235-
if WorkingDirectory == "" {
236-
if p, err := filepath.Abs(os.Args[0]); err == nil {
237-
WorkingDirectory = filepath.Dir(p)
238-
}
239-
}
240-
if LogFile == "" {
241-
LogFile = filepath.Join(WorkingDirectory, "logs")
242-
}
243233
if ConfigurationFile == "" {
244-
ConfigurationFile = filepath.Join(WorkingDirectory, "conf", "app.conf")
245-
config := filepath.Join(WorkingDirectory, "conf", "app.conf.example")
234+
ConfigurationFile = filepath.Join("conf", "app.conf")
235+
config := filepath.Join("conf", "app.conf.example")
246236
if !utils.FileExists(ConfigurationFile) && utils.FileExists(config) {
247237
utils.CopyFile(ConfigurationFile, config)
248238
}
249239
}
250-
gocaptcha.ReadFonts(filepath.Join(WorkingDirectory, "static", "fonts"), ".ttf")
240+
gocaptcha.ReadFonts(filepath.Join("static", "fonts"), ".ttf")
251241

252242
err := beego.LoadAppConfig("ini", ConfigurationFile)
253243

254244
if err != nil {
255245
log.Println("An error occurred:", err)
256246
os.Exit(1)
257247
}
258-
uploads := filepath.Join(WorkingDirectory, "uploads")
248+
uploads := filepath.Join("uploads")
259249

260250
os.MkdirAll(uploads, 0666)
261251

262-
beego.BConfig.WebConfig.StaticDir["/static"] = filepath.Join(WorkingDirectory, "static")
263-
beego.BConfig.WebConfig.StaticDir["/uploads"] = uploads
264-
beego.BConfig.WebConfig.ViewsPath = filepath.Join(WorkingDirectory, "views")
252+
beego.BConfig.WebConfig.StaticDir["/static"] = filepath.Join("static")
253+
// beego.BConfig.WebConfig.StaticDir["/uploads"] = uploads
254+
beego.BConfig.WebConfig.ViewsPath = filepath.Join("views")
265255

266-
fonts := filepath.Join(WorkingDirectory, "static", "fonts")
256+
fonts := filepath.Join("static", "fonts")
267257

268258
if !utils.FileExists(fonts) {
269259
log.Fatal("Font path not exist.")
270260
}
271-
gocaptcha.ReadFonts(filepath.Join(WorkingDirectory, "static", "fonts"), ".ttf")
261+
gocaptcha.ReadFonts(filepath.Join("static", "fonts"), ".ttf")
272262

273263
RegisterDataBase()
274264
RegisterModel()
@@ -280,8 +270,4 @@ func init() {
280270

281271
gocaptcha.ReadFonts("./static/fonts", ".ttf")
282272
gob.Register(models.Member{})
283-
284-
if p, err := filepath.Abs(os.Args[0]); err == nil {
285-
WorkingDirectory = filepath.Dir(p)
286-
}
287273
}

commands/daemon/daemon.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ type Daemon struct {
2020
func NewDaemon() *Daemon {
2121

2222
config := &service.Config{
23-
Name: "BookStackd", //服务显示名称
24-
DisplayName: "BookStack Service", //服务名称
25-
Description: "A document online management program.", //服务描述
26-
WorkingDirectory: commands.WorkingDirectory,
27-
Arguments: os.Args[1:],
23+
Name: "BookStackd", //服务显示名称
24+
DisplayName: "BookStack Service", //服务名称
25+
Description: "A document online management program.", //服务描述
26+
Arguments: os.Args[1:],
2827
}
2928

3029
return &Daemon{

conf/app.conf.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ appId=""
1111
# 微信小程序appSecret
1212
appSecret=""
1313

14+
# 是否允许跨域(针对小程序或者APP开发)
15+
allowCors = true
16+
1417
# 是否限制API请求,也就是如果不是上述配置的微信小程序的appId请求的接口,则直接拒绝
1518
limitReferer=false
1619

conf/enumerate.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package conf
33

44
import (
55
"strings"
6+
"sync"
67

78
"github.com/astaxie/beego"
89
)
@@ -66,6 +67,24 @@ var (
6667
GO_VERSION string
6768
)
6869

70+
var (
71+
AudioExt sync.Map
72+
VideoExt sync.Map
73+
)
74+
75+
// 初始化支持的音视频格式
76+
func init() {
77+
// 音频格式
78+
for _, ext := range []string{".flac", ".wma", ".weba", ".aac", ".oga", ".ogg", ".mp3", ".webm", ".mid", ".wav", ".opus", ".m4a", ".amr", ".aiff", ".au"} {
79+
AudioExt.Store(ext, true)
80+
}
81+
82+
// 视频格式
83+
for _, ext := range []string{".ogm", ".wmv", ".asx", ".mpg", ".webm", ".mp4", ".ogv", ".mpeg", ".mov", ".m4v", ".avi"} {
84+
VideoExt.Store(ext, true)
85+
}
86+
}
87+
6988
// app_key
7089
func GetAppKey() string {
7190
return beego.AppConfig.DefaultString("app_key", "godoc")
@@ -109,7 +128,17 @@ func GetUploadFileExt() []string {
109128
}
110129

111130
//判断是否是允许商城的文件类型.
112-
func IsAllowUploadFileExt(ext string) bool {
131+
func IsAllowUploadFileExt(ext string, typ ...string) bool {
132+
if len(typ) > 0 {
133+
t := strings.ToLower(strings.TrimSpace(typ[0]))
134+
if t == "audio" {
135+
_, ok := AudioExt.Load(ext)
136+
return ok
137+
} else if t == "video" {
138+
_, ok := VideoExt.Load(ext)
139+
return ok
140+
}
141+
}
113142

114143
if strings.HasPrefix(ext, ".") {
115144
ext = string(ext[1:])

controllers/BookController.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/TruthHun/BookStack/models/store"
2020
"github.com/russross/blackfriday"
2121

22-
"github.com/TruthHun/BookStack/commands"
2322
"github.com/TruthHun/BookStack/conf"
2423
"github.com/TruthHun/BookStack/models"
2524
"github.com/TruthHun/BookStack/utils"
@@ -414,7 +413,7 @@ func (this *BookController) UploadCover() {
414413
this.JsonResult(500, "图片剪切")
415414
}
416415

417-
filePath = filepath.Join(commands.WorkingDirectory, "uploads", time.Now().Format("200601"), fileName+ext)
416+
filePath = filepath.Join("uploads", time.Now().Format("200601"), fileName+ext)
418417

419418
//生成缩略图并保存到磁盘
420419
err = graphics.ImageResizeSaveFile(subImg, 175, 230, filePath)
@@ -423,7 +422,7 @@ func (this *BookController) UploadCover() {
423422
this.JsonResult(500, "保存图片失败")
424423
}
425424

426-
url := "/" + strings.Replace(strings.TrimPrefix(filePath, commands.WorkingDirectory), "\\", "/", -1)
425+
url := "/" + strings.Replace(filePath, "\\", "/", -1)
427426
if strings.HasPrefix(url, "//") {
428427
url = string(url[1:])
429428
}
@@ -691,9 +690,8 @@ func (this *BookController) Delete() {
691690
this.JsonResult(0, "ok")
692691
}
693692

694-
//发布书籍.
693+
// 发布书籍.
695694
func (this *BookController) Release() {
696-
697695
identify := this.GetString("identify")
698696
bookId := 0
699697
if this.Member.IsAdministrator() {

0 commit comments

Comments
 (0)