remove deprecated log
This commit is contained in:
@ -6,7 +6,7 @@ import (
|
|||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/leanote/leanote/app/info"
|
"github.com/leanote/leanote/app/info"
|
||||||
. "github.com/leanote/leanote/app/lea"
|
// . "github.com/leanote/leanote/app/lea"
|
||||||
"github.com/leanote/leanote/app/lea/blog"
|
"github.com/leanote/leanote/app/lea/blog"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
// "github.com/leanote/leanote/app/types"
|
// "github.com/leanote/leanote/app/types"
|
||||||
@ -609,7 +609,7 @@ func (c Blog) Post(userIdOrEmail, noteId string) (re revel.Result) {
|
|||||||
hasDomain, userBlog := c.domain()
|
hasDomain, userBlog := c.domain()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
Log(err)
|
// Log(err)
|
||||||
re = c.e404(userBlog.ThemePath)
|
re = c.e404(userBlog.ThemePath)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -234,20 +234,21 @@ func (c Note) UpdateNoteOrContent(noteOrContent info.NoteOrContent) revel.Result
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------
|
//-------------
|
||||||
afterContentUsn := 0
|
// afterContentUsn := 0
|
||||||
contentOk := false
|
// contentOk := false
|
||||||
contentMsg := ""
|
// contentMsg := ""
|
||||||
if c.Has("Content") {
|
if c.Has("Content") {
|
||||||
// noteService.UpdateNoteContent(noteOrContent.UserId, c.GetUserId(),
|
// noteService.UpdateNoteContent(noteOrContent.UserId, c.GetUserId(),
|
||||||
// noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract)
|
// noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract)
|
||||||
contentOk, contentMsg, afterContentUsn = noteService.UpdateNoteContent(c.GetUserId(),
|
// contentOk, contentMsg, afterContentUsn =
|
||||||
|
noteService.UpdateNoteContent(c.GetUserId(),
|
||||||
noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract,
|
noteOrContent.NoteId, noteOrContent.Content, noteOrContent.Abstract,
|
||||||
needUpdateNote, -1, time.Now())
|
needUpdateNote, -1, time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(afterContentUsn)
|
// Log("usn", "afterContentUsn", afterContentUsn + "")
|
||||||
Log(contentOk)
|
// Log(contentOk)
|
||||||
Log(contentMsg)
|
// Log(contentMsg)
|
||||||
|
|
||||||
return c.RenderJSON(true)
|
return c.RenderJSON(true)
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ func (c ApiNote) fixPostNotecontent(noteOrContent *info.ApiNote) {
|
|||||||
// "/api/file/getImage?fileId="+file.FileId, -1)
|
// "/api/file/getImage?fileId="+file.FileId, -1)
|
||||||
} else {
|
} else {
|
||||||
reg, _ := regexp.Compile(`https*://[^/]*?/api/file/getAttach\?fileId=`+file.LocalFileId)
|
reg, _ := regexp.Compile(`https*://[^/]*?/api/file/getAttach\?fileId=`+file.LocalFileId)
|
||||||
Log(reg)
|
// Log(reg)
|
||||||
noteOrContent.Content = reg.ReplaceAllString(noteOrContent.Content, `/api/file/getAttach?fileId=`+file.FileId)
|
noteOrContent.Content = reg.ReplaceAllString(noteOrContent.Content, `/api/file/getAttach?fileId=`+file.FileId)
|
||||||
/*
|
/*
|
||||||
noteOrContent.Content = strings.Replace(noteOrContent.Content,
|
noteOrContent.Content = strings.Replace(noteOrContent.Content,
|
||||||
|
@ -6,21 +6,17 @@ import (
|
|||||||
"github.com/revel/revel"
|
"github.com/revel/revel"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Log(i ...interface{}) {
|
func Log(msg string, i ...interface{}) {
|
||||||
revel.INFO.Println(i...)
|
revel.AppLog.Info(msg, i...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogW(i ...interface{}) {
|
func LogW(msg string, i ...interface{}) {
|
||||||
revel.WARN.Println(i...)
|
revel.AppLog.Warn(msg, i...)
|
||||||
}
|
|
||||||
|
|
||||||
func Log1(key, i interface{}) {
|
|
||||||
revel.INFO.Println(key, i)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogJ(i interface{}) {
|
func LogJ(i interface{}) {
|
||||||
b, _ := json.MarshalIndent(i, "", " ")
|
b, _ := json.MarshalIndent(i, "", " ")
|
||||||
revel.INFO.Println(string(b))
|
revel.AppLog.Info(string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为test用
|
// 为test用
|
||||||
|
@ -79,7 +79,6 @@ func SendEmailOld(to, subject, body string) bool {
|
|||||||
err := smtp.SendMail(host+":"+port, auth, username, send_to, msg)
|
err := smtp.SendMail(host+":"+port, auth, username, send_to, msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Log(err)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -183,7 +183,6 @@ func PutFileStrContent(path, content string) bool {
|
|||||||
// Log(path)
|
// Log(path)
|
||||||
|
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
Log(err1)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -400,9 +400,6 @@ func FixFilename(filename string) string {
|
|||||||
func IsValidTime(t time.Time) bool {
|
func IsValidTime(t time.Time) bool {
|
||||||
if t.Year() > 20 {
|
if t.Year() > 20 {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
Log("------")
|
|
||||||
Log(t)
|
|
||||||
Log(now)
|
|
||||||
if t.Before(now) {
|
if t.Before(now) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -178,13 +178,13 @@ func init() {
|
|||||||
|
|
||||||
func I18nFilter(c *revel.Controller, fc []revel.Filter) {
|
func I18nFilter(c *revel.Controller, fc []revel.Filter) {
|
||||||
if foundCookie, cookieValue := hasLocaleCookie(c.Request); foundCookie {
|
if foundCookie, cookieValue := hasLocaleCookie(c.Request); foundCookie {
|
||||||
revel.TRACE.Printf("Found locale cookie value: %s", cookieValue)
|
// revel.TRACE.Printf("Found locale cookie value: %s", cookieValue)
|
||||||
setCurrentLocaleControllerArguments(c, cookieValue)
|
setCurrentLocaleControllerArguments(c, cookieValue)
|
||||||
} else if foundHeader, headerValue := hasAcceptLanguageHeader(c.Request); foundHeader {
|
} else if foundHeader, headerValue := hasAcceptLanguageHeader(c.Request); foundHeader {
|
||||||
revel.TRACE.Printf("Found Accept-Language header value: %s", headerValue)
|
// revel.TRACE.Printf("Found Accept-Language header value: %s", headerValue)
|
||||||
setCurrentLocaleControllerArguments(c, headerValue)
|
setCurrentLocaleControllerArguments(c, headerValue)
|
||||||
} else {
|
} else {
|
||||||
revel.TRACE.Println("Unable to find locale in cookie or header, using empty string")
|
// revel.TRACE.Println("Unable to find locale in cookie or header, using empty string")
|
||||||
setCurrentLocaleControllerArguments(c, "")
|
setCurrentLocaleControllerArguments(c, "")
|
||||||
}
|
}
|
||||||
fc[0](c, fc[1:])
|
fc[0](c, fc[1:])
|
||||||
@ -215,7 +215,7 @@ func hasLocaleCookie(request *revel.Request) (bool, string) {
|
|||||||
if cookie, error := request.Cookie(name); error == nil {
|
if cookie, error := request.Cookie(name); error == nil {
|
||||||
return true, cookie.GetValue()
|
return true, cookie.GetValue()
|
||||||
} else {
|
} else {
|
||||||
revel.TRACE.Printf("Unable to read locale cookie with name '%s': %s", name, error.Error())
|
// revel.TRACE.Printf("Unable to read locale cookie with name '%s': %s", name, error.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ func WriteUrl(url string, toPath string) (length int64, newFilename, path string
|
|||||||
func GetContent(url string) (content []byte, err error) {
|
func GetContent(url string) (content []byte, err error) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
resp, err = http.Get(url)
|
resp, err = http.Get(url)
|
||||||
Log(err)
|
|
||||||
if resp != nil && resp.Body != nil {
|
if resp != nil && resp.Body != nil {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
} else {
|
} else {
|
||||||
@ -65,7 +64,6 @@ func GetContent(url string) (content []byte, err error) {
|
|||||||
var buf []byte
|
var buf []byte
|
||||||
buf, err = ioutil.ReadAll(resp.Body)
|
buf, err = ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Log(err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package route
|
|||||||
import (
|
import (
|
||||||
"github.com/leanote/leanote/app/db"
|
"github.com/leanote/leanote/app/db"
|
||||||
"github.com/revel/revel"
|
"github.com/revel/revel"
|
||||||
. "github.com/leanote/leanote/app/lea"
|
// . "github.com/leanote/leanote/app/lea"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -25,7 +25,7 @@ func RouterFilter(c *revel.Controller, fc []revel.Filter) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Log("---------" + route.Action + " " + path)
|
// Log("---------" + route.Action + " " + path)
|
||||||
|
|
||||||
// The route may want to explicitly return a 404.
|
// The route may want to explicitly return a 404.
|
||||||
if route.Action == "404" {
|
if route.Action == "404" {
|
||||||
|
@ -1106,7 +1106,7 @@ func (this *NoteService) FixContent(content string, isMarkdown bool) string {
|
|||||||
reg2, _ = regexp.Compile("<a(?:[^>]+?)(" + eachPattern["src"] + `=['"]*` + baseUrlPattern + eachPattern["middle"] + `\?` + eachPattern["param"] + `=([a-z0-9A-Z]{24})["']*)[^>]*>`)
|
reg2, _ = regexp.Compile("<a(?:[^>]+?)(" + eachPattern["src"] + `=['"]*` + baseUrlPattern + eachPattern["middle"] + `\?` + eachPattern["param"] + `=([a-z0-9A-Z]{24})["']*)[^>]*>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(reg2)
|
// Log(reg2)
|
||||||
|
|
||||||
content = reg.ReplaceAllStringFunc(content, func(str string) string {
|
content = reg.ReplaceAllStringFunc(content, func(str string) string {
|
||||||
// str=这样的
|
// str=这样的
|
||||||
|
@ -360,8 +360,8 @@ func (this *NotebookService) DragNotebooks(userId string, curNotebookId string,
|
|||||||
func (this *NotebookService) ReCountNotebookNumberNotes(notebookId string) bool {
|
func (this *NotebookService) ReCountNotebookNumberNotes(notebookId string) bool {
|
||||||
notebookIdO := bson.ObjectIdHex(notebookId)
|
notebookIdO := bson.ObjectIdHex(notebookId)
|
||||||
count := db.Count(db.Notes, bson.M{"NotebookId": notebookIdO, "IsTrash": false, "IsDeleted": false})
|
count := db.Count(db.Notes, bson.M{"NotebookId": notebookIdO, "IsTrash": false, "IsDeleted": false})
|
||||||
Log(count)
|
// Log(count)
|
||||||
Log(notebookId)
|
// Log(notebookId)
|
||||||
return db.UpdateByQField(db.Notebooks, bson.M{"_id": notebookIdO}, "NumberNotes", count)
|
return db.UpdateByQField(db.Notebooks, bson.M{"_id": notebookIdO}, "NumberNotes", count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"github.com/leanote/leanote/app/db"
|
"github.com/leanote/leanote/app/db"
|
||||||
"github.com/leanote/leanote/app/info"
|
"github.com/leanote/leanote/app/info"
|
||||||
. "github.com/leanote/leanote/app/lea"
|
// . "github.com/leanote/leanote/app/lea"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
"time"
|
"time"
|
||||||
// "strings"
|
// "strings"
|
||||||
@ -66,10 +66,10 @@ func (this *SessionService) GetCaptcha(sessionId string) string {
|
|||||||
}
|
}
|
||||||
func (this *SessionService) SetCaptcha(sessionId, captcha string) bool {
|
func (this *SessionService) SetCaptcha(sessionId, captcha string) bool {
|
||||||
this.Get(sessionId)
|
this.Get(sessionId)
|
||||||
Log(sessionId)
|
// Log(sessionId)
|
||||||
Log(captcha)
|
// Log(captcha)
|
||||||
ok := this.Update(sessionId, "Captcha", captcha)
|
ok := this.Update(sessionId, "Captcha", captcha)
|
||||||
Log(ok)
|
// Log(ok)
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ func (this *ThemeService) UpdateTplContent(userId, themeId, filename, content st
|
|||||||
basePath := this.GetThemeAbsolutePath(userId, themeId)
|
basePath := this.GetThemeAbsolutePath(userId, themeId)
|
||||||
path := basePath + "/" + filename
|
path := basePath + "/" + filename
|
||||||
if strings.Contains(filename, ".html") {
|
if strings.Contains(filename, ".html") {
|
||||||
Log(">>")
|
// Log(">>")
|
||||||
if ok, msg = this.ValidateTheme(basePath, filename, content); ok {
|
if ok, msg = this.ValidateTheme(basePath, filename, content); ok {
|
||||||
// 模板
|
// 模板
|
||||||
if ok, msg = this.mustTpl(filename, content); ok {
|
if ok, msg = this.mustTpl(filename, content); ok {
|
||||||
@ -359,7 +359,7 @@ func (this *ThemeService) mustTpl(filename, content string) (ok bool, msg string
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
ok = false
|
ok = false
|
||||||
Log(err)
|
// Log(err)
|
||||||
msg = fmt.Sprintf("%v", err)
|
msg = fmt.Sprintf("%v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -405,7 +405,7 @@ func (this *ThemeService) ExportTheme(userId, themeId string) (ok bool, path str
|
|||||||
theme := this.GetThemeById(themeId)
|
theme := this.GetThemeById(themeId)
|
||||||
// 打包
|
// 打包
|
||||||
// 验证路径, 别把整个项目打包了
|
// 验证路径, 别把整个项目打包了
|
||||||
Log(theme.Path)
|
// Log(theme.Path)
|
||||||
if theme.Path == "" ||
|
if theme.Path == "" ||
|
||||||
(!strings.HasPrefix(theme.Path, "public/upload") &&
|
(!strings.HasPrefix(theme.Path, "public/upload") &&
|
||||||
!strings.HasPrefix(theme.Path, "public/blog/themes")) ||
|
!strings.HasPrefix(theme.Path, "public/blog/themes")) ||
|
||||||
@ -417,12 +417,12 @@ func (this *ThemeService) ExportTheme(userId, themeId string) (ok bool, path str
|
|||||||
targetPath := revel.BasePath + "/public/upload/" + userId + "/tmp"
|
targetPath := revel.BasePath + "/public/upload/" + userId + "/tmp"
|
||||||
err := os.MkdirAll(targetPath, 0755)
|
err := os.MkdirAll(targetPath, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Log(err)
|
// Log(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
targetName := targetPath + "/" + theme.Name + ".zip"
|
targetName := targetPath + "/" + theme.Name + ".zip"
|
||||||
Log(sourcePath)
|
// Log(sourcePath)
|
||||||
Log(targetName)
|
// Log(targetName)
|
||||||
ok = archive.Zip(sourcePath, targetName)
|
ok = archive.Zip(sourcePath, targetName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@ -445,7 +445,7 @@ func (this *ThemeService) ImportTheme(userId, path string) (ok bool, msg string)
|
|||||||
}
|
}
|
||||||
if ok, msg = archive.Unzip(path, targetPath); !ok {
|
if ok, msg = archive.Unzip(path, targetPath); !ok {
|
||||||
DeleteFile(targetPath)
|
DeleteFile(targetPath)
|
||||||
Log("oh no")
|
// Log("oh no")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,8 +558,8 @@ func (this *ThemeService) InstallTheme(userId, themeId string) (ok bool) {
|
|||||||
// 验证主题是否全法, 存在循环引用?
|
// 验证主题是否全法, 存在循环引用?
|
||||||
// filename, newContent 表示在修改模板时要判断模板修改时是否有错误
|
// filename, newContent 表示在修改模板时要判断模板修改时是否有错误
|
||||||
func (this *ThemeService) ValidateTheme(path string, filename, newContent string) (ok bool, msg string) {
|
func (this *ThemeService) ValidateTheme(path string, filename, newContent string) (ok bool, msg string) {
|
||||||
Log("theme Path")
|
// Log("theme Path")
|
||||||
Log(path)
|
// Log(path)
|
||||||
// 建立一个有向图
|
// 建立一个有向图
|
||||||
// 将该path下的所有文件提出, 得到文件的引用情况
|
// 将该path下的所有文件提出, 得到文件的引用情况
|
||||||
files := ListDir(path)
|
files := ListDir(path)
|
||||||
@ -613,9 +613,9 @@ func (this *ThemeService) ValidateTheme(path string, filename, newContent string
|
|||||||
for _, includes := range finds {
|
for _, includes := range finds {
|
||||||
include := includes[1]
|
include := includes[1]
|
||||||
includeIndex, has := fileIndexMap[include]
|
includeIndex, has := fileIndexMap[include]
|
||||||
Log(includeIndex)
|
// Log(includeIndex)
|
||||||
Log("??")
|
// Log("??")
|
||||||
Log(has)
|
// Log(has)
|
||||||
if has {
|
if has {
|
||||||
vector[thisIndex][includeIndex] = 1
|
vector[thisIndex][includeIndex] = 1
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ func (this *UserService) GetAllUserByFilter(userFilterEmail, userFilterWhiteList
|
|||||||
users := []info.User{}
|
users := []info.User{}
|
||||||
q := db.Users.Find(query)
|
q := db.Users.Find(query)
|
||||||
q.All(&users)
|
q.All(&users)
|
||||||
Log(len(users))
|
// Log(len(users))
|
||||||
|
|
||||||
return users
|
return users
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,8 @@ GET /upload/*filepath Static.Serve("public/upload")
|
|||||||
# the prefix of member's controllername is "Member"
|
# the prefix of member's controllername is "Member"
|
||||||
* /member MemberIndex.Index
|
* /member MemberIndex.Index
|
||||||
* /member/index MemberIndex.Index
|
* /member/index MemberIndex.Index
|
||||||
|
|
||||||
|
# 不知道为什么, group就是不行 member/blog可以
|
||||||
* /member/group/index MemberGroup.Index
|
* /member/group/index MemberGroup.Index
|
||||||
* /member/group/addGroup MemberGroup.AddGroup
|
* /member/group/addGroup MemberGroup.AddGroup
|
||||||
* /member/group/updateGroupTitle MemberGroup.UpdateGroupTitle
|
* /member/group/updateGroupTitle MemberGroup.UpdateGroupTitle
|
||||||
|
Reference in New Issue
Block a user