mirror of https://github.com/mindoc-org/mindoc.git
1、解决分页BUG
2、解决切换文档上传附件混乱的BUG 3、无法清空文档标识的BUG 4、实现上传文件不限制后缀 5、实现上传文件大小限制 6、实现自动发布功能 7、优化登录时密码框错误提示不消失问题 8、优化网站首页限制网站titlepull/219/head
parent
848d3752e3
commit
54b51d7c27
|
@ -133,6 +133,9 @@ func RegisterFunction() {
|
|||
|
||||
beego.AddFuncMap("cdn", func(p string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdn", "")
|
||||
if strings.HasPrefix(p,"http://") || strings.HasPrefix(p,"https://") {
|
||||
return p
|
||||
}
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(cdn, "/") {
|
||||
return cdn + string(p[1:])
|
||||
}
|
||||
|
@ -144,6 +147,9 @@ func RegisterFunction() {
|
|||
|
||||
beego.AddFuncMap("cdnjs", func(p string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdnjs", "")
|
||||
if strings.HasPrefix(p,"http://") || strings.HasPrefix(p,"https://") {
|
||||
return p
|
||||
}
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(cdn, "/") {
|
||||
return cdn + string(p[1:])
|
||||
}
|
||||
|
@ -154,6 +160,9 @@ func RegisterFunction() {
|
|||
})
|
||||
beego.AddFuncMap("cdncss", func(p string) string {
|
||||
cdn := beego.AppConfig.DefaultString("cdncss", "")
|
||||
if strings.HasPrefix(p,"http://") || strings.HasPrefix(p,"https://") {
|
||||
return p
|
||||
}
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(cdn, "/") {
|
||||
return cdn + string(p[1:])
|
||||
}
|
||||
|
@ -163,6 +172,9 @@ func RegisterFunction() {
|
|||
return cdn + p
|
||||
})
|
||||
beego.AddFuncMap("cdnimg", func(p string) string {
|
||||
if strings.HasPrefix(p,"http://") || strings.HasPrefix(p,"https://") {
|
||||
return p
|
||||
}
|
||||
cdn := beego.AppConfig.DefaultString("cdnimg", "")
|
||||
if strings.HasPrefix(p, "/") && strings.HasSuffix(cdn, "/") {
|
||||
return cdn + string(p[1:])
|
||||
|
|
|
@ -6,6 +6,9 @@ sessionon = true
|
|||
sessionname = mindoc_id
|
||||
copyrequestbody = true
|
||||
|
||||
#是否自动发布文档,false 为否, true 保存文档后自动发布
|
||||
auto_release=false
|
||||
|
||||
#默认Session生成Key的秘钥
|
||||
beegoserversessionkey=123456
|
||||
|
||||
|
@ -47,8 +50,10 @@ avatar=/static/images/headimgurl.jpg
|
|||
#默认阅读令牌长度
|
||||
token_size=12
|
||||
|
||||
#上传文件的后缀
|
||||
#上传文件的后缀,如果不限制后缀可以设置为 *
|
||||
upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif
|
||||
#上传的文件大小限制,如果不填写,默认不限制,单位可以是 GB KB MB
|
||||
upload_file_size=10MB
|
||||
|
||||
####################邮件配置######################
|
||||
#是否启用邮件
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 登录用户的Session名
|
||||
|
@ -12,7 +13,7 @@ const LoginSessionName = "LoginSessionName"
|
|||
|
||||
const CaptchaSessionName = "__captcha__"
|
||||
|
||||
const RegexpEmail = `^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$`
|
||||
const RegexpEmail = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
|
||||
|
||||
//允许用户名中出现点号
|
||||
|
||||
|
@ -101,6 +102,30 @@ func GetUploadFileExt() []string {
|
|||
}
|
||||
return exts
|
||||
}
|
||||
// 获取上传文件允许的最大值
|
||||
func GetUploadFileSize() int64 {
|
||||
size := beego.AppConfig.DefaultString("upload_file_size","0")
|
||||
|
||||
if strings.HasSuffix(size,"MB") {
|
||||
if s,e := strconv.ParseInt(size[0:len(size) - 2], 10, 64);e == nil {
|
||||
return s * 1024 * 1024
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(size,"GB") {
|
||||
if s,e := strconv.ParseInt(size[0:len(size) - 2], 10, 64);e == nil {
|
||||
return s * 1024 * 1024 * 1024
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(size,"KB") {
|
||||
if s,e := strconv.ParseInt(size[0:len(size) - 2], 10, 64);e == nil {
|
||||
return s * 1024
|
||||
}
|
||||
}
|
||||
if s,e := strconv.ParseInt(size, 10, 64);e == nil {
|
||||
return s * 1024
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//判断是否是允许商城的文件类型.
|
||||
func IsAllowUploadFileExt(ext string) bool {
|
||||
|
|
|
@ -29,6 +29,7 @@ func (c *BaseController) Prepare (){
|
|||
c.EnableDocumentHistory = false
|
||||
|
||||
if member,ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0{
|
||||
|
||||
c.Member = &member
|
||||
c.Data["Member"] = c.Member
|
||||
}else{
|
||||
|
|
|
@ -392,9 +392,8 @@ func (c *DocumentController) Create() {
|
|||
document.MemberId = c.Member.MemberId
|
||||
document.BookId = book_id
|
||||
|
||||
if doc_identify != "" {
|
||||
document.Identify = doc_identify
|
||||
}
|
||||
document.Identify = doc_identify
|
||||
|
||||
|
||||
document.Version = time.Now().Unix()
|
||||
document.DocumentName = doc_name
|
||||
|
@ -435,14 +434,26 @@ func (c *DocumentController) Upload() {
|
|||
|
||||
defer file.Close()
|
||||
|
||||
type Size interface {
|
||||
Size() int64
|
||||
}
|
||||
beego.Info(conf.GetUploadFileSize())
|
||||
beego.Info(moreFile.Size)
|
||||
if conf.GetUploadFileSize() > 0 && moreFile.Size > conf.GetUploadFileSize() {
|
||||
c.JsonResult(6009,"查过文件允许的上传最大值")
|
||||
}
|
||||
|
||||
|
||||
ext := filepath.Ext(moreFile.Filename)
|
||||
|
||||
if ext == "" {
|
||||
c.JsonResult(6003, "无法解析文件的格式")
|
||||
}
|
||||
|
||||
if !conf.IsAllowUploadFileExt(ext) {
|
||||
c.JsonResult(6004, "不允许的文件类型")
|
||||
//如果文件类型设置为 * 标识不限制文件类型
|
||||
if beego.AppConfig.DefaultString("upload_file_ext", "") != "*" {
|
||||
if !conf.IsAllowUploadFileExt(ext) {
|
||||
c.JsonResult(6004, "不允许的文件类型")
|
||||
}
|
||||
}
|
||||
|
||||
book_id := 0
|
||||
|
@ -806,6 +817,14 @@ func (c *DocumentController) Content() {
|
|||
beego.Error("DocumentHistory InsertOrUpdate => ", err)
|
||||
}
|
||||
}
|
||||
if beego.AppConfig.DefaultBool("auto_release", false) {
|
||||
go func(identify string) {
|
||||
models.NewDocument().ReleaseContent(book_id)
|
||||
|
||||
|
||||
}(identify)
|
||||
}
|
||||
|
||||
|
||||
c.JsonResult(0, "ok", doc)
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
# Created by .ignore support plugin (hsz.mobi)
|
|
@ -51,7 +51,7 @@
|
|||
"<label>" + imageLang.url + "</label>" +
|
||||
"<input type=\"text\" data-url />" + (function(){
|
||||
return (settings.imageUpload) ? "<div class=\"" + classPrefix + "file-input\">" +
|
||||
"<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/*\" />" +
|
||||
"<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/jpeg,image/png,image/gif,image/jpg\" />" +
|
||||
"<input type=\"submit\" value=\"" + imageLang.uploadButton + "\" />" +
|
||||
"</div>" : "";
|
||||
})() +
|
||||
|
|
|
@ -144,11 +144,16 @@ $(function () {
|
|||
resetEditor();
|
||||
if (res.errcode === 0) {
|
||||
window.isLoad = true;
|
||||
window.editor.clear();
|
||||
window.editor.insertValue(res.data.markdown);
|
||||
window.editor.setCursor({ line : 0, ch : 0 });
|
||||
try {
|
||||
window.editor.clear();
|
||||
window.editor.insertValue(res.data.markdown);
|
||||
window.editor.setCursor({line: 0, ch: 0});
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
var node = { "id": res.data.doc_id, 'parent': res.data.parent_id === 0 ? '#' : res.data.parent_id, "text": res.data.doc_name, "identify": res.data.identify, "version": res.data.version };
|
||||
pushDocumentCategory(node);
|
||||
console.log(node);
|
||||
window.selectNode = node;
|
||||
pushVueLists(res.data.attach);
|
||||
} else {
|
||||
|
@ -351,6 +356,7 @@ $(function () {
|
|||
}).on('loaded.jstree', function () {
|
||||
window.treeCatalog = $(this).jstree();
|
||||
}).on('select_node.jstree', function (node, selected, event) {
|
||||
|
||||
if ($("#markdown-save").hasClass('change')) {
|
||||
if (confirm("编辑内容未保存,需要保存吗?")) {
|
||||
saveDocument(false, function () {
|
||||
|
@ -362,7 +368,9 @@ $(function () {
|
|||
|
||||
loadDocument(selected);
|
||||
}).on("move_node.jstree", jstree_save);
|
||||
|
||||
/**
|
||||
* 打开文档模板
|
||||
*/
|
||||
$("#documentTemplateModal").on("click", ".section>a[data-type]", function () {
|
||||
var $this = $(this).attr("data-type");
|
||||
var body = $("#template-" + $this).html();
|
||||
|
|
|
@ -166,7 +166,7 @@ func DealUri(po *PageOptions, requestURI string) {
|
|||
func fun4(po *PageOptions, totalPages int) string {
|
||||
rs := ""
|
||||
rs += getHeader(po, totalPages)
|
||||
rs += "<li><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(1) + "'>" + con.Itoa(1) + "</a><li>"
|
||||
rs += "<li><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(1) + "'>" + con.Itoa(1) + "</a></li>"
|
||||
rs += "<li><a href=''>...</a></li>"
|
||||
for i := totalPages - po.LinkItemCount; i <= totalPages; i++ {
|
||||
if po.CurrentPage != i {
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#account,#passwd,#code").on('focus', function () {
|
||||
$("#account,#password,#code").on('focus', function () {
|
||||
$(this).tooltip('destroy').parents('.form-group').removeClass('has-error');
|
||||
});
|
||||
|
||||
|
@ -104,6 +104,7 @@
|
|||
});
|
||||
|
||||
$("#btn-login").on('click', function () {
|
||||
$(this).tooltip('destroy').parents('.form-group').removeClass('has-error');
|
||||
var $btn = $(this).button('loading');
|
||||
|
||||
var account = $.trim($("#account").val());
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
<link href="{{cdncss "/static/css/jstree.css"}}" rel="stylesheet">
|
||||
<link href="{{cdncss "/static/highlight/styles/zenburn.css"}}" rel="stylesheet">
|
||||
<link href="{{cdncss "/static/webuploader/webuploader.css"}}" rel="stylesheet">
|
||||
<link href="/static/css/markdown.css" rel="stylesheet">
|
||||
<link href="{{cdncss "/static/css/markdown.css"}}" rel="stylesheet">
|
||||
<link href="{{cdncss "/static/prettify/themes/atelier-estuary-dark.min.css"}}" rel="stylesheet">
|
||||
<link href="/static/css/markdown.preview.css" rel="stylesheet">
|
||||
<link href="{{cdncss "/static/css/markdown.preview.css"}}" rel="stylesheet">
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
|
@ -310,6 +310,7 @@
|
|||
compress : false
|
||||
}).on("beforeFileQueued",function (file) {
|
||||
uploader.reset();
|
||||
this.options.formData.doc_id = window.selectNode.id;
|
||||
}).on( 'fileQueued', function( file ) {
|
||||
var item = {
|
||||
state : "wait",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>网站首页 - Powered by MinDoc</title>
|
||||
<title>{{.SITE_NAME}} - Powered by MinDoc</title>
|
||||
<meta name="author" content="Minho" />
|
||||
<meta name="site" content="https://www.iminho.me" />
|
||||
<!-- Bootstrap -->
|
||||
|
@ -44,7 +44,7 @@
|
|||
<dl class="manual-item-standard">
|
||||
<dt>
|
||||
<a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" title="{{$item.BookName}}-{{$item.CreateName}}" target="_blank">
|
||||
<img src="{{$item.Cover}}" class="cover" alt="{{$item.BookName}}-{{$item.CreateName}}">
|
||||
<img src="{{$item.Cover}}" class="cover" alt="{{$item.BookName}}-{{$item.CreateName}}" onerror="this.src='{{cdnimg "static/images/book.jpg"}}';">
|
||||
</a>
|
||||
</dt>
|
||||
<dd>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<header class="navbar navbar-static-top navbar-fixed-top manual-header" role="banner">
|
||||
<div class="container">
|
||||
<div class="navbar-header col-sm-12 col-md-7 col-lg-6">
|
||||
<div class="navbar-header col-sm-12 col-md-10 col-lg-8">
|
||||
<a href="/" class="navbar-brand" title="{{.SITE_NAME}}">
|
||||
{{if .SITE_TITLE}}
|
||||
{{.SITE_TITLE}}
|
||||
|
|
Loading…
Reference in New Issue