mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
实现分享开关
This commit is contained in:
@@ -32,7 +32,7 @@ func (c *AccountController) Login() {
|
||||
u = c.Ctx.Request.Header.Get("Referer")
|
||||
}
|
||||
if u == "" {
|
||||
u = utils.URLFor("HomeController.Index")
|
||||
u = conf.URLFor("HomeController.Index")
|
||||
}
|
||||
c.Redirect(u,302)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (c *AccountController) Login() {
|
||||
u = c.Ctx.Request.Header.Get("Referer")
|
||||
}
|
||||
if u == "" {
|
||||
u = utils.URLFor("HomeController.Index")
|
||||
u = conf.URLFor("HomeController.Index")
|
||||
}
|
||||
|
||||
c.JsonResult(0, "ok", u)
|
||||
@@ -97,7 +97,7 @@ func (c *AccountController) Login() {
|
||||
u = c.Ctx.Request.Header.Get("Referer")
|
||||
}
|
||||
if u == "" {
|
||||
u = utils.URLFor("HomeController.Index")
|
||||
u = conf.URLFor("HomeController.Index")
|
||||
}
|
||||
c.Data["url"] = url.PathEscape(u)
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (c *AccountController) LoggedIn(isPost bool) interface{} {
|
||||
if !isPost {
|
||||
// 检查是否存在 turl 参数,如果有则重定向至 turl 处,否则进入 Home 页面
|
||||
if turl == "" {
|
||||
turl = utils.URLFor("HomeController.Index")
|
||||
turl = conf.URLFor("HomeController.Index")
|
||||
}
|
||||
c.Redirect(turl, 302)
|
||||
return nil
|
||||
@@ -130,7 +130,7 @@ func (c *AccountController) Register() {
|
||||
|
||||
//如果用户登录了,则跳转到网站首页
|
||||
if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 {
|
||||
c.Redirect(utils.URLFor("HomeController.Index"),302)
|
||||
c.Redirect(conf.URLFor("HomeController.Index"),302)
|
||||
}
|
||||
// 如果没有开启用户注册
|
||||
if v, ok := c.Option["ENABLED_REGISTER"]; ok && !strings.EqualFold(v, "true") {
|
||||
@@ -244,7 +244,7 @@ func (c *AccountController) FindPassword() {
|
||||
|
||||
data := map[string]interface{}{
|
||||
"SITE_NAME": c.Option["SITE_NAME"],
|
||||
"url": utils.URLFor("AccountController.FindPassword", "token", member_token.Token, "mail", email),
|
||||
"url": conf.URLFor("AccountController.FindPassword", "token", member_token.Token, "mail", email),
|
||||
"BaseUrl": c.BaseUrl(),
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ func (c *AccountController) FindPassword() {
|
||||
//}
|
||||
}(mail_conf, email, body)
|
||||
|
||||
c.JsonResult(0, "ok", utils.URLFor("AccountController.Login"))
|
||||
c.JsonResult(0, "ok", conf.URLFor("AccountController.Login"))
|
||||
}
|
||||
|
||||
token := c.GetString("token")
|
||||
@@ -396,7 +396,7 @@ func (c *AccountController) ValidEmail() {
|
||||
beego.Error(err)
|
||||
c.JsonResult(6006, "保存密码失败")
|
||||
}
|
||||
c.JsonResult(0, "ok", utils.URLFor("AccountController.Login"))
|
||||
c.JsonResult(0, "ok", conf.URLFor("AccountController.Login"))
|
||||
}
|
||||
|
||||
// Logout 退出登录
|
||||
@@ -407,7 +407,7 @@ func (c *AccountController) Logout() {
|
||||
|
||||
u := c.Ctx.Request.Header.Get("Referer")
|
||||
|
||||
c.Redirect(utils.URLFor("AccountController.Login","url",u), 302)
|
||||
c.Redirect(conf.URLFor("AccountController.Login","url",u), 302)
|
||||
}
|
||||
|
||||
// 验证码
|
||||
|
||||
@@ -111,7 +111,7 @@ func (c *BookController) Setting() {
|
||||
c.Abort("403")
|
||||
}
|
||||
if book.PrivateToken != "" {
|
||||
book.PrivateToken = utils.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
|
||||
book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
|
||||
}
|
||||
c.Data["Model"] = book
|
||||
|
||||
@@ -140,6 +140,7 @@ func (c *BookController) SaveBook() {
|
||||
publisher := strings.TrimSpace(c.GetString("publisher"))
|
||||
historyCount,_ := c.GetInt("history_count",0)
|
||||
isDownload := strings.TrimSpace(c.GetString("is_download")) == "on"
|
||||
enableShare := strings.TrimSpace(c.GetString("enable_share")) == "on"
|
||||
|
||||
if strings.Count(description, "") > 500 {
|
||||
c.JsonResult(6004, "项目描述不能大于500字")
|
||||
@@ -176,6 +177,11 @@ func (c *BookController) SaveBook() {
|
||||
}else{
|
||||
book.IsDownload = 1
|
||||
}
|
||||
if enableShare {
|
||||
book.IsEnableShare = 0
|
||||
}else{
|
||||
book.IsEnableShare = 1
|
||||
}
|
||||
if err := book.Update(); err != nil {
|
||||
c.JsonResult(6006, "保存失败")
|
||||
}
|
||||
@@ -345,7 +351,7 @@ func (c *BookController) UploadCover() {
|
||||
|
||||
oldCover := book.Cover
|
||||
|
||||
book.Cover = utils.URLForWithCdnImage(url)
|
||||
book.Cover = conf.URLForWithCdnImage(url)
|
||||
|
||||
if err := book.Update(); err != nil {
|
||||
c.JsonResult(6001, "保存图片失败")
|
||||
@@ -554,7 +560,7 @@ func (c *BookController) CreateToken() {
|
||||
logs.Error("生成阅读令牌失败 => ", err)
|
||||
c.JsonResult(6003, "生成阅读令牌失败")
|
||||
}
|
||||
c.JsonResult(0, "ok", utils.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken))
|
||||
c.JsonResult(0, "ok", conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken))
|
||||
} else {
|
||||
book.PrivateToken = ""
|
||||
if err := book.Update(); err != nil {
|
||||
|
||||
@@ -105,7 +105,7 @@ func promptUserToLogIn(c *DocumentController) {
|
||||
if c.IsAjax() {
|
||||
c.JsonResult(6000, "请重新登录。")
|
||||
} else {
|
||||
c.Redirect(utils.URLFor("AccountController.Login")+ "?url=" + url.PathEscape(conf.BaseUrl+ c.Ctx.Request.URL.RequestURI()), 302)
|
||||
c.Redirect(conf.URLFor("AccountController.Login")+ "?url=" + url.PathEscape(conf.BaseUrl+ c.Ctx.Request.URL.RequestURI()), 302)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ func (c *DocumentController) Upload() {
|
||||
if strings.EqualFold(ext, ".jpg") || strings.EqualFold(ext, ".jpeg") || strings.EqualFold(ext, ".png") || strings.EqualFold(ext, ".gif") {
|
||||
attachment.HttpPath = "/" + strings.Replace(strings.TrimPrefix(filePath, conf.WorkingDirectory), "\\", "/", -1)
|
||||
if strings.HasPrefix(attachment.HttpPath, "//") {
|
||||
attachment.HttpPath = utils.URLForWithCdnImage(string(attachment.HttpPath[1:]))
|
||||
attachment.HttpPath = conf.URLForWithCdnImage(string(attachment.HttpPath[1:]))
|
||||
}
|
||||
|
||||
is_attach = false
|
||||
@@ -537,7 +537,7 @@ func (c *DocumentController) Upload() {
|
||||
}
|
||||
|
||||
if attachment.HttpPath == "" {
|
||||
attachment.HttpPath = utils.URLFor("DocumentController.DownloadAttachment", ":key", identify, ":attach_id", attachment.AttachmentId)
|
||||
attachment.HttpPath = conf.URLFor("DocumentController.DownloadAttachment", ":key", identify, ":attach_id", attachment.AttachmentId)
|
||||
|
||||
if err := attachment.Update(); err != nil {
|
||||
beego.Error("SaveToFile => ", err)
|
||||
@@ -892,7 +892,7 @@ func (c *DocumentController) Export() {
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(bookResult.Cover, "http:://") && !strings.HasPrefix(bookResult.Cover, "https:://") {
|
||||
bookResult.Cover = utils.URLForWithCdnImage(bookResult.Cover)
|
||||
bookResult.Cover = conf.URLForWithCdnImage(bookResult.Cover)
|
||||
}
|
||||
|
||||
if output == "markdown" {
|
||||
@@ -951,7 +951,7 @@ func (c *DocumentController) QrCode() {
|
||||
c.Abort("404")
|
||||
}
|
||||
|
||||
uri := utils.URLFor("DocumentController.Index", ":key", identify)
|
||||
uri := conf.URLFor("DocumentController.Index", ":key", identify)
|
||||
code, err := qr.Encode(uri, qr.L, qr.Unicode)
|
||||
if err != nil {
|
||||
beego.Error(err)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/lifei6671/mindoc/conf"
|
||||
"github.com/lifei6671/mindoc/models"
|
||||
"github.com/lifei6671/mindoc/utils"
|
||||
"github.com/lifei6671/mindoc/utils/pagination"
|
||||
)
|
||||
|
||||
@@ -20,7 +19,7 @@ func (c *HomeController) Index() {
|
||||
c.TplName = "home/index.tpl"
|
||||
//如果没有开启匿名访问,则跳转到登录页面
|
||||
if !c.EnableAnonymous && c.Member == nil {
|
||||
c.Redirect(utils.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302)
|
||||
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302)
|
||||
}
|
||||
pageIndex, _ := c.GetInt("page", 1)
|
||||
pageSize := 18
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/lifei6671/mindoc/conf"
|
||||
"github.com/lifei6671/mindoc/models"
|
||||
"github.com/lifei6671/mindoc/utils"
|
||||
"github.com/lifei6671/mindoc/utils/pagination"
|
||||
)
|
||||
|
||||
@@ -20,7 +19,7 @@ func (c *LabelController) Prepare() {
|
||||
|
||||
//如果没有开启你们访问则跳转到登录
|
||||
if !c.EnableAnonymous && c.Member == nil {
|
||||
c.Redirect(utils.URLFor("AccountController.Login"), 302)
|
||||
c.Redirect(conf.URLFor("AccountController.Login"), 302)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func (c *ManagerController) EditBook() {
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
if book.PrivateToken != "" {
|
||||
book.PrivateToken = utils.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
|
||||
book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
|
||||
}
|
||||
c.Data["Model"] = book
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func (c *ManagerController) CreateToken() {
|
||||
logs.Error("生成阅读令牌失败 => ", err)
|
||||
c.JsonResult(6003, "生成阅读令牌失败")
|
||||
}
|
||||
c.JsonResult(0, "ok", utils.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken))
|
||||
c.JsonResult(0, "ok", conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken))
|
||||
} else {
|
||||
book.PrivateToken = ""
|
||||
if err := book.Update(); err != nil {
|
||||
@@ -610,7 +610,7 @@ func (c *ManagerController) AttachDetailed() {
|
||||
}
|
||||
|
||||
attach.FilePath = filepath.Join(conf.WorkingDirectory, attach.FilePath)
|
||||
attach.HttpPath = utils.URLForWithCdnImage(attach.HttpPath)
|
||||
attach.HttpPath = conf.URLForWithCdnImage(attach.HttpPath)
|
||||
|
||||
attach.IsExist = utils.FileExists(attach.FilePath)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *SearchController) Index() {
|
||||
|
||||
//如果没有开启你们访问则跳转到登录
|
||||
if !c.EnableAnonymous && c.Member == nil {
|
||||
c.Redirect(utils.URLFor("AccountController.Login"), 302)
|
||||
c.Redirect(conf.URLFor("AccountController.Login"), 302)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user