register open option

This commit is contained in:
life committed 2014-05-07 20:31:30 +08:00
1 parent d5928b06cf
commit 4a6381bf5d
17 files changed
+350 -311

No files matched your search

+12 -1
View File
@@ -18,6 +18,8 @@ func (c Auth) Login(email string) revel.Result {
c.RenderArgs["title"] = c.Message("login")
c.RenderArgs["subTitle"] = c.Message("login")
c.RenderArgs["email"] = email
c.RenderArgs["openRegister"] = openRegister
if c.Has("demo") {
c.RenderArgs["demo"] = true
c.RenderArgs["email"] = "demo@leanote.com"
@@ -38,8 +40,9 @@ func (c Auth) DoLogin(email, pwd string) revel.Result {
// 注销
func (c Auth) Logout() revel.Result {
c.ClearSession()
return c.Redirect("login")
return c.Redirect("/login")
}
// 体验一下
func (c Auth) Demo() revel.Result {
c.DoLogin("demo@leanote.com", "demo@leanote.com")
@@ -49,11 +52,19 @@ func (c Auth) Demo() revel.Result {
//--------
// 注册
func (c Auth) Register() revel.Result {
if !openRegister {
return c.Redirect("/index")
}
c.RenderArgs["title"] = c.Message("register")
c.RenderArgs["subTitle"] = c.Message("register")
return c.RenderTemplate("home/register.html")
}
func (c Auth) DoRegister(email, pwd string) revel.Result {
if !openRegister {
return c.Redirect("/index")
}
re := info.NewRe();
if email == "" {
+3 -2
View File
@@ -14,8 +14,9 @@ type Index struct {
// leanote展示页, 没有登录的, 或已登录明确要进该页的
func (c Index) Index() revel.Result {
c.SetUserInfo();
c.RenderArgs["title"] = "leanote";
c.SetUserInfo()
c.RenderArgs["title"] = "leanote"
c.RenderArgs["openRegister"] = openRegister
c.SetLocale()
return c.RenderTemplate("home/index.html");
+2
View File
@@ -32,6 +32,8 @@ func (c Note) Index() revel.Result {
return c.Redirect("/login")
}
c.RenderArgs["openRegister"] = openRegister
// 已登录了, 那么得到所有信息
notebooks := notebookService.GetNotebooks(userId)
shareNotebooks, sharedUserInfos := shareService.GetShareNotebooks(userId)
+3
View File
@@ -27,6 +27,7 @@ var pageSize = 1000
var defaultSortField = "UpdatedTime"
var leanoteUserId = "52d26b4e99c37b609a000001"
var siteUrl = "http://leanote.com"
var openRegister = true
// 拦截器
// 不需要拦截的url
@@ -72,6 +73,7 @@ func AuthInterceptor(c *revel.Controller) revel.Result {
var controller = strings.Title(c.Name)
var method = strings.Title(c.MethodName)
// 是否需要验证?
if !needValidate(controller, method) {
return nil
@@ -122,5 +124,6 @@ func init() {
revel.OnAppStart(func() {
leanoteUserId, _ = revel.Config.String("adminUsername")
siteUrl, _ = revel.Config.String("site.url")
openRegister, _ = revel.Config.Bool("register.open")
})
}
+171 -171
View File
@@ -75,129 +75,82 @@ func (_ tStatic) ServeModule(
}
type tBlog struct {}
var Blog tBlog
type tFile struct {}
var File tFile
func (_ tBlog) SetNote2Blog(
noteId string,
isBlog bool,
isTop bool,
func (_ tFile) UploadImage(
renderHtml string,
) string {
args := make(map[string]string)
revel.Unbind(args, "noteId", noteId)
revel.Unbind(args, "isBlog", isBlog)
revel.Unbind(args, "isTop", isTop)
return revel.MainRouter.Reverse("Blog.SetNote2Blog", args).Url
revel.Unbind(args, "renderHtml", renderHtml)
return revel.MainRouter.Reverse("File.UploadImage", args).Url
}
func (_ tBlog) SetNotebook2Blog(
notebookId string,
isBlog bool,
func (_ tFile) UploadBlogLogo(
) string {
args := make(map[string]string)
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "isBlog", isBlog)
return revel.MainRouter.Reverse("Blog.SetNotebook2Blog", args).Url
return revel.MainRouter.Reverse("File.UploadBlogLogo", args).Url
}
func (_ tBlog) Index(
userId string,
func (_ tFile) UploadImageJson(
renderHtml string,
) string {
args := make(map[string]string)
revel.Unbind(args, "renderHtml", renderHtml)
return revel.MainRouter.Reverse("File.UploadImageJson", args).Url
}
type tNotebook struct {}
var Notebook tNotebook
func (_ tNotebook) Index(
notebook interface{},
i int,
name string,
) string {
args := make(map[string]string)
revel.Unbind(args, "notebook", notebook)
revel.Unbind(args, "i", i)
revel.Unbind(args, "name", name)
return revel.MainRouter.Reverse("Notebook.Index", args).Url
}
func (_ tNotebook) DeleteNotebook(
notebookId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "userId", userId)
revel.Unbind(args, "notebookId", notebookId)
return revel.MainRouter.Reverse("Blog.Index", args).Url
return revel.MainRouter.Reverse("Notebook.DeleteNotebook", args).Url
}
func (_ tBlog) View(
noteId string,
func (_ tNotebook) AddNotebook(
notebookId string,
title string,
) string {
args := make(map[string]string)
revel.Unbind(args, "noteId", noteId)
return revel.MainRouter.Reverse("Blog.View", args).Url
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "title", title)
return revel.MainRouter.Reverse("Notebook.AddNotebook", args).Url
}
func (_ tBlog) SearchBlog(
userId string,
key string,
func (_ tNotebook) UpdateNotebookTitle(
notebookId string,
title string,
) string {
args := make(map[string]string)
revel.Unbind(args, "userId", userId)
revel.Unbind(args, "key", key)
return revel.MainRouter.Reverse("Blog.SearchBlog", args).Url
}
func (_ tBlog) Set(
) string {
args := make(map[string]string)
return revel.MainRouter.Reverse("Blog.Set", args).Url
}
func (_ tBlog) SetUserBlogBase(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogBase", args).Url
}
func (_ tBlog) SetUserBlogComment(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogComment", args).Url
}
func (_ tBlog) SetUserBlogStyle(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogStyle", args).Url
}
func (_ tBlog) AboutMe(
userId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "userId", userId)
return revel.MainRouter.Reverse("Blog.AboutMe", args).Url
}
type tIndex struct {}
var Index tIndex
func (_ tIndex) Index(
) string {
args := make(map[string]string)
return revel.MainRouter.Reverse("Index.Index", args).Url
}
func (_ tIndex) Suggestion(
addr string,
suggestion string,
) string {
args := make(map[string]string)
revel.Unbind(args, "addr", addr)
revel.Unbind(args, "suggestion", suggestion)
return revel.MainRouter.Reverse("Index.Suggestion", args).Url
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "title", title)
return revel.MainRouter.Reverse("Notebook.UpdateNotebookTitle", args).Url
}
@@ -331,20 +284,6 @@ func (_ tNote) Html2Image(
}
type tOauth struct {}
var Oauth tOauth
func (_ tOauth) GithubCallback(
code string,
) string {
args := make(map[string]string)
revel.Unbind(args, "code", code)
return revel.MainRouter.Reverse("Oauth.GithubCallback", args).Url
}
type tShare struct {}
var Share tShare
@@ -698,33 +637,129 @@ func (_ tAuth) FindPasswordUpdate(
}
type tFile struct {}
var File tFile
type tBlog struct {}
var Blog tBlog
func (_ tFile) UploadImage(
renderHtml string,
func (_ tBlog) SetNote2Blog(
noteId string,
isBlog bool,
isTop bool,
) string {
args := make(map[string]string)
revel.Unbind(args, "renderHtml", renderHtml)
return revel.MainRouter.Reverse("File.UploadImage", args).Url
revel.Unbind(args, "noteId", noteId)
revel.Unbind(args, "isBlog", isBlog)
revel.Unbind(args, "isTop", isTop)
return revel.MainRouter.Reverse("Blog.SetNote2Blog", args).Url
}
func (_ tFile) UploadBlogLogo(
func (_ tBlog) SetNotebook2Blog(
notebookId string,
isBlog bool,
) string {
args := make(map[string]string)
return revel.MainRouter.Reverse("File.UploadBlogLogo", args).Url
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "isBlog", isBlog)
return revel.MainRouter.Reverse("Blog.SetNotebook2Blog", args).Url
}
func (_ tFile) UploadImageJson(
renderHtml string,
func (_ tBlog) Index(
userId string,
notebookId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "renderHtml", renderHtml)
return revel.MainRouter.Reverse("File.UploadImageJson", args).Url
revel.Unbind(args, "userId", userId)
revel.Unbind(args, "notebookId", notebookId)
return revel.MainRouter.Reverse("Blog.Index", args).Url
}
func (_ tBlog) View(
noteId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "noteId", noteId)
return revel.MainRouter.Reverse("Blog.View", args).Url
}
func (_ tBlog) SearchBlog(
userId string,
key string,
) string {
args := make(map[string]string)
revel.Unbind(args, "userId", userId)
revel.Unbind(args, "key", key)
return revel.MainRouter.Reverse("Blog.SearchBlog", args).Url
}
func (_ tBlog) Set(
) string {
args := make(map[string]string)
return revel.MainRouter.Reverse("Blog.Set", args).Url
}
func (_ tBlog) SetUserBlogBase(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogBase", args).Url
}
func (_ tBlog) SetUserBlogComment(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogComment", args).Url
}
func (_ tBlog) SetUserBlogStyle(
userBlog interface{},
) string {
args := make(map[string]string)
revel.Unbind(args, "userBlog", userBlog)
return revel.MainRouter.Reverse("Blog.SetUserBlogStyle", args).Url
}
func (_ tBlog) AboutMe(
userId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "userId", userId)
return revel.MainRouter.Reverse("Blog.AboutMe", args).Url
}
type tIndex struct {}
var Index tIndex
func (_ tIndex) Index(
) string {
args := make(map[string]string)
return revel.MainRouter.Reverse("Index.Index", args).Url
}
func (_ tIndex) Suggestion(
addr string,
suggestion string,
) string {
args := make(map[string]string)
revel.Unbind(args, "addr", addr)
revel.Unbind(args, "suggestion", suggestion)
return revel.MainRouter.Reverse("Index.Suggestion", args).Url
}
@@ -747,55 +782,6 @@ func (_ tMobile) Logout(
}
type tNotebook struct {}
var Notebook tNotebook
func (_ tNotebook) Index(
notebook interface{},
i int,
name string,
) string {
args := make(map[string]string)
revel.Unbind(args, "notebook", notebook)
revel.Unbind(args, "i", i)
revel.Unbind(args, "name", name)
return revel.MainRouter.Reverse("Notebook.Index", args).Url
}
func (_ tNotebook) DeleteNotebook(
notebookId string,
) string {
args := make(map[string]string)
revel.Unbind(args, "notebookId", notebookId)
return revel.MainRouter.Reverse("Notebook.DeleteNotebook", args).Url
}
func (_ tNotebook) AddNotebook(
notebookId string,
title string,
) string {
args := make(map[string]string)
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "title", title)
return revel.MainRouter.Reverse("Notebook.AddNotebook", args).Url
}
func (_ tNotebook) UpdateNotebookTitle(
notebookId string,
title string,
) string {
args := make(map[string]string)
revel.Unbind(args, "notebookId", notebookId)
revel.Unbind(args, "title", title)
return revel.MainRouter.Reverse("Notebook.UpdateNotebookTitle", args).Url
}
type tNoteContentHistory struct {}
var NoteContentHistory tNoteContentHistory
@@ -810,3 +796,17 @@ func (_ tNoteContentHistory) ListHistories(
}
type tOauth struct {}
var Oauth tOauth
func (_ tOauth) GithubCallback(
code string,
) string {
args := make(map[string]string)
revel.Unbind(args, "code", code)
return revel.MainRouter.Reverse("Oauth.GithubCallback", args).Url
}
+8 -4
View File
@@ -4,6 +4,7 @@ import (
"labix.org/v2/mgo/bson"
// "github.com/leanote/leanote/app/db"
"github.com/leanote/leanote/app/info"
"github.com/revel/revel"
. "github.com/leanote/leanote/app/lea"
"fmt"
)
@@ -53,11 +54,13 @@ func (this *AuthService) register(user info.User) (bool, string) {
}
email := user.Email
// 添加leanote -> 该用户的共享
leanoteUserId := "5368c1aa99c37b029d000001";
nk1 := "5368c1aa99c37b029d000002" // leanote
welcomeNoteId := "5368c1b919807a6f95000000" // 欢迎来到leanote
// 添加leanote -> 该用户的共享
leanoteUserId, _ := revel.Config.String("register.sharedUserId"); // "5368c1aa99c37b029d000001";
nk1, _ := revel.Config.String("register.sharedUserShareNotebookId"); // 5368c1aa99c37b029d000002" // leanote
welcomeNoteId, _ := revel.Config.String("register.welcomeNoteId") // "5368c1b919807a6f95000000" // 欢迎来到leanote
if leanoteUserId != "" && nk1 != "" && welcomeNoteId != "" {
shareService.AddShareNotebook(nk1, 0, leanoteUserId, email);
shareService.AddShareNote(welcomeNoteId, 0, leanoteUserId, email);
@@ -67,6 +70,7 @@ func (this *AuthService) register(user info.User) (bool, string) {
// 公开为博客
noteUpdate := bson.M{"IsBlog": true}
noteService.UpdateNote(user.UserId.Hex(), user.UserId.Hex(), note.NoteId.Hex(), noteUpdate)
}
//---------------
// 添加一条userBlog
+124 -124
View File
@@ -102,88 +102,27 @@ func main() {
})
revel.RegisterController((*controllers.Blog)(nil),
revel.RegisterController((*controllers.File)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "SetNote2Blog",
Name: "UploadImage",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "isBlog", Type: reflect.TypeOf((*bool)(nil)) },
&revel.MethodArg{Name: "isTop", Type: reflect.TypeOf((*bool)(nil)) },
&revel.MethodArg{Name: "renderHtml", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetNotebook2Blog",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "isBlog", Type: reflect.TypeOf((*bool)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Index",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "View",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SearchBlog",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Set",
Name: "UploadBlogLogo",
Args: []*revel.MethodArg{
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetUserBlogBase",
Name: "UploadImageJson",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogBase)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetUserBlogComment",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogComment)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetUserBlogStyle",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogStyle)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "AboutMe",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "renderHtml", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
@@ -191,20 +130,40 @@ func main() {
})
revel.RegisterController((*controllers.Index)(nil),
revel.RegisterController((*controllers.Notebook)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "Index",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebook", Type: reflect.TypeOf((*info.Notebook)(nil)) },
&revel.MethodArg{Name: "i", Type: reflect.TypeOf((*int)(nil)) },
&revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Suggestion",
Name: "DeleteNotebook",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "addr", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "suggestion", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "AddNotebook",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "UpdateNotebookTitle",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
@@ -325,19 +284,6 @@ func main() {
})
revel.RegisterController((*controllers.Oauth)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "GithubCallback",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "code", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
})
revel.RegisterController((*controllers.Share)(nil),
[]*revel.MethodType{
&revel.MethodType{
@@ -641,27 +587,109 @@ func main() {
})
revel.RegisterController((*controllers.File)(nil),
revel.RegisterController((*controllers.Blog)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "UploadImage",
Name: "SetNote2Blog",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "renderHtml", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "isBlog", Type: reflect.TypeOf((*bool)(nil)) },
&revel.MethodArg{Name: "isTop", Type: reflect.TypeOf((*bool)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "UploadBlogLogo",
Name: "SetNotebook2Blog",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "isBlog", Type: reflect.TypeOf((*bool)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Index",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "View",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SearchBlog",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Set",
Args: []*revel.MethodArg{
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "UploadImageJson",
Name: "SetUserBlogBase",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "renderHtml", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogBase)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetUserBlogComment",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogComment)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "SetUserBlogStyle",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userBlog", Type: reflect.TypeOf((*info.UserBlogStyle)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "AboutMe",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
})
revel.RegisterController((*controllers.Index)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "Index",
Args: []*revel.MethodArg{
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "Suggestion",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "addr", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "suggestion", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
@@ -688,40 +716,12 @@ func main() {
})
revel.RegisterController((*controllers.Notebook)(nil),
revel.RegisterController((*controllers.NoteContentHistory)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "Index",
Name: "ListHistories",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebook", Type: reflect.TypeOf((*info.Notebook)(nil)) },
&revel.MethodArg{Name: "i", Type: reflect.TypeOf((*int)(nil)) },
&revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "DeleteNotebook",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "AddNotebook",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
},
&revel.MethodType{
Name: "UpdateNotebookTitle",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
@@ -729,12 +729,12 @@ func main() {
})
revel.RegisterController((*controllers.NoteContentHistory)(nil),
revel.RegisterController((*controllers.Oauth)(nil),
[]*revel.MethodType{
&revel.MethodType{
Name: "ListHistories",
Name: "GithubCallback",
Args: []*revel.MethodArg{
&revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) },
&revel.MethodArg{Name: "code", Type: reflect.TypeOf((*string)(nil)) },
},
RenderArgNames: map[int][]string{
},
-5
View File
@@ -3,11 +3,6 @@
{{else}}
{{template "home/header_box.html" .}}
<style>
html, body {
height: 100%;
}
</style>
<section id="box">
<div>
<h1>error-404</h1>
+2
View File
@@ -39,8 +39,10 @@ function log(o) {
<a href="/logout">{{msg . "logout"}}</a>
{{else}}
<a href="/login">{{msg . "login"}}</a>
{{if .openRegister}}
<a href="/register" class="btn-register">{{msg . "register"}}</a>
{{end}}
{{end}}
</div>
<ul id="blogNav" class="pull-right">
+2
View File
@@ -12,12 +12,14 @@
&nbsp;
&nbsp;
<a class="btn btn-default" href="/demo">Try it</a>
{{if .openRegister}}
&nbsp;
&nbsp;
OR
&nbsp;
&nbsp;
<a class="btn btn-default" href="/register">{{msg . "register"}}</a>
{{end}}
</div>
</div>
+5 -1
View File
@@ -25,13 +25,17 @@
<button id="loginBtn" class="btn btn-success" style="width: 100%">{{msg . "login"}}</button>
<br />
<a href="/findPassword">{{msg . "forgetPassword"}}</a>
{{if .openRegister}}
<br />
<a href="/register">{{msg . "register"}}</a> {{msg . "or"}}
<a href="/register">{{msg . "register"}}</a>
{{msg . "or"}}
<a href="/demo">{{msg . "try"}}</a>
<div style="border-top: 1px dashed #666;margin:2px 0">
{{msg . "3th"}}: <a id="github">github<i class="fa fa-github"></i></a>
<span id="thirdLoginLoading" style="display: none"> <img src="/images/loading-a-20-2.gif" />正在登录...</span>
</div>
{{end}}
</td>
</tr>
</table>
+3
View File
@@ -97,11 +97,14 @@ function log(o) {
<div class="pull-left" style="line-height: 40px; margin-top: 10px; margin-left: 10px;" id="leanoteMsg">
<span id="msg" style="display: inline-block;"></span>
<img id="loading" style="visibility: hidden" src="/images/loading-a-20.gif" />
{{if .openRegister}}
{{if eq .userInfo.Email "demo@leanote.com"}}
<span>
{{msg . "demoRegister"}}
</span>
{{end}}
{{end}}
</div>
<!--
+3
View File
@@ -97,11 +97,14 @@ function log(o) {
<div class="pull-left" style="line-height: 40px; margin-top: 10px; margin-left: 10px;" id="leanoteMsg">
<span id="msg" style="display: inline-block;"></span>
<img id="loading" style="visibility: hidden" src="/images/loading-a-20.gif" />
{{if .openRegister}}
{{if eq .userInfo.Email "demo@leanote.com"}}
<span>
{{msg . "demoRegister"}}
</span>
{{end}}
{{end}}
</div>
<!--
+9
View File
@@ -4,6 +4,9 @@
http.port=80
# open for register?
open=true
site.url=http://localhost
# the administrator username
@@ -25,6 +28,12 @@ email.port=25
email.username=
email.password=
# open for register?
register.open=true
register.sharedUserId=5368c1aa99c37b029d000001
register.sharedUserShareNotebookId=5368c1aa99c37b029d000002
register.welcomeNoteId=5368c1b919807a6f95000000
#--------------------------------
# revel config
# for dev
+1 -1
View File
@@ -1,2 +1,2 @@
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{factory(jQuery)}})(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{s=decodeURIComponent(s.replace(pluses," "));return config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==="number"){var days=options.expires,t=options.expires=new Date;t.setTime(+t+days*864e5)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}var result=key?undefined:{};var cookies=document.cookie?document.cookie.split("; "):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split("=");var name=decode(parts.shift());var cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie}}return result};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false}$.cookie(key,"",$.extend({},options,{expires:-1}));return!$.cookie(key)}});if(typeof jQuery==="undefined"){throw new Error("Bootstrap requires jQuery")}+function($){"use strict";function transitionEnd(){var el=document.createElement("bootstrap");var transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var name in transEndEventNames){if(el.style[name]!==undefined){return{end:transEndEventNames[name]}}}}$.fn.emulateTransitionEnd=function(duration){var called=false,$el=this;$(this).one($.support.transition.end,function(){called=true});var callback=function(){if(!called)$($el).trigger($.support.transition.end)};setTimeout(callback,duration);return this};$(function(){$.support.transition=transitionEnd()})}(jQuery);+function($){"use strict";var dismiss='[data-dismiss="alert"]';var Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){var $this=$(this);var selector=$this.attr("data-target");if(!selector){selector=$this.attr("href");selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")}var $parent=$(selector);if(e)e.preventDefault();if(!$parent.length){$parent=$this.hasClass("alert")?$this:$this.parent()}$parent.trigger(e=$.Event("close.bs.alert"));if(e.isDefaultPrevented())return;$parent.removeClass("in");function removeElement(){$parent.trigger("closed.bs.alert").remove()}$.support.transition&&$parent.hasClass("fade")?$parent.one($.support.transition.end,removeElement).emulateTransitionEnd(150):removeElement()};var old=$.fn.alert;$.fn.alert=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.alert");if(!data)$this.data("bs.alert",data=new Alert(this));if(typeof option=="string")data[option].call($this)})};$.fn.alert.Constructor=Alert;$.fn.alert.noConflict=function(){$.fn.alert=old;return this};$(document).on("click.bs.alert.data-api",dismiss,Alert.prototype.close)}(jQuery);+function($){"use strict";var Button=function(element,options){this.$element=$(element);this.options=$.extend({},Button.DEFAULTS,options)};Button.DEFAULTS={loadingText:"loading..."};Button.prototype.setState=function(state){var d="disabled";var $el=this.$element;var val=$el.is("input")?"val":"html";var data=$el.data();state=state+"Text";if(!data.resetText)$el.data("resetText",$el[val]());$el[val](data[state]||this.options[state]);setTimeout(function(){state=="loadingText"?$el.addClass(d).attr(d,d):$el.removeClass(d).removeAttr(d)},0)};Button.prototype.toggle=function(){var $parent=this.$element.closest('[data-toggle="buttons"]');if($parent.length){var $input=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");if($input.prop("type")==="radio")$parent.find(".active").removeClass("active")}this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.button");var options=typeof option=="object"&&option;if(!data)$this.data("bs.button",data=new Button(this,options));if(option=="toggle")data.toggle();else if(option)data.setState(option)})};$.fn.button.Constructor=Button;$.fn.button.noConflict=function(){$.fn.button=old;return this};$(document).on("click.bs.button.data-api","[data-toggle^=button]",function(e){var $btn=$(Line truncated
})};$.fn.tab.Constructor=Tab;$.fn.tab.noConflict=function(){$.fn.tab=old;return this};$(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault();$(this).tab("show")})}(jQuery);+function($){"use strict";var Affix=function(element,options){this.options=$.extend({},Affix.DEFAULTS,options);this.$window=$(window).on("scroll.bs.affix.data-api",$.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",$.proxy(this.checkPositionWithEventLoop,this));this.$element=$(element);this.affixed=this.unpin=null;this.checkPosition()};Affix.RESET="affix affix-top affix-bottom";Affix.DEFAULTS={offset:0};Affix.prototype.checkPositionWithEventLoop=function(){setTimeout($.proxy(this.checkPosition,this),1)};Affix.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var scrollHeight=$(document).height();var scrollTop=this.$window.scrollTop();var position=this.$element.offset();var offset=this.options.offset;var offsetTop=offset.top;var offsetBottom=offset.bottom;if(typeof offset!="object")offsetBottom=offsetTop=offset;if(typeof offsetTop=="function")offsetTop=offset.top();if(typeof offsetBottom=="function")offsetBottom=offset.bottom();var affix=this.unpin!=null&&scrollTop+this.unpin<=position.top?false:offsetBottom!=null&&position.top+this.$element.height()>=scrollHeight-offsetBottom?"bottom":offsetTop!=null&&scrollTop<=offsetTop?"top":false;if(this.affixed===affix)return;if(this.unpin)this.$element.css("top","");this.affixed=affix;this.unpin=affix=="bottom"?position.top-scrollTop:null;this.$element.removeClass(Affix.RESET).addClass("affix"+(affix?"-"+affix:""));if(affix=="bottom"){this.$element.offset({top:document.body.offsetHeight-offsetBottom-this.$element.height()})}};var old=$.fn.affix;$.fn.affix=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.affix");var options=typeof option=="object"&&option;if(!data)$this.data("bs.affix",data=new Affix(this,options));if(typeof option=="string")data[option]()})};$.fn.affix.Constructor=Affix;$.fn.affix.noConflict=function(){$.fn.affix=old;return this};$(window).on("load",function(){$('[data-spy="affix"]').each(function(){var $spy=$(this);var data=$spy.data();data.offset=data.offset||{};if(data.offsetBottom)data.offset.bottom=data.offsetBottom;if(data.offsetTop)data.offset.top=data.offsetTop;$spy.affix(data)})})}(jQuery);var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failLine truncated
})};$.fn.tab.Constructor=Tab;$.fn.tab.noConflict=function(){$.fn.tab=old;return this};$(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault();$(this).tab("show")})}(jQuery);+function($){"use strict";var Affix=function(element,options){this.options=$.extend({},Affix.DEFAULTS,options);this.$window=$(window).on("scroll.bs.affix.data-api",$.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",$.proxy(this.checkPositionWithEventLoop,this));this.$element=$(element);this.affixed=this.unpin=null;this.checkPosition()};Affix.RESET="affix affix-top affix-bottom";Affix.DEFAULTS={offset:0};Affix.prototype.checkPositionWithEventLoop=function(){setTimeout($.proxy(this.checkPosition,this),1)};Affix.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var scrollHeight=$(document).height();var scrollTop=this.$window.scrollTop();var position=this.$element.offset();var offset=this.options.offset;var offsetTop=offset.top;var offsetBottom=offset.bottom;if(typeof offset!="object")offsetBottom=offsetTop=offset;if(typeof offsetTop=="function")offsetTop=offset.top();if(typeof offsetBottom=="function")offsetBottom=offset.bottom();var affix=this.unpin!=null&&scrollTop+this.unpin<=position.top?false:offsetBottom!=null&&position.top+this.$element.height()>=scrollHeight-offsetBottom?"bottom":offsetTop!=null&&scrollTop<=offsetTop?"top":false;if(this.affixed===affix)return;if(this.unpin)this.$element.css("top","");this.affixed=affix;this.unpin=affix=="bottom"?position.top-scrollTop:null;this.$element.removeClass(Affix.RESET).addClass("affix"+(affix?"-"+affix:""));if(affix=="bottom"){this.$element.offset({top:document.body.offsetHeight-offsetBottom-this.$element.height()})}};var old=$.fn.affix;$.fn.affix=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.affix");var options=typeof option=="object"&&option;if(!data)$this.data("bs.affix",data=new Affix(this,options));if(typeof option=="string")data[option]()})};$.fn.affix.Constructor=Affix;$.fn.affix.noConflict=function(){$.fn.affix=old;return this};$(window).on("load",function(){$('[data-spy="affix"]').each(function(){var $spy=$(this);var data=$spy.data();data.offset=data.offset||{};if(data.offsetBottom)data.offset.bottom=data.offsetBottom;if(data.offsetTop)data.offset.top=data.offsetTop;$spy.affix(data)})})}(jQuery);var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failLine truncated
+1 -1
View File
@@ -1 +1 @@
var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failureFunc,async){_ajax("POST",url,param,successFunc,failureFunc,async)}function ajaxPostJson(url,param,successFunc,failureFunc,async){log("-------------------ajaxPostJson:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({url:url,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:async,data:JSON.stringify(param),success:function(ret,stats){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function findParents(target,selector){if($(target).is(selector)){return $(target)}var parents=$(target).parents();for(var i=0;i<parents.length;++i){log(parents.eq(i));if(parents.eq(i).is(selector)){return parents.seq(i)}}return null}function switchEditor(isMarkdown){if(!isMarkdown){$("#editor").show();$("#mdEditor").css("z-index",1)}else{$("#mdEditor").css("z-index",3).show()}}var previewToken="<div style='display: none'>FORTOKEN</div>";function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(!isMarkdown){$("#editorContent").html(content);var editor=tinymce.activeEditor;if(editor){editor.setContent(content);editor.undoManager.clear()}else{setTimeout(function(){setEditorContent(content,false)},100)}}else{$("#wmd-input").val(content);if(!content||preview){$("#wmd-preview").html(preview).css("height","auto");ScrollLink.onPreviewFinished()}else{if(MarkdownEditor){$("#wmd-preview").html(previewToken+"<div style='text-align:center; padding: 10px 0;'><img src='http://leanote.com/images/loading-24.gif' /> 正在转换...</div>");MarkdownEditor.refreshPreview()}else{setTimeout(function(){setEditorContent(content,true,preview)},200)}}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBody());content.find("pinit").remove();content.find(".thunderpin").remove();content.find(".pin").parent().remove();content=$(content).html();if(content){while(true){var lastEndScriptPos=content.lastIndexOf("</script>");if(lastEndScriptPos==-1){return content}var length=content.length;if(length-9==lastEndScriptPos){var lastScriptPos=content.lastIndexOf("<script ");if(lastScriptPos==-1){lastScriptPos=content.lastIndexOf("<script>")}if(lastScriptPos!=-1){content=conLine truncated
var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failureFunc,async){_ajax("POST",url,param,successFunc,failureFunc,async)}function ajaxPostJson(url,param,successFunc,failureFunc,async){log("-------------------ajaxPostJson:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({url:url,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:async,data:JSON.stringify(param),success:function(ret,stats){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function findParents(target,selector){if($(target).is(selector)){return $(target)}var parents=$(target).parents();for(var i=0;i<parents.length;++i){log(parents.eq(i));if(parents.eq(i).is(selector)){return parents.seq(i)}}return null}function switchEditor(isMarkdown){if(!isMarkdown){$("#editor").show();$("#mdEditor").css("z-index",1)}else{$("#mdEditor").css("z-index",3).show()}}var previewToken="<div style='display: none'>FORTOKEN</div>";function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(!isMarkdown){$("#editorContent").html(content);var editor=tinymce.activeEditor;if(editor){editor.setContent(content);editor.undoManager.clear()}else{setTimeout(function(){setEditorContent(content,false)},100)}}else{$("#wmd-input").val(content);if(!content||preview){$("#wmd-preview").html(preview).css("height","auto");ScrollLink.onPreviewFinished()}else{if(MarkdownEditor){$("#wmd-preview").html(previewToken+"<div style='text-align:center; padding: 10px 0;'><img src='http://leanote.com/images/loading-24.gif' /> 正在转换...</div>");MarkdownEditor.refreshPreview()}else{setTimeout(function(){setEditorContent(content,true,preview)},200)}}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBody());content.find("pinit").remove();content.find(".thunderpin").remove();content.find(".pin").parent().remove();content=$(content).html();if(content){while(true){var lastEndScriptPos=content.lastIndexOf("</script>");if(lastEndScriptPos==-1){return content}var length=content.length;if(length-9==lastEndScriptPos){var lastScriptPos=content.lastIndexOf("<script ");if(lastScriptPos==-1){lastScriptPos=content.lastIndexOf("<script>")}if(lastScriptPos!=-1){content=conLine truncated
+1 -1
View File
@@ -706,7 +706,7 @@ function hideLoading() {
// 注销, 先清空cookie
function logout() {
$.removeCookie("REVEL_SESSION");
$.removeCookie("LEANOTE_SESSION");
location.href = "/logout?id=1";
}