diff --git a/README.md b/README.md index 64ee551..054a057 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ The repository contains leanote source and dependencies, just for developers. ## Current version -* leanote-v1.3 +* leanote-v1.3.1 * revel 0.12 * [mgo](http://blog.labix.org/2015/01/24/readying-mgo-for-mongodb-3-0) support for mongodb-3.0 -## leanote-v1.3 +## leanote-v1.3.1 * Note batch operation ## How to install leanote diff --git a/src/github.com/leanote/leanote/Gulpfile.js b/src/github.com/leanote/leanote/Gulpfile.js index be99a7c..118f7e3 100644 --- a/src/github.com/leanote/leanote/Gulpfile.js +++ b/src/github.com/leanote/leanote/Gulpfile.js @@ -306,8 +306,8 @@ gulp.task('minifycss', function() { }); // tinymce -// !! You must has tinymce_dev on public/ -var tinymceBase = base + '/tinymce_dev'; +// please set the right path on your own env +var tinymceBase = '/Users/life/leanote/leanote-tools/tinymce_4.1.9_leanote_public'; gulp.task('tinymce', function() { // 先清理 fs.unlink(tinymceBase + '/js/tinymce/tinymce.dev.js'); @@ -317,7 +317,7 @@ gulp.task('tinymce', function() { var cp = require('child_process'); - var bundleCmd = 'grunt bundle --themes leanote --plugins autolink,link,leaui_image,leaui_mind,lists,hr,paste,searchreplace,leanote_nav,leanote_code,tabfocus,table,directionality,textcolor'; + var bundleCmd = 'grunt bundle --themes leanote --plugins autolink,link,leaui_image,lists,hr,paste,searchreplace,leanote_nav,leanote_code,tabfocus,table,directionality,textcolor'; // build cp.exec('grunt minify', {cwd: tinymceBase}, function(err, stdout, stderr) { console.log('stdout: ' + stdout); diff --git a/src/github.com/leanote/leanote/app/routes/routes.go b/src/github.com/leanote/leanote/app/routes/routes.go index eb6bfff..8f2af70 100644 --- a/src/github.com/leanote/leanote/app/routes/routes.go +++ b/src/github.com/leanote/leanote/app/routes/routes.go @@ -54,156 +54,173 @@ func (_ tStatic) ServeModule( } -type tAttach struct {} -var Attach tAttach +type tIndex struct {} +var Index tIndex -func (_ tAttach) UploadAttach( - noteId string, +func (_ tIndex) Default( ) string { args := make(map[string]string) - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Attach.UploadAttach", args).Url + return revel.MainRouter.Reverse("Index.Default", args).Url } -func (_ tAttach) DeleteAttach( - attachId string, +func (_ tIndex) Index( ) string { args := make(map[string]string) - revel.Unbind(args, "attachId", attachId) - return revel.MainRouter.Reverse("Attach.DeleteAttach", args).Url + return revel.MainRouter.Reverse("Index.Index", args).Url } -func (_ tAttach) GetAttachs( - noteId string, +func (_ tIndex) Suggestion( + addr string, + suggestion string, ) string { args := make(map[string]string) - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Attach.GetAttachs", args).Url + revel.Unbind(args, "addr", addr) + revel.Unbind(args, "suggestion", suggestion) + return revel.MainRouter.Reverse("Index.Suggestion", args).Url } -func (_ tAttach) Download( - attachId string, + +type tCaptcha struct {} +var Captcha tCaptcha + + +func (_ tCaptcha) Get( ) string { args := make(map[string]string) - revel.Unbind(args, "attachId", attachId) - return revel.MainRouter.Reverse("Attach.Download", args).Url + return revel.MainRouter.Reverse("Captcha.Get", args).Url } -func (_ tAttach) DownloadAll( - noteId string, + +type tNotebook struct {} +var Notebook tNotebook + + +func (_ tNotebook) Index( + notebook interface{}, + i int, + name string, ) string { args := make(map[string]string) - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Attach.DownloadAll", args).Url + 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) GetNotebooks( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Notebook.GetNotebooks", args).Url +} -type tAuth struct {} -var Auth tAuth - - -func (_ tAuth) Login( - email string, - from string, +func (_ tNotebook) DeleteNotebook( + notebookId string, ) string { args := make(map[string]string) - revel.Unbind(args, "email", email) - revel.Unbind(args, "from", from) - return revel.MainRouter.Reverse("Auth.Login", args).Url + revel.Unbind(args, "notebookId", notebookId) + return revel.MainRouter.Reverse("Notebook.DeleteNotebook", args).Url } -func (_ tAuth) DoLogin( - email string, - pwd string, - captcha string, +func (_ tNotebook) AddNotebook( + notebookId string, + title string, + parentNotebookId string, ) string { args := make(map[string]string) - revel.Unbind(args, "email", email) - revel.Unbind(args, "pwd", pwd) - revel.Unbind(args, "captcha", captcha) - return revel.MainRouter.Reverse("Auth.DoLogin", args).Url + revel.Unbind(args, "notebookId", notebookId) + revel.Unbind(args, "title", title) + revel.Unbind(args, "parentNotebookId", parentNotebookId) + return revel.MainRouter.Reverse("Notebook.AddNotebook", args).Url } -func (_ tAuth) Logout( +func (_ tNotebook) UpdateNotebookTitle( + notebookId string, + title string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("Auth.Logout", args).Url + revel.Unbind(args, "notebookId", notebookId) + revel.Unbind(args, "title", title) + return revel.MainRouter.Reverse("Notebook.UpdateNotebookTitle", args).Url } -func (_ tAuth) Demo( +func (_ tNotebook) DragNotebooks( + data string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("Auth.Demo", args).Url + revel.Unbind(args, "data", data) + return revel.MainRouter.Reverse("Notebook.DragNotebooks", args).Url } -func (_ tAuth) Register( - from string, - iu string, +func (_ tNotebook) SetNotebook2Blog( + notebookId string, + isBlog bool, ) string { args := make(map[string]string) - revel.Unbind(args, "from", from) - revel.Unbind(args, "iu", iu) - return revel.MainRouter.Reverse("Auth.Register", args).Url + revel.Unbind(args, "notebookId", notebookId) + revel.Unbind(args, "isBlog", isBlog) + return revel.MainRouter.Reverse("Notebook.SetNotebook2Blog", args).Url } -func (_ tAuth) DoRegister( - email string, - pwd string, - iu string, + +type tAttach struct {} +var Attach tAttach + + +func (_ tAttach) UploadAttach( + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "email", email) - revel.Unbind(args, "pwd", pwd) - revel.Unbind(args, "iu", iu) - return revel.MainRouter.Reverse("Auth.DoRegister", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Attach.UploadAttach", args).Url } -func (_ tAuth) FindPassword( +func (_ tAttach) DeleteAttach( + attachId string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("Auth.FindPassword", args).Url + revel.Unbind(args, "attachId", attachId) + return revel.MainRouter.Reverse("Attach.DeleteAttach", args).Url } -func (_ tAuth) DoFindPassword( - email string, +func (_ tAttach) GetAttachs( + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "email", email) - return revel.MainRouter.Reverse("Auth.DoFindPassword", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Attach.GetAttachs", args).Url } -func (_ tAuth) FindPassword2( - token string, +func (_ tAttach) Download( + attachId string, ) string { args := make(map[string]string) - revel.Unbind(args, "token", token) - return revel.MainRouter.Reverse("Auth.FindPassword2", args).Url + revel.Unbind(args, "attachId", attachId) + return revel.MainRouter.Reverse("Attach.Download", args).Url } -func (_ tAuth) FindPasswordUpdate( - token string, - pwd string, +func (_ tAttach) DownloadAll( + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "token", token) - revel.Unbind(args, "pwd", pwd) - return revel.MainRouter.Reverse("Auth.FindPasswordUpdate", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Attach.DownloadAll", args).Url } @@ -423,328 +440,96 @@ func (_ tBlog) ListCateLatest( } -type tTag struct {} -var Tag tTag +type tNoteContentHistory struct {} +var NoteContentHistory tNoteContentHistory -func (_ tTag) UpdateTag( - tag string, +func (_ tNoteContentHistory) ListHistories( + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "tag", tag) - return revel.MainRouter.Reverse("Tag.UpdateTag", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("NoteContentHistory.ListHistories", args).Url } -func (_ tTag) DeleteTag( - tag string, + +type tNote struct {} +var Note tNote + + +func (_ tNote) Index( + noteId string, + online string, ) string { args := make(map[string]string) - revel.Unbind(args, "tag", tag) - return revel.MainRouter.Reverse("Tag.DeleteTag", args).Url + revel.Unbind(args, "noteId", noteId) + revel.Unbind(args, "online", online) + return revel.MainRouter.Reverse("Note.Index", args).Url } - -type tCaptcha struct {} -var Captcha tCaptcha - - -func (_ tCaptcha) Get( +func (_ tNote) ListNotes( + notebookId string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("Captcha.Get", args).Url + revel.Unbind(args, "notebookId", notebookId) + return revel.MainRouter.Reverse("Note.ListNotes", args).Url } - -type tFile struct {} -var File tFile - - -func (_ tFile) UploadBlogLogo( +func (_ tNote) ListTrashNotes( ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("File.UploadBlogLogo", args).Url + return revel.MainRouter.Reverse("Note.ListTrashNotes", args).Url } -func (_ tFile) PasteImage( +func (_ tNote) GetNoteAndContent( noteId string, ) string { args := make(map[string]string) revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("File.PasteImage", args).Url + return revel.MainRouter.Reverse("Note.GetNoteAndContent", args).Url } -func (_ tFile) UploadAvatar( +func (_ tNote) GetNoteContent( + noteId string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("File.UploadAvatar", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Note.GetNoteContent", args).Url } -func (_ tFile) UploadImageLeaui( - albumId string, +func (_ tNote) UpdateNoteOrContent( + noteOrContent controllers.NoteOrContent, ) string { args := make(map[string]string) - revel.Unbind(args, "albumId", albumId) - return revel.MainRouter.Reverse("File.UploadImageLeaui", args).Url + revel.Unbind(args, "noteOrContent", noteOrContent) + return revel.MainRouter.Reverse("Note.UpdateNoteOrContent", args).Url } -func (_ tFile) GetImages( - albumId string, - key string, - page int, +func (_ tNote) DeleteNote( + noteIds []string, + isShared bool, ) string { args := make(map[string]string) - revel.Unbind(args, "albumId", albumId) - revel.Unbind(args, "key", key) - revel.Unbind(args, "page", page) - return revel.MainRouter.Reverse("File.GetImages", args).Url + revel.Unbind(args, "noteIds", noteIds) + revel.Unbind(args, "isShared", isShared) + return revel.MainRouter.Reverse("Note.DeleteNote", args).Url } -func (_ tFile) UpdateImageTitle( - fileId string, - title string, +func (_ tNote) DeleteTrash( + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "fileId", fileId) - revel.Unbind(args, "title", title) - return revel.MainRouter.Reverse("File.UpdateImageTitle", args).Url -} - -func (_ tFile) DeleteImage( - fileId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "fileId", fileId) - return revel.MainRouter.Reverse("File.DeleteImage", args).Url -} - -func (_ tFile) OutputImage( - noteId string, - fileId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - revel.Unbind(args, "fileId", fileId) - return revel.MainRouter.Reverse("File.OutputImage", args).Url -} - -func (_ tFile) CopyImage( - userId string, - fileId string, - toUserId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "userId", userId) - revel.Unbind(args, "fileId", fileId) - revel.Unbind(args, "toUserId", toUserId) - return revel.MainRouter.Reverse("File.CopyImage", args).Url -} - -func (_ tFile) CopyHttpImage( - src string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "src", src) - return revel.MainRouter.Reverse("File.CopyHttpImage", args).Url -} - - -type tIndex struct {} -var Index tIndex - - -func (_ tIndex) Default( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("Index.Default", args).Url -} - -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 -} - - -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) GetNotebooks( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("Notebook.GetNotebooks", 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, - parentNotebookId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "notebookId", notebookId) - revel.Unbind(args, "title", title) - revel.Unbind(args, "parentNotebookId", parentNotebookId) - 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 -} - -func (_ tNotebook) DragNotebooks( - data string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "data", data) - return revel.MainRouter.Reverse("Notebook.DragNotebooks", args).Url -} - -func (_ tNotebook) SetNotebook2Blog( - notebookId string, - isBlog bool, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "notebookId", notebookId) - revel.Unbind(args, "isBlog", isBlog) - return revel.MainRouter.Reverse("Notebook.SetNotebook2Blog", args).Url -} - - -type tNote struct {} -var Note tNote - - -func (_ tNote) Index( - noteId string, - online string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - revel.Unbind(args, "online", online) - return revel.MainRouter.Reverse("Note.Index", args).Url -} - -func (_ tNote) ListNotes( - notebookId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "notebookId", notebookId) - return revel.MainRouter.Reverse("Note.ListNotes", args).Url -} - -func (_ tNote) ListTrashNotes( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("Note.ListTrashNotes", args).Url -} - -func (_ tNote) GetNoteAndContent( - noteId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Note.GetNoteAndContent", args).Url -} - -func (_ tNote) GetNoteContent( - noteId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Note.GetNoteContent", args).Url -} - -func (_ tNote) UpdateNoteOrContent( - noteOrContent controllers.NoteOrContent, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteOrContent", noteOrContent) - return revel.MainRouter.Reverse("Note.UpdateNoteOrContent", args).Url -} - -func (_ tNote) DeleteNote( - noteIds []string, - isShared bool, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteIds", noteIds) - revel.Unbind(args, "isShared", isShared) - return revel.MainRouter.Reverse("Note.DeleteNote", args).Url -} - -func (_ tNote) DeleteTrash( - noteId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Note.DeleteTrash", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Note.DeleteTrash", args).Url } func (_ tNote) MoveNote( @@ -812,87 +597,25 @@ func (_ tNote) ToPdf( } func (_ tNote) ExportPdf( - noteId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("Note.ExportPdf", args).Url -} - -func (_ tNote) SetNote2Blog( - noteIds []string, - isBlog bool, - isTop bool, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteIds", noteIds) - revel.Unbind(args, "isBlog", isBlog) - revel.Unbind(args, "isTop", isTop) - return revel.MainRouter.Reverse("Note.SetNote2Blog", args).Url -} - - -type tAlbum struct {} -var Album tAlbum - - -func (_ tAlbum) Index( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("Album.Index", args).Url -} - -func (_ tAlbum) GetAlbums( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("Album.GetAlbums", args).Url -} - -func (_ tAlbum) DeleteAlbum( - albumId string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "albumId", albumId) - return revel.MainRouter.Reverse("Album.DeleteAlbum", args).Url -} - -func (_ tAlbum) AddAlbum( - name string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "name", name) - return revel.MainRouter.Reverse("Album.AddAlbum", args).Url -} - -func (_ tAlbum) UpdateAlbum( - albumId string, - name string, + noteId string, ) string { args := make(map[string]string) - revel.Unbind(args, "albumId", albumId) - revel.Unbind(args, "name", name) - return revel.MainRouter.Reverse("Album.UpdateAlbum", args).Url + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("Note.ExportPdf", args).Url } - -type tNoteContentHistory struct {} -var NoteContentHistory tNoteContentHistory - - -func (_ tNoteContentHistory) ListHistories( - noteId string, +func (_ tNote) SetNote2Blog( + noteIds []string, + isBlog bool, + isTop bool, ) string { args := make(map[string]string) - revel.Unbind(args, "noteId", noteId) - return revel.MainRouter.Reverse("NoteContentHistory.ListHistories", args).Url + revel.Unbind(args, "noteIds", noteIds) + revel.Unbind(args, "isBlog", isBlog) + revel.Unbind(args, "isTop", isTop) + return revel.MainRouter.Reverse("Note.SetNote2Blog", args).Url } @@ -1095,28 +818,257 @@ func (_ tShare) AddShareNotebookGroup( return revel.MainRouter.Reverse("Share.AddShareNotebookGroup", args).Url } -func (_ tShare) DeleteShareNotebookGroup( - notebookId string, - groupId string, +func (_ tShare) DeleteShareNotebookGroup( + notebookId string, + groupId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "notebookId", notebookId) + revel.Unbind(args, "groupId", groupId) + return revel.MainRouter.Reverse("Share.DeleteShareNotebookGroup", args).Url +} + +func (_ tShare) UpdateShareNotebookGroupPerm( + notebookId string, + groupId string, + perm int, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "notebookId", notebookId) + revel.Unbind(args, "groupId", groupId) + revel.Unbind(args, "perm", perm) + return revel.MainRouter.Reverse("Share.UpdateShareNotebookGroupPerm", args).Url +} + + +type tAuth struct {} +var Auth tAuth + + +func (_ tAuth) Login( + email string, + from string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "email", email) + revel.Unbind(args, "from", from) + return revel.MainRouter.Reverse("Auth.Login", args).Url +} + +func (_ tAuth) DoLogin( + email string, + pwd string, + captcha string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "email", email) + revel.Unbind(args, "pwd", pwd) + revel.Unbind(args, "captcha", captcha) + return revel.MainRouter.Reverse("Auth.DoLogin", args).Url +} + +func (_ tAuth) Logout( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Auth.Logout", args).Url +} + +func (_ tAuth) Demo( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Auth.Demo", args).Url +} + +func (_ tAuth) Register( + from string, + iu string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "from", from) + revel.Unbind(args, "iu", iu) + return revel.MainRouter.Reverse("Auth.Register", args).Url +} + +func (_ tAuth) DoRegister( + email string, + pwd string, + iu string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "email", email) + revel.Unbind(args, "pwd", pwd) + revel.Unbind(args, "iu", iu) + return revel.MainRouter.Reverse("Auth.DoRegister", args).Url +} + +func (_ tAuth) FindPassword( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Auth.FindPassword", args).Url +} + +func (_ tAuth) DoFindPassword( + email string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "email", email) + return revel.MainRouter.Reverse("Auth.DoFindPassword", args).Url +} + +func (_ tAuth) FindPassword2( + token string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "token", token) + return revel.MainRouter.Reverse("Auth.FindPassword2", args).Url +} + +func (_ tAuth) FindPasswordUpdate( + token string, + pwd string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "token", token) + revel.Unbind(args, "pwd", pwd) + return revel.MainRouter.Reverse("Auth.FindPasswordUpdate", args).Url +} + + +type tFile struct {} +var File tFile + + +func (_ tFile) UploadBlogLogo( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("File.UploadBlogLogo", args).Url +} + +func (_ tFile) PasteImage( + noteId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "noteId", noteId) + return revel.MainRouter.Reverse("File.PasteImage", args).Url +} + +func (_ tFile) UploadAvatar( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("File.UploadAvatar", args).Url +} + +func (_ tFile) UploadImageLeaui( + albumId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "albumId", albumId) + return revel.MainRouter.Reverse("File.UploadImageLeaui", args).Url +} + +func (_ tFile) GetImages( + albumId string, + key string, + page int, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "albumId", albumId) + revel.Unbind(args, "key", key) + revel.Unbind(args, "page", page) + return revel.MainRouter.Reverse("File.GetImages", args).Url +} + +func (_ tFile) UpdateImageTitle( + fileId string, + title string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "fileId", fileId) + revel.Unbind(args, "title", title) + return revel.MainRouter.Reverse("File.UpdateImageTitle", args).Url +} + +func (_ tFile) DeleteImage( + fileId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "fileId", fileId) + return revel.MainRouter.Reverse("File.DeleteImage", args).Url +} + +func (_ tFile) OutputImage( + noteId string, + fileId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "noteId", noteId) + revel.Unbind(args, "fileId", fileId) + return revel.MainRouter.Reverse("File.OutputImage", args).Url +} + +func (_ tFile) CopyImage( + userId string, + fileId string, + toUserId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "userId", userId) + revel.Unbind(args, "fileId", fileId) + revel.Unbind(args, "toUserId", toUserId) + return revel.MainRouter.Reverse("File.CopyImage", args).Url +} + +func (_ tFile) CopyHttpImage( + src string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "src", src) + return revel.MainRouter.Reverse("File.CopyHttpImage", args).Url +} + + +type tTag struct {} +var Tag tTag + + +func (_ tTag) UpdateTag( + tag string, ) string { args := make(map[string]string) - revel.Unbind(args, "notebookId", notebookId) - revel.Unbind(args, "groupId", groupId) - return revel.MainRouter.Reverse("Share.DeleteShareNotebookGroup", args).Url + revel.Unbind(args, "tag", tag) + return revel.MainRouter.Reverse("Tag.UpdateTag", args).Url } -func (_ tShare) UpdateShareNotebookGroupPerm( - notebookId string, - groupId string, - perm int, +func (_ tTag) DeleteTag( + tag string, ) string { args := make(map[string]string) - revel.Unbind(args, "notebookId", notebookId) - revel.Unbind(args, "groupId", groupId) - revel.Unbind(args, "perm", perm) - return revel.MainRouter.Reverse("Share.UpdateShareNotebookGroupPerm", args).Url + revel.Unbind(args, "tag", tag) + return revel.MainRouter.Reverse("Tag.DeleteTag", args).Url } @@ -1232,6 +1184,54 @@ func (_ tUser) UpdateLeftIsMin( } +type tAlbum struct {} +var Album tAlbum + + +func (_ tAlbum) Index( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Album.Index", args).Url +} + +func (_ tAlbum) GetAlbums( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("Album.GetAlbums", args).Url +} + +func (_ tAlbum) DeleteAlbum( + albumId string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "albumId", albumId) + return revel.MainRouter.Reverse("Album.DeleteAlbum", args).Url +} + +func (_ tAlbum) AddAlbum( + name string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "name", name) + return revel.MainRouter.Reverse("Album.AddAlbum", args).Url +} + +func (_ tAlbum) UpdateAlbum( + albumId string, + name string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "albumId", albumId) + revel.Unbind(args, "name", name) + return revel.MainRouter.Reverse("Album.UpdateAlbum", args).Url +} + + type tAdminBaseController struct {} var AdminBaseController tAdminBaseController @@ -1342,63 +1342,6 @@ func (_ tPreview) Search( } -type tAdminData struct {} -var AdminData tAdminData - - -func (_ tAdminData) Index( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("AdminData.Index", args).Url -} - -func (_ tAdminData) Backup( - ) string { - args := make(map[string]string) - - return revel.MainRouter.Reverse("AdminData.Backup", args).Url -} - -func (_ tAdminData) Restore( - createdTime string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "createdTime", createdTime) - return revel.MainRouter.Reverse("AdminData.Restore", args).Url -} - -func (_ tAdminData) Delete( - createdTime string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "createdTime", createdTime) - return revel.MainRouter.Reverse("AdminData.Delete", args).Url -} - -func (_ tAdminData) UpdateRemark( - createdTime string, - remark string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "createdTime", createdTime) - revel.Unbind(args, "remark", remark) - return revel.MainRouter.Reverse("AdminData.UpdateRemark", args).Url -} - -func (_ tAdminData) Download( - createdTime string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "createdTime", createdTime) - return revel.MainRouter.Reverse("AdminData.Download", args).Url -} - - type tAdminSetting struct {} var AdminSetting tAdminSetting @@ -1601,33 +1544,6 @@ func (_ tAdminUser) DoResetPwd( } -type tAdminBlog struct {} -var AdminBlog tAdminBlog - - -func (_ tAdminBlog) Index( - sorter string, - keywords string, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "sorter", sorter) - revel.Unbind(args, "keywords", keywords) - return revel.MainRouter.Reverse("AdminBlog.Index", args).Url -} - -func (_ tAdminBlog) SetRecommend( - noteId string, - recommend bool, - ) string { - args := make(map[string]string) - - revel.Unbind(args, "noteId", noteId) - revel.Unbind(args, "recommend", recommend) - return revel.MainRouter.Reverse("AdminBlog.SetRecommend", args).Url -} - - type tAdmin struct {} var Admin tAdmin @@ -1658,29 +1574,87 @@ func (_ tAdmin) GetView( } -type tAdminUpgrade struct {} -var AdminUpgrade tAdminUpgrade +type tAdminData struct {} +var AdminData tAdminData -func (_ tAdminUpgrade) UpgradeBlog( +func (_ tAdminData) Index( ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBlog", args).Url + return revel.MainRouter.Reverse("AdminData.Index", args).Url } -func (_ tAdminUpgrade) UpgradeBetaToBeta2( +func (_ tAdminData) Backup( ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBetaToBeta2", args).Url + return revel.MainRouter.Reverse("AdminData.Backup", args).Url } -func (_ tAdminUpgrade) UpgradeBeta3ToBeta4( +func (_ tAdminData) Restore( + createdTime string, ) string { args := make(map[string]string) - return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBeta3ToBeta4", args).Url + revel.Unbind(args, "createdTime", createdTime) + return revel.MainRouter.Reverse("AdminData.Restore", args).Url +} + +func (_ tAdminData) Delete( + createdTime string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "createdTime", createdTime) + return revel.MainRouter.Reverse("AdminData.Delete", args).Url +} + +func (_ tAdminData) UpdateRemark( + createdTime string, + remark string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "createdTime", createdTime) + revel.Unbind(args, "remark", remark) + return revel.MainRouter.Reverse("AdminData.UpdateRemark", args).Url +} + +func (_ tAdminData) Download( + createdTime string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "createdTime", createdTime) + return revel.MainRouter.Reverse("AdminData.Download", args).Url +} + + +type tAdminBlog struct {} +var AdminBlog tAdminBlog + + +func (_ tAdminBlog) Index( + sorter string, + keywords string, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "sorter", sorter) + revel.Unbind(args, "keywords", keywords) + return revel.MainRouter.Reverse("AdminBlog.Index", args).Url +} + +func (_ tAdminBlog) SetRecommend( + noteId string, + recommend bool, + ) string { + args := make(map[string]string) + + revel.Unbind(args, "noteId", noteId) + revel.Unbind(args, "recommend", recommend) + return revel.MainRouter.Reverse("AdminBlog.SetRecommend", args).Url } @@ -1854,6 +1828,32 @@ func (_ tAdminEmail) List( } +type tAdminUpgrade struct {} +var AdminUpgrade tAdminUpgrade + + +func (_ tAdminUpgrade) UpgradeBlog( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBlog", args).Url +} + +func (_ tAdminUpgrade) UpgradeBetaToBeta2( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBetaToBeta2", args).Url +} + +func (_ tAdminUpgrade) UpgradeBeta3ToBeta4( + ) string { + args := make(map[string]string) + + return revel.MainRouter.Reverse("AdminUpgrade.UpgradeBeta3ToBeta4", args).Url +} + + type tApiFile struct {} var ApiFile tApiFile diff --git a/src/github.com/leanote/leanote/app/service/ConfigService.go b/src/github.com/leanote/leanote/app/service/ConfigService.go index 095a02b..e7c2082 100644 --- a/src/github.com/leanote/leanote/app/service/ConfigService.go +++ b/src/github.com/leanote/leanote/app/service/ConfigService.go @@ -594,5 +594,5 @@ func (this *ConfigService) HomePageIsAdminsBlog() bool { } func (this *ConfigService) GetVersion() string { - return "1.3" + return "1.3.1" } diff --git a/src/github.com/leanote/leanote/app/tmp/main.go b/src/github.com/leanote/leanote/app/tmp/main.go index 67085f8..479648d 100644 --- a/src/github.com/leanote/leanote/app/tmp/main.go +++ b/src/github.com/leanote/leanote/app/tmp/main.go @@ -78,133 +78,152 @@ func main() { }) - revel.RegisterController((*controllers.Attach)(nil), + revel.RegisterController((*controllers.Index)(nil), []*revel.MethodType{ &revel.MethodType{ - Name: "UploadAttach", + Name: "Default", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteAttach", + Name: "Index", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "attachId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetAttachs", + Name: "Suggestion", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "addr", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "suggestion", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, + + }) + + revel.RegisterController((*controllers.Captcha)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "Download", + Name: "Get", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "attachId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ + 42: []string{ + }, }, }, + + }) + + revel.RegisterController((*controllers.Notebook)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "DownloadAll", + Name: "Index", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &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.RegisterController((*controllers.Auth)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "Login", + Name: "GetNotebooks", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "from", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DoLogin", + Name: "DeleteNotebook", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "captcha", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "Logout", + Name: "AddNotebook", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "parentNotebookId", 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{ }, }, &revel.MethodType{ - Name: "Demo", + Name: "DragNotebooks", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "data", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "Register", + Name: "SetNotebook2Blog", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "from", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "iu", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "isBlog", Type: reflect.TypeOf((*bool)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, + + }) + + revel.RegisterController((*controllers.Attach)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "DoRegister", + Name: "UploadAttach", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "iu", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "FindPassword", + Name: "DeleteAttach", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "attachId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DoFindPassword", + Name: "GetAttachs", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "FindPassword2", + Name: "Download", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "token", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "attachId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "FindPasswordUpdate", + Name: "DownloadAll", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "token", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, @@ -389,217 +408,153 @@ func main() { }) - revel.RegisterController((*controllers.Tag)(nil), - []*revel.MethodType{ - &revel.MethodType{ - Name: "UpdateTag", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "tag", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "DeleteTag", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "tag", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - - }) - - revel.RegisterController((*controllers.Captcha)(nil), + revel.RegisterController((*controllers.NoteContentHistory)(nil), []*revel.MethodType{ &revel.MethodType{ - Name: "Get", + Name: "ListHistories", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ - 42: []string{ - }, }, }, }) - revel.RegisterController((*controllers.File)(nil), + revel.RegisterController((*controllers.Note)(nil), []*revel.MethodType{ &revel.MethodType{ - Name: "UploadBlogLogo", - Args: []*revel.MethodArg{ - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "PasteImage", + Name: "Index", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "online", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UploadAvatar", - Args: []*revel.MethodArg{ - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "UploadImageLeaui", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "GetImages", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "page", Type: reflect.TypeOf((*int)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "UpdateImageTitle", + Name: "ListNotes", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteImage", + Name: "ListTrashNotes", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "OutputImage", + Name: "GetNoteAndContent", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "CopyImage", + Name: "GetNoteContent", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "CopyHttpImage", + Name: "UpdateNoteOrContent", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "src", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteOrContent", Type: reflect.TypeOf((*controllers.NoteOrContent)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*controllers.Index)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "Default", + Name: "DeleteNote", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "isShared", Type: reflect.TypeOf((*bool)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "Index", + Name: "DeleteTrash", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "Suggestion", + Name: "MoveNote", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "addr", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "suggestion", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*controllers.Notebook)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "Index", + Name: "CopyNote", 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)) }, + &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetNotebooks", + Name: "CopySharedNote", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteNotebook", + Name: "SearchNote", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "AddNotebook", + Name: "SearchNoteByTags", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "parentNotebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "tags", Type: reflect.TypeOf((*[]string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpdateNotebookTitle", + Name: "ToPdf", 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)) }, + &revel.MethodArg{Name: "appKey", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DragNotebooks", + Name: "ExportPdf", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "data", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "SetNotebook2Blog", + Name: "SetNote2Blog", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteIds", 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{ }, @@ -607,42 +562,48 @@ func main() { }) - revel.RegisterController((*controllers.Note)(nil), + revel.RegisterController((*controllers.Share)(nil), []*revel.MethodType{ &revel.MethodType{ - Name: "Index", + Name: "AddShareNote", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "online", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "emails", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ListNotes", + Name: "AddShareNotebook", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "emails", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ListTrashNotes", + Name: "ListShareNotes", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetNoteAndContent", + Name: "GetShareNoteContent", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "sharedUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetNoteContent", + Name: "ListNoteShareUserInfo", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, @@ -650,335 +611,330 @@ func main() { }, }, &revel.MethodType{ - Name: "UpdateNoteOrContent", + Name: "ListNotebookShareUserInfo", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteOrContent", Type: reflect.TypeOf((*controllers.NoteOrContent)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteNote", + Name: "UpdateShareNotePerm", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, - &revel.MethodArg{Name: "isShared", Type: reflect.TypeOf((*bool)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteTrash", + Name: "UpdateShareNotebookPerm", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "MoveNote", + Name: "DeleteShareNote", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "CopyNote", + Name: "DeleteShareNotebook", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "CopySharedNote", + Name: "DeleteShareNoteBySharedUser", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteIds", Type: reflect.TypeOf((*[]string)(nil)) }, - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "SearchNote", + Name: "DeleteShareNotebookBySharedUser", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "SearchNoteByTags", + Name: "DeleteUserShareNoteAndNotebook", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "tags", Type: reflect.TypeOf((*[]string)(nil)) }, + &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ToPdf", + Name: "AddShareNoteGroup", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "appKey", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ExportPdf", + Name: "DeleteShareNoteGroup", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "SetNote2Blog", + Name: "UpdateShareNoteGroupPerm", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteIds", 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: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*controllers.Album)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "Index", + Name: "AddShareNotebookGroup", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetAlbums", + Name: "DeleteShareNotebookGroup", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteAlbum", + Name: "UpdateShareNotebookGroupPerm", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, + + }) + + revel.RegisterController((*controllers.Auth)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "AddAlbum", + Name: "Login", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "from", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpdateAlbum", + Name: "DoLogin", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "captcha", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*controllers.NoteContentHistory)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "ListHistories", + Name: "Logout", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*controllers.Share)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "AddShareNote", + Name: "Demo", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "emails", Type: reflect.TypeOf((*[]string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "AddShareNotebook", + Name: "Register", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "emails", Type: reflect.TypeOf((*[]string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "from", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "iu", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ListShareNotes", + Name: "DoRegister", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "iu", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetShareNoteContent", + Name: "FindPassword", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "sharedUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ListNoteShareUserInfo", + Name: "DoFindPassword", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "email", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "ListNotebookShareUserInfo", + Name: "FindPassword2", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "token", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpdateShareNotePerm", + Name: "FindPasswordUpdate", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, - &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "token", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "pwd", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, + + }) + + revel.RegisterController((*controllers.File)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "UpdateShareNotebookPerm", + Name: "UploadBlogLogo", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, - &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteShareNote", + Name: "PasteImage", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteShareNotebook", + Name: "UploadAvatar", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteShareNoteBySharedUser", + Name: "UploadImageLeaui", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteShareNotebookBySharedUser", + Name: "GetImages", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "key", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "page", Type: reflect.TypeOf((*int)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteUserShareNoteAndNotebook", + Name: "UpdateImageTitle", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "fromUserId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "title", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "AddShareNoteGroup", + Name: "DeleteImage", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "DeleteShareNoteGroup", + Name: "OutputImage", Args: []*revel.MethodArg{ &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpdateShareNoteGroupPerm", + Name: "CopyImage", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "userId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "fileId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "toUserId", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "AddShareNotebookGroup", + Name: "CopyHttpImage", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "src", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, + + }) + + revel.RegisterController((*controllers.Tag)(nil), + []*revel.MethodType{ &revel.MethodType{ - Name: "DeleteShareNotebookGroup", + Name: "UpdateTag", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "tag", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpdateShareNotebookGroupPerm", + Name: "DeleteTag", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "notebookId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "groupId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "perm", Type: reflect.TypeOf((*int)(nil)) }, + &revel.MethodArg{Name: "tag", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, @@ -1083,6 +1039,50 @@ func main() { }) + revel.RegisterController((*controllers.Album)(nil), + []*revel.MethodType{ + &revel.MethodType{ + Name: "Index", + Args: []*revel.MethodArg{ + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "GetAlbums", + Args: []*revel.MethodArg{ + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "DeleteAlbum", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "AddAlbum", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "UpdateAlbum", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "albumId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "name", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + + }) + revel.RegisterController((*admin.AdminBaseController)(nil), []*revel.MethodType{ @@ -1176,58 +1176,6 @@ func main() { }) - revel.RegisterController((*admin.AdminData)(nil), - []*revel.MethodType{ - &revel.MethodType{ - Name: "Index", - Args: []*revel.MethodArg{ - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "Backup", - Args: []*revel.MethodArg{ - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "Restore", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "Delete", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "UpdateRemark", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "remark", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - &revel.MethodType{ - Name: "Download", - Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, - }, - RenderArgNames: map[int][]string{ - }, - }, - - }) - revel.RegisterController((*admin.AdminSetting)(nil), []*revel.MethodType{ &revel.MethodType{ @@ -1397,22 +1345,27 @@ func main() { }) - revel.RegisterController((*admin.AdminBlog)(nil), + revel.RegisterController((*admin.Admin)(nil), []*revel.MethodType{ &revel.MethodType{ Name: "Index", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "sorter", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "keywords", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "SetRecommend", + Name: "T", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, - &revel.MethodArg{Name: "recommend", Type: reflect.TypeOf((*bool)(nil)) }, + &revel.MethodArg{Name: "t", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "GetView", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "view", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, @@ -1420,7 +1373,7 @@ func main() { }) - revel.RegisterController((*admin.Admin)(nil), + revel.RegisterController((*admin.AdminData)(nil), []*revel.MethodType{ &revel.MethodType{ Name: "Index", @@ -1430,43 +1383,64 @@ func main() { }, }, &revel.MethodType{ - Name: "T", + Name: "Backup", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "t", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "GetView", + Name: "Restore", Args: []*revel.MethodArg{ - &revel.MethodArg{Name: "view", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, - - }) - - revel.RegisterController((*admin.AdminUpgrade)(nil), - []*revel.MethodType{ &revel.MethodType{ - Name: "UpgradeBlog", + Name: "Delete", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpgradeBetaToBeta2", + Name: "UpdateRemark", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "remark", Type: reflect.TypeOf((*string)(nil)) }, }, RenderArgNames: map[int][]string{ }, }, &revel.MethodType{ - Name: "UpgradeBeta3ToBeta4", + Name: "Download", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "createdTime", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + + }) + + revel.RegisterController((*admin.AdminBlog)(nil), + []*revel.MethodType{ + &revel.MethodType{ + Name: "Index", + Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "sorter", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "keywords", Type: reflect.TypeOf((*string)(nil)) }, + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "SetRecommend", Args: []*revel.MethodArg{ + &revel.MethodArg{Name: "noteId", Type: reflect.TypeOf((*string)(nil)) }, + &revel.MethodArg{Name: "recommend", Type: reflect.TypeOf((*bool)(nil)) }, }, RenderArgNames: map[int][]string{ }, @@ -1614,6 +1588,32 @@ func main() { }) + revel.RegisterController((*admin.AdminUpgrade)(nil), + []*revel.MethodType{ + &revel.MethodType{ + Name: "UpgradeBlog", + Args: []*revel.MethodArg{ + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "UpgradeBetaToBeta2", + Args: []*revel.MethodArg{ + }, + RenderArgNames: map[int][]string{ + }, + }, + &revel.MethodType{ + Name: "UpgradeBeta3ToBeta4", + Args: []*revel.MethodArg{ + }, + RenderArgNames: map[int][]string{ + }, + }, + + }) + revel.RegisterController((*api.ApiFile)(nil), []*revel.MethodType{ &revel.MethodType{ diff --git a/src/github.com/leanote/leanote/app/views/note/note-dev.html b/src/github.com/leanote/leanote/app/views/note/note-dev.html index 2eaa03d..584a8e5 100644 --- a/src/github.com/leanote/leanote/app/views/note/note-dev.html +++ b/src/github.com/leanote/leanote/app/views/note/note-dev.html @@ -17,16 +17,16 @@ - + - + @@ -174,7 +174,7 @@
- * obj = yaml.parseFile('config.yml');
- *
- *
- * @param string input Path of YAML file
- *
- * @return array The YAML converted to a JS representation
- *
- * @throws YamlParseException If the YAML is not valid
- */
- parseFile: function(file /* String */, callback /* Function */)
- {
- if ( callback == null )
- {
- var input = this.getFileContents(file);
- var ret = null;
- try
- {
- ret = this.parse(input);
- }
- catch ( e )
- {
- if ( e instanceof YamlParseException ) {
- e.setParsedFile(file);
- }
- throw e;
- }
- return ret;
- }
-
- this.getFileContents(file, function(data)
- {
- callback(new Yaml().parse(data));
- });
- },
-
- /**
- * Parses YAML into a JS representation.
- *
- * The parse method, when supplied with a YAML stream (string),
- * will do its best to convert YAML into a JS representation.
- *
- * Usage:
- *
- * obj = yaml.parse(...);
- *
- *
- * @param string input string containing YAML
- *
- * @return array The YAML converted to a JS representation
- *
- * @throws YamlParseException If the YAML is not valid
- */
- parse: function(input /* String */)
- {
- var yaml = new YamlParser();
-
- return yaml.parse(input);
- },
-
- /**
- * Dumps a JS representation to a YAML string.
- *
- * The dump method, when supplied with an array, will do its best
- * to convert the array into friendly YAML.
- *
- * @param array array JS representation
- * @param integer inline The level where you switch to inline YAML
- *
- * @return string A YAML string representing the original JS representation
- *
- * @api
- */
- dump: function(array, inline, spaces)
- {
- if ( inline == null ) inline = 2;
-
- var yaml = new YamlDumper();
- if (spaces) {
- yaml.numSpacesForIndentation = spaces;
- }
-
- return yaml.dump(array, inline);
- },
-
- getXHR: function()
- {
- if ( window.XMLHttpRequest )
- return new XMLHttpRequest();
-
- if ( window.ActiveXObject )
- {
- var names = [
- "Msxml2.XMLHTTP.6.0",
- "Msxml2.XMLHTTP.3.0",
- "Msxml2.XMLHTTP",
- "Microsoft.XMLHTTP"
- ];
-
- for ( var i = 0; i < 4; i++ )
- {
- try{ return new ActiveXObject(names[i]); }
- catch(e){}
- }
- }
- return null;
- },
-
- getFileContents: function(file, callback)
- {
- if ( YamlRunningUnderNode )
- {
- var fs = require('fs');
- if ( callback == null )
- {
- var data = fs.readFileSync(file);
- if (data == null) return null;
- return ''+data;
- }
- else
- {
- fs.readFile(file, function(err, data)
- {
- if (err)
- callback(null);
- else
- callback(data);
- });
- }
- }
- else
- {
- var request = this.getXHR();
-
- // Sync
- if ( callback == null )
- {
- request.open('GET', file, false);
- request.send(null);
-
- if ( request.status == 200 || request.status == 0 )
- return request.responseText;
-
- return null;
- }
-
- // Async
- request.onreadystatechange = function()
- {
- if ( request.readyState == 4 )
- if ( request.status == 200 || request.status == 0 )
- callback(request.responseText);
- else
- callback(null);
- };
- request.open('GET', file, true);
- request.send(null);
- }
- }
-};
-
-var YAML =
-{
- /*
- * @param integer inline The level where you switch to inline YAML
- */
-
- stringify: function(input, inline, spaces)
- {
- return new Yaml().dump(input, inline, spaces);
- },
-
- parse: function(input)
- {
- return new Yaml().parse(input);
- },
-
- load: function(file, callback)
- {
- return new Yaml().parseFile(file, callback);
- }
-};
-
-// Handle node.js case
-if (typeof exports !== 'undefined') {
- if (typeof module !== 'undefined' && module.exports) {
- exports = module.exports = YAML;
- YamlRunningUnderNode = true;
-
- // Add require handler
- (function () {
- var require_handler = function (module, filename) {
- // fill in result
- module.exports = YAML.load(filename);
- };
-
- // register require extensions only if we're on node.js
- // hack for browserify
- if ( undefined !== require.extensions ) {
- require.extensions['.yml'] = require_handler;
- require.extensions['.yaml'] = require_handler;
- }
- }());
- }
-}
-
-// Handle browser case
-if ( typeof(window) != "undefined" )
-{
- window.YAML = YAML;
-}
-
-/**
- * YamlInline implements a YAML parser/dumper for the YAML inline syntax.
- */
-var YamlInline = function(){};
-YamlInline.prototype =
-{
- i: null,
-
- /**
- * Convert a YAML string to a JS object.
- *
- * @param string value A YAML string
- *
- * @return object A JS object representing the YAML string
- */
- parse: function(value)
- {
- var result = null;
- value = this.trim(value);
-
- if ( 0 == value.length )
- {
- return '';
- }
-
- switch ( value.charAt(0) )
- {
- case '[':
- result = this.parseSequence(value);
- break;
- case '{':
- result = this.parseMapping(value);
- break;
- default:
- result = this.parseScalar(value);
- }
-
- // some comment can end the scalar
- if ( value.substr(this.i+1).replace(/^\s*#.*$/, '') != '' ) {
- console.log("oups "+value.substr(this.i+1));
- throw new YamlParseException('Unexpected characters near "'+value.substr(this.i)+'".');
- }
-
- return result;
- },
-
- /**
- * Dumps a given JS variable to a YAML string.
- *
- * @param mixed value The JS variable to convert
- *
- * @return string The YAML string representing the JS object
- */
- dump: function(value)
- {
- if ( undefined == value || null == value )
- return 'null';
- if ( value instanceof Date)
- return value.toISOString();
- if ( typeof(value) == 'object')
- return this.dumpObject(value);
- if ( typeof(value) == 'boolean' )
- return value ? 'true' : 'false';
- if ( /^\d+$/.test(value) )
- return typeof(value) == 'string' ? "'"+value+"'" : parseInt(value);
- if ( this.isNumeric(value) )
- return typeof(value) == 'string' ? "'"+value+"'" : parseFloat(value);
- if ( typeof(value) == 'number' )
- return value == Infinity ? '.Inf' : ( value == -Infinity ? '-.Inf' : ( isNaN(value) ? '.NAN' : value ) );
- var yaml = new YamlEscaper();
- if ( yaml.requiresDoubleQuoting(value) )
- return yaml.escapeWithDoubleQuotes(value);
- if ( yaml.requiresSingleQuoting(value) )
- return yaml.escapeWithSingleQuotes(value);
- if ( '' == value )
- return '""';
- if ( this.getTimestampRegex().test(value) )
- return "'"+value+"'";
- if ( this.inArray(value.toLowerCase(), ['null','~','true','false']) )
- return "'"+value+"'";
- // default
- return value;
- },
-
- /**
- * Dumps a JS object to a YAML string.
- *
- * @param object value The JS array to dump
- *
- * @return string The YAML string representing the JS object
- */
- dumpObject: function(value)
- {
- var keys = this.getKeys(value);
- var output = null;
- var i;
- var len = keys.length;
-
- // array
- if ( value instanceof Array )
- /*( 1 == len && '0' == keys[0] )
- ||
- ( len > 1 && this.reduceArray(keys, function(v,w){return Math.floor(v+w);}, 0) == len * (len - 1) / 2) )*/
- {
- output = [];
- for ( i = 0; i < len; i++ )
- {
- output.push(this.dump(value[keys[i]]));
- }
-
- return '['+output.join(', ')+']';
- }
-
- // mapping
- output = [];
- for ( i = 0; i < len; i++ )
- {
- output.push(this.dump(keys[i])+': '+this.dump(value[keys[i]]));
- }
-
- return '{ '+output.join(', ')+' }';
- },
-
- /**
- * Parses a scalar to a YAML string.
- *
- * @param scalar scalar
- * @param string delimiters
- * @param object stringDelimiters
- * @param integer i
- * @param boolean evaluate
- *
- * @return string A YAML string
- *
- * @throws YamlParseException When malformed inline YAML string is parsed
- */
- parseScalar: function(scalar, delimiters, stringDelimiters, i, evaluate)
- {
- if ( delimiters == undefined ) delimiters = null;
- if ( stringDelimiters == undefined ) stringDelimiters = ['"', "'"];
- if ( i == undefined ) i = 0;
- if ( evaluate == undefined ) evaluate = true;
-
- var output = null;
- var pos = null;
- var matches = null;
-
- if ( this.inArray(scalar[i], stringDelimiters) )
- {
- // quoted scalar
- output = this.parseQuotedScalar(scalar, i);
- i = this.i;
- if (null !== delimiters) {
- var tmp = scalar.substr(i).replace(/^\s+/, '');
- if (!this.inArray(tmp.charAt(0), delimiters)) {
- throw new YamlParseException('Unexpected characters ('+scalar.substr(i)+').');
- }
- }
- }
- else
- {
- // "normal" string
- if ( !delimiters )
- {
- output = (scalar+'').substring(i);
-
- i += output.length;
-
- // remove comments
- pos = output.indexOf(' #');
- if ( pos != -1 )
- {
- output = output.substr(0, pos).replace(/\s+$/g,'');
- }
- }
- else if ( matches = new RegExp('^(.+?)('+delimiters.join('|')+')').exec((scalar+'').substring(i)) )
- {
- output = matches[1];
- i += output.length;
- }
- else
- {
- throw new YamlParseException('Malformed inline YAML string ('+scalar+').');
- }
- output = evaluate ? this.evaluateScalar(output) : output;
- }
-
- this.i = i;
-
- return output;
- },
-
- /**
- * Parses a quoted scalar to YAML.
- *
- * @param string scalar
- * @param integer i
- *
- * @return string A YAML string
- *
- * @throws YamlParseException When malformed inline YAML string is parsed
- */
- parseQuotedScalar: function(scalar, i)
- {
- var matches = null;
- //var item = /^(.*?)['"]\s*(?:[,:]|[}\]]\s*,)/.exec((scalar+'').substring(i))[1];
-
- if ( !(matches = new RegExp('^'+YamlInline.REGEX_QUOTED_STRING).exec((scalar+'').substring(i))) )
- {
- throw new YamlParseException('Malformed inline YAML string ('+(scalar+'').substring(i)+').');
- }
-
- var output = matches[0].substr(1, matches[0].length - 2);
-
- var unescaper = new YamlUnescaper();
-
- if ( '"' == (scalar+'').charAt(i) )
- {
- output = unescaper.unescapeDoubleQuotedString(output);
- }
- else
- {
- output = unescaper.unescapeSingleQuotedString(output);
- }
-
- i += matches[0].length;
-
- this.i = i;
- return output;
- },
-
- /**
- * Parses a sequence to a YAML string.
- *
- * @param string sequence
- * @param integer i
- *
- * @return string A YAML string
- *
- * @throws YamlParseException When malformed inline YAML string is parsed
- */
- parseSequence: function(sequence, i)
- {
- if ( i == undefined ) i = 0;
-
- var output = [];
- var len = sequence.length;
- i += 1;
-
- // [foo, bar, ...]
- while ( i < len )
- {
- switch ( sequence.charAt(i) )
- {
- case '[':
- // nested sequence
- output.push(this.parseSequence(sequence, i));
- i = this.i;
- break;
- case '{':
- // nested mapping
- output.push(this.parseMapping(sequence, i));
- i = this.i;
- break;
- case ']':
- this.i = i;
- return output;
- case ',':
- case ' ':
- break;
- default:
- var isQuoted = this.inArray(sequence.charAt(i), ['"', "'"]);
- var value = this.parseScalar(sequence, [',', ']'], ['"', "'"], i);
- i = this.i;
-
- if ( !isQuoted && (value+'').indexOf(': ') != -1 )
- {
- // embedded mapping?
- try
- {
- value = this.parseMapping('{'+value+'}');
- }
- catch ( e )
- {
- if ( !(e instanceof YamlParseException ) ) throw e;
- // no, it's not
- }
- }
-
- output.push(value);
-
- i--;
- }
-
- i++;
- }
-
- throw new YamlParseException('Malformed inline YAML string "'+sequence+'"');
- },
-
- /**
- * Parses a mapping to a YAML string.
- *
- * @param string mapping
- * @param integer i
- *
- * @return string A YAML string
- *
- * @throws YamlParseException When malformed inline YAML string is parsed
- */
- parseMapping: function(mapping, i)
- {
- if ( i == undefined ) i = 0;
- var output = {};
- var len = mapping.length;
- i += 1;
- var done = false;
- var doContinue = false;
-
- // {foo: bar, bar:foo, ...}
- while ( i < len )
- {
- doContinue = false;
-
- switch ( mapping.charAt(i) )
- {
- case ' ':
- case ',':
- i++;
- doContinue = true;
- break;
- case '}':
- this.i = i;
- return output;
- }
-
- if ( doContinue ) continue;
-
- // key
- var key = this.parseScalar(mapping, [':', ' '], ['"', "'"], i, false);
- i = this.i;
-
- // value
- done = false;
- while ( i < len )
- {
- switch ( mapping.charAt(i) )
- {
- case '[':
- // nested sequence
- output[key] = this.parseSequence(mapping, i);
- i = this.i;
- done = true;
- break;
- case '{':
- // nested mapping
- output[key] = this.parseMapping(mapping, i);
- i = this.i;
- done = true;
- break;
- case ':':
- case ' ':
- break;
- default:
- output[key] = this.parseScalar(mapping, [',', '}'], ['"', "'"], i);
- i = this.i;
- done = true;
- i--;
- }
-
- ++i;
-
- if ( done )
- {
- doContinue = true;
- break;
- }
- }
-
- if ( doContinue ) continue;
- }
-
- throw new YamlParseException('Malformed inline YAML string "'+mapping+'"');
- },
-
- /**
- * Evaluates scalars and replaces magic values.
- *
- * @param string scalar
- *
- * @return string A YAML string
- */
- evaluateScalar: function(scalar)
- {
- scalar = this.trim(scalar);
-
- var raw = null;
- var cast = null;
-
- if ( ( 'null' == scalar.toLowerCase() ) ||
- ( '' == scalar ) ||
- ( '~' == scalar ) )
- return null;
- if ( (scalar+'').indexOf('!str ') == 0 )
- return (''+scalar).substring(5);
- if ( (scalar+'').indexOf('! ') == 0 )
- return parseInt(this.parseScalar((scalar+'').substr(2)));
- if ( /^\d+$/.test(scalar) )
- {
- raw = scalar;
- cast = parseInt(scalar);
- return '0' == scalar.charAt(0) ? this.octdec(scalar) : (( ''+raw == ''+cast ) ? cast : raw);
- }
- if ( 'true' == (scalar+'').toLowerCase() )
- return true;
- if ( 'false' == (scalar+'').toLowerCase() )
- return false;
- if ( this.isNumeric(scalar) )
- return '0x' == (scalar+'').substr(0, 2) ? this.hexdec(scalar) : parseFloat(scalar);
- if ( scalar.toLowerCase() == '.inf' )
- return Infinity;
- if ( scalar.toLowerCase() == '.nan' )
- return NaN;
- if ( scalar.toLowerCase() == '-.inf' )
- return -Infinity;
- if ( /^(-|\+)?[0-9,]+(\.[0-9]+)?$/.test(scalar) )
- return parseFloat(scalar.split(',').join(''));
- if ( this.getTimestampRegex().test(scalar) )
- return new Date(this.strtotime(scalar));
- //else
- return ''+scalar;
- },
-
- /**
- * Gets a regex that matches an unix timestamp
- *
- * @return string The regular expression
- */
- getTimestampRegex: function()
- {
- return new RegExp('^'+
- '([0-9][0-9][0-9][0-9])'+
- '-([0-9][0-9]?)'+
- '-([0-9][0-9]?)'+
- '(?:(?:[Tt]|[ \t]+)'+
- '([0-9][0-9]?)'+
- ':([0-9][0-9])'+
- ':([0-9][0-9])'+
- '(?:\.([0-9]*))?'+
- '(?:[ \t]*(Z|([-+])([0-9][0-9]?)'+
- '(?::([0-9][0-9]))?))?)?'+
- '$','gi');
- },
-
- trim: function(str /* String */)
- {
- return (str+'').replace(/^\s+/,'').replace(/\s+$/,'');
- },
-
- isNumeric: function(input)
- {
- return (input - 0) == input && input.length > 0 && input.replace(/\s+/g,'') != '';
- },
-
- inArray: function(key, tab)
- {
- var i;
- var len = tab.length;
- for ( i = 0; i < len; i++ )
- {
- if ( key == tab[i] ) return true;
- }
- return false;
- },
-
- getKeys: function(tab)
- {
- var ret = [];
-
- for ( var name in tab )
- {
- if ( tab.hasOwnProperty(name) )
- {
- ret.push(name);
- }
- }
-
- return ret;
- },
-
- /*reduceArray: function(tab, fun)
- {
- var len = tab.length;
- if (typeof fun != "function")
- throw new YamlParseException("fun is not a function");
-
- // no value to return if no initial value and an empty array
- if (len == 0 && arguments.length == 1)
- throw new YamlParseException("empty array");
-
- var i = 0;
- if (arguments.length >= 2)
- {
- var rv = arguments[1];
- }
- else
- {
- do
- {
- if (i in tab)
- {
- rv = tab[i++];
- break;
- }
-
- // if array contains no values, no initial value to return
- if (++i >= len)
- throw new YamlParseException("no initial value to return");
- }
- while (true);
- }
-
- for (; i < len; i++)
- {
- if (i in tab)
- rv = fun.call(null, rv, tab[i], i, tab);
- }
-
- return rv;
- },*/
-
- octdec: function(input)
- {
- return parseInt((input+'').replace(/[^0-7]/gi, ''), 8);
- },
-
- hexdec: function(input)
- {
- input = this.trim(input);
- if ( (input+'').substr(0, 2) == '0x' ) input = (input+'').substring(2);
- return parseInt((input+'').replace(/[^a-f0-9]/gi, ''), 16);
- },
-
- /**
- * @see http://phpjs.org/functions/strtotime
- * @note we need timestamp with msecs so /1000 removed
- * @note original contained binary | 0 (wtf?!) everywhere, which messes everything up
- */
- strtotime: function (h,b){var f,c,g,k,d="";h=(h+"").replace(/\s{2,}|^\s|\s$/g," ").replace(/[\t\r\n]/g,"");if(h==="now"){return b===null||isNaN(b)?new Date().getTime()||0:b||0}else{if(!isNaN(d=Date.parse(h))){return d||0}else{if(b){b=new Date(b)}else{b=new Date()}}}h=h.toLowerCase();var e={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]};var a=function(i){var o=(i[2]&&i[2]==="ago");var n=(n=i[0]==="last"?-1:1)*(o?-1:1);switch(i[0]){case"last":case"next":switch(i[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+n);break;case"wee":b.setDate(b.getDate()+(n*7));break;case"day":b.setDate(b.getDate()+n);break;case"hou":b.setHours(b.getHours()+n);break;case"min":b.setMinutes(b.getMinutes()+n);break;case"sec":b.setSeconds(b.getSeconds()+n);break;case"mon":if(i[1]==="month"){b.setMonth(b.getMonth()+n);break}default:var l=e.day[i[1].substring(0,3)];if(typeof l!=="undefined"){var p=l-b.getDay();if(p===0){p=7*n}else{if(p>0){if(i[0]==="last"){p-=7}}else{if(i[0]==="next"){p+=7}}}b.setDate(b.getDate()+p);b.setHours(0,0,0,0)}}break;default:if(/\d+/.test(i[0])){n*=parseInt(i[0],10);switch(i[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+n);break;case"mon":b.setMonth(b.getMonth()+n);break;case"wee":b.setDate(b.getDate()+(n*7));break;case"day":b.setDate(b.getDate()+n);break;case"hou":b.setHours(b.getHours()+n);break;case"min":b.setMinutes(b.getMinutes()+n);break;case"sec":b.setSeconds(b.getSeconds()+n);break}}else{return false}break}return true};g=h.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(g!==null){if(!g[2]){g[2]="00:00:00"}else{if(!g[3]){g[2]+=":00"}}k=g[1].split(/-/g);k[1]=e.mon[k[1]-1]||k[1];k[0]=+k[0];k[0]=(k[0]>=0&&k[0]<=69)?"20"+(k[0]<10?"0"+k[0]:k[0]+""):(k[0]>=70&&k[0]<=99)?"19"+k[0]:k[0]+"";return parseInt(this.strtotime(k[2]+" "+k[1]+" "+k[0]+" "+g[2])+(g[4]?g[4]:""),10)}var j="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";g=h.match(new RegExp(j,"gi"));if(g===null){return false}for(f=0,c=g.length;fAdds extra features to the original Markdown syntax.
\n- * For a fairly comprehensive set of languages see the - * README - * file that came with this source. At a minimum, the lexer should work on a - * number of languages including C and friends, Java, Python, Bash, SQL, HTML, - * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk - * and a subset of Perl, but, because of commenting conventions, doesn't work on - * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class. - *
- * Usage:
} and {@code } tags in your source with
- * {@code class=prettyprint.}
- * You can also use the (html deprecated) {@code } tag, but the pretty
- * printer needs to do more substantial DOM manipulations to support that, so
- * some css styles may not be preserved.
- *
} or {@code } element to specify the
- * language, as in {@code }. Any class that
- * starts with "lang-" followed by a file extension, specifies the file type.
- * See the "lang-*.js" files in this directory for code that implements
- * per-language file handlers.
- *
- * Change log:
- * cbeust, 2006/08/22
- *
- * Java annotations (start with "@") are now captured as literals ("lit")
- *
- * @requires console
- */
-
-// JSLint declarations
-/*global console, document, navigator, setTimeout, window, define */
-
-/** @define {boolean} */
-var IN_GLOBAL_SCOPE = true;
-
-/**
- * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
- * UI events.
- * If set to {@code false}, {@code prettyPrint()} is synchronous.
- */
-window['PR_SHOULD_USE_CONTINUATION'] = true;
-
-/**
- * Pretty print a chunk of code.
- * @param {string} sourceCodeHtml The HTML to pretty print.
- * @param {string} opt_langExtension The language name to use.
- * Typically, a filename extension like 'cpp' or 'java'.
- * @param {number|boolean} opt_numberLines True to number lines,
- * or the 1-indexed number of the first line in sourceCodeHtml.
- * @return {string} code as html, but prettier
- */
-var prettyPrintOne;
-/**
- * Find all the {@code } and {@code } tags in the DOM with
- * {@code class=prettyprint} and prettify them.
- *
- * @param {Function} opt_whenDone called when prettifying is done.
- * @param {HTMLElement|HTMLDocument} opt_root an element or document
- * containing all the elements to pretty print.
- * Defaults to {@code document.body}.
- */
-var prettyPrint;
-
-
-(function () {
- var win = window;
- // Keyword lists for various languages.
- // We use things that coerce to strings to make them compact when minified
- // and to defeat aggressive optimizers that fold large string constants.
- var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
- var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
- "double,enum,extern,float,goto,inline,int,long,register,short,signed," +
- "sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];
- var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
- "new,operator,private,protected,public,this,throw,true,try,typeof"];
- var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
- "concept,concept_map,const_cast,constexpr,decltype,delegate," +
- "dynamic_cast,explicit,export,friend,generic,late_check," +
- "mutable,namespace,nullptr,property,reinterpret_cast,static_assert," +
- "static_cast,template,typeid,typename,using,virtual,where"];
- var JAVA_KEYWORDS = [COMMON_KEYWORDS,
- "abstract,assert,boolean,byte,extends,final,finally,implements,import," +
- "instanceof,interface,null,native,package,strictfp,super,synchronized," +
- "throws,transient"];
- var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
- "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
- "fixed,foreach,from,group,implicit,in,internal,into,is,let," +
- "lock,object,out,override,orderby,params,partial,readonly,ref,sbyte," +
- "sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort," +
- "var,virtual,where"];
- var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
- "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
- "throw,true,try,unless,until,when,while,yes";
- var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
- "debugger,eval,export,function,get,null,set,undefined,var,with," +
- "Infinity,NaN"];
- var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
- "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
- "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
- var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
- "elif,except,exec,finally,from,global,import,in,is,lambda," +
- "nonlocal,not,or,pass,print,raise,try,with,yield," +
- "False,True,None"];
- var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
- "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
- "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
- "BEGIN,END"];
- var RUST_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "as,assert,const,copy,drop," +
- "enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv," +
- "pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"];
- var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
- "function,in,local,set,then,until"];
- var ALL_KEYWORDS = [
- CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS,
- PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
- var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;
-
- // token style names. correspond to css classes
- /**
- * token style for a string literal
- * @const
- */
- var PR_STRING = 'str';
- /**
- * token style for a keyword
- * @const
- */
- var PR_KEYWORD = 'kwd';
- /**
- * token style for a comment
- * @const
- */
- var PR_COMMENT = 'com';
- /**
- * token style for a type
- * @const
- */
- var PR_TYPE = 'typ';
- /**
- * token style for a literal value. e.g. 1, null, true.
- * @const
- */
- var PR_LITERAL = 'lit';
- /**
- * token style for a punctuation string.
- * @const
- */
- var PR_PUNCTUATION = 'pun';
- /**
- * token style for plain text.
- * @const
- */
- var PR_PLAIN = 'pln';
-
- /**
- * token style for an sgml tag.
- * @const
- */
- var PR_TAG = 'tag';
- /**
- * token style for a markup declaration such as a DOCTYPE.
- * @const
- */
- var PR_DECLARATION = 'dec';
- /**
- * token style for embedded source.
- * @const
- */
- var PR_SOURCE = 'src';
- /**
- * token style for an sgml attribute name.
- * @const
- */
- var PR_ATTRIB_NAME = 'atn';
- /**
- * token style for an sgml attribute value.
- * @const
- */
- var PR_ATTRIB_VALUE = 'atv';
-
- /**
- * A class that indicates a section of markup that is not code, e.g. to allow
- * embedding of line numbers within code listings.
- * @const
- */
- var PR_NOCODE = 'nocode';
-
-
-
- /**
- * A set of tokens that can precede a regular expression literal in
- * javascript
- * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
- * has the full list, but I've removed ones that might be problematic when
- * seen in languages that don't support regular expression literals.
- *
- * Specifically, I've removed any keywords that can't precede a regexp
- * literal in a syntactically legal javascript program, and I've removed the
- * "in" keyword since it's not a keyword in many languages, and might be used
- * as a count of inches.
- *
- *
The link above does not accurately describe EcmaScript rules since
- * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
- * very well in practice.
- *
- * @private
- * @const
- */
- var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
-
- // CAVEAT: this does not properly handle the case where a regular
- // expression immediately follows another since a regular expression may
- // have flags for case-sensitivity and the like. Having regexp tokens
- // adjacent is not valid in any language I'm aware of, so I'm punting.
- // TODO: maybe style special characters inside a regexp as punctuation.
-
- /**
- * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
- * matches the union of the sets of strings matched by the input RegExp.
- * Since it matches globally, if the input strings have a start-of-input
- * anchor (/^.../), it is ignored for the purposes of unioning.
- * @param {Array.} regexs non multiline, non-global regexs.
- * @return {RegExp} a global regex.
- */
- function combinePrefixPatterns(regexs) {
- var capturedGroupIndex = 0;
-
- var needToFoldCase = false;
- var ignoreCase = false;
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.ignoreCase) {
- ignoreCase = true;
- } else if (/[a-z]/i.test(regex.source.replace(
- /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
- needToFoldCase = true;
- ignoreCase = false;
- break;
- }
- }
-
- var escapeCharToCodeUnit = {
- 'b': 8,
- 't': 9,
- 'n': 0xa,
- 'v': 0xb,
- 'f': 0xc,
- 'r': 0xd
- };
-
- function decodeEscape(charsetPart) {
- var cc0 = charsetPart.charCodeAt(0);
- if (cc0 !== 92 /* \\ */) {
- return cc0;
- }
- var c1 = charsetPart.charAt(1);
- cc0 = escapeCharToCodeUnit[c1];
- if (cc0) {
- return cc0;
- } else if ('0' <= c1 && c1 <= '7') {
- return parseInt(charsetPart.substring(1), 8);
- } else if (c1 === 'u' || c1 === 'x') {
- return parseInt(charsetPart.substring(2), 16);
- } else {
- return charsetPart.charCodeAt(1);
- }
- }
-
- function encodeEscape(charCode) {
- if (charCode < 0x20) {
- return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
- }
- var ch = String.fromCharCode(charCode);
- return (ch === '\\' || ch === '-' || ch === ']' || ch === '^')
- ? "\\" + ch : ch;
- }
-
- function caseFoldCharset(charSet) {
- var charsetParts = charSet.substring(1, charSet.length - 1).match(
- new RegExp(
- '\\\\u[0-9A-Fa-f]{4}'
- + '|\\\\x[0-9A-Fa-f]{2}'
- + '|\\\\[0-3][0-7]{0,2}'
- + '|\\\\[0-7]{1,2}'
- + '|\\\\[\\s\\S]'
- + '|-'
- + '|[^-\\\\]',
- 'g'));
- var ranges = [];
- var inverse = charsetParts[0] === '^';
-
- var out = ['['];
- if (inverse) { out.push('^'); }
-
- for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
- var p = charsetParts[i];
- if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
- out.push(p);
- } else {
- var start = decodeEscape(p);
- var end;
- if (i + 2 < n && '-' === charsetParts[i + 1]) {
- end = decodeEscape(charsetParts[i + 2]);
- i += 2;
- } else {
- end = start;
- }
- ranges.push([start, end]);
- // If the range might intersect letters, then expand it.
- // This case handling is too simplistic.
- // It does not deal with non-latin case folding.
- // It works for latin source code identifiers though.
- if (!(end < 65 || start > 122)) {
- if (!(end < 65 || start > 90)) {
- ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
- }
- if (!(end < 97 || start > 122)) {
- ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
- }
- }
- }
- }
-
- // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
- // -> [[1, 12], [14, 14], [16, 17]]
- ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
- var consolidatedRanges = [];
- var lastRange = [];
- for (var i = 0; i < ranges.length; ++i) {
- var range = ranges[i];
- if (range[0] <= lastRange[1] + 1) {
- lastRange[1] = Math.max(lastRange[1], range[1]);
- } else {
- consolidatedRanges.push(lastRange = range);
- }
- }
-
- for (var i = 0; i < consolidatedRanges.length; ++i) {
- var range = consolidatedRanges[i];
- out.push(encodeEscape(range[0]));
- if (range[1] > range[0]) {
- if (range[1] + 1 > range[0]) { out.push('-'); }
- out.push(encodeEscape(range[1]));
- }
- }
- out.push(']');
- return out.join('');
- }
-
- function allowAnywhereFoldCaseAndRenumberGroups(regex) {
- // Split into character sets, escape sequences, punctuation strings
- // like ('(', '(?:', ')', '^'), and runs of characters that do not
- // include any of the above.
- var parts = regex.source.match(
- new RegExp(
- '(?:'
- + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
- + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
- + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
- + '|\\\\[0-9]+' // a back-reference or octal escape
- + '|\\\\[^ux0-9]' // other escape sequence
- + '|\\(\\?[:!=]' // start of a non-capturing group
- + '|[\\(\\)\\^]' // start/end of a group, or line start
- + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
- + ')',
- 'g'));
- var n = parts.length;
-
- // Maps captured group numbers to the number they will occupy in
- // the output or to -1 if that has not been determined, or to
- // undefined if they need not be capturing in the output.
- var capturedGroups = [];
-
- // Walk over and identify back references to build the capturedGroups
- // mapping.
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- // groups are 1-indexed, so max group index is count of '('
- ++groupIndex;
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue) {
- if (decimalValue <= groupIndex) {
- capturedGroups[decimalValue] = -1;
- } else {
- // Replace with an unambiguous escape sequence so that
- // an octal escape sequence does not turn into a backreference
- // to a capturing group from an earlier regex.
- parts[i] = encodeEscape(decimalValue);
- }
- }
- }
- }
-
- // Renumber groups and reduce capturing groups to non-capturing groups
- // where possible.
- for (var i = 1; i < capturedGroups.length; ++i) {
- if (-1 === capturedGroups[i]) {
- capturedGroups[i] = ++capturedGroupIndex;
- }
- }
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- ++groupIndex;
- if (!capturedGroups[groupIndex]) {
- parts[i] = '(?:';
- }
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue && decimalValue <= groupIndex) {
- parts[i] = '\\' + capturedGroups[decimalValue];
- }
- }
- }
-
- // Remove any prefix anchors so that the output will match anywhere.
- // ^^ really does mean an anchored match though.
- for (var i = 0; i < n; ++i) {
- if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
- }
-
- // Expand letters to groups to handle mixing of case-sensitive and
- // case-insensitive patterns if necessary.
- if (regex.ignoreCase && needToFoldCase) {
- for (var i = 0; i < n; ++i) {
- var p = parts[i];
- var ch0 = p.charAt(0);
- if (p.length >= 2 && ch0 === '[') {
- parts[i] = caseFoldCharset(p);
- } else if (ch0 !== '\\') {
- // TODO: handle letters in numeric escapes.
- parts[i] = p.replace(
- /[a-zA-Z]/g,
- function (ch) {
- var cc = ch.charCodeAt(0);
- return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
- });
- }
- }
- }
-
- return parts.join('');
- }
-
- var rewritten = [];
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.global || regex.multiline) { throw new Error('' + regex); }
- rewritten.push(
- '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
- }
-
- return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
- }
-
- /**
- * Split markup into a string of source code and an array mapping ranges in
- * that string to the text nodes in which they appear.
- *
- *
- * The HTML DOM structure:
- *
- * (Element "p"
- * (Element "b"
- * (Text "print ")) ; #1
- * (Text "'Hello '") ; #2
- * (Element "br") ; #3
- * (Text " + 'World';")) ; #4
- *
- *
- * corresponds to the HTML
- * {@code
print 'Hello '
+ 'World';
}.
- *
- *
- * It will produce the output:
- *
- * {
- * sourceCode: "print 'Hello '\n + 'World';",
- * // 1 2
- * // 012345678901234 5678901234567
- * spans: [0, #1, 6, #2, 14, #3, 15, #4]
- * }
- *
- *
- * where #1 is a reference to the {@code "print "} text node above, and so
- * on for the other text nodes.
- *
- *
- *
- * The {@code} spans array is an array of pairs. Even elements are the start
- * indices of substrings, and odd elements are the text nodes (or BR elements)
- * that contain the text for those substrings.
- * Substrings continue until the next index or the end of the source.
- *
- *
- * @param {Node} node an HTML DOM subtree containing source-code.
- * @param {boolean} isPreformatted true if white-space in text nodes should
- * be considered significant.
- * @return {Object} source code and the text nodes in which they occur.
- */
- function extractSourceSpans(node, isPreformatted) {
- var nocode = /(?:^|\s)nocode(?:\s|$)/;
-
- var chunks = [];
- var length = 0;
- var spans = [];
- var k = 0;
-
- function walk(node) {
- var type = node.nodeType;
- if (type == 1) { // Element
- if (nocode.test(node.className)) { return; }
- for (var child = node.firstChild; child; child = child.nextSibling) {
- walk(child);
- }
- var nodeName = node.nodeName.toLowerCase();
- if ('br' === nodeName || 'li' === nodeName) {
- chunks[k] = '\n';
- spans[k << 1] = length++;
- spans[(k++ << 1) | 1] = node;
- }
- } else if (type == 3 || type == 4) { // Text
- var text = node.nodeValue;
- if (text.length) {
- if (!isPreformatted) {
- text = text.replace(/[ \t\r\n]+/g, ' ');
- } else {
- text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
- }
- // TODO: handle tabs here?
- chunks[k] = text;
- spans[k << 1] = length;
- length += text.length;
- spans[(k++ << 1) | 1] = node;
- }
- }
- }
-
- walk(node);
-
- return {
- sourceCode: chunks.join('').replace(/\n$/, ''),
- spans: spans
- };
- }
-
- /**
- * Apply the given language handler to sourceCode and add the resulting
- * decorations to out.
- * @param {number} basePos the index of sourceCode within the chunk of source
- * whose decorations are already present on out.
- */
- function appendDecorations(basePos, sourceCode, langHandler, out) {
- if (!sourceCode) { return; }
- var job = {
- sourceCode: sourceCode,
- basePos: basePos
- };
- langHandler(job);
- out.push.apply(out, job.decorations);
- }
-
- var notWs = /\S/;
-
- /**
- * Given an element, if it contains only one child element and any text nodes
- * it contains contain only space characters, return the sole child element.
- * Otherwise returns undefined.
- *
- * This is meant to return the CODE element in {@code
} when
- * there is a single child element that contains all the non-space textual
- * content, but not to return anything where there are multiple child elements
- * as in {@code ...
...
} or when there
- * is textual content.
- */
- function childContentWrapper(element) {
- var wrapper = undefined;
- for (var c = element.firstChild; c; c = c.nextSibling) {
- var type = c.nodeType;
- wrapper = (type === 1) // Element Node
- ? (wrapper ? element : c)
- : (type === 3) // Text Node
- ? (notWs.test(c.nodeValue) ? element : wrapper)
- : wrapper;
- }
- return wrapper === element ? undefined : wrapper;
- }
-
- /** Given triples of [style, pattern, context] returns a lexing function,
- * The lexing function interprets the patterns to find token boundaries and
- * returns a decoration list of the form
- * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
- * where index_n is an index into the sourceCode, and style_n is a style
- * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
- * all characters in sourceCode[index_n-1:index_n].
- *
- * The stylePatterns is a list whose elements have the form
- * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
- *
- * Style is a style constant like PR_PLAIN, or can be a string of the
- * form 'lang-FOO', where FOO is a language extension describing the
- * language of the portion of the token in $1 after pattern executes.
- * E.g., if style is 'lang-lisp', and group 1 contains the text
- * '(hello (world))', then that portion of the token will be passed to the
- * registered lisp handler for formatting.
- * The text before and after group 1 will be restyled using this decorator
- * so decorators should take care that this doesn't result in infinite
- * recursion. For example, the HTML lexer rule for SCRIPT elements looks
- * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
- * '}
+ * define style rules. See the example page for examples.
+ * mark the {@code } and {@code } tags in your source with
+ * {@code class=prettyprint.}
+ * You can also use the (html deprecated) {@code } tag, but the pretty
+ * printer needs to do more substantial DOM manipulations to support that, so
+ * some css styles may not be preserved.
+ *
+ * That's it. I wanted to keep the API as simple as possible, so there's no
+ * need to specify which language the code is in, but if you wish, you can add
+ * another class to the {@code } or {@code } element to specify the
+ * language, as in {@code }. Any class that
+ * starts with "lang-" followed by a file extension, specifies the file type.
+ * See the "lang-*.js" files in this directory for code that implements
+ * per-language file handlers.
+ *
+ * Change log:
+ * cbeust, 2006/08/22
+ *
+ * Java annotations (start with "@") are now captured as literals ("lit")
+ *
+ * @requires console
+ */
- if (this.node.getTotalLength) {
- return this.node.getTotalLength();
- }
+// JSLint declarations
+/*global console, document, navigator, setTimeout, window, define */
- return getTotalLength(path);
- };
- /*\
- * Element.getPointAtLength
- [ method ]
- **
- * Return coordinates of the point located at the given length on the given path. Only works for element of “path” type.
- **
- > Parameters
- **
- - length (number)
- **
- = (object) representation of the point:
- o {
- o x: (number) x coordinate
- o y: (number) y coordinate
- o alpha: (number) angle of derivative
- o }
- \*/
- elproto.getPointAtLength = function (length) {
- var path = this.getPath();
- if (!path) {
- return;
- }
+/** @define {boolean} */
+var IN_GLOBAL_SCOPE = true;
- return getPointAtLength(path, length);
- };
- /*\
- * Element.getPath
- [ method ]
- **
- * Returns path of the element. Only works for elements of “path” type and simple elements like circle.
- = (object) path
- **
- \*/
- elproto.getPath = function () {
- var path,
- getPath = R._getPath[this.type];
-
- if (this.type == "text" || this.type == "set") {
- return;
- }
+/**
+ * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
+ * UI events.
+ * If set to {@code false}, {@code prettyPrint()} is synchronous.
+ */
+window['PR_SHOULD_USE_CONTINUATION'] = true;
- if (getPath) {
- path = getPath(this);
- }
+/**
+ * Pretty print a chunk of code.
+ * @param {string} sourceCodeHtml The HTML to pretty print.
+ * @param {string} opt_langExtension The language name to use.
+ * Typically, a filename extension like 'cpp' or 'java'.
+ * @param {number|boolean} opt_numberLines True to number lines,
+ * or the 1-indexed number of the first line in sourceCodeHtml.
+ * @return {string} code as html, but prettier
+ */
+var prettyPrintOne;
+/**
+ * Find all the {@code } and {@code } tags in the DOM with
+ * {@code class=prettyprint} and prettify them.
+ *
+ * @param {Function} opt_whenDone called when prettifying is done.
+ * @param {HTMLElement|HTMLDocument} opt_root an element or document
+ * containing all the elements to pretty print.
+ * Defaults to {@code document.body}.
+ */
+var prettyPrint;
- return path;
- };
- /*\
- * Element.getSubpath
- [ method ]
- **
- * Return subpath of a given element from given length to given length. Only works for element of “path” type.
- **
- > Parameters
- **
- - from (number) position of the start of the segment
- - to (number) position of the end of the segment
- **
- = (string) pathstring for the segment
- \*/
- elproto.getSubpath = function (from, to) {
- var path = this.getPath();
- if (!path) {
- return;
- }
- return R.getSubpath(path, from, to);
- };
- /*\
- * Raphael.easing_formulas
- [ property ]
- **
- * Object that contains easing formulas for animation. You could extend it with your own. By default it has following list of easing:
- #
- # - “linear”
- # - “<” or “easeIn” or “ease-in”
- # - “>” or “easeOut” or “ease-out”
- # - “<>” or “easeInOut” or “ease-in-out”
- # - “backIn” or “back-in”
- # - “backOut” or “back-out”
- # - “elastic”
- # - “bounce”
- #
- # See also Easing demo.
- \*/
- var ef = R.easing_formulas = {
- linear: function (n) {
- return n;
- },
- "<": function (n) {
- return pow(n, 1.7);
- },
- ">": function (n) {
- return pow(n, .48);
- },
- "<>": function (n) {
- var q = .48 - n / 1.04,
- Q = math.sqrt(.1734 + q * q),
- x = Q - q,
- X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1),
- y = -Q - q,
- Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1),
- t = X + Y + .5;
- return (1 - t) * 3 * t * t + t * t * t;
- },
- backIn: function (n) {
- var s = 1.70158;
- return n * n * ((s + 1) * n - s);
- },
- backOut: function (n) {
- n = n - 1;
- var s = 1.70158;
- return n * n * ((s + 1) * n + s) + 1;
- },
- elastic: function (n) {
- if (n == !!n) {
- return n;
- }
- return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1;
- },
- bounce: function (n) {
- var s = 7.5625,
- p = 2.75,
- l;
- if (n < (1 / p)) {
- l = s * n * n;
- } else {
- if (n < (2 / p)) {
- n -= (1.5 / p);
- l = s * n * n + .75;
- } else {
- if (n < (2.5 / p)) {
- n -= (2.25 / p);
- l = s * n * n + .9375;
- } else {
- n -= (2.625 / p);
- l = s * n * n + .984375;
- }
- }
- }
- return l;
- }
+(function () {
+ var win = window;
+ // Keyword lists for various languages.
+ // We use things that coerce to strings to make them compact when minified
+ // and to defeat aggressive optimizers that fold large string constants.
+ var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
+ var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
+ "double,enum,extern,float,goto,inline,int,long,register,short,signed," +
+ "sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];
+ var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
+ "new,operator,private,protected,public,this,throw,true,try,typeof"];
+ var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
+ "concept,concept_map,const_cast,constexpr,decltype,delegate," +
+ "dynamic_cast,explicit,export,friend,generic,late_check," +
+ "mutable,namespace,nullptr,property,reinterpret_cast,static_assert," +
+ "static_cast,template,typeid,typename,using,virtual,where"];
+ var JAVA_KEYWORDS = [COMMON_KEYWORDS,
+ "abstract,assert,boolean,byte,extends,final,finally,implements,import," +
+ "instanceof,interface,null,native,package,strictfp,super,synchronized," +
+ "throws,transient"];
+ var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
+ "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
+ "fixed,foreach,from,group,implicit,in,internal,into,is,let," +
+ "lock,object,out,override,orderby,params,partial,readonly,ref,sbyte," +
+ "sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort," +
+ "var,virtual,where"];
+ var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
+ "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
+ "throw,true,try,unless,until,when,while,yes";
+ var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
+ "debugger,eval,export,function,get,null,set,undefined,var,with," +
+ "Infinity,NaN"];
+ var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
+ "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
+ "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
+ var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
+ "elif,except,exec,finally,from,global,import,in,is,lambda," +
+ "nonlocal,not,or,pass,print,raise,try,with,yield," +
+ "False,True,None"];
+ var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
+ "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
+ "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
+ "BEGIN,END"];
+ var RUST_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "as,assert,const,copy,drop," +
+ "enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv," +
+ "pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"];
+ var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
+ "function,in,local,set,then,until"];
+ var ALL_KEYWORDS = [
+ CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS,
+ PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
+ var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;
+
+ // token style names. correspond to css classes
+ /**
+ * token style for a string literal
+ * @const
+ */
+ var PR_STRING = 'str';
+ /**
+ * token style for a keyword
+ * @const
+ */
+ var PR_KEYWORD = 'kwd';
+ /**
+ * token style for a comment
+ * @const
+ */
+ var PR_COMMENT = 'com';
+ /**
+ * token style for a type
+ * @const
+ */
+ var PR_TYPE = 'typ';
+ /**
+ * token style for a literal value. e.g. 1, null, true.
+ * @const
+ */
+ var PR_LITERAL = 'lit';
+ /**
+ * token style for a punctuation string.
+ * @const
+ */
+ var PR_PUNCTUATION = 'pun';
+ /**
+ * token style for plain text.
+ * @const
+ */
+ var PR_PLAIN = 'pln';
+
+ /**
+ * token style for an sgml tag.
+ * @const
+ */
+ var PR_TAG = 'tag';
+ /**
+ * token style for a markup declaration such as a DOCTYPE.
+ * @const
+ */
+ var PR_DECLARATION = 'dec';
+ /**
+ * token style for embedded source.
+ * @const
+ */
+ var PR_SOURCE = 'src';
+ /**
+ * token style for an sgml attribute name.
+ * @const
+ */
+ var PR_ATTRIB_NAME = 'atn';
+ /**
+ * token style for an sgml attribute value.
+ * @const
+ */
+ var PR_ATTRIB_VALUE = 'atv';
+
+ /**
+ * A class that indicates a section of markup that is not code, e.g. to allow
+ * embedding of line numbers within code listings.
+ * @const
+ */
+ var PR_NOCODE = 'nocode';
+
+
+
+ /**
+ * A set of tokens that can precede a regular expression literal in
+ * javascript
+ * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
+ * has the full list, but I've removed ones that might be problematic when
+ * seen in languages that don't support regular expression literals.
+ *
+ * Specifically, I've removed any keywords that can't precede a regexp
+ * literal in a syntactically legal javascript program, and I've removed the
+ * "in" keyword since it's not a keyword in many languages, and might be used
+ * as a count of inches.
+ *
+ *
The link above does not accurately describe EcmaScript rules since
+ * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
+ * very well in practice.
+ *
+ * @private
+ * @const
+ */
+ var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
+
+ // CAVEAT: this does not properly handle the case where a regular
+ // expression immediately follows another since a regular expression may
+ // have flags for case-sensitivity and the like. Having regexp tokens
+ // adjacent is not valid in any language I'm aware of, so I'm punting.
+ // TODO: maybe style special characters inside a regexp as punctuation.
+
+ /**
+ * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
+ * matches the union of the sets of strings matched by the input RegExp.
+ * Since it matches globally, if the input strings have a start-of-input
+ * anchor (/^.../), it is ignored for the purposes of unioning.
+ * @param {Array.} regexs non multiline, non-global regexs.
+ * @return {RegExp} a global regex.
+ */
+ function combinePrefixPatterns(regexs) {
+ var capturedGroupIndex = 0;
+
+ var needToFoldCase = false;
+ var ignoreCase = false;
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.ignoreCase) {
+ ignoreCase = true;
+ } else if (/[a-z]/i.test(regex.source.replace(
+ /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
+ needToFoldCase = true;
+ ignoreCase = false;
+ break;
+ }
+ }
+
+ var escapeCharToCodeUnit = {
+ 'b': 8,
+ 't': 9,
+ 'n': 0xa,
+ 'v': 0xb,
+ 'f': 0xc,
+ 'r': 0xd
};
- ef.easeIn = ef["ease-in"] = ef["<"];
- ef.easeOut = ef["ease-out"] = ef[">"];
- ef.easeInOut = ef["ease-in-out"] = ef["<>"];
- ef["back-in"] = ef.backIn;
- ef["back-out"] = ef.backOut;
-
- var animationElements = [],
- requestAnimFrame = window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function (callback) {
- setTimeout(callback, 16);
- },
- animation = function () {
- var Now = +new Date,
- l = 0;
- for (; l < animationElements.length; l++) {
- var e = animationElements[l];
- if (e.el.removed || e.paused) {
- continue;
- }
- var time = Now - e.start,
- ms = e.ms,
- easing = e.easing,
- from = e.from,
- diff = e.diff,
- to = e.to,
- t = e.t,
- that = e.el,
- set = {},
- now,
- init = {},
- key;
- if (e.initstatus) {
- time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms;
- e.status = e.initstatus;
- delete e.initstatus;
- e.stop && animationElements.splice(l--, 1);
- } else {
- e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top;
- }
- if (time < 0) {
- continue;
- }
- if (time < ms) {
- var pos = easing(time / ms);
- for (var attr in from) if (from[has](attr)) {
- switch (availableAnimAttrs[attr]) {
- case nu:
- now = +from[attr] + pos * ms * diff[attr];
- break;
- case "colour":
- now = "rgb(" + [
- upto255(round(from[attr].r + pos * ms * diff[attr].r)),
- upto255(round(from[attr].g + pos * ms * diff[attr].g)),
- upto255(round(from[attr].b + pos * ms * diff[attr].b))
- ].join(",") + ")";
- break;
- case "path":
- now = [];
- for (var i = 0, ii = from[attr].length; i < ii; i++) {
- now[i] = [from[attr][i][0]];
- for (var j = 1, jj = from[attr][i].length; j < jj; j++) {
- now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];
- }
- now[i] = now[i].join(S);
- }
- now = now.join(S);
- break;
- case "transform":
- if (diff[attr].real) {
- now = [];
- for (i = 0, ii = from[attr].length; i < ii; i++) {
- now[i] = [from[attr][i][0]];
- for (j = 1, jj = from[attr][i].length; j < jj; j++) {
- now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j];
- }
- }
- } else {
- var get = function (i) {
- return +from[attr][i] + pos * ms * diff[attr][i];
- };
- // now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]];
- now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]];
- }
- break;
- case "csv":
- if (attr == "clip-rect") {
- now = [];
- i = 4;
- while (i--) {
- now[i] = +from[attr][i] + pos * ms * diff[attr][i];
- }
- }
- break;
- default:
- var from2 = [][concat](from[attr]);
- now = [];
- i = that.paper.customAttributes[attr].length;
- while (i--) {
- now[i] = +from2[i] + pos * ms * diff[attr][i];
- }
- break;
- }
- set[attr] = now;
- }
- that.attr(set);
- (function (id, that, anim) {
- setTimeout(function () {
- eve("raphael.anim.frame." + id, that, anim);
- });
- })(that.id, that, e.anim);
- } else {
- (function(f, el, a) {
- setTimeout(function() {
- eve("raphael.anim.frame." + el.id, el, a);
- eve("raphael.anim.finish." + el.id, el, a);
- R.is(f, "function") && f.call(el);
- });
- })(e.callback, that, e.anim);
- that.attr(to);
- animationElements.splice(l--, 1);
- if (e.repeat > 1 && !e.next) {
- for (key in to) if (to[has](key)) {
- init[key] = e.totalOrigin[key];
- }
- e.el.attr(init);
- runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1);
- }
- if (e.next && !e.stop) {
- runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat);
- }
- }
+
+ function decodeEscape(charsetPart) {
+ var cc0 = charsetPart.charCodeAt(0);
+ if (cc0 !== 92 /* \\ */) {
+ return cc0;
+ }
+ var c1 = charsetPart.charAt(1);
+ cc0 = escapeCharToCodeUnit[c1];
+ if (cc0) {
+ return cc0;
+ } else if ('0' <= c1 && c1 <= '7') {
+ return parseInt(charsetPart.substring(1), 8);
+ } else if (c1 === 'u' || c1 === 'x') {
+ return parseInt(charsetPart.substring(2), 16);
+ } else {
+ return charsetPart.charCodeAt(1);
+ }
+ }
+
+ function encodeEscape(charCode) {
+ if (charCode < 0x20) {
+ return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
+ }
+ var ch = String.fromCharCode(charCode);
+ return (ch === '\\' || ch === '-' || ch === ']' || ch === '^')
+ ? "\\" + ch : ch;
+ }
+
+ function caseFoldCharset(charSet) {
+ var charsetParts = charSet.substring(1, charSet.length - 1).match(
+ new RegExp(
+ '\\\\u[0-9A-Fa-f]{4}'
+ + '|\\\\x[0-9A-Fa-f]{2}'
+ + '|\\\\[0-3][0-7]{0,2}'
+ + '|\\\\[0-7]{1,2}'
+ + '|\\\\[\\s\\S]'
+ + '|-'
+ + '|[^-\\\\]',
+ 'g'));
+ var ranges = [];
+ var inverse = charsetParts[0] === '^';
+
+ var out = ['['];
+ if (inverse) { out.push('^'); }
+
+ for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
+ var p = charsetParts[i];
+ if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
+ out.push(p);
+ } else {
+ var start = decodeEscape(p);
+ var end;
+ if (i + 2 < n && '-' === charsetParts[i + 1]) {
+ end = decodeEscape(charsetParts[i + 2]);
+ i += 2;
+ } else {
+ end = start;
+ }
+ ranges.push([start, end]);
+ // If the range might intersect letters, then expand it.
+ // This case handling is too simplistic.
+ // It does not deal with non-latin case folding.
+ // It works for latin source code identifiers though.
+ if (!(end < 65 || start > 122)) {
+ if (!(end < 65 || start > 90)) {
+ ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
}
- R.svg && that && that.paper && that.paper.safari();
- animationElements.length && requestAnimFrame(animation);
- },
- upto255 = function (color) {
- return color > 255 ? 255 : color < 0 ? 0 : color;
- };
- /*\
- * Element.animateWith
- [ method ]
- **
- * Acts similar to @Element.animate, but ensure that given animation runs in sync with another given element.
- **
- > Parameters
- **
- - el (object) element to sync with
- - anim (object) animation to sync with
- - params (object) #optional final attributes for the element, see also @Element.attr
- - ms (number) #optional number of milliseconds for animation to run
- - easing (string) #optional easing type. Accept on of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)`
- - callback (function) #optional callback function. Will be called at the end of animation.
- * or
- - element (object) element to sync with
- - anim (object) animation to sync with
- - animation (object) #optional animation object, see @Raphael.animation
- **
- = (object) original element
- \*/
- elproto.animateWith = function (el, anim, params, ms, easing, callback) {
- var element = this;
- if (element.removed) {
- callback && callback.call(element);
- return element;
- }
- var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback),
- x, y;
- runAnimation(a, element, a.percents[0], null, element.attr());
- for (var i = 0, ii = animationElements.length; i < ii; i++) {
- if (animationElements[i].anim == anim && animationElements[i].el == el) {
- animationElements[ii - 1].start = animationElements[i].start;
- break;
+ if (!(end < 97 || start > 122)) {
+ ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
}
+ }
}
- return element;
- //
- //
- // var a = params ? R.animation(params, ms, easing, callback) : anim,
- // status = element.status(anim);
- // return this.animate(a).status(a, status * anim.ms / a.ms);
- };
- function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
- var cx = 3 * p1x,
- bx = 3 * (p2x - p1x) - cx,
- ax = 1 - cx - bx,
- cy = 3 * p1y,
- by = 3 * (p2y - p1y) - cy,
- ay = 1 - cy - by;
- function sampleCurveX(t) {
- return ((ax * t + bx) * t + cx) * t;
+ }
+
+ // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
+ // -> [[1, 12], [14, 14], [16, 17]]
+ ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
+ var consolidatedRanges = [];
+ var lastRange = [];
+ for (var i = 0; i < ranges.length; ++i) {
+ var range = ranges[i];
+ if (range[0] <= lastRange[1] + 1) {
+ lastRange[1] = Math.max(lastRange[1], range[1]);
+ } else {
+ consolidatedRanges.push(lastRange = range);
}
- function solve(x, epsilon) {
- var t = solveCurveX(x, epsilon);
- return ((ay * t + by) * t + cy) * t;
+ }
+
+ for (var i = 0; i < consolidatedRanges.length; ++i) {
+ var range = consolidatedRanges[i];
+ out.push(encodeEscape(range[0]));
+ if (range[1] > range[0]) {
+ if (range[1] + 1 > range[0]) { out.push('-'); }
+ out.push(encodeEscape(range[1]));
}
- function solveCurveX(x, epsilon) {
- var t0, t1, t2, x2, d2, i;
- for(t2 = x, i = 0; i < 8; i++) {
- x2 = sampleCurveX(t2) - x;
- if (abs(x2) < epsilon) {
- return t2;
- }
- d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;
- if (abs(d2) < 1e-6) {
- break;
- }
- t2 = t2 - x2 / d2;
- }
- t0 = 0;
- t1 = 1;
- t2 = x;
- if (t2 < t0) {
- return t0;
- }
- if (t2 > t1) {
- return t1;
- }
- while (t0 < t1) {
- x2 = sampleCurveX(t2);
- if (abs(x2 - x) < epsilon) {
- return t2;
- }
- if (x > x2) {
- t0 = t2;
- } else {
- t1 = t2;
- }
- t2 = (t1 - t0) / 2 + t0;
+ }
+ out.push(']');
+ return out.join('');
+ }
+
+ function allowAnywhereFoldCaseAndRenumberGroups(regex) {
+ // Split into character sets, escape sequences, punctuation strings
+ // like ('(', '(?:', ')', '^'), and runs of characters that do not
+ // include any of the above.
+ var parts = regex.source.match(
+ new RegExp(
+ '(?:'
+ + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
+ + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
+ + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
+ + '|\\\\[0-9]+' // a back-reference or octal escape
+ + '|\\\\[^ux0-9]' // other escape sequence
+ + '|\\(\\?[:!=]' // start of a non-capturing group
+ + '|[\\(\\)\\^]' // start/end of a group, or line start
+ + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
+ + ')',
+ 'g'));
+ var n = parts.length;
+
+ // Maps captured group numbers to the number they will occupy in
+ // the output or to -1 if that has not been determined, or to
+ // undefined if they need not be capturing in the output.
+ var capturedGroups = [];
+
+ // Walk over and identify back references to build the capturedGroups
+ // mapping.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ // groups are 1-indexed, so max group index is count of '('
+ ++groupIndex;
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue) {
+ if (decimalValue <= groupIndex) {
+ capturedGroups[decimalValue] = -1;
+ } else {
+ // Replace with an unambiguous escape sequence so that
+ // an octal escape sequence does not turn into a backreference
+ // to a capturing group from an earlier regex.
+ parts[i] = encodeEscape(decimalValue);
}
- return t2;
+ }
+ }
+ }
+
+ // Renumber groups and reduce capturing groups to non-capturing groups
+ // where possible.
+ for (var i = 1; i < capturedGroups.length; ++i) {
+ if (-1 === capturedGroups[i]) {
+ capturedGroups[i] = ++capturedGroupIndex;
+ }
+ }
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ ++groupIndex;
+ if (!capturedGroups[groupIndex]) {
+ parts[i] = '(?:';
+ }
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ parts[i] = '\\' + capturedGroups[decimalValue];
+ }
+ }
+ }
+
+ // Remove any prefix anchors so that the output will match anywhere.
+ // ^^ really does mean an anchored match though.
+ for (var i = 0; i < n; ++i) {
+ if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
+ }
+
+ // Expand letters to groups to handle mixing of case-sensitive and
+ // case-insensitive patterns if necessary.
+ if (regex.ignoreCase && needToFoldCase) {
+ for (var i = 0; i < n; ++i) {
+ var p = parts[i];
+ var ch0 = p.charAt(0);
+ if (p.length >= 2 && ch0 === '[') {
+ parts[i] = caseFoldCharset(p);
+ } else if (ch0 !== '\\') {
+ // TODO: handle letters in numeric escapes.
+ parts[i] = p.replace(
+ /[a-zA-Z]/g,
+ function (ch) {
+ var cc = ch.charCodeAt(0);
+ return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
+ });
+ }
}
- return solve(t, 1 / (200 * duration));
+ }
+
+ return parts.join('');
}
- elproto.onAnimation = function (f) {
- f ? eve.on("raphael.anim.frame." + this.id, f) : eve.unbind("raphael.anim.frame." + this.id);
- return this;
- };
- function Animation(anim, ms) {
- var percents = [],
- newAnim = {};
- this.ms = ms;
- this.times = 1;
- if (anim) {
- for (var attr in anim) if (anim[has](attr)) {
- newAnim[toFloat(attr)] = anim[attr];
- percents.push(toFloat(attr));
- }
- percents.sort(sortByNumber);
+
+ var rewritten = [];
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.global || regex.multiline) { throw new Error('' + regex); }
+ rewritten.push(
+ '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
+ }
+
+ return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
+ }
+
+ /**
+ * Split markup into a string of source code and an array mapping ranges in
+ * that string to the text nodes in which they appear.
+ *
+ *
+ * The HTML DOM structure:
+ *
+ * (Element "p"
+ * (Element "b"
+ * (Text "print ")) ; #1
+ * (Text "'Hello '") ; #2
+ * (Element "br") ; #3
+ * (Text " + 'World';")) ; #4
+ *
+ *
+ * corresponds to the HTML
+ * {@code
print 'Hello '
+ 'World';
}.
+ *
+ *
+ * It will produce the output:
+ *
+ * {
+ * sourceCode: "print 'Hello '\n + 'World';",
+ * // 1 2
+ * // 012345678901234 5678901234567
+ * spans: [0, #1, 6, #2, 14, #3, 15, #4]
+ * }
+ *
+ *
+ * where #1 is a reference to the {@code "print "} text node above, and so
+ * on for the other text nodes.
+ *
+ *
+ *
+ * The {@code} spans array is an array of pairs. Even elements are the start
+ * indices of substrings, and odd elements are the text nodes (or BR elements)
+ * that contain the text for those substrings.
+ * Substrings continue until the next index or the end of the source.
+ *
+ *
+ * @param {Node} node an HTML DOM subtree containing source-code.
+ * @param {boolean} isPreformatted true if white-space in text nodes should
+ * be considered significant.
+ * @return {Object} source code and the text nodes in which they occur.
+ */
+ function extractSourceSpans(node, isPreformatted) {
+ var nocode = /(?:^|\s)nocode(?:\s|$)/;
+
+ var chunks = [];
+ var length = 0;
+ var spans = [];
+ var k = 0;
+
+ function walk(node) {
+ var type = node.nodeType;
+ if (type == 1) { // Element
+ if (nocode.test(node.className)) { return; }
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ walk(child);
}
- this.anim = newAnim;
- this.top = percents[percents.length - 1];
- this.percents = percents;
+ var nodeName = node.nodeName.toLowerCase();
+ if ('br' === nodeName || 'li' === nodeName) {
+ chunks[k] = '\n';
+ spans[k << 1] = length++;
+ spans[(k++ << 1) | 1] = node;
+ }
+ } else if (type == 3 || type == 4) { // Text
+ var text = node.nodeValue;
+ if (text.length) {
+ if (!isPreformatted) {
+ text = text.replace(/[ \t\r\n]+/g, ' ');
+ } else {
+ text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
+ }
+ // TODO: handle tabs here?
+ chunks[k] = text;
+ spans[k << 1] = length;
+ length += text.length;
+ spans[(k++ << 1) | 1] = node;
+ }
+ }
}
- /*\
- * Animation.delay
- [ method ]
- **
- * Creates a copy of existing animation object with given delay.
- **
- > Parameters
- **
- - delay (number) number of ms to pass between animation start and actual animation
- **
- = (object) new altered Animation object
- | var anim = Raphael.animation({cx: 10, cy: 20}, 2e3);
- | circle1.animate(anim); // run the given animation immediately
- | circle2.animate(anim.delay(500)); // run the given animation after 500 ms
- \*/
- Animation.prototype.delay = function (delay) {
- var a = new Animation(this.anim, this.ms);
- a.times = this.times;
- a.del = +delay || 0;
- return a;
+
+ walk(node);
+
+ return {
+ sourceCode: chunks.join('').replace(/\n$/, ''),
+ spans: spans
};
- /*\
- * Animation.repeat
- [ method ]
- **
- * Creates a copy of existing animation object with given repetition.
- **
- > Parameters
- **
- - repeat (number) number iterations of animation. For infinite animation pass `Infinity`
- **
- = (object) new altered Animation object
- \*/
- Animation.prototype.repeat = function (times) {
- var a = new Animation(this.anim, this.ms);
- a.del = this.del;
- a.times = math.floor(mmax(times, 0)) || 1;
- return a;
+ }
+
+ /**
+ * Apply the given language handler to sourceCode and add the resulting
+ * decorations to out.
+ * @param {number} basePos the index of sourceCode within the chunk of source
+ * whose decorations are already present on out.
+ */
+ function appendDecorations(basePos, sourceCode, langHandler, out) {
+ if (!sourceCode) { return; }
+ var job = {
+ sourceCode: sourceCode,
+ basePos: basePos
};
- function runAnimation(anim, element, percent, status, totalOrigin, times) {
- percent = toFloat(percent);
- var params,
- isInAnim,
- isInAnimSet,
- percents = [],
- next,
- prev,
- timestamp,
- ms = anim.ms,
- from = {},
- to = {},
- diff = {};
- if (status) {
- for (i = 0, ii = animationElements.length; i < ii; i++) {
- var e = animationElements[i];
- if (e.el.id == element.id && e.anim == anim) {
- if (e.percent != percent) {
- animationElements.splice(i, 1);
- isInAnimSet = 1;
- } else {
- isInAnim = e;
- }
- element.attr(e.totalOrigin);
- break;
- }
- }
- } else {
- status = +to; // NaN
- }
- for (var i = 0, ii = anim.percents.length; i < ii; i++) {
- if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) {
- percent = anim.percents[i];
- prev = anim.percents[i - 1] || 0;
- ms = ms / anim.top * (percent - prev);
- next = anim.percents[i + 1];
- params = anim.anim[percent];
- break;
- } else if (status) {
- element.attr(anim.anim[anim.percents[i]]);
- }
+ langHandler(job);
+ out.push.apply(out, job.decorations);
+ }
+
+ var notWs = /\S/;
+
+ /**
+ * Given an element, if it contains only one child element and any text nodes
+ * it contains contain only space characters, return the sole child element.
+ * Otherwise returns undefined.
+ *
+ * This is meant to return the CODE element in {@code
} when
+ * there is a single child element that contains all the non-space textual
+ * content, but not to return anything where there are multiple child elements
+ * as in {@code ...
...
} or when there
+ * is textual content.
+ */
+ function childContentWrapper(element) {
+ var wrapper = undefined;
+ for (var c = element.firstChild; c; c = c.nextSibling) {
+ var type = c.nodeType;
+ wrapper = (type === 1) // Element Node
+ ? (wrapper ? element : c)
+ : (type === 3) // Text Node
+ ? (notWs.test(c.nodeValue) ? element : wrapper)
+ : wrapper;
+ }
+ return wrapper === element ? undefined : wrapper;
+ }
+
+ /** Given triples of [style, pattern, context] returns a lexing function,
+ * The lexing function interprets the patterns to find token boundaries and
+ * returns a decoration list of the form
+ * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
+ * where index_n is an index into the sourceCode, and style_n is a style
+ * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
+ * all characters in sourceCode[index_n-1:index_n].
+ *
+ * The stylePatterns is a list whose elements have the form
+ * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
+ *
+ * Style is a style constant like PR_PLAIN, or can be a string of the
+ * form 'lang-FOO', where FOO is a language extension describing the
+ * language of the portion of the token in $1 after pattern executes.
+ * E.g., if style is 'lang-lisp', and group 1 contains the text
+ * '(hello (world))', then that portion of the token will be passed to the
+ * registered lisp handler for formatting.
+ * The text before and after group 1 will be restyled using this decorator
+ * so decorators should take care that this doesn't result in infinite
+ * recursion. For example, the HTML lexer rule for SCRIPT elements looks
+ * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
+ * '',"",'<%= documentHTML %>',"