beta2 ok
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
"github.com/revel/revel"
|
||||
"strings"
|
||||
// "encoding/json"
|
||||
"fmt"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/leanote/leanote/app/lea/blog"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"fmt"
|
||||
// "github.com/leanote/leanote/app/types"
|
||||
// "io/ioutil"
|
||||
// "math"
|
||||
@@ -47,26 +47,25 @@ $.bootstrapCssUrl
|
||||
$.bootstrapJsUrl
|
||||
*/
|
||||
|
||||
|
||||
func (c Blog) render(templateName string, themePath string) revel.Result {
|
||||
isPreview := false
|
||||
if c.RenderArgs["isPreview"] != nil {
|
||||
if c.RenderArgs["isPreview"] != nil {
|
||||
themePath2 := c.RenderArgs["themePath"]
|
||||
if themePath2 == nil {
|
||||
return c.E404();
|
||||
return c.E404()
|
||||
}
|
||||
isPreview = true
|
||||
themePath = themePath2.(string)
|
||||
c.setPreviewUrl()
|
||||
}
|
||||
return blog.RenderTemplate(templateName, c.RenderArgs, revel.BasePath + "/" + themePath, isPreview)
|
||||
return blog.RenderTemplate(templateName, c.RenderArgs, revel.BasePath+"/"+themePath, isPreview)
|
||||
}
|
||||
|
||||
// 404
|
||||
func (c Blog) e404(themePath string) revel.Result {
|
||||
// 不知道是谁的404, 则用系统的404
|
||||
if themePath == "" {
|
||||
return c.E404();
|
||||
return c.E404()
|
||||
}
|
||||
return c.render("404.html", themePath)
|
||||
}
|
||||
@@ -101,24 +100,24 @@ func (c Blog) domain() (ok bool, userBlog info.UserBlog) {
|
||||
// 渲染模板之
|
||||
func (c Blog) setPreviewUrl() {
|
||||
var indexUrl, postUrl, searchUrl, cateUrl, singleUrl, tagsUrl, archiveUrl string
|
||||
|
||||
|
||||
userId := c.GetUserId()
|
||||
themeId := c.Session["themeId"]
|
||||
theme := themeService.GetTheme(userId, themeId)
|
||||
|
||||
|
||||
siteUrl := configService.GetSiteUrl()
|
||||
blogUrl := siteUrl + "/preview" // blog.leanote.com
|
||||
userIdOrEmail := userId
|
||||
|
||||
indexUrl = blogUrl + "/" + userIdOrEmail
|
||||
cateUrl = blogUrl + "/cate" // /notebookId
|
||||
|
||||
postUrl = blogUrl + "/post" // /xxxxx
|
||||
searchUrl = blogUrl + "/search/" + userIdOrEmail // blog.leanote.com/search/userId
|
||||
singleUrl = blogUrl + "/single" // blog.leanote.com/single/singleId
|
||||
cateUrl = blogUrl + "/cate" // /notebookId
|
||||
|
||||
postUrl = blogUrl + "/post" // /xxxxx
|
||||
searchUrl = blogUrl + "/search/" + userIdOrEmail // blog.leanote.com/search/userId
|
||||
singleUrl = blogUrl + "/single" // blog.leanote.com/single/singleId
|
||||
archiveUrl = blogUrl + "/archives/" + userIdOrEmail // blog.leanote.com/archive/userId
|
||||
tagsUrl = blogUrl + "/tags/" + userIdOrEmail // blog.leanote.com/archive/userId
|
||||
|
||||
tagsUrl = blogUrl + "/tags/" + userIdOrEmail // blog.leanote.com/archive/userId
|
||||
|
||||
c.RenderArgs["indexUrl"] = indexUrl
|
||||
c.RenderArgs["cateUrl"] = cateUrl
|
||||
c.RenderArgs["postUrl"] = postUrl
|
||||
@@ -127,7 +126,7 @@ func (c Blog) setPreviewUrl() {
|
||||
c.RenderArgs["archiveUrl"] = archiveUrl
|
||||
c.RenderArgs["archivesUrl"] = archiveUrl // 别名
|
||||
c.RenderArgs["tagsUrl"] = tagsUrl
|
||||
c.RenderArgs["tagPostsUrl"] = blogUrl + "/tag/" + userIdOrEmail
|
||||
c.RenderArgs["tagPostsUrl"] = blogUrl + "/tag/" + userIdOrEmail
|
||||
c.RenderArgs["tagUrl"] = c.RenderArgs["tagPostsUrl"]
|
||||
|
||||
// themeBaseUrl 本theme的路径url, 可以加载js, css, images之类的
|
||||
@@ -137,89 +136,55 @@ func (c Blog) setPreviewUrl() {
|
||||
// 各种地址设置
|
||||
func (c Blog) setUrl(userBlog info.UserBlog, userInfo info.User) {
|
||||
// 主页 http://leanote.com/blog/life or http://blog.leanote.com/life or http:// xxxx.leanote.com or aa.com
|
||||
var indexUrl, postUrl, searchUrl, cateUrl, singleUrl, tagsUrl, archiveUrl, tagPostsUrl, staticUrl string
|
||||
host := c.Request.Request.Host
|
||||
staticUrl = configService.GetUserUrl(strings.Split(host, ":")[0])
|
||||
var staticUrl = configService.GetUserUrl(strings.Split(host, ":")[0])
|
||||
// staticUrl == host, 为保证同源!!! 只有host, http://leanote.com, http://blog/leanote.com
|
||||
// life.leanote.com, lealife.com
|
||||
siteUrl := configService.GetSiteUrl()
|
||||
if userBlog.Domain != "" && configService.AllowCustomDomain() {
|
||||
// ok
|
||||
indexUrl = configService.GetUserUrl(userBlog.Domain)
|
||||
cateUrl = indexUrl + "/cate" // /xxxxx
|
||||
postUrl = indexUrl + "/post" // /xxxxx
|
||||
searchUrl = indexUrl + "/search" // /xxxxx
|
||||
singleUrl = indexUrl + "/single"
|
||||
archiveUrl = indexUrl + "/archives"
|
||||
tagsUrl = indexUrl + "/tags"
|
||||
tagPostsUrl = indexUrl + "/tag"
|
||||
} else if userBlog.SubDomain != "" {
|
||||
indexUrl = configService.GetUserSubUrl(userBlog.SubDomain)
|
||||
cateUrl = indexUrl + "/cate" // /xxxxx
|
||||
postUrl = indexUrl + "/post" // /xxxxx
|
||||
searchUrl = indexUrl + "/search" // /xxxxx
|
||||
singleUrl = indexUrl + "/single"
|
||||
archiveUrl = indexUrl + "/archives"
|
||||
tagsUrl = indexUrl + "/tags"
|
||||
tagPostsUrl = indexUrl + "/tag"
|
||||
} else {
|
||||
// ok
|
||||
blogUrl := configService.GetBlogUrl() // blog.leanote.com
|
||||
userIdOrEmail := ""
|
||||
if userInfo.Username != "" {
|
||||
userIdOrEmail = userInfo.Username
|
||||
} else if userInfo.Email != "" {
|
||||
userIdOrEmail = userInfo.Email
|
||||
} else {
|
||||
userIdOrEmail = userInfo.UserId.Hex()
|
||||
}
|
||||
indexUrl = blogUrl + "/" + userIdOrEmail
|
||||
cateUrl = blogUrl + "/cate" // /notebookId
|
||||
postUrl = blogUrl + "/post" // /xxxxx
|
||||
searchUrl = blogUrl + "/search/" + userIdOrEmail // blog.leanote.com/search/userId
|
||||
singleUrl = blogUrl + "/single" // blog.leanote.com/single/singleId
|
||||
archiveUrl = blogUrl + "/archives/" + userIdOrEmail // blog.leanote.com/archive/userId
|
||||
tagsUrl = blogUrl + "/tags/" + userIdOrEmail
|
||||
tagPostsUrl = blogUrl + "/tag/" + userIdOrEmail // blog.leanote.com/archive/userId
|
||||
}
|
||||
|
||||
blogUrls := blogService.GetBlogUrls(&userBlog, &userInfo)
|
||||
// 分类
|
||||
// 搜索
|
||||
// 查看
|
||||
c.RenderArgs["siteUrl"] = siteUrl
|
||||
c.RenderArgs["indexUrl"] = indexUrl
|
||||
c.RenderArgs["cateUrl"] = cateUrl
|
||||
c.RenderArgs["postUrl"] = postUrl
|
||||
c.RenderArgs["searchUrl"] = searchUrl
|
||||
c.RenderArgs["singleUrl"] = singleUrl // 单页
|
||||
c.RenderArgs["archiveUrl"] = archiveUrl
|
||||
c.RenderArgs["archivesUrl"] = archiveUrl // 别名
|
||||
c.RenderArgs["tagsUrl"] = tagsUrl
|
||||
c.RenderArgs["tagPostsUrl"] = tagPostsUrl
|
||||
c.RenderArgs["tagUrl"] = c.RenderArgs["tagPostsUrl"] // 别名
|
||||
c.RenderArgs["indexUrl"] = blogUrls.IndexUrl
|
||||
c.RenderArgs["cateUrl"] = blogUrls.CateUrl
|
||||
c.RenderArgs["postUrl"] = blogUrls.PostUrl
|
||||
c.RenderArgs["searchUrl"] = blogUrls.SearchUrl
|
||||
c.RenderArgs["singleUrl"] = blogUrls.SingleUrl // 单页
|
||||
c.RenderArgs["archiveUrl"] = blogUrls.ArchiveUrl
|
||||
c.RenderArgs["archivesUrl"] = blogUrls.ArchiveUrl // 别名
|
||||
c.RenderArgs["tagsUrl"] = blogUrls.TagsUrl
|
||||
c.RenderArgs["tagPostsUrl"] = blogUrls.TagPostsUrl
|
||||
c.RenderArgs["tagUrl"] = blogUrls.TagPostsUrl // 别名
|
||||
|
||||
// themeBaseUrl 本theme的路径url, 可以加载js, css, images之类的
|
||||
c.RenderArgs["themeBaseUrl"] = "/" + userBlog.ThemePath
|
||||
|
||||
// 其它static js
|
||||
c.RenderArgs["jQueryUrl"] = siteUrl + "/js/jquery-1.9.0.min.js"
|
||||
|
||||
|
||||
c.RenderArgs["prettifyJsUrl"] = siteUrl + "/js/google-code-prettify/prettify.js"
|
||||
c.RenderArgs["prettifyCssUrl"] = siteUrl + "/js/google-code-prettify/prettify.css"
|
||||
|
||||
|
||||
c.RenderArgs["blogCommonJsUrl"] = siteUrl + "/public/blog/js/common.js"
|
||||
|
||||
|
||||
c.RenderArgs["shareCommentCssUrl"] = siteUrl + "/public/blog/css/share_comment.css"
|
||||
c.RenderArgs["shareCommentJsUrl"] = siteUrl + "/public/blog/js/share_comment.js"
|
||||
|
||||
|
||||
c.RenderArgs["fontAwesomeUrl"] = staticUrl + "/css/font-awesome-4.2.0/css/font-awesome.css"
|
||||
|
||||
|
||||
c.RenderArgs["bootstrapCssUrl"] = siteUrl + "/css/bootstrap.css"
|
||||
c.RenderArgs["bootstrapJsUrl"] = siteUrl + "/js/bootstrap-min.js"
|
||||
}
|
||||
|
||||
// 笔记本分类
|
||||
// cates = [{title:"xxx", cateId: "xxxx"}, {}]
|
||||
func (c Blog) getCateUrlTitle(n *info.Notebook) string {
|
||||
if n.UrlTitle != "" {
|
||||
return n.UrlTitle
|
||||
}
|
||||
return n.NotebookId.Hex()
|
||||
}
|
||||
func (c Blog) getCates(userBlog info.UserBlog) {
|
||||
notebooks := blogService.ListBlogNotebooks(userBlog.UserId.Hex())
|
||||
notebooksMap := map[string]info.Notebook{}
|
||||
@@ -236,7 +201,7 @@ func (c Blog) getCates(userBlog info.UserBlog) {
|
||||
if cateIds != nil && len(cateIds) > 0 {
|
||||
for _, cateId := range cateIds {
|
||||
if n, ok := notebooksMap[cateId]; ok {
|
||||
cates[i] = map[string]string{"Title": n.Title, "CateId": n.NotebookId.Hex()}
|
||||
cates[i] = map[string]string{"Title": n.Title, "UrlTitle": c.getCateUrlTitle(&n), "CateId": n.NotebookId.Hex()}
|
||||
i++
|
||||
has[cateId] = true
|
||||
}
|
||||
@@ -246,7 +211,7 @@ func (c Blog) getCates(userBlog info.UserBlog) {
|
||||
for _, n := range notebooks {
|
||||
id := n.NotebookId.Hex()
|
||||
if !has[id] {
|
||||
cates[i] = map[string]string{"Title": n.Title, "CateId": id}
|
||||
cates[i] = map[string]string{"Title": n.Title, "UrlTitle": c.getCateUrlTitle(&n), "CateId": id}
|
||||
i++
|
||||
}
|
||||
}
|
||||
@@ -279,39 +244,15 @@ func (c Blog) setBlog(userBlog info.UserBlog, userInfo info.User) {
|
||||
"Logo": userBlog.Logo,
|
||||
"OpenComment": userBlog.CanComment,
|
||||
"CommentType": userBlog.CommentType, // leanote, or disqus
|
||||
"DisqusId": userBlog.DisqusId,
|
||||
"DisqusId": userBlog.DisqusId,
|
||||
"ThemeId": userBlog.ThemeId,
|
||||
"SubDomain": userBlog.SubDomain,
|
||||
"Domain": userBlog.Domain,
|
||||
}
|
||||
c.RenderArgs["blogInfo"] = blogInfo
|
||||
/*
|
||||
blogInfo := info.BlogInfoCustom{
|
||||
UserId: userBlog.UserId.Hex(),
|
||||
Username: userInfo.Username,
|
||||
UserLogo: userInfo.Logo,
|
||||
Title: userBlog.Title,
|
||||
SubTitle: userBlog.SubTitle,
|
||||
Logo: userBlog.Logo,
|
||||
OpenComment: userBlog.CanComment,
|
||||
CommentType: userBlog.CommentType, // leanote, or disqus
|
||||
ThemeId: userBlog.ThemeId,
|
||||
SubDomain: userBlog.SubDomain,
|
||||
Domain: userBlog.Domain,
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (c Blog) setPaging(pageInfo info.Page) {
|
||||
/*
|
||||
// 这些分类信息用一个变量
|
||||
paging := map[string]interface{}{ // 分页信息
|
||||
"CurPage": pageInfo.CurPage, // 当前页
|
||||
"TotalPage": pageInfo.TotalPage, // 总页数
|
||||
"PerPageSize": pageInfo.PerPageSize, // 每一页的记录数
|
||||
"Count": pageInfo.Count, // 总记录数
|
||||
}
|
||||
*/
|
||||
c.RenderArgs["paging"] = pageInfo
|
||||
}
|
||||
|
||||
@@ -323,13 +264,13 @@ func (c Blog) blogCommon(userId string, userBlog info.UserBlog, userInfo info.Us
|
||||
return false, userBlog
|
||||
}
|
||||
}
|
||||
// c.RenderArgs["userInfo"] = userInfo
|
||||
// c.RenderArgs["userInfo"] = userInfo
|
||||
|
||||
// 最新笔记
|
||||
_, recentBlogs := blogService.ListBlogs(userId, "", 1, 5, userBlog.SortField, userBlog.IsAsc)
|
||||
c.RenderArgs["recentPosts"] = c.fixBlogs(recentBlogs)
|
||||
c.RenderArgs["latestPosts"] = c.RenderArgs["recentPosts"]
|
||||
c.RenderArgs["tags"] = blogService.GetBlogTags(userId)
|
||||
c.RenderArgs["recentPosts"] = blogService.FixBlogs(recentBlogs)
|
||||
c.RenderArgs["latestPosts"] = c.RenderArgs["recentPosts"]
|
||||
c.RenderArgs["tags"] = blogService.GetBlogTags(userId)
|
||||
|
||||
// 语言, url地址
|
||||
c.SetLocale()
|
||||
@@ -339,7 +280,7 @@ func (c Blog) blogCommon(userId string, userBlog info.UserBlog, userInfo info.Us
|
||||
userBlog = blogService.GetUserBlog(userId)
|
||||
}
|
||||
c.setBlog(userBlog, userInfo)
|
||||
// c.RenderArgs["userBlog"] = userBlog
|
||||
// c.RenderArgs["userBlog"] = userBlog
|
||||
|
||||
// 分类导航
|
||||
c.getCates(userBlog)
|
||||
@@ -352,42 +293,14 @@ func (c Blog) blogCommon(userId string, userBlog info.UserBlog, userInfo info.Us
|
||||
// 当前分类Id, 全设为""
|
||||
c.RenderArgs["curCateId"] = ""
|
||||
c.RenderArgs["curSingleId"] = ""
|
||||
|
||||
|
||||
// 得到主题信息
|
||||
themeInfo := themeService.GetThemeInfo(userBlog.ThemeId.Hex(), userBlog.Style)
|
||||
LogJ(themeInfo)
|
||||
c.RenderArgs["themeInfo"] = themeInfo
|
||||
|
||||
return true, userBlog
|
||||
}
|
||||
|
||||
// 修复博客, index, cate用到
|
||||
func (c Blog) fixBlog(blog info.BlogItem) info.Post {
|
||||
blog2 := info.Post{
|
||||
NoteId: blog.NoteId.Hex(),
|
||||
Title: blog.Title,
|
||||
CreatedTime: blog.CreatedTime,
|
||||
UpdatedTime: blog.UpdatedTime,
|
||||
PublicTime: blog.PublicTime,
|
||||
Desc: blog.Desc,
|
||||
Abstract: blog.Abstract,
|
||||
Content: blog.Content,
|
||||
Tags: blog.Tags,
|
||||
CommentNum: blog.CommentNum,
|
||||
ReadNum: blog.ReadNum,
|
||||
LikeNum: blog.LikeNum,
|
||||
IsMarkdown: blog.IsMarkdown,
|
||||
}
|
||||
return blog2
|
||||
}
|
||||
func (c Blog) fixBlogs(blogs []info.BlogItem) []info.Post {
|
||||
blogs2 := make([]info.Post, len(blogs))
|
||||
for i, blog := range blogs {
|
||||
blogs2[i] = c.fixBlog(blog)
|
||||
}
|
||||
return blogs2
|
||||
}
|
||||
|
||||
// 404
|
||||
func (c Blog) E(userIdOrEmail, tag string) revel.Result {
|
||||
ok, userBlog := c.domain()
|
||||
@@ -403,8 +316,8 @@ func (c Blog) E(userIdOrEmail, tag string) revel.Result {
|
||||
userInfo = userService.GetUserInfoByAny(userIdOrEmail)
|
||||
}
|
||||
userId = userInfo.UserId.Hex()
|
||||
_, userBlog = c.blogCommon(userId, userBlog, userInfo);
|
||||
|
||||
_, userBlog = c.blogCommon(userId, userBlog, userInfo)
|
||||
|
||||
return c.e404(userBlog.ThemePath)
|
||||
}
|
||||
|
||||
@@ -413,10 +326,10 @@ func (c Blog) Tags(userIdOrEmail string) (re revel.Result) {
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
@@ -448,10 +361,10 @@ func (c Blog) Tag(userIdOrEmail, tag string) (re revel.Result) {
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
@@ -465,23 +378,23 @@ func (c Blog) Tag(userIdOrEmail, tag string) (re revel.Result) {
|
||||
userInfo = userService.GetUserInfoByAny(userIdOrEmail)
|
||||
}
|
||||
userId = userInfo.UserId.Hex()
|
||||
|
||||
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
}
|
||||
|
||||
|
||||
if hasDomain && tag == "" {
|
||||
tag = userIdOrEmail
|
||||
}
|
||||
|
||||
|
||||
c.RenderArgs["curIsTagPosts"] = true
|
||||
c.RenderArgs["curTag"] = tag
|
||||
page := c.GetPage()
|
||||
pageInfo, blogs := blogService.SearchBlogByTags([]string{tag}, userId, page, userBlog.PerPageSize, userBlog.SortField, userBlog.IsAsc)
|
||||
c.setPaging(pageInfo)
|
||||
|
||||
c.RenderArgs["posts"] = c.fixBlogs(blogs)
|
||||
c.RenderArgs["posts"] = blogService.FixBlogs(blogs)
|
||||
tagPostsUrl := c.RenderArgs["tagPostsUrl"].(string)
|
||||
c.RenderArgs["pagingBaseUrl"] = tagPostsUrl + "/" + tag
|
||||
|
||||
@@ -496,7 +409,7 @@ func (c Blog) Archives(userIdOrEmail string, cateId string, year, month int) (re
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
fmt.Println(err)
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
userId := ""
|
||||
@@ -532,59 +445,52 @@ func (c Blog) Archives(userIdOrEmail string, cateId string, year, month int) (re
|
||||
}
|
||||
c.RenderArgs["curYear"] = year
|
||||
c.RenderArgs["curMonth"] = month
|
||||
|
||||
|
||||
return c.render("archive.html", userBlog.ThemePath)
|
||||
}
|
||||
|
||||
// 进入某个用户的博客
|
||||
// TODO 可以配置, 排序和数目
|
||||
var blogPageSize = 5
|
||||
var searchBlogPageSize = 30
|
||||
|
||||
// 分类 /cate/xxxxxxxx?notebookId=1212
|
||||
func (c Blog) Cate(notebookId string) (re revel.Result) {
|
||||
func (c Blog) Cate(userIdOrEmail string, notebookId string) (re revel.Result) {
|
||||
// 自定义域名
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
fmt.Println(err)
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
|
||||
if notebookId == "" {
|
||||
return c.e404(userBlog.ThemePath);
|
||||
}
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
}
|
||||
|
||||
userId, userInfo := c.userIdOrEmail(hasDomain, userBlog, userIdOrEmail)
|
||||
notebookId2 := notebookId
|
||||
var notebook info.Notebook
|
||||
notebook = notebookService.GetNotebookById(notebookId)
|
||||
if userId == "" { // 证明没有userIdOrEmail, 只有singleId, 那么直接查
|
||||
notebook = notebookService.GetNotebookById(notebookId)
|
||||
userId = notebook.UserId.Hex()
|
||||
} else {
|
||||
notebook = notebookService.GetNotebookByUserIdAndUrlTitle(userId, notebookId)
|
||||
notebookId2 = notebook.NotebookId.Hex()
|
||||
}
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
}
|
||||
if !notebook.IsBlog {
|
||||
return c.e404("")
|
||||
}
|
||||
if userId != "" && userId != notebook.UserId.Hex() {
|
||||
return c.e404("")
|
||||
}
|
||||
userId = notebook.UserId.Hex()
|
||||
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, info.User{}); !ok {
|
||||
return c.e404(userBlog.ThemePath)
|
||||
}
|
||||
|
||||
// 分页的话, 需要分页信息, totalPage, curPage
|
||||
page := c.GetPage()
|
||||
pageInfo, blogs := blogService.ListBlogs(userId, notebookId, page, userBlog.PerPageSize, userBlog.SortField, userBlog.IsAsc)
|
||||
blogs2 := c.fixBlogs(blogs)
|
||||
pageInfo, blogs := blogService.ListBlogs(userId, notebookId2, page, userBlog.PerPageSize, userBlog.SortField, userBlog.IsAsc)
|
||||
blogs2 := blogService.FixBlogs(blogs)
|
||||
c.RenderArgs["posts"] = blogs2
|
||||
|
||||
c.setPaging(pageInfo)
|
||||
|
||||
c.RenderArgs["curCateTitle"] = notebook.Title
|
||||
c.RenderArgs["curCateId"] = notebookId
|
||||
c.RenderArgs["curCateId"] = notebookId2
|
||||
cateUrl := c.RenderArgs["cateUrl"].(string)
|
||||
c.RenderArgs["pagingBaseUrl"] = cateUrl + "/" + notebookId
|
||||
c.RenderArgs["curIsCate"] = true
|
||||
@@ -592,31 +498,37 @@ func (c Blog) Cate(notebookId string) (re revel.Result) {
|
||||
return c.render("cate.html", userBlog.ThemePath)
|
||||
}
|
||||
|
||||
func (c Blog) userIdOrEmail(hasDomain bool, userBlog info.UserBlog, userIdOrEmail string) (userId string, userInfo info.User) {
|
||||
userId = ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
}
|
||||
if userId != "" {
|
||||
userInfo = userService.GetUserInfoByAny(userId)
|
||||
} else {
|
||||
if userIdOrEmail != "" {
|
||||
userInfo = userService.GetUserInfoByAny(userIdOrEmail)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
userId = userInfo.UserId.Hex()
|
||||
return
|
||||
}
|
||||
|
||||
func (c Blog) Index(userIdOrEmail string) (re revel.Result) {
|
||||
// 自定义域名
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
}
|
||||
|
||||
// 用户id为空, 转至博客平台
|
||||
// 用户id为空, 则是admin用户的博客
|
||||
if userIdOrEmail == "" {
|
||||
userIdOrEmail = configService.GetAdminUsername()
|
||||
}
|
||||
var userInfo info.User
|
||||
if userId != "" {
|
||||
userInfo = userService.GetUserInfoByAny(userId)
|
||||
} else {
|
||||
userInfo = userService.GetUserInfoByAny(userIdOrEmail)
|
||||
}
|
||||
userId = userInfo.UserId.Hex()
|
||||
|
||||
userId, userInfo := c.userIdOrEmail(hasDomain, userBlog, userIdOrEmail)
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
@@ -625,7 +537,7 @@ func (c Blog) Index(userIdOrEmail string) (re revel.Result) {
|
||||
// 分页的话, 需要分页信息, totalPage, curPage
|
||||
page := c.GetPage()
|
||||
pageInfo, blogs := blogService.ListBlogs(userId, "", page, userBlog.PerPageSize, userBlog.SortField, userBlog.IsAsc)
|
||||
blogs2 := c.fixBlogs(blogs)
|
||||
blogs2 := blogService.FixBlogs(blogs)
|
||||
c.RenderArgs["posts"] = blogs2
|
||||
|
||||
c.setPaging(pageInfo)
|
||||
@@ -636,66 +548,36 @@ func (c Blog) Index(userIdOrEmail string) (re revel.Result) {
|
||||
return c.render("index.html", userBlog.ThemePath)
|
||||
}
|
||||
|
||||
// 详情
|
||||
// 为了上一篇, 下一篇
|
||||
func (c Blog) fixNote(note info.Note) map[string]interface{} {
|
||||
if note.NoteId == "" {
|
||||
return nil
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"NoteId": note.NoteId.Hex(),
|
||||
"Title": note.Title,
|
||||
"CreatedTime": note.CreatedTime,
|
||||
"UpdatedTime": note.UpdatedTime,
|
||||
"PublicTime": note.PublicTime,
|
||||
"Desc": note.Desc,
|
||||
"Tags": note.Tags,
|
||||
"CommentNum": note.CommentNum,
|
||||
"ReadNum": note.ReadNum,
|
||||
"LikeNum": note.LikeNum,
|
||||
"IsMarkdown": note.IsMarkdown,
|
||||
}
|
||||
}
|
||||
|
||||
func (c Blog) Post(noteId string) (re revel.Result) {
|
||||
func (c Blog) Post(userIdOrEmail, noteId string) (re revel.Result) {
|
||||
// 自定义域名
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
Log(err)
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
|
||||
userId, userInfo := c.userIdOrEmail(hasDomain, userBlog, userIdOrEmail)
|
||||
var blogInfo info.BlogItem
|
||||
if userId == "" { // 证明没有userIdOrEmail, 只有singleId, 那么直接查
|
||||
blogInfo = blogService.GetBlog(noteId)
|
||||
userId = blogInfo.UserId.Hex()
|
||||
} else {
|
||||
blogInfo = blogService.GetBlogByIdAndUrlTitle(userId, noteId)
|
||||
}
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
}
|
||||
if blogInfo.NoteId == "" {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
}
|
||||
|
||||
blogInfo := blogService.GetBlog(noteId)
|
||||
userInfo := userService.GetUserInfo(blogInfo.UserId.Hex())
|
||||
if userId != "" && userInfo.UserId.Hex() != userId {
|
||||
panic("error")
|
||||
}
|
||||
|
||||
userId = userInfo.UserId.Hex()
|
||||
_, userBlog = c.blogCommon(userId, userBlog, info.User{})
|
||||
|
||||
c.RenderArgs["post"] = c.fixBlog(blogInfo)
|
||||
c.RenderArgs["post"] = blogService.FixBlog(blogInfo)
|
||||
// c.RenderArgs["userInfo"] = userInfo
|
||||
c.RenderArgs["curIsPost"] = true
|
||||
|
||||
// 得到访问者id
|
||||
/*
|
||||
visitUserId := c.GetUserId()
|
||||
if visitUserId != "" {
|
||||
visitUserInfo := userService.GetUserInfo(visitUserId)
|
||||
c.RenderArgs["visitUserInfoJson"] = c.Json(visitUserInfo)
|
||||
c.RenderArgs["visitUserInfo"] = visitUserInfo
|
||||
} else {
|
||||
c.RenderArgs["visitUserInfoJson"] = "{}"
|
||||
}
|
||||
*/
|
||||
|
||||
// 上一篇, 下一篇
|
||||
var baseTime interface{}
|
||||
if userBlog.SortField == "PublicTime" {
|
||||
@@ -708,44 +590,46 @@ func (c Blog) Post(noteId string) (re revel.Result) {
|
||||
baseTime = blogInfo.Title
|
||||
}
|
||||
|
||||
preNote, nextNote := blogService.PreNextBlog(userId, userBlog.SortField, userBlog.IsAsc, baseTime)
|
||||
c.RenderArgs["prePost"] = c.fixNote(preNote)
|
||||
c.RenderArgs["nextPost"] = c.fixNote(nextNote)
|
||||
Log("---------")
|
||||
prePost, nextPost := blogService.PreNextBlog(userId, userBlog.SortField, userBlog.IsAsc, baseTime)
|
||||
c.RenderArgs["prePost"] = prePost
|
||||
c.RenderArgs["nextPost"] = nextPost
|
||||
return c.render("post.html", userBlog.ThemePath)
|
||||
}
|
||||
|
||||
func (c Blog) Single(singleId string) (re revel.Result) {
|
||||
func (c Blog) Single(userIdOrEmail, singleId string) (re revel.Result) {
|
||||
// 自定义域名
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
|
||||
userId := ""
|
||||
if hasDomain {
|
||||
userId = userBlog.UserId.Hex()
|
||||
}
|
||||
|
||||
single := blogService.GetSingle(singleId)
|
||||
userInfo := userService.GetUserInfo(single.UserId.Hex())
|
||||
if userId != "" && userInfo.UserId.Hex() != userId {
|
||||
return c.e404(userBlog.ThemePath)
|
||||
userId, userInfo := c.userIdOrEmail(hasDomain, userBlog, userIdOrEmail)
|
||||
var single info.BlogSingle
|
||||
if userId == "" { // 证明没有userIdOrEmail, 只有singleId, 那么直接查
|
||||
single = blogService.GetSingle(singleId)
|
||||
userId = single.UserId.Hex()
|
||||
} else {
|
||||
single = blogService.GetSingleByUserIdAndUrlTitle(userId, singleId)
|
||||
}
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
return c.e404(userBlog.ThemePath) // 404 TODO 使用用户的404
|
||||
}
|
||||
if single.SingleId == "" {
|
||||
panic("")
|
||||
}
|
||||
|
||||
userId = userInfo.UserId.Hex()
|
||||
_, userBlog = c.blogCommon(userId, userBlog, info.User{})
|
||||
|
||||
c.RenderArgs["single"] = map[string]interface{}{
|
||||
"SingleId": single.SingleId.Hex(),
|
||||
"Title": single.Title,
|
||||
"UrlTitle": single.UrlTitle,
|
||||
"Content": single.Content,
|
||||
"CreatedTime": single.CreatedTime,
|
||||
"UpdatedTime": single.UpdatedTime,
|
||||
}
|
||||
c.RenderArgs["curSingleId"] = singleId
|
||||
c.RenderArgs["curSingleId"] = single.SingleId.Hex()
|
||||
c.RenderArgs["curIsSingle"] = true
|
||||
|
||||
return c.render("single.html", userBlog.ThemePath)
|
||||
@@ -757,7 +641,7 @@ func (c Blog) Search(userIdOrEmail, keywords string) (re revel.Result) {
|
||||
hasDomain, userBlog := c.domain()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
re = c.e404(userBlog.ThemePath);
|
||||
re = c.e404(userBlog.ThemePath)
|
||||
}
|
||||
}()
|
||||
userId := ""
|
||||
@@ -771,7 +655,7 @@ func (c Blog) Search(userIdOrEmail, keywords string) (re revel.Result) {
|
||||
} else {
|
||||
userInfo = userService.GetUserInfoByAny(userIdOrEmail)
|
||||
}
|
||||
// c.RenderArgs["userInfo"] = userInfo
|
||||
// c.RenderArgs["userInfo"] = userInfo
|
||||
userId = userInfo.UserId.Hex()
|
||||
var ok = false
|
||||
if ok, userBlog = c.blogCommon(userId, userBlog, userInfo); !ok {
|
||||
@@ -782,7 +666,7 @@ func (c Blog) Search(userIdOrEmail, keywords string) (re revel.Result) {
|
||||
pageInfo, blogs := blogService.SearchBlog(keywords, userId, page, userBlog.PerPageSize, userBlog.SortField, userBlog.IsAsc)
|
||||
c.setPaging(pageInfo)
|
||||
|
||||
c.RenderArgs["posts"] = c.fixBlogs(blogs)
|
||||
c.RenderArgs["posts"] = blogService.FixBlogs(blogs)
|
||||
c.RenderArgs["keywords"] = keywords
|
||||
searchUrl, _ := c.RenderArgs["searchUrl"].(string)
|
||||
c.RenderArgs["pagingBaseUrl"] = searchUrl + "?keywords=" + keywords
|
||||
@@ -808,7 +692,7 @@ func (c Blog) GetPostStat(noteId string) revel.Result {
|
||||
re.Ok = true
|
||||
statInfo := blogService.GetBlogStat(noteId)
|
||||
re.Item = statInfo
|
||||
return c.RenderJson(re);
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// jsonP
|
||||
@@ -819,7 +703,7 @@ func (c Blog) GetLikes(noteId string, callback string) revel.Result {
|
||||
userId := c.GetUserId()
|
||||
result := map[string]interface{}{}
|
||||
isILikeIt := false
|
||||
if userId != "" {
|
||||
if userId != "" {
|
||||
isILikeIt = blogService.IsILikeIt(noteId, userId)
|
||||
result["visitUserInfo"] = userService.GetUserAndBlog(userId)
|
||||
}
|
||||
@@ -841,11 +725,11 @@ func (c Blog) GetLikesAndComments(noteId, callback string) revel.Result {
|
||||
|
||||
// 我也点过?
|
||||
isILikeIt := false
|
||||
if userId != "" {
|
||||
if userId != "" {
|
||||
isILikeIt = blogService.IsILikeIt(noteId, userId)
|
||||
result["visitUserInfo"] = userService.GetUserAndBlog(userId)
|
||||
}
|
||||
|
||||
|
||||
// 点赞用户列表
|
||||
likedUsers, hasMoreLikedUser := blogService.ListLikedUsers(noteId, false)
|
||||
// 评论
|
||||
@@ -892,18 +776,21 @@ func (c Blog) GetComments(noteId string) revel.Result {
|
||||
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// jsonp
|
||||
func (c Blog) DeleteComment(noteId, commentId string, callback string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = blogService.DeleteComment(noteId, commentId, c.GetUserId())
|
||||
return c.RenderJsonP(callback, re)
|
||||
}
|
||||
|
||||
// jsonp
|
||||
func (c Blog) CommentPost(noteId, content, toCommentId string, callback string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Item = blogService.Comment(noteId, toCommentId, c.GetUserId(), content)
|
||||
return c.RenderJsonP(callback, re)
|
||||
}
|
||||
|
||||
// jsonp
|
||||
func (c Blog) LikeComment(commentId string, callback string) revel.Result {
|
||||
re := info.NewRe()
|
||||
|
||||
@@ -14,6 +14,10 @@ type Index struct {
|
||||
|
||||
// leanote展示页, 没有登录的, 或已登录明确要进该页的
|
||||
func (c Index) Index() revel.Result {
|
||||
if configService.HomePageIsAdminsBlog(){
|
||||
blog := Blog{c.BaseController}
|
||||
return blog.Index(configService.GetAdminUsername());
|
||||
}
|
||||
c.SetUserInfo()
|
||||
c.RenderArgs["title"] = "leanote"
|
||||
c.RenderArgs["openRegister"] = configService.GlobalStringConfigs["openRegister"]
|
||||
|
||||
@@ -71,25 +71,25 @@ func (c Preview) Archives(userIdOrEmail string, notebookId string, year, month i
|
||||
return c.Blog.Archives(c.GetUserId(), notebookId, year, month)
|
||||
// return blog.RenderTemplate("archive.html", c.RenderArgs, c.getPreviewThemeAbsolutePath(""))
|
||||
}
|
||||
func (c Preview) Cate(notebookId string) revel.Result {
|
||||
func (c Preview) Cate(userIdOrEmail, notebookId string) revel.Result {
|
||||
if !c.getPreviewThemeAbsolutePath("") {
|
||||
return c.E404()
|
||||
}
|
||||
return c.Blog.Cate(notebookId)
|
||||
return c.Blog.Cate(userIdOrEmail, notebookId)
|
||||
// return blog.RenderTemplate("cate.html", c.RenderArgs, c.getPreviewThemeAbsolutePath(""))
|
||||
}
|
||||
func (c Preview) Post(noteId string) revel.Result {
|
||||
func (c Preview) Post(userIdOrEmail, noteId string) revel.Result {
|
||||
if !c.getPreviewThemeAbsolutePath("") {
|
||||
return c.E404()
|
||||
}
|
||||
return c.Blog.Post(noteId)
|
||||
return c.Blog.Post(userIdOrEmail, noteId)
|
||||
// return blog.RenderTemplate("view.html", c.RenderArgs, c.getPreviewThemeAbsolutePath(""))
|
||||
}
|
||||
func (c Preview) Single(singleId string) revel.Result {
|
||||
func (c Preview) Single(userIdOrEmail, singleId string) revel.Result {
|
||||
if !c.getPreviewThemeAbsolutePath("") {
|
||||
return c.E404()
|
||||
}
|
||||
return c.Blog.Single(singleId)
|
||||
return c.Blog.Single(userIdOrEmail, singleId)
|
||||
// return blog.RenderTemplate("single.html", c.RenderArgs, c.getPreviewThemeAbsolutePath(""))
|
||||
}
|
||||
func (c Preview) Search(userIdOrEmail, keywords string) revel.Result {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/revel/revel"
|
||||
// "encoding/json"
|
||||
// "gopkg.in/mgo.v2/bson"
|
||||
// . "github.com/leanote/leanote/app/lea"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
// "github.com/leanote/leanote/app/types"
|
||||
// "io/ioutil"
|
||||
@@ -87,6 +87,8 @@ func (c Share) ListNoteShareUserInfo(noteId string) revel.Result {
|
||||
noteShareUserInfos := shareService.ListNoteShareUserInfo(noteId, c.GetUserId())
|
||||
c.RenderArgs["noteOrNotebookShareUserInfos"] = noteShareUserInfos
|
||||
|
||||
c.RenderArgs["noteOrNotebookShareGroupInfos"] = shareService.GetNoteShareGroups(noteId, c.GetUserId())
|
||||
|
||||
c.RenderArgs["isNote"] = true
|
||||
c.RenderArgs["noteOrNotebookId"] = note.NoteId.Hex();
|
||||
c.RenderArgs["title"] = note.Title
|
||||
@@ -99,6 +101,9 @@ func (c Share) ListNotebookShareUserInfo(notebookId string) revel.Result {
|
||||
notebookShareUserInfos := shareService.ListNotebookShareUserInfo(notebookId, c.GetUserId())
|
||||
c.RenderArgs["noteOrNotebookShareUserInfos"] = notebookShareUserInfos
|
||||
|
||||
c.RenderArgs["noteOrNotebookShareGroupInfos"] = shareService.GetNotebookShareGroups(notebookId, c.GetUserId())
|
||||
LogJ(c.RenderArgs["noteOrNotebookShareGroupInfos"])
|
||||
|
||||
c.RenderArgs["isNote"] = false
|
||||
c.RenderArgs["noteOrNotebookId"] = notebook.NotebookId.Hex();
|
||||
c.RenderArgs["title"] = notebook.Title
|
||||
@@ -139,4 +144,45 @@ func (c Share) DeleteShareNotebookBySharedUser(notebookId string, fromUserId str
|
||||
// 删除fromUserId分享给我的所有note, notebook
|
||||
func (c Share) DeleteUserShareNoteAndNotebook(fromUserId string) revel.Result {
|
||||
return c.RenderJson(shareService.DeleteUserShareNoteAndNotebook(fromUserId, c.GetUserId()));
|
||||
}
|
||||
|
||||
//-------------
|
||||
// 用户组
|
||||
|
||||
|
||||
// 将笔记分享给分组
|
||||
func (c Share) AddShareNoteGroup(noteId, groupId string, perm int) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = shareService.AddShareNoteGroup(c.GetUserId(), noteId, groupId, perm);
|
||||
return c.RenderJson(re);
|
||||
}
|
||||
// 删除
|
||||
func (c Share) DeleteShareNoteGroup(noteId, groupId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = shareService.DeleteShareNoteGroup(c.GetUserId(), noteId, groupId);
|
||||
return c.RenderJson(re);
|
||||
}
|
||||
// 更新, 也是一样, 先删后加
|
||||
func (c Share) UpdateShareNoteGroupPerm(noteId, groupId string, perm int) revel.Result {
|
||||
return c.AddShareNoteGroup(noteId, groupId, perm)
|
||||
}
|
||||
|
||||
|
||||
//------
|
||||
|
||||
// 将笔记分享给分组
|
||||
func (c Share) AddShareNotebookGroup(notebookId, groupId string, perm int) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = shareService.AddShareNotebookGroup(c.GetUserId(), notebookId, groupId, perm);
|
||||
return c.RenderJson(re);
|
||||
}
|
||||
// 删除
|
||||
func (c Share) DeleteShareNotebookGroup(notebookId, groupId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = shareService.DeleteShareNotebookGroup(c.GetUserId(), notebookId, groupId);
|
||||
return c.RenderJson(re);
|
||||
}
|
||||
// 更新, 也是一样, 先删后加
|
||||
func (c Share) UpdateShareNotebookGroupPerm(notebookId, groupId string, perm int) revel.Result {
|
||||
return c.AddShareNotebookGroup(notebookId, groupId, perm)
|
||||
}
|
||||
@@ -16,7 +16,7 @@ type AdminBlog struct {
|
||||
func (c AdminBlog) Index(sorter, keywords string) revel.Result {
|
||||
pageNumber := c.GetPage()
|
||||
sorterField, isAsc := c.getSorter("CreatedTime", false, []string{"title", "userId", "isRecommed", "createdTime"});
|
||||
pageInfo, blogs := blogService.ListAllBlogs("", keywords, false, pageNumber, userPageSize, sorterField, isAsc);
|
||||
pageInfo, blogs := blogService.ListAllBlogs("", "", keywords, false, pageNumber, userPageSize, sorterField, isAsc);
|
||||
c.RenderArgs["pageInfo"] = pageInfo
|
||||
c.RenderArgs["blogs"] = blogs
|
||||
c.RenderArgs["keywords"] = keywords
|
||||
@@ -27,4 +27,4 @@ func (c AdminBlog) SetRecommend(noteId string, recommend bool) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = blogService.SetRecommend(noteId, recommend);
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func (c Admin) T(t string) revel.Result {
|
||||
c.RenderArgs["arr"] = configService.GlobalArrayConfigs
|
||||
c.RenderArgs["map"] = configService.GlobalMapConfigs
|
||||
c.RenderArgs["arrMap"] = configService.GlobalArrMapConfigs
|
||||
c.RenderArgs["version"] = configService.GetVersion()
|
||||
return c.RenderTemplate("admin/" + t + ".html")
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,15 @@ func (c AdminSetting) OpenRegister(openRegister string) revel.Result {
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c AdminSetting) HomePage(homePage string) revel.Result {
|
||||
re := info.NewRe()
|
||||
if homePage == "0" {
|
||||
homePage = ""
|
||||
}
|
||||
re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "homePage", homePage)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c AdminSetting) Mongodb(mongodumpPath, mongorestorePath string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "mongodumpPath", mongodumpPath)
|
||||
|
||||
@@ -17,8 +17,8 @@ func (c AdminUpgrade) UpgradeBlog() revel.Result {
|
||||
return nil;
|
||||
}
|
||||
|
||||
func (c AdminUpgrade) UpgradeBetaToSelfBlog() revel.Result {
|
||||
func (c AdminUpgrade) UpgradeBetaToBeta2() revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = upgradeService.UpgradeBetaToSelfBlog(c.GetUserId())
|
||||
re.Ok, re.Msg = upgradeService.UpgradeBetaToBeta2(c.GetUserId())
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
"fmt"
|
||||
"strings"
|
||||
// "github.com/leanote/leanote/app/lea/blog"
|
||||
)
|
||||
|
||||
// admin 首页
|
||||
// 博客管理
|
||||
|
||||
type MemberBlog struct {
|
||||
MemberBaseController
|
||||
@@ -33,6 +34,82 @@ func (c MemberBlog) common() info.UserBlog {
|
||||
return userBlog
|
||||
}
|
||||
|
||||
|
||||
// 得到sorterField 和 isAsc
|
||||
// okSorter = ['email', 'username']
|
||||
func (c MemberBlog) getSorter(sorterField string, isAsc bool, okSorter []string) (string, bool){
|
||||
sorter := ""
|
||||
c.Params.Bind(&sorter, "sorter")
|
||||
if sorter == "" {
|
||||
return sorterField, isAsc;
|
||||
}
|
||||
|
||||
// sorter形式 email-up, email-down
|
||||
s2 := strings.Split(sorter, "-")
|
||||
if len(s2) != 2 {
|
||||
return sorterField, isAsc;
|
||||
}
|
||||
|
||||
// 必须是可用的sorter
|
||||
if okSorter != nil && len(okSorter) > 0 {
|
||||
if !InArray(okSorter, s2[0]) {
|
||||
return sorterField, isAsc;
|
||||
}
|
||||
}
|
||||
|
||||
sorterField = strings.Title(s2[0])
|
||||
if s2[1] == "up" {
|
||||
isAsc = true
|
||||
} else {
|
||||
isAsc = false
|
||||
}
|
||||
c.RenderArgs["sorter"] = sorter
|
||||
return sorterField, isAsc;
|
||||
}
|
||||
|
||||
// 博客列表
|
||||
var userPageSize = 15
|
||||
func (c MemberBlog) Index(sorter, keywords string) revel.Result {
|
||||
c.RenderArgs["title"] = "Posts"
|
||||
pageNumber := c.GetPage()
|
||||
sorterField, isAsc := c.getSorter("CreatedTime", false, []string{"title", "urlTitle", "updatedTime", "publicTime", "createdTime"});
|
||||
pageInfo, blogs := blogService.ListAllBlogs(c.GetUserId(), "", keywords, false, pageNumber, userPageSize, sorterField, isAsc);
|
||||
c.RenderArgs["pageInfo"] = pageInfo
|
||||
c.RenderArgs["blogs"] = blogs
|
||||
c.RenderArgs["keywords"] = keywords
|
||||
|
||||
userAndBlog := userService.GetUserAndBlog(c.GetUserId())
|
||||
c.RenderArgs["userAndBlog"] = userAndBlog
|
||||
|
||||
return c.RenderTemplate("member/blog/list.html");
|
||||
}
|
||||
|
||||
// 修改笔记的urlTitle
|
||||
func (c MemberBlog) UpdateBlogUrlTitle(noteId, urlTitle string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Item = blogService.UpateBlogUrlTitle(c.GetUserId(), noteId, urlTitle)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
|
||||
// 修改笔记的urlTitle
|
||||
func (c MemberBlog) UpdateBlogAbstract(noteId string) revel.Result {
|
||||
c.RenderArgs["title"] = "Update Post Abstract"
|
||||
note := noteService.GetNoteAndContent(noteId, c.GetUserId());
|
||||
if !note.Note.IsBlog {
|
||||
return c.E404();
|
||||
}
|
||||
c.RenderArgs["note"] = note
|
||||
c.RenderArgs["noteId"] = noteId
|
||||
return c.RenderTemplate("member/blog/update_abstract.html");
|
||||
}
|
||||
func (c MemberBlog) DoUpdateBlogAbstract(noteId, imgSrc, desc, abstract string) revel.Result {
|
||||
|
||||
re := info.NewRe()
|
||||
re.Ok = blogService.UpateBlogAbstract(c.GetUserId(), noteId, imgSrc, desc, abstract)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 基本信息设置
|
||||
func (c MemberBlog) Base() revel.Result {
|
||||
c.common()
|
||||
@@ -101,6 +178,12 @@ func (c MemberBlog) UpateCateIds(cateIds []string) revel.Result {
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c MemberBlog) UpdateCateUrlTitle(cateId, urlTitle string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Item = blogService.UpateCateUrlTitle(c.GetUserId(), cateId, urlTitle)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 保存之, 包含增加与保存
|
||||
func (c MemberBlog) DoAddOrUpdateSingle(singleId, title, content string) revel.Result {
|
||||
re := info.NewRe()
|
||||
@@ -127,6 +210,14 @@ func (c MemberBlog) DeleteSingle(singleId string) revel.Result {
|
||||
re.Ok = blogService.DeleteSingle(c.GetUserId(), singleId)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 修改页面标题
|
||||
func (c MemberBlog) UpdateSingleUrlTitle(singleId, urlTitle string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Item = blogService.UpdateSingleUrlTitle(c.GetUserId(), singleId, urlTitle)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c MemberBlog) Single() revel.Result {
|
||||
c.common()
|
||||
c.RenderArgs["title"] = "Cate"
|
||||
@@ -425,4 +516,4 @@ func (c MemberBlog) SetUserBlogPaging(perPageSize int, sortField string, isAsc b
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = blogService.UpdateUserBlogPaging(c.GetUserId(), perPageSize, sortField, isAsc)
|
||||
return c.RenderRe(re)
|
||||
}
|
||||
}
|
||||
|
||||
58
app/controllers/member/MemberGroupController.go
Normal file
58
app/controllers/member/MemberGroupController.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package member
|
||||
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
)
|
||||
|
||||
// 分组管理
|
||||
type MemberGroup struct {
|
||||
MemberBaseController
|
||||
}
|
||||
|
||||
// 首页, 显示所有分组和用户
|
||||
func (c MemberGroup) Index() revel.Result {
|
||||
c.SetUserInfo()
|
||||
c.SetLocale()
|
||||
c.RenderArgs["title"] = "My Group"
|
||||
c.RenderArgs["groups"] = groupService.GetGroupsAndUsers(c.GetUserId())
|
||||
return c.RenderTemplate("member/group/index.html");
|
||||
}
|
||||
|
||||
// 添加分组
|
||||
func (c MemberGroup) AddGroup(title string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Item = groupService.AddGroup(c.GetUserId(), title)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c MemberGroup) UpdateGroupTitle(groupId, title string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = groupService.UpdateGroupTitle(c.GetUserId(), groupId, title)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
func (c MemberGroup) DeleteGroup(groupId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = groupService.DeleteGroup(c.GetUserId(), groupId)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
func (c MemberGroup) AddUser(groupId, email string) revel.Result {
|
||||
re := info.NewRe()
|
||||
userInfo := userService.GetUserInfoByAny(email)
|
||||
if userInfo.UserId == "" {
|
||||
re.Msg = "userNotExists"
|
||||
} else {
|
||||
re.Ok, re.Msg = groupService.AddUser(c.GetUserId(), groupId, userInfo.UserId.Hex())
|
||||
re.Item = userInfo
|
||||
}
|
||||
return c.RenderRe(re)
|
||||
}
|
||||
|
||||
func (c MemberGroup) DeleteUser(groupId, userId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = groupService.DeleteUser(c.GetUserId(), groupId, userId)
|
||||
return c.RenderRe(re)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
var userService *service.UserService
|
||||
var groupService *service.GroupService
|
||||
var noteService *service.NoteService
|
||||
var trashService *service.TrashService
|
||||
var notebookService *service.NotebookService
|
||||
@@ -106,6 +107,7 @@ func InitService() {
|
||||
trashService = service.TrashS
|
||||
shareService = service.ShareS
|
||||
userService = service.UserS
|
||||
groupService = service.GroupS
|
||||
tagService = service.TagS
|
||||
blogService = service.BlogS
|
||||
tokenService = service.TokenS
|
||||
|
||||
@@ -23,6 +23,8 @@ type BlogInfoCustom struct {
|
||||
type Post struct {
|
||||
NoteId string
|
||||
Title string
|
||||
UrlTitle string
|
||||
ImgSrc string
|
||||
CreatedTime time.Time
|
||||
UpdatedTime time.Time
|
||||
PublicTime time.Time
|
||||
|
||||
@@ -74,9 +74,10 @@ type BlogStat struct {
|
||||
|
||||
// 单页
|
||||
type BlogSingle struct {
|
||||
SingleId bson.ObjectId `bson:"_id"`
|
||||
SingleId bson.ObjectId `bson:"_id,omitempty"`
|
||||
UserId bson.ObjectId `UserId`
|
||||
Title string `Title`
|
||||
UrlTitle string `UrlTitle` // 2014/11/11
|
||||
Content string `Content`
|
||||
UpdatedTime time.Time `UpdatedTime`
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
@@ -87,7 +88,7 @@ type BlogSingle struct {
|
||||
|
||||
// 点赞记录
|
||||
type BlogLike struct {
|
||||
LikeId bson.ObjectId `bson:"_id"`
|
||||
LikeId bson.ObjectId `bson:"_id,omitempty"`
|
||||
NoteId bson.ObjectId `NoteId`
|
||||
UserId bson.ObjectId `UserId`
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
@@ -95,7 +96,7 @@ type BlogLike struct {
|
||||
|
||||
// 评论
|
||||
type BlogComment struct {
|
||||
CommentId bson.ObjectId `bson:"_id"`
|
||||
CommentId bson.ObjectId `bson:"_id,omitempty"`
|
||||
NoteId bson.ObjectId `NoteId`
|
||||
|
||||
UserId bson.ObjectId `UserId` // UserId回复ToUserId
|
||||
@@ -114,3 +115,14 @@ type BlogCommentPublic struct {
|
||||
BlogComment
|
||||
IsILikeIt bool
|
||||
}
|
||||
|
||||
type BlogUrls struct {
|
||||
IndexUrl string
|
||||
CateUrl string
|
||||
SearchUrl string
|
||||
SingleUrl string
|
||||
PostUrl string
|
||||
ArchiveUrl string
|
||||
TagsUrl string
|
||||
TagPostsUrl string
|
||||
}
|
||||
|
||||
25
app/info/GroupInfo.go
Normal file
25
app/info/GroupInfo.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 分组
|
||||
type Group struct {
|
||||
GroupId bson.ObjectId `bson:"_id"` // 谁的
|
||||
UserId bson.ObjectId `UserId` // 所有者Id
|
||||
Title string `Title` // 标题
|
||||
UserCount int `UserCount` // 用户数
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
|
||||
Users []User `Users,omitempty` // 分组下的用户, 不保存, 仅查看
|
||||
}
|
||||
|
||||
// 分组好友
|
||||
type GroupUser struct {
|
||||
GroupUserId bson.ObjectId `bson:"_id"` // 谁的
|
||||
GroupId bson.ObjectId `GroupId` // 分组
|
||||
UserId bson.ObjectId `UserId` // 用户
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
}
|
||||
@@ -20,9 +20,11 @@ type Note struct {
|
||||
|
||||
IsTrash bool `IsTrash` // 是否是trash, 默认是false
|
||||
|
||||
IsBlog bool `IsBlog,omitempty` // 是否设置成了blog 2013/12/29 新加
|
||||
IsRecommend bool `IsRecommend,omitempty` // 是否为推荐博客 2014/9/24新加
|
||||
IsTop bool `IsTop,omitempty` // blog是否置顶
|
||||
IsBlog bool `IsBlog,omitempty` // 是否设置成了blog 2013/12/29 新加
|
||||
UrlTitle string `UrlTitle,omitempty` // 博客的url标题, 为了更友好的url, 在UserId, UrlName下唯一
|
||||
IsRecommend bool `IsRecommend,omitempty` // 是否为推荐博客 2014/9/24新加
|
||||
IsTop bool `IsTop,omitempty` // blog是否置顶
|
||||
HasSelfDefined bool `HasSelfDefined` // 是否已经自定义博客图片, desc, abstract
|
||||
|
||||
// 2014/9/28 添加评论社交功能
|
||||
ReadNum int `ReadNum,omitempty` // 阅读次数 2014/9/28
|
||||
@@ -35,9 +37,9 @@ type Note struct {
|
||||
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
UpdatedTime time.Time `UpdatedTime`
|
||||
RecommendTime time.Time `RecommendTime,omitempty` // 推荐时间
|
||||
PublicTime time.Time `PublicTime,omitempty` // 发表时间, 公开为博客则设置
|
||||
UpdatedUserId bson.ObjectId `bson:"UpdatedUserId"` // 如果共享了, 并可写, 那么可能是其它他修改了
|
||||
RecommendTime time.Time `RecommendTime,omitempty` // 推荐时间
|
||||
PublicTime time.Time `PublicTime,omitempty` // 发表时间, 公开为博客则设置
|
||||
UpdatedUserId bson.ObjectId `bson:"UpdatedUserId"` // 如果共享了, 并可写, 那么可能是其它他修改了
|
||||
}
|
||||
|
||||
// 内容
|
||||
|
||||
@@ -13,6 +13,7 @@ type Notebook struct {
|
||||
ParentNotebookId bson.ObjectId `bson:"ParentNotebookId,omitempty"` // 上级
|
||||
Seq int `Seq` // 排序
|
||||
Title string `Title` // 标题
|
||||
UrlTitle string `UrlTitle` // Url标题 2014/11.11加
|
||||
NumberNotes int `NumberNotes` // 笔记数
|
||||
IsTrash bool `IsTrash,omitempty` // 是否是trash, 默认是false
|
||||
IsBlog bool `IsBlog,omitempty` // 是否是Blog 2013/12/29 新加
|
||||
|
||||
@@ -76,7 +76,9 @@ type SharingNotebookAndNotes struct {
|
||||
type ShareNotebook struct {
|
||||
ShareNotebookId bson.ObjectId `bson:"_id,omitempty"` // 必须要设置bson:"_id" 不然mgo不会认为是主键
|
||||
UserId bson.ObjectId `bson:"UserId"`
|
||||
ToUserId bson.ObjectId `bson:"ToUserId"`
|
||||
ToUserId bson.ObjectId `bson:"ToUserId,omitempty"`
|
||||
ToGroupId bson.ObjectId `bson:"ToGroupId,omitempty"` // 分享给的用户组
|
||||
ToGroup Group `ToGroup,omitempty` // 仅仅为了显示, 不存储, 分组信息
|
||||
NotebookId bson.ObjectId `bson:"NotebookId"`
|
||||
Seq int `bson:"Seq"` // 排序
|
||||
Perm int `bson:"Perm"` // 权限, 其下所有notes 0只读, 1可修改
|
||||
@@ -134,7 +136,9 @@ type ShareNotebooksByUser struct {
|
||||
type ShareNote struct {
|
||||
ShareNoteId bson.ObjectId `bson:"_id,omitempty"` // 必须要设置bson:"_id" 不然mgo不会认为是主键
|
||||
UserId bson.ObjectId `bson:"UserId"`
|
||||
ToUserId bson.ObjectId `bson:"ToUserId"`
|
||||
ToUserId bson.ObjectId `bson:"ToUserId,omitempty"`
|
||||
ToGroupId bson.ObjectId `bson:"ToGroupId,omitempty"` // 分享给的用户组
|
||||
ToGroup Group `ToGroup,omitempty` // 仅仅为了显示, 不存储, 分组信息
|
||||
NoteId bson.ObjectId `bson:"NoteId"`
|
||||
Perm int `bson:"Perm"` // 权限, 0只读, 1可修改
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
|
||||
@@ -74,5 +74,7 @@ type UserAndBlog struct {
|
||||
Logo string `Logo`
|
||||
BlogTitle string `BlogTitle` // 博客标题
|
||||
BlogLogo string `BlogLogo` // 博客Logo
|
||||
BlogUrl string `BlogUrl` // 博客链接
|
||||
BlogUrl string `BlogUrl` // 博客链接, 主页
|
||||
|
||||
BlogUrls // 各个页面
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type Page struct {
|
||||
CurPage int // 当前页码
|
||||
TotalPage int // 总页
|
||||
PerPageSize int
|
||||
Count int // 总记录数
|
||||
List interface{}
|
||||
}
|
||||
@@ -18,5 +19,5 @@ func NewPage(page, perPageSize, count int, list interface{}) Page {
|
||||
if count > 0 {
|
||||
totalPage = int(math.Ceil(float64(count) / float64(perPageSize)))
|
||||
}
|
||||
return Page{page, totalPage, count, list}
|
||||
}
|
||||
return Page{page, totalPage, perPageSize, count, list}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -78,6 +79,10 @@ func init() {
|
||||
}
|
||||
return str
|
||||
}
|
||||
revel.TemplateFuncs["decodeUrlValue"] = func(i string) string {
|
||||
v, _ := url.ParseQuery("a=" + i)
|
||||
return v.Get("a")
|
||||
}
|
||||
revel.TemplateFuncs["json"] = func(i interface{}) string {
|
||||
b, _ := json.Marshal(i)
|
||||
return string(b)
|
||||
@@ -318,4 +323,4 @@ func init() {
|
||||
member.InitService()
|
||||
service.ConfigS.InitGlobalConfigs()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (this *AuthService) Login(emailOrUsername, pwd string) info.User {
|
||||
func (this *AuthService) Register(email, pwd string) (bool, string) {
|
||||
// 用户是否已存在
|
||||
if userService.IsExistsUser(email) {
|
||||
return false, email + " 已被注册"
|
||||
return false, "userHasBeenRegistered-" + email
|
||||
}
|
||||
user := info.User{UserId: bson.NewObjectId(), Email: email, Username: email, Pwd: Md5(pwd)}
|
||||
return this.register(user)
|
||||
@@ -90,7 +90,10 @@ func (this *AuthService) register(user info.User) (bool, string) {
|
||||
Title: user.Username + " 's Blog",
|
||||
SubTitle: "love leanote!",
|
||||
AboutMe: "Hello, I am (^_^)",
|
||||
CanComment: true,
|
||||
})
|
||||
// 添加一个单页面
|
||||
blogService.AddOrUpdateSingle(user.UserId.Hex(), "", "About Me", "Hello, I am (^_^)")
|
||||
}
|
||||
|
||||
return true, ""
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -573,3 +573,12 @@ func (this *ConfigService) GetGlobalConfigForUser() map[string]interface{} {
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// 主页是否是管理员的博客页
|
||||
func (this *ConfigService) HomePageIsAdminsBlog() bool {
|
||||
return this.GetGlobalStringConfig("homePage") == ""
|
||||
}
|
||||
|
||||
func (this *ConfigService) GetVersion() string {
|
||||
return "1.0-beta2"
|
||||
}
|
||||
|
||||
130
app/service/GroupService.go
Normal file
130
app/service/GroupService.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
// . "github.com/leanote/leanote/app/lea"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
// "strings"
|
||||
)
|
||||
|
||||
// 用户组, 用户组用户管理
|
||||
|
||||
type GroupService struct {
|
||||
}
|
||||
|
||||
// 添加分组
|
||||
func (this *GroupService) AddGroup(userId, title string) (bool, info.Group) {
|
||||
group := info.Group {
|
||||
GroupId: bson.NewObjectId(),
|
||||
UserId: bson.ObjectIdHex(userId),
|
||||
Title: title,
|
||||
CreatedTime: time.Now(),
|
||||
}
|
||||
return db.Insert(db.Groups, group), group
|
||||
}
|
||||
// 删除分组
|
||||
// 判断是否有好友
|
||||
func (this *GroupService) DeleteGroup(userId, groupId string) (ok bool, msg string) {
|
||||
if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)}) {
|
||||
return false, "hasUsers"
|
||||
}
|
||||
return db.DeleteByIdAndUserId(db.Groups, groupId, userId), ""
|
||||
|
||||
// TODO 删除分组后, 在shareNote, shareNotebook中也要删除
|
||||
}
|
||||
// 修改group标题
|
||||
func (this *GroupService) UpdateGroupTitle(userId, groupId, title string) (ok bool) {
|
||||
return db.UpdateByIdAndUserIdField(db.Groups, groupId, userId, "Title", title)
|
||||
}
|
||||
|
||||
// 得到用户的所有分组(包括下的所有用户)
|
||||
func (this *GroupService) GetGroupsAndUsers(userId string) ([]info.Group) {
|
||||
// 得到分组s
|
||||
groups := []info.Group{}
|
||||
db.ListByQ(db.Groups, bson.M{"UserId": bson.ObjectIdHex(userId)}, &groups)
|
||||
// 得到其下的用户
|
||||
for i, group := range groups {
|
||||
group.Users = this.GetUsers(group.GroupId.Hex())
|
||||
groups[i] = group
|
||||
}
|
||||
return groups
|
||||
}
|
||||
// 仅仅得到所有分组
|
||||
func (this *GroupService) GetGroups(userId string) ([]info.Group) {
|
||||
// 得到分组s
|
||||
groups := []info.Group{}
|
||||
db.ListByQ(db.Groups, bson.M{"UserId": bson.ObjectIdHex(userId)}, &groups)
|
||||
return groups
|
||||
}
|
||||
// 得到分组, shareService用
|
||||
func (this *GroupService) GetGroup(userId, groupId string) (info.Group) {
|
||||
// 得到分组s
|
||||
group := info.Group{}
|
||||
db.GetByIdAndUserId(db.Groups, groupId, userId, &group)
|
||||
return group
|
||||
}
|
||||
|
||||
// 得到某分组下的用户
|
||||
func (this *GroupService) GetUsers(groupId string) ([]info.User) {
|
||||
// 得到UserIds
|
||||
groupUsers := []info.GroupUser{}
|
||||
db.ListByQWithFields(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)}, []string{"UserId"}, &groupUsers)
|
||||
if len(groupUsers) == 0 {
|
||||
return nil
|
||||
}
|
||||
userIds := make([]bson.ObjectId, len(groupUsers))
|
||||
for i, each := range groupUsers {
|
||||
userIds[i] = each.UserId
|
||||
}
|
||||
// 得到userInfos
|
||||
return userService.ListUserInfosByUserIds(userIds)
|
||||
}
|
||||
|
||||
// 得到我所属的所有分组ids
|
||||
func (this *GroupService) GetBelongToGroupIds(userId string) ([]bson.ObjectId) {
|
||||
// 得到UserIds
|
||||
groupUsers := []info.GroupUser{}
|
||||
db.ListByQWithFields(db.GroupUsers, bson.M{"UserId": bson.ObjectIdHex(userId)}, []string{"GroupId"}, &groupUsers)
|
||||
if len(groupUsers) == 0 {
|
||||
return nil
|
||||
}
|
||||
groupIds := make([]bson.ObjectId, len(groupUsers))
|
||||
for i, each := range groupUsers {
|
||||
groupIds[i] = each.GroupId
|
||||
}
|
||||
return groupIds
|
||||
}
|
||||
|
||||
func (this *GroupService) isMyGroup(ownUserId, groupId string) (ok bool) {
|
||||
return db.Has(db.Groups, bson.M{"_id": bson.ObjectIdHex(groupId), "UserId": bson.ObjectIdHex(ownUserId)})
|
||||
}
|
||||
// 为group添加用户
|
||||
// 用户是否已存在?
|
||||
func (this *GroupService) AddUser(ownUserId, groupId, userId string) (ok bool, msg string) {
|
||||
// groupId是否是ownUserId的?
|
||||
if !this.isMyGroup(ownUserId, groupId) {
|
||||
return false, "forbidden"
|
||||
}
|
||||
|
||||
// 是否已存在
|
||||
if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId), "UserId": bson.ObjectIdHex(userId)}) {
|
||||
return false, "hasUsers"
|
||||
}
|
||||
|
||||
return db.Insert(db.GroupUsers, info.GroupUser{
|
||||
GroupUserId: bson.NewObjectId(),
|
||||
GroupId: bson.ObjectIdHex(groupId),
|
||||
UserId: bson.ObjectIdHex(userId),
|
||||
CreatedTime: time.Now(),
|
||||
}), ""
|
||||
}
|
||||
// 删除用户
|
||||
func (this *GroupService) DeleteUser(ownUserId, groupId, userId string) (ok bool, msg string) {
|
||||
// groupId是否是ownUserId的?
|
||||
if !this.isMyGroup(ownUserId, groupId) {
|
||||
return false, "forbidden"
|
||||
}
|
||||
return db.Delete(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId), "UserId": bson.ObjectIdHex(userId)}), ""
|
||||
}
|
||||
@@ -32,7 +32,12 @@ func (this *NoteImageService) GetNoteIds(imageId string) ([]bson.ObjectId) {
|
||||
// 解析内容中的图片, 建立图片与note的关系
|
||||
// <img src="/file/outputImage?fileId=12323232" />
|
||||
// 图片必须是我的, 不然不添加
|
||||
func (this *NoteImageService) UpdateNoteImages(userId, noteId, content string) bool {
|
||||
// imgSrc 防止博客修改了, 但内容删除了
|
||||
func (this *NoteImageService) UpdateNoteImages(userId, noteId, imgSrc, content string) bool {
|
||||
// 让主图成为内容的一员
|
||||
if imgSrc != "" {
|
||||
content = "<img src=\"" + imgSrc + "\" >" + content
|
||||
}
|
||||
reg, _ := regexp.Compile("outputImage\\?fileId=([a-z0-9A-Z]{24})")
|
||||
find := reg.FindAllStringSubmatch(content, -1) // 查找所有的
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ func (this *NoteService) ListNoteContentByNoteIds(noteIds []bson.ObjectId) (note
|
||||
// 添加笔记
|
||||
// 首先要判断Notebook是否是Blog, 是的话设为blog
|
||||
// [ok]
|
||||
|
||||
func (this *NoteService) AddNote(note info.Note) info.Note {
|
||||
if(note.NoteId.Hex() == "") {
|
||||
noteId := bson.NewObjectId();
|
||||
@@ -129,6 +130,7 @@ func (this *NoteService) AddNote(note info.Note) info.Note {
|
||||
note.UpdatedTime = note.CreatedTime
|
||||
note.IsTrash = false
|
||||
note.UpdatedUserId = note.UserId
|
||||
note.UrlTitle = GetUrTitle(note.UserId.Hex(), note.Title, "note")
|
||||
|
||||
// 设为blog
|
||||
notebookId := note.NotebookId.Hex()
|
||||
@@ -169,7 +171,7 @@ func (this *NoteService) AddNoteContent(noteContent info.NoteContent) info.NoteC
|
||||
db.Insert(db.NoteContents, noteContent)
|
||||
|
||||
// 更新笔记图片
|
||||
noteImageService.UpdateNoteImages(noteContent.UserId.Hex(), noteContent.NoteId.Hex(), noteContent.Content)
|
||||
noteImageService.UpdateNoteImages(noteContent.UserId.Hex(), noteContent.NoteId.Hex(), "", noteContent.Content)
|
||||
|
||||
return noteContent;
|
||||
}
|
||||
@@ -205,7 +207,6 @@ func (this *NoteService) AddNoteAndContent(note info.Note, noteContent info.Note
|
||||
}
|
||||
|
||||
// 修改笔记
|
||||
// [ok] TODO perm还没测
|
||||
func (this *NoteService) UpdateNote(userId, updatedUserId, noteId string, needUpdate bson.M) bool {
|
||||
// updatedUserId 要修改userId的note, 此时需要判断是否有修改权限
|
||||
if userId != updatedUserId {
|
||||
@@ -217,6 +218,13 @@ func (this *NoteService) UpdateNote(userId, updatedUserId, noteId string, needUp
|
||||
}
|
||||
}
|
||||
|
||||
// 是否已自定义
|
||||
note := this.GetNoteById(noteId)
|
||||
if note.IsBlog && note.HasSelfDefined {
|
||||
delete(needUpdate, "ImgSrc")
|
||||
delete(needUpdate, "Desc")
|
||||
}
|
||||
|
||||
needUpdate["UpdatedUserId"] = bson.ObjectIdHex(updatedUserId);
|
||||
needUpdate["UpdatedTime"] = time.Now();
|
||||
|
||||
@@ -260,12 +268,18 @@ func (this *NoteService) UpdateNoteContent(userId, updatedUserId, noteId, conten
|
||||
}
|
||||
}
|
||||
|
||||
if db.UpdateByIdAndUserIdMap(db.NoteContents, noteId, userId,
|
||||
bson.M{"UpdatedUserId": bson.ObjectIdHex(updatedUserId),
|
||||
data := bson.M{"UpdatedUserId": bson.ObjectIdHex(updatedUserId),
|
||||
"Content": content,
|
||||
"Abstract": abstract,
|
||||
"UpdatedTime": time.Now()}) {
|
||||
|
||||
"UpdatedTime": time.Now()}
|
||||
|
||||
// 是否已自定义
|
||||
note := this.GetNoteById(noteId)
|
||||
if note.IsBlog && note.HasSelfDefined {
|
||||
delete(data, "Abstract")
|
||||
}
|
||||
|
||||
if db.UpdateByIdAndUserIdMap(db.NoteContents, noteId, userId, data) {
|
||||
// 这里, 添加历史记录
|
||||
noteContentHistoryService.AddHistory(noteId, userId, info.EachHistory{UpdatedUserId: bson.ObjectIdHex(updatedUserId),
|
||||
Content: content,
|
||||
@@ -273,7 +287,7 @@ func (this *NoteService) UpdateNoteContent(userId, updatedUserId, noteId, conten
|
||||
})
|
||||
|
||||
// 更新笔记图片
|
||||
noteImageService.UpdateNoteImages(userId, noteId, content)
|
||||
noteImageService.UpdateNoteImages(userId, noteId, note.ImgSrc, content)
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -306,6 +320,8 @@ func (this *NoteService) ToBlog(userId, noteId string, isBlog, isTop bool) bool
|
||||
noteUpdate["IsTop"] = isTop
|
||||
if isBlog {
|
||||
noteUpdate["PublicTime"] = time.Now()
|
||||
} else {
|
||||
noteUpdate["HasSelfDefined"] = false
|
||||
}
|
||||
ok := db.UpdateByIdAndUserIdMap(db.Notes, noteId, userId, noteUpdate)
|
||||
// 重新计算tags
|
||||
|
||||
@@ -101,6 +101,15 @@ func (this *NotebookService) GetNotebookById(notebookId string) info.Notebook {
|
||||
db.Get(db.Notebooks, notebookId, ¬ebook)
|
||||
return notebook
|
||||
}
|
||||
func (this *NotebookService) GetNotebookByUserIdAndUrlTitle(userId, notebookIdOrUrlTitle string) info.Notebook {
|
||||
notebook := info.Notebook{}
|
||||
if IsObjectId(notebookIdOrUrlTitle) {
|
||||
db.Get(db.Notebooks, notebookIdOrUrlTitle, ¬ebook)
|
||||
} else {
|
||||
db.GetByQ(db.Notebooks, bson.M{"UserId": bson.ObjectIdHex(userId), "UrlTitle": encodeValue(notebookIdOrUrlTitle)}, ¬ebook)
|
||||
}
|
||||
return notebook
|
||||
}
|
||||
|
||||
// 得到用户下所有的notebook
|
||||
// 排序好之后返回
|
||||
@@ -133,6 +142,7 @@ func (this *NotebookService) GetNotebooksByNotebookIds(notebookIds []bson.Object
|
||||
// 添加
|
||||
// [ok]
|
||||
func (this *NotebookService) AddNotebook(notebook info.Notebook) bool {
|
||||
notebook.UrlTitle = GetUrTitle(notebook.UserId.Hex(), notebook.Title, "notebook")
|
||||
err := db.Notebooks.Insert(notebook)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -180,6 +190,8 @@ func (this *NotebookService) ToBlog(userId, notebookId string, isBlog bool) (boo
|
||||
data := bson.M{"IsBlog": isBlog}
|
||||
if isBlog {
|
||||
data["PublicTime"] = time.Now()
|
||||
} else {
|
||||
data["HasSelfDefined"] = false
|
||||
}
|
||||
db.UpdateByQMap(db.Notes, q, data)
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ import (
|
||||
type ShareService struct {
|
||||
}
|
||||
|
||||
//-----------------
|
||||
//-----------------------------------
|
||||
// 返回shareNotebooks, sharedUserInfos
|
||||
// info.ShareNotebooksByUser, []info.User
|
||||
|
||||
// 总体来说, 这个方法比较麻烦, 速度未知. 以后按以下方案来缓存用户基础数据
|
||||
|
||||
// 以后建个用户的基本数据表, 放所有notebook, sharedNotebook的缓存!!
|
||||
@@ -27,23 +30,48 @@ type ShareService struct {
|
||||
// 3 每个层按seq进行排序
|
||||
// 4 按用户分组
|
||||
// [ok]
|
||||
func (this *ShareService) GetShareNotebooks(userId string) (info.ShareNotebooksByUser, []info.User) {
|
||||
//-------------
|
||||
// 查询HasShareNote表得到所有其它用户信息
|
||||
hasShareNotes := []info.HasShareNote{}
|
||||
db.ListByQ(db.HasShareNotes, bson.M{"ToUserId": bson.ObjectIdHex(userId)}, &hasShareNotes);
|
||||
|
||||
userIds := make([]bson.ObjectId, len(hasShareNotes))
|
||||
for i, each := range hasShareNotes {
|
||||
userIds[i] = each.UserId
|
||||
|
||||
// 谁共享给了我的Query
|
||||
func (this *ShareService) getOrQ(userId string) bson.M {
|
||||
// 得到我参与的组织
|
||||
groupIds := groupService.GetBelongToGroupIds(userId)
|
||||
q := bson.M{}
|
||||
if len(groupIds) > 0 {
|
||||
orQ := []bson.M{
|
||||
bson.M{"ToUserId": bson.ObjectIdHex(userId)},
|
||||
bson.M{"ToGroupId": bson.M{"$in": groupIds}},
|
||||
}
|
||||
// 不是trash的
|
||||
q["$or"] = orQ
|
||||
} else {
|
||||
q["ToUserId"] = bson.ObjectIdHex(userId);
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
func (this *ShareService) GetShareNotebooks(userId string) (info.ShareNotebooksByUser, []info.User) {
|
||||
// 得到共享给我的用户s信息
|
||||
// 得到我参与的组织
|
||||
q := this.getOrQ(userId)
|
||||
|
||||
// 不查hasShareNotes
|
||||
// 直接查shareNotes, shareNotebooks表得到userId
|
||||
userIds1 := []bson.ObjectId{}
|
||||
db.Distinct(db.ShareNotes, q, "UserId", &userIds1)
|
||||
|
||||
userIds2 := []bson.ObjectId{}
|
||||
db.Distinct(db.ShareNotebooks, q, "UserId", &userIds1)
|
||||
|
||||
userIds := append(userIds1, userIds2...)
|
||||
userInfos := userService.GetUserInfosOrderBySeq(userIds);
|
||||
|
||||
//--------------------
|
||||
// 得到他们共享给我的notebooks
|
||||
|
||||
// 这里可能会得到重复的记录
|
||||
// 权限: 笔记本分享给个人 > 笔记本分享给组织
|
||||
shareNotebooks := []info.ShareNotebook{}
|
||||
db.ShareNotebooks.Find(bson.M{"ToUserId": bson.ObjectIdHex(userId)}).All(&shareNotebooks)
|
||||
db.ShareNotebooks.Find(q).Sort("-ToUserId").All(&shareNotebooks) // 按ToUserId降序排序, 那么有ToUserId的在前面
|
||||
|
||||
if len(shareNotebooks) == 0 {
|
||||
return nil, userInfos
|
||||
@@ -52,12 +80,15 @@ func (this *ShareService) GetShareNotebooks(userId string) (info.ShareNotebooksB
|
||||
shareNotebooksLen := len(shareNotebooks)
|
||||
|
||||
// 找到了所有的notbookId, 那么找notebook表得到其详细信息
|
||||
notebookIds := make([]bson.ObjectId, shareNotebooksLen)
|
||||
notebookIds := []bson.ObjectId{}
|
||||
shareNotebooksMap := make(map[bson.ObjectId]info.ShareNotebook, shareNotebooksLen)
|
||||
for i, each := range shareNotebooks {
|
||||
// 默认的是没有notebookId的
|
||||
notebookIds[i] = each.NotebookId
|
||||
shareNotebooksMap[each.NotebookId] = each
|
||||
for _, each := range shareNotebooks {
|
||||
// 之后的就不要了, 只留权限高的
|
||||
if _, ok := shareNotebooksMap[each.NotebookId]; !ok {
|
||||
// 默认的是没有notebookId的
|
||||
notebookIds = append(notebookIds, each.NotebookId)
|
||||
shareNotebooksMap[each.NotebookId] = each
|
||||
}
|
||||
}
|
||||
|
||||
// 1, 2
|
||||
@@ -127,9 +158,13 @@ func (this *ShareService) parseToSubShareNotebooks(subNotebooks *info.SubNoteboo
|
||||
func (this *ShareService) ListShareNotesByNotebookId(notebookId, myUserId, sharedUserId string,
|
||||
page, pageSize int, sortField string, isAsc bool) ([]info.ShareNoteWithPerm) {
|
||||
// 1 首先判断是否真的sharedUserId 共享了 notebookId 给 myUserId
|
||||
q := this.getOrQ(myUserId)
|
||||
q["NotebookId"] = bson.ObjectIdHex(notebookId);
|
||||
q["UserId"] = bson.ObjectIdHex(sharedUserId);
|
||||
shareNotebook := info.ShareNotebook{}
|
||||
db.GetByQ(db.ShareNotebooks, bson.M{"NotebookId": bson.ObjectIdHex(notebookId),
|
||||
"UserId": bson.ObjectIdHex(sharedUserId), "ToUserId": bson.ObjectIdHex(myUserId)}, &shareNotebook)
|
||||
db.GetByQ(db.ShareNotebooks,
|
||||
q,
|
||||
&shareNotebook)
|
||||
|
||||
if shareNotebook.NotebookId == "" {
|
||||
return nil
|
||||
@@ -146,7 +181,19 @@ func (this *ShareService) ListShareNotesByNotebookId(notebookId, myUserId, share
|
||||
for i, note := range notes {
|
||||
noteIds[i] = note.NoteId
|
||||
}
|
||||
notePerms := this.getNotesPerm(noteIds, myUserId, sharedUserId);
|
||||
// 笔记的权限
|
||||
shareNotes := []info.ShareNote{}
|
||||
delete(q, "NotebookId")
|
||||
q["NoteId"] = bson.M{"$in": noteIds}
|
||||
db.ShareNotes.Find(q).Sort("-ToUserId").All(&shareNotes) // 给个的权限>给组织的权限
|
||||
notePerms := map[bson.ObjectId]int{}
|
||||
for _, each := range shareNotes {
|
||||
if _, ok := notePerms[each.NoteId]; !ok {
|
||||
notePerms[each.NoteId] = each.Perm
|
||||
}
|
||||
}
|
||||
Log("笔记权限")
|
||||
LogJ(notePerms);
|
||||
|
||||
// 3.2 组合
|
||||
notesWithPerm := make([]info.ShareNoteWithPerm, len(notes))
|
||||
@@ -162,17 +209,21 @@ func (this *ShareService) ListShareNotesByNotebookId(notebookId, myUserId, share
|
||||
}
|
||||
|
||||
// 得到note的perm信息
|
||||
func (this *ShareService) getNotesPerm(noteIds []bson.ObjectId, myUserId, sharedUserId string) map[bson.ObjectId]int {
|
||||
shareNotes := []info.ShareNote{}
|
||||
db.ListByQ(db.ShareNotes, bson.M{"NoteId": bson.M{"$in": noteIds}, "UserId": bson.ObjectIdHex(sharedUserId), "ToUserId": bson.ObjectIdHex(myUserId)}, &shareNotes)
|
||||
|
||||
notesPerm := make(map[bson.ObjectId]int, len(shareNotes))
|
||||
for _, each := range shareNotes {
|
||||
notesPerm[each.NoteId] = each.Perm
|
||||
}
|
||||
|
||||
return notesPerm
|
||||
}
|
||||
//func (this *ShareService) getNotesPerm(noteIds []bson.ObjectId, myUserId, sharedUserId string) map[bson.ObjectId]int {
|
||||
// shareNotes := []info.ShareNote{}
|
||||
// db.ListByQ(db.ShareNotes,
|
||||
// bson.M{
|
||||
// "NoteId": bson.M{"$in": noteIds},
|
||||
// "UserId": bson.ObjectIdHex(sharedUserId),
|
||||
// "ToUserId": bson.ObjectIdHex(myUserId)}, &shareNotes)
|
||||
//
|
||||
// notesPerm := make(map[bson.ObjectId]int, len(shareNotes))
|
||||
// for _, each := range shareNotes {
|
||||
// notesPerm[each.NoteId] = each.Perm
|
||||
// }
|
||||
//
|
||||
// return notesPerm
|
||||
//}
|
||||
|
||||
// 得到默认的单个的notes 共享集
|
||||
// 如果真要支持排序, 这里得到所有共享的notes, 到noteService方再sort和limit
|
||||
@@ -184,9 +235,12 @@ func (this *ShareService) ListShareNotes(myUserId, sharedUserId string,
|
||||
skipNum, _ := parsePageAndSort(pageNumber, pageSize, sortField, isAsc)
|
||||
shareNotes := []info.ShareNote{}
|
||||
|
||||
q := this.getOrQ(myUserId)
|
||||
q["UserId"] = bson.ObjectIdHex(sharedUserId);
|
||||
|
||||
db.ShareNotes.
|
||||
Find(bson.M{"UserId": bson.ObjectIdHex(sharedUserId), "ToUserId": bson.ObjectIdHex(myUserId)}).
|
||||
// Sort(sortFieldR).
|
||||
Find(q).
|
||||
Sort("-ToUserId"). // 给个人的权限 > 给组织的权限
|
||||
Skip(skipNum).
|
||||
Limit(pageSize).
|
||||
All(&shareNotes)
|
||||
@@ -200,15 +254,20 @@ func (this *ShareService) ListShareNotes(myUserId, sharedUserId string,
|
||||
noteIds[i] = each.NoteId
|
||||
}
|
||||
notes := noteService.ListNotesByNoteIds(noteIds)
|
||||
notesMap := make(map[bson.ObjectId]info.Note, len(notes))
|
||||
notesMap := map[bson.ObjectId]info.Note{}
|
||||
for _, each := range notes {
|
||||
notesMap[each.NoteId] = each
|
||||
}
|
||||
|
||||
// 将shareNotes与notes结合起来
|
||||
notesWithPerm := make([]info.ShareNoteWithPerm, len(shareNotes))
|
||||
for i, each := range shareNotes {
|
||||
notesWithPerm[i] = info.ShareNoteWithPerm{notesMap[each.NoteId], each.Perm}
|
||||
notesWithPerm := []info.ShareNoteWithPerm{}
|
||||
hasAdded := map[bson.ObjectId]bool{} // 防止重复, 只要前面权限高的
|
||||
for _, each := range shareNotes {
|
||||
if !hasAdded[each.NoteId] {
|
||||
// 待优化
|
||||
notesWithPerm = append(notesWithPerm, info.ShareNoteWithPerm{notesMap[each.NoteId], each.Perm})
|
||||
hasAdded[each.NoteId] = true
|
||||
}
|
||||
}
|
||||
return notesWithPerm
|
||||
}
|
||||
@@ -286,19 +345,25 @@ func (this *ShareService) AddShareNote(noteId string, perm int, userId, email st
|
||||
return db.Insert(db.ShareNotes, shareNote), "", toUserId
|
||||
}
|
||||
|
||||
|
||||
// updatedUserId是否有查看userId noteId的权限?
|
||||
// userId是所有者
|
||||
func (this *ShareService) HasReadPerm(userId, updatedUserId, noteId string) bool {
|
||||
if !db.Has(db.ShareNotes,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NoteId": bson.ObjectIdHex(noteId)}) {
|
||||
q := this.getOrQ(updatedUserId) // (toUserId == "xxx" || ToGroupId in (1, 2,3))
|
||||
q["UserId"] = bson.ObjectIdHex(userId)
|
||||
q["NoteId"] = bson.ObjectIdHex(noteId)
|
||||
if !db.Has(db.ShareNotes, q) {
|
||||
// noteId的notebookId是否被共享了?
|
||||
notebookId := noteService.GetNotebookId(noteId)
|
||||
if notebookId.Hex() == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
delete(q, "NoteId")
|
||||
q["NotebookId"] = notebookId
|
||||
|
||||
// 判断notebook是否被共享
|
||||
if !db.Has(db.ShareNotebooks,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NotebookId": notebookId}) {
|
||||
if !db.Has(db.ShareNotebooks, q) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
@@ -310,43 +375,44 @@ func (this *ShareService) HasReadPerm(userId, updatedUserId, noteId string) bool
|
||||
|
||||
// updatedUserId是否有修改userId noteId的权限?
|
||||
func (this *ShareService) HasUpdatePerm(userId, updatedUserId, noteId string) bool {
|
||||
// 1. noteId是否被共享了?
|
||||
// 得到该note share的信息
|
||||
/*
|
||||
UserId bson.ObjectId `bson:"UserId"`
|
||||
ToUserId bson.ObjectId `bson:"ToUserId"`
|
||||
NoteId bson.ObjectId `bson:"NoteId"`
|
||||
Perm int `bson:"Perm"` // 权限, 0只读, 1可修改
|
||||
*/
|
||||
if !db.Has(db.ShareNotes,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NoteId": bson.ObjectIdHex(noteId), "Perm": 1}) {
|
||||
// noteId的notebookId是否被共享了?
|
||||
notebookId := noteService.GetNotebookId(noteId)
|
||||
if notebookId.Hex() == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 判断notebook是否被共享
|
||||
if !db.Has(db.ShareNotebooks,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NotebookId": notebookId, "Perm": 1}) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
q := this.getOrQ(updatedUserId) // (toUserId == "xxx" || ToGroupId in (1, 2,3))
|
||||
q["UserId"] = bson.ObjectIdHex(userId)
|
||||
q["NoteId"] = bson.ObjectIdHex(noteId)
|
||||
|
||||
// note的权限
|
||||
shares := []info.ShareNote{}
|
||||
db.ShareNotes.Find(q).Sort("-ToUserId").All(&shares) // 个人 > 组织
|
||||
for _, share := range shares {
|
||||
return share.Perm == 1 // 第1个权限最大
|
||||
}
|
||||
|
||||
// notebook的权限
|
||||
notebookId := noteService.GetNotebookId(noteId)
|
||||
if notebookId.Hex() == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
delete(q, "NoteId")
|
||||
q["NotebookId"] = notebookId
|
||||
shares2 := []info.ShareNotebook{}
|
||||
db.ShareNotebooks.Find(q).Sort("-ToUserId").All(&shares2) // 个人 > 组织
|
||||
for _, share := range shares2 {
|
||||
return share.Perm == 1 // 第1个权限最大
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// updatedUserId是否有修改userId notebookId的权限?
|
||||
func (this *ShareService) HasUpdateNotebookPerm(userId, updatedUserId, notebookId string) bool {
|
||||
// 判断notebook是否被共享
|
||||
if !db.Has(db.ShareNotebooks,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NotebookId": bson.ObjectIdHex(notebookId), "Perm": 1}) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
q := this.getOrQ(updatedUserId) // (toUserId == "xxx" || ToGroupId in (1, 2,3))
|
||||
q["UserId"] = bson.ObjectIdHex(userId)
|
||||
q["NotebookId"] = bson.ObjectIdHex(notebookId)
|
||||
shares2 := []info.ShareNotebook{}
|
||||
db.ShareNotebooks.Find(q).Sort("-ToUserId").All(&shares2) // 个人 > 组织
|
||||
for _, share := range shares2 {
|
||||
return share.Perm == 1 // 第1个权限最大
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 共享note, notebook时使用
|
||||
@@ -372,12 +438,16 @@ func (this *ShareService) HasSharedNotebook(noteId, myUserId, sharedUserId strin
|
||||
}
|
||||
|
||||
// 得到共享的笔记内容
|
||||
// 首先要判断这个note是否我被共享了
|
||||
// 并返回笔记的权限!!!
|
||||
func (this *ShareService) GetShareNoteContent(noteId, myUserId, sharedUserId string) (noteContent info.NoteContent) {
|
||||
noteContent = info.NoteContent{}
|
||||
// 是否单独共享了该notebook
|
||||
// 或者, 其notebook共享了我
|
||||
if this.HasSharedNote(noteId, myUserId) || this.HasSharedNotebook(noteId, myUserId, sharedUserId) {
|
||||
// Log(this.HasSharedNote(noteId, myUserId))
|
||||
// Log(this.HasSharedNotebook(noteId, myUserId, sharedUserId))
|
||||
Log(this.HasReadPerm(sharedUserId, myUserId, noteId))
|
||||
if this.HasReadPerm(sharedUserId, myUserId, noteId) {
|
||||
// if this.HasSharedNote(noteId, myUserId) || this.HasSharedNotebook(noteId, myUserId, sharedUserId) {
|
||||
db.Get(db.NoteContents, noteId, ¬eContent)
|
||||
} else {
|
||||
}
|
||||
@@ -391,7 +461,15 @@ func (this *ShareService) GetShareNoteContent(noteId, myUserId, sharedUserId str
|
||||
func (this *ShareService) ListNoteShareUserInfo(noteId, userId string) []info.ShareUserInfo {
|
||||
// 得到shareNote信息, 得到所有的ToUserId
|
||||
shareNotes := []info.ShareNote{}
|
||||
db.ListByQLimit(db.ShareNotes, bson.M{"NoteId": bson.ObjectIdHex(noteId), "UserId": bson.ObjectIdHex(userId)}, &shareNotes, 100)
|
||||
db.ListByQLimit(db.ShareNotes,
|
||||
bson.M{
|
||||
"NoteId": bson.ObjectIdHex(noteId),
|
||||
"UserId": bson.ObjectIdHex(userId),
|
||||
"ToGroupId": bson.M{"$exists": false},
|
||||
}, &shareNotes, 100)
|
||||
|
||||
// Log("<<>>>>")
|
||||
// Log(len(shareNotes))
|
||||
|
||||
if len(shareNotes) == 0 {
|
||||
return nil
|
||||
@@ -450,7 +528,11 @@ func (this *ShareService) ListNotebookShareUserInfo(notebookId, userId string) [
|
||||
shareNotebooks := []info.ShareNotebook{}
|
||||
|
||||
db.ListByQLimit(db.ShareNotebooks,
|
||||
bson.M{"NotebookId": bson.ObjectIdHex(notebookId), "UserId": bson.ObjectIdHex(userId)},
|
||||
bson.M{
|
||||
"NotebookId": bson.ObjectIdHex(notebookId),
|
||||
"UserId": bson.ObjectIdHex(userId),
|
||||
"ToGroupId": bson.M{"$exists": false},
|
||||
},
|
||||
&shareNotebooks, 100)
|
||||
|
||||
if len(shareNotebooks) == 0 {
|
||||
@@ -555,7 +637,7 @@ func (this *ShareService) HasUpdateNotePerm(noteId, userId string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// 用户userId是否有修改noteId的权限
|
||||
// 用户userId是否有查看noteId的权限
|
||||
func (this *ShareService) HasReadNotePerm(noteId, userId string) bool {
|
||||
if noteId == "" || userId == "" {
|
||||
return false;
|
||||
@@ -576,4 +658,121 @@ func (this *ShareService) HasReadNotePerm(noteId, userId string) bool {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------
|
||||
// 用户分组
|
||||
|
||||
// 得到笔记分享给的groups
|
||||
func (this *ShareService) GetNoteShareGroups(noteId, userId string) []info.ShareNote {
|
||||
// 得到分组s
|
||||
groups := groupService.GetGroups(userId)
|
||||
|
||||
// 得到有分享的分组
|
||||
shares := []info.ShareNote{}
|
||||
db.ListByQ(db.ShareNotes,
|
||||
bson.M{"NoteId": bson.ObjectIdHex(noteId), "UserId": bson.ObjectIdHex(userId), "ToGroupId": bson.M{"$exists":true}}, &shares)
|
||||
mapShares := map[bson.ObjectId]info.ShareNote{}
|
||||
for _, share := range shares {
|
||||
mapShares[share.ToGroupId] = share
|
||||
}
|
||||
|
||||
// 所有的groups都有share, 但没有share的group没有shareId
|
||||
shares2 := make([]info.ShareNote, len(groups))
|
||||
for i, group := range groups {
|
||||
share, ok := mapShares[group.GroupId]
|
||||
if !ok {
|
||||
share = info.ShareNote{}
|
||||
}
|
||||
share.ToGroup = group;
|
||||
shares2[i] = share
|
||||
}
|
||||
|
||||
return shares2
|
||||
}
|
||||
|
||||
// 共享笔记给分组
|
||||
func (this *ShareService) AddShareNoteGroup(userId, noteId, groupId string, perm int) (bool) {
|
||||
// 得到group, 是否是我的group
|
||||
group := groupService.GetGroup(userId, groupId)
|
||||
if group.GroupId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 先删除之
|
||||
this.DeleteShareNoteGroup(userId, noteId, groupId)
|
||||
|
||||
shareNote := info.ShareNote{NoteId: bson.ObjectIdHex(noteId),
|
||||
UserId: bson.ObjectIdHex(userId), // 冗余字段
|
||||
ToGroupId: bson.ObjectIdHex(groupId),
|
||||
Perm: perm,
|
||||
CreatedTime: time.Now(),
|
||||
}
|
||||
return db.Insert(db.ShareNotes, shareNote)
|
||||
}
|
||||
|
||||
// 删除
|
||||
func (this *ShareService) DeleteShareNoteGroup(userId, noteId, groupId string) bool {
|
||||
return db.Delete(db.ShareNotes, bson.M{"NoteId": bson.ObjectIdHex(noteId),
|
||||
"UserId": bson.ObjectIdHex(userId),
|
||||
"ToGroupId": bson.ObjectIdHex(groupId),
|
||||
});
|
||||
}
|
||||
|
||||
//-------
|
||||
|
||||
// 得到笔记本分享给的groups
|
||||
func (this *ShareService) GetNotebookShareGroups(notebookId, userId string) []info.ShareNotebook {
|
||||
// 得到分组s
|
||||
groups := groupService.GetGroups(userId)
|
||||
|
||||
// 得到有分享的分组
|
||||
shares := []info.ShareNotebook{}
|
||||
db.ListByQ(db.ShareNotebooks,
|
||||
bson.M{"NotebookId": bson.ObjectIdHex(notebookId), "UserId": bson.ObjectIdHex(userId), "ToGroupId": bson.M{"$exists":true}}, &shares)
|
||||
mapShares := map[bson.ObjectId]info.ShareNotebook{}
|
||||
for _, share := range shares {
|
||||
mapShares[share.ToGroupId] = share
|
||||
}
|
||||
LogJ(shares)
|
||||
|
||||
// 所有的groups都有share, 但没有share的group没有shareId
|
||||
shares2 := make([]info.ShareNotebook, len(groups))
|
||||
for i, group := range groups {
|
||||
share, ok := mapShares[group.GroupId]
|
||||
if !ok {
|
||||
share = info.ShareNotebook{}
|
||||
}
|
||||
share.ToGroup = group;
|
||||
shares2[i] = share
|
||||
}
|
||||
|
||||
return shares2
|
||||
}
|
||||
// 共享笔记给分组
|
||||
func (this *ShareService) AddShareNotebookGroup(userId, notebookId, groupId string, perm int) (bool) {
|
||||
// 得到group, 是否是我的group
|
||||
group := groupService.GetGroup(userId, groupId)
|
||||
if group.GroupId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 先删除之
|
||||
this.DeleteShareNotebookGroup(userId, notebookId, groupId)
|
||||
|
||||
shareNotebook := info.ShareNotebook{NotebookId: bson.ObjectIdHex(notebookId),
|
||||
UserId: bson.ObjectIdHex(userId), // 冗余字段
|
||||
ToGroupId: bson.ObjectIdHex(groupId),
|
||||
Perm: perm,
|
||||
CreatedTime: time.Now(),
|
||||
}
|
||||
return db.Insert(db.ShareNotebooks, shareNotebook)
|
||||
}
|
||||
|
||||
// 删除
|
||||
func (this *ShareService) DeleteShareNotebookGroup(userId, notebookId, groupId string) bool {
|
||||
return db.Delete(db.ShareNotebooks, bson.M{"NotebookId": bson.ObjectIdHex(notebookId),
|
||||
"UserId": bson.ObjectIdHex(userId),
|
||||
"ToGroupId": bson.ObjectIdHex(groupId),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -433,6 +433,36 @@ func (this *ThemeService) ImportTheme(userId, path string) (ok bool, msg string)
|
||||
return
|
||||
}
|
||||
|
||||
// 升级用
|
||||
// public/
|
||||
|
||||
func (this *ThemeService) UpgradeThemeBeta2() (ok bool) {
|
||||
adminUserId := configService.GetAdminUserId()
|
||||
this.upgradeThemeBeta2(adminUserId, this.GetDefaultThemePath(defaultStyle), true)
|
||||
this.upgradeThemeBeta2(adminUserId, this.GetDefaultThemePath(elegantStyle), false)
|
||||
this.upgradeThemeBeta2(adminUserId, this.GetDefaultThemePath(fixedStyle), false)
|
||||
return true
|
||||
}
|
||||
func (this *ThemeService) upgradeThemeBeta2(userId, targetPath string, isActive bool) (ok bool) {
|
||||
// 解压成功, 那么新建之
|
||||
// 保存到数据库中
|
||||
theme, _ := this.getThemeConfig(revel.BasePath + "/" + targetPath)
|
||||
if theme.Name == "" {
|
||||
ok = false
|
||||
return
|
||||
}
|
||||
themeIdO := bson.NewObjectId()
|
||||
theme.ThemeId = themeIdO
|
||||
theme.Path = targetPath // public
|
||||
theme.CreatedTime = time.Now()
|
||||
theme.UpdatedTime = theme.CreatedTime
|
||||
theme.UserId = bson.ObjectIdHex(userId)
|
||||
theme.IsActive = isActive
|
||||
theme.IsDefault = true
|
||||
ok = db.Insert(db.Themes, theme)
|
||||
return ok
|
||||
}
|
||||
|
||||
// 安装主题
|
||||
// 得到该主题路径
|
||||
func (this *ThemeService) InstallTheme(userId, themeId string) (ok bool) {
|
||||
|
||||
@@ -29,8 +29,15 @@ func (this *UpgradeService) UpgradeBlog() bool {
|
||||
}
|
||||
|
||||
// 11-5自定义博客升级, 将aboutMe移至pages
|
||||
func (this *UpgradeService) UpgradeBetaToSelfBlog(userId string) (ok bool, msg string) {
|
||||
if configService.GetGlobalStringConfig("UpgradeBetaToSelfBlog") != "" {
|
||||
/*
|
||||
<li>Migrate "About me" to single(a single post)</li>
|
||||
<li>Add some default themes to administrator</li>
|
||||
<li>Generate "UrlTitle" for all notes. "UrlTitle" is a friendly url for post</li>
|
||||
<li>Generate "UrlTitle" for all notebooks</li>
|
||||
<li>Generate "UrlTitle" for all singles</li>
|
||||
*/
|
||||
func (this *UpgradeService) UpgradeBetaToBeta2(userId string) (ok bool, msg string) {
|
||||
if configService.GetGlobalStringConfig("UpgradeBetaToBeta2") != "" {
|
||||
return false, "已升级"
|
||||
}
|
||||
|
||||
@@ -42,11 +49,58 @@ func (this *UpgradeService) UpgradeBetaToSelfBlog(userId string) (ok bool, msg s
|
||||
blogService.AddOrUpdateSingle(userBlog.UserId.Hex(), "", "About Me", userBlog.AboutMe)
|
||||
}
|
||||
|
||||
configService.UpdateGlobalStringConfig(userId, "UpgradeBetaToSelfBlog", "ok")
|
||||
|
||||
// 2. 默认主题, 给admin用户
|
||||
themeService.UpgradeThemeBeta2()
|
||||
|
||||
// 3. UrlTitles
|
||||
|
||||
// 3.1 note
|
||||
notes := []info.Note{}
|
||||
db.ListByQ(db.Notes, bson.M{}, ¬es)
|
||||
for _, note := range notes {
|
||||
data := bson.M{}
|
||||
noteId := note.NoteId.Hex()
|
||||
// PublicTime, RecommendTime = UpdatedTime
|
||||
if note.IsBlog && note.PublicTime.Year() < 100 {
|
||||
data["PublicTime"] = note.UpdatedTime
|
||||
data["RecommendTime"] = note.UpdatedTime
|
||||
Log("Time " + noteId)
|
||||
}
|
||||
data["UrlTitle"] = GetUrTitle(note.UserId.Hex(), note.Title, "note")
|
||||
db.UpdateByIdAndUserIdMap2(db.Notes, note.NoteId, note.UserId, data)
|
||||
Log(noteId)
|
||||
}
|
||||
|
||||
// 3.2
|
||||
Log("notebook")
|
||||
notebooks := []info.Notebook{}
|
||||
db.ListByQ(db.Notebooks, bson.M{}, ¬ebooks)
|
||||
for _, notebook := range notebooks {
|
||||
notebookId := notebook.NotebookId.Hex()
|
||||
data := bson.M{}
|
||||
data["UrlTitle"] = GetUrTitle(notebook.UserId.Hex(), notebook.Title, "notebook")
|
||||
db.UpdateByIdAndUserIdMap2(db.Notebooks, notebook.NotebookId, notebook.UserId, data)
|
||||
Log(notebookId)
|
||||
}
|
||||
|
||||
// 3.3 single
|
||||
/*
|
||||
singles := []info.BlogSingle{}
|
||||
db.ListByQ(db.BlogSingles, bson.M{}, &singles)
|
||||
for _, single := range singles {
|
||||
singleId := single.SingleId.Hex()
|
||||
blogService.UpdateSingleUrlTitle(single.UserId.Hex(), singleId, single.Title)
|
||||
Log(singleId)
|
||||
}
|
||||
*/
|
||||
|
||||
// 删除索引
|
||||
db.ShareNotes.DropIndex("UserId", "ToUserId", "NoteId")
|
||||
|
||||
ok = true
|
||||
msg = "success"
|
||||
configService.UpdateGlobalStringConfig(userId, "UpgradeBetaToBeta2", "1")
|
||||
|
||||
// 2. 默认主题, 给admin用户
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,6 +41,13 @@ func (this *UserService) GetUserId(email string) string {
|
||||
return user.UserId.Hex()
|
||||
}
|
||||
|
||||
// 得到用户名
|
||||
func (this *UserService) GetUsername(userId string) string {
|
||||
user := info.User{}
|
||||
db.GetByQWithFields(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, []string{"Username"}, &user)
|
||||
return user.Username
|
||||
}
|
||||
|
||||
// 是否存在该用户 email
|
||||
func (this *UserService) IsExistsUser(email string) bool {
|
||||
if this.GetUserId(email) == "" {
|
||||
@@ -163,7 +170,7 @@ func (this *UserService) MapUserAndBlogByUserIds(userIds []bson.ObjectId) map[st
|
||||
Logo: user.Logo,
|
||||
BlogTitle: userBlog.Title,
|
||||
BlogLogo: userBlog.Logo,
|
||||
BlogUrl: blogService.GetUserBlogUrl(&userBlog),
|
||||
BlogUrl: blogService.GetUserBlogUrl(&userBlog, user.Username),
|
||||
}
|
||||
}
|
||||
return userAndBlogMap
|
||||
@@ -180,7 +187,8 @@ func (this *UserService) GetUserAndBlog(userId string) info.UserAndBlog {
|
||||
Logo: user.Logo,
|
||||
BlogTitle: userBlog.Title,
|
||||
BlogLogo: userBlog.Logo,
|
||||
BlogUrl: blogService.GetUserBlogUrl(&userBlog),
|
||||
BlogUrl: blogService.GetUserBlogUrl(&userBlog, user.Username),
|
||||
BlogUrls: blogService.GetBlogUrls(&userBlog, &user),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +277,20 @@ func (this *UserService) UpdateTheme(userId, theme string) (bool) {
|
||||
return ok
|
||||
}
|
||||
|
||||
// 帐户类型设置
|
||||
func (this *UserService) UpdateAccount(userId, accountType string, accountStartTime, accountEndTime time.Time,
|
||||
maxImageNum, maxImageSize, maxAttachNum, maxAttachSize, maxPerAttachSize int) bool {
|
||||
return db.UpdateByQI(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, info.UserAccount{
|
||||
AccountType: accountType,
|
||||
AccountStartTime: accountStartTime,
|
||||
AccountEndTime: accountEndTime,
|
||||
MaxImageNum: maxImageNum,
|
||||
MaxImageSize: maxImageSize,
|
||||
MaxAttachNum: maxAttachNum,
|
||||
MaxAttachSize: maxAttachSize,
|
||||
MaxPerAttachSize: maxPerAttachSize,
|
||||
})
|
||||
}
|
||||
|
||||
//---------------
|
||||
// 修改email
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"gopkg.in/mgo.v2"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
// init service, for share service bettween services
|
||||
@@ -13,6 +20,7 @@ var noteContentHistoryService, NoteContentHistoryS *NoteContentHistoryService
|
||||
var trashService, TrashS *TrashService
|
||||
var shareService, ShareS *ShareService
|
||||
var userService, UserS *UserService
|
||||
var groupService, GroupS *GroupService
|
||||
var tagService, TagS *TagService
|
||||
var blogService, BlogS *BlogService
|
||||
var tokenService, TokenS *TokenService
|
||||
@@ -37,6 +45,7 @@ func InitService() {
|
||||
TrashS = &TrashService{}
|
||||
ShareS = &ShareService{}
|
||||
UserS = &UserService{}
|
||||
GroupS = &GroupService{}
|
||||
TagS = &TagService{}
|
||||
BlogS = &BlogService{}
|
||||
TokenS = &TokenService{}
|
||||
@@ -59,6 +68,7 @@ func InitService() {
|
||||
trashService = TrashS
|
||||
shareService = ShareS
|
||||
userService = UserS
|
||||
groupService = GroupS
|
||||
tagService = TagS
|
||||
blogService = BlogS
|
||||
tokenService = TokenS
|
||||
@@ -71,3 +81,70 @@ func InitService() {
|
||||
sessionService = SessionS
|
||||
themeService = ThemeS
|
||||
}
|
||||
|
||||
//----------------
|
||||
// service 公用方法
|
||||
|
||||
// 将name=val的val进行encoding
|
||||
func decodeValue(val string) string {
|
||||
v, _ := url.ParseQuery("a=" + val)
|
||||
return v.Get("a")
|
||||
}
|
||||
|
||||
func encodeValue(val string) string {
|
||||
if val == "" {
|
||||
return val
|
||||
}
|
||||
v := url.Values{}
|
||||
v.Set("", val)
|
||||
return v.Encode()[1:]
|
||||
}
|
||||
// 添加笔记时通过title得到urlTitle
|
||||
func fixUrlTitle(urlTitle string) string {
|
||||
if urlTitle != "" {
|
||||
// 把特殊字段给替换掉
|
||||
// str := `life "%&()+,/:;<>=?@\|`
|
||||
reg, _ := regexp.Compile("/|#|\\$|!|\\^|\\*|'| |\"|%|&|\\(|\\)|\\+|\\,|/|:|;|<|>|=|\\?|@|\\||\\\\")
|
||||
urlTitle = reg.ReplaceAllString(urlTitle, "-")
|
||||
urlTitle = strings.Trim(urlTitle, "-") // 左右单独的-去掉
|
||||
// 把空格替换成-
|
||||
// urlTitle = strings.Replace(urlTitle, " ", "-", -1)
|
||||
for strings.Index(urlTitle, "--") >= 0 { // 防止出现连续的--
|
||||
urlTitle = strings.Replace(urlTitle, "--", "-", -1)
|
||||
}
|
||||
return encodeValue(urlTitle)
|
||||
}
|
||||
return urlTitle
|
||||
}
|
||||
|
||||
func getUniqueUrlTitle(userId string, urlTitle string, types string, padding int) string {
|
||||
urlTitle2 := urlTitle
|
||||
if padding > 1 {
|
||||
urlTitle2 = urlTitle + "-" + strconv.Itoa(padding)
|
||||
}
|
||||
userIdO := bson.ObjectIdHex(userId)
|
||||
|
||||
var collection *mgo.Collection
|
||||
if types == "note" {
|
||||
collection = db.Notes
|
||||
} else if types == "notebook" {
|
||||
collection = db.Notebooks
|
||||
} else if types == "single" {
|
||||
collection = db.BlogSingles
|
||||
}
|
||||
for db.Has(collection, bson.M{"UserId": userIdO, "UrlTitle": urlTitle2}) { // 用户下唯一
|
||||
padding++
|
||||
urlTitle2 = urlTitle + "-" + strconv.Itoa(padding)
|
||||
}
|
||||
|
||||
return urlTitle2
|
||||
}
|
||||
// types == note,notebook,single
|
||||
func GetUrTitle(userId string, title string, types string) string {
|
||||
urlTitle := strings.Trim(title, " ")
|
||||
if urlTitle == "" {
|
||||
urlTitle = "Untitled-" + userId
|
||||
}
|
||||
urlTitle = fixUrlTitle(urlTitle)
|
||||
return getUniqueUrlTitle(userId, urlTitle, types, 1)
|
||||
}
|
||||
|
||||
@@ -128,10 +128,18 @@
|
||||
</i>
|
||||
</span>
|
||||
<span>
|
||||
Setting
|
||||
Configuration
|
||||
</span>
|
||||
</a>
|
||||
<ul class="nav lt">
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/home_page">
|
||||
<span>
|
||||
Home Page
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/demo">
|
||||
<span>
|
||||
@@ -141,7 +149,7 @@
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/openRegister">
|
||||
<a href="/admin/t?t=setting/open_register">
|
||||
<span>
|
||||
Open Register
|
||||
</span>
|
||||
@@ -200,5 +208,32 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-space-shuttle icon">
|
||||
<b class="bg-danger">
|
||||
</b>
|
||||
</i>
|
||||
<span class="pull-right">
|
||||
<i class="fa fa-angle-down text">
|
||||
</i>
|
||||
<i class="fa fa-angle-up text-active">
|
||||
</i>
|
||||
</span>
|
||||
|
||||
<span>
|
||||
Upgrade
|
||||
</span>
|
||||
</a>
|
||||
<ul class="nav lt">
|
||||
<li>
|
||||
<a href="/admin/t?t=upgrade/beta2">
|
||||
<span>
|
||||
v1.0-beta to v1.0-beta2
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
49
app/views/admin/setting/home_page.html
Normal file
49
app/views/admin/setting/home_page.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{{template "admin/top.html" .}}
|
||||
<div class="m-b-md"> <h3 class="m-b-none">Home Page</h3></div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-6">
|
||||
<form id="form_data">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label><a href="/blog" target="_blank">Admin's Blog Page</a></label>
|
||||
<input type="radio" class="form-control" name="homePage" {{if not .str.homePage}}checked="checked"{{end}} value="0">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><a href="/index" target="_blank">Index Page</a></label>
|
||||
<input type="radio" class="form-control" name="homePage" {{if .str.homePage}}checked="checked"{{end}} value="1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="panel-footer text-right bg-light lter">
|
||||
<button type="submit" id="submit" class="btn btn-success btn-s-xs">Submit</button>
|
||||
</footer>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "admin/footer.html" .}}
|
||||
<script>
|
||||
$(function() {
|
||||
$("#submit").click(function(e){
|
||||
e.preventDefault();
|
||||
var t = this;
|
||||
$(t).button('loading');
|
||||
ajaxPost("/adminSetting/homePage", getFormJsonData("form_data"), function(ret){
|
||||
$(t).button('reset');
|
||||
if(!ret.Ok) {
|
||||
art.alert(ret.Msg);
|
||||
} else {
|
||||
art.tips("Success");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "admin/end.html" .}}
|
||||
47
app/views/admin/upgrade/beta2.html
Normal file
47
app/views/admin/upgrade/beta2.html
Normal file
@@ -0,0 +1,47 @@
|
||||
{{template "admin/top.html" .}}
|
||||
<div class="m-b-md"> <h3 class="m-b-none">Upgrade v1.0-beta to v1.0-beta2</h3></div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-6">
|
||||
<form id="add_user_form">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
Current Version: <span class="label label-success">leanote v{{.version}}</span>
|
||||
<ul>
|
||||
<li>Migrate "About me" to single(a single post)</li>
|
||||
<li>Add some default themes to administrator</li>
|
||||
<li>Generate "UrlTitle" for all notes. "UrlTitle" is a friendly url for post</li>
|
||||
<li>Generate "UrlTitle" for all notebooks</li>
|
||||
<li>Generate "UrlTitle" for all singles</li>
|
||||
</ul>
|
||||
</div>
|
||||
<footer class="panel-footer text-right bg-light lter">
|
||||
<button type="submit" id="submit" class="btn btn-success btn-s-xs">Upgrade</button>
|
||||
</footer>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "admin/footer.html" .}}
|
||||
<script>
|
||||
$(function() {
|
||||
$("#submit").click(function(e){
|
||||
e.preventDefault();
|
||||
var t = this;
|
||||
$(t).button('loading');
|
||||
ajaxPost("/adminUpgrade/UpgradeBetaToBeta2", {}, function(ret){
|
||||
$(t).button('reset')
|
||||
if(!ret.Ok) {
|
||||
art.alert(ret.Msg)
|
||||
} else {
|
||||
art.tips("Success");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "admin/end.html" .}}
|
||||
@@ -12,6 +12,9 @@
|
||||
{{range .notebooks}}
|
||||
<li class="list-group-item" draggable="true" data-id="{{.NotebookId.Hex}}">
|
||||
<span class="pull-left media-xs"><i class="fa fa-sort text-muted fa m-r-sm"></i></span>
|
||||
<div class="pull-right" style="margin-right: 10px">
|
||||
固定链接: /cate/<input data-id="{{.NotebookId.Hex}}" class="url-title" type="text" value="{{if .UrlTitle}}{{.UrlTitle|decodeUrlValue}}{{else}}{{.NotebookId.Hex}}{{end}}"/>
|
||||
</div>
|
||||
{{.Title}}
|
||||
</li>
|
||||
{{end}}
|
||||
@@ -33,7 +36,7 @@ $(function() {
|
||||
$(".list-group-item").each(function() {
|
||||
ids.push($(this).data("id"));
|
||||
});
|
||||
ajaxPost("/member/blog/upateCateIds", {cateIds: ids}, function(re){
|
||||
ajaxPost("/member/blog/", {cateIds: ids}, function(re){
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success");
|
||||
} else {
|
||||
@@ -41,6 +44,19 @@ $(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".url-title").change(function(){
|
||||
var $t = $(this);
|
||||
var url = $t.val();
|
||||
var cateId = $t.data('id');
|
||||
ajaxPost("/member/blog/updateCateUrlTitle", {cateId: cateId, urlTitle: url}, function(re){
|
||||
if(reIsOk(re)) {
|
||||
$t.val(re.Item);
|
||||
} else {
|
||||
art.alert(re.Msg || "error");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
<div class="alert alert-danger" id="baseMsg" style="display: none"></div>
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="subTitle" class="col-sm-3 control-label">{{msg . "chooseComment"}}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-12">
|
||||
<label>
|
||||
<input type="checkbox" id="CanComment" name="CanComment"
|
||||
{{if .userBlog.CanComment}}checked="checked"{{end}} > {{msg . "openComment"}}
|
||||
|
||||
169
app/views/member/blog/list.html
Normal file
169
app/views/member/blog/list.html
Normal file
@@ -0,0 +1,169 @@
|
||||
{{template "member/top.html" .}}
|
||||
<div class="m-b-md"><h3 class="m-b-none">文章列表</h3></div>
|
||||
<style>
|
||||
.url-title {
|
||||
width: 260px;
|
||||
}
|
||||
</style>
|
||||
<section class="panel panel-default">
|
||||
<div class="row wrapper">
|
||||
<div class="col-sm-5 m-b-xs">
|
||||
</div>
|
||||
<div class="col-sm-4 m-b-xs">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group search-group">
|
||||
<input type="text" class="input-sm form-control" placeholder="Title" id="keywords" value="{{.keywords}}" />
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-sm btn-default" type="button" data-url="/member/blog/index">Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped b-t b-light">
|
||||
<thead>
|
||||
<tr>
|
||||
{{$url := urlConcat "/member/blog/index" "keywords" .keywords}}
|
||||
<th style="width: 300px"
|
||||
{{sorterTh $url "title" .sorter}}
|
||||
>
|
||||
Title
|
||||
<span class="th-sort">
|
||||
<i class="fa fa-sort-down"></i>
|
||||
<i class="fa fa-sort-up"></i>
|
||||
<i class="fa fa-sort"></i>
|
||||
</span>
|
||||
</th>
|
||||
|
||||
<th
|
||||
style="width: 300px"
|
||||
{{sorterTh $url "urlTitle" .sorter}}
|
||||
>
|
||||
固定链接
|
||||
<span class="th-sort">
|
||||
<i class="fa fa-sort-down"></i>
|
||||
<i class="fa fa-sort-up"></i>
|
||||
<i class="fa fa-sort"></i>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
{{sorterTh $url "publicTime" .sorter}}
|
||||
>
|
||||
发布日期
|
||||
<span class="th-sort">
|
||||
<i class="fa fa-sort-down"></i>
|
||||
<i class="fa fa-sort-up"></i>
|
||||
<i class="fa fa-sort"></i>
|
||||
</span>
|
||||
</th>
|
||||
|
||||
<th
|
||||
{{sorterTh $url "updatedTime" .sorter}}
|
||||
>
|
||||
更新日期
|
||||
<span class="th-sort">
|
||||
<i class="fa fa-sort-down"></i>
|
||||
<i class="fa fa-sort-up"></i>
|
||||
<i class="fa fa-sort"></i>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
{{sorterTh $url "createdTime" .sorter}}
|
||||
>
|
||||
创建日期
|
||||
<span class="th-sort">
|
||||
<i class="fa fa-sort-down"></i>
|
||||
<i class="fa fa-sort-up"></i>
|
||||
<i class="fa fa-sort"></i>
|
||||
</span>
|
||||
</th>
|
||||
<th width="30">
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .blogs}}
|
||||
|
||||
{{if .UrlTitle}}
|
||||
{{set $ "urlTitle" (decodeUrlValue .UrlTitle)}}
|
||||
{{else}}
|
||||
{{set $ "urlTitle" .NoteId.Hex}}
|
||||
{{end}}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{$.userAndBlog.PostUrl}}/{{$.urlTitle}}" class="post" target="_blank">{{.Title|raw}}</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
/post/
|
||||
<input type="text" data-id="{{.NoteId.Hex}}" class="url-title" value="{{$.urlTitle}}"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{.PublicTime|datetime}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{.UpdatedTime|datetime}}
|
||||
</td>
|
||||
<td>
|
||||
{{.CreatedTime|datetime}}
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<a
|
||||
{{if .HasSelfDefined}}
|
||||
title="已设置"
|
||||
class="btn btn-sm btn-success"
|
||||
{{else}}
|
||||
title="未设置"
|
||||
class="btn btn-sm btn-default"
|
||||
{{end}}
|
||||
href="/member/blog/updateBlogAbstract?noteId={{.NoteId.Hex}}">摘要设置</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<footer class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-4 text-center">
|
||||
<small class="text-muted inline m-t-sm m-b-sm">
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-sm-4 text-right text-center-xs">
|
||||
{{set . "url" (urlConcat "/member/blog/index" "sorter" .sorter "keywords" .keywords)}}
|
||||
{{template "member/blog/page.html" .}}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
{{template "member/footer.html" .}}
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var postUrl="{{$.userAndBlog.PostUrl}}";
|
||||
$(".url-title").change(function(){
|
||||
var $t = $(this);
|
||||
var url = $t.val();
|
||||
var noteId = $t.data('id');
|
||||
ajaxPost("/member/blog/updateBlogUrlTitle", {noteId: noteId, urlTitle: url}, function(re){
|
||||
if(reIsOk(re)) {
|
||||
$t.val(re.Item);
|
||||
var $a = $t.closest("tr").find(".post");
|
||||
|
||||
$a.attr("href", postUrl + "/" + encodeURI(re.Item));
|
||||
} else {
|
||||
art.alert(re.Msg || "error");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "member/end.html" .}}
|
||||
33
app/views/member/blog/page.html
Normal file
33
app/views/member/blog/page.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{{if gt .pageInfo.TotalPage 1}}
|
||||
<ul class="pagination pagination-sm m-t-none m-b-none">
|
||||
<li class="{{if eq $.pageInfo.CurPage 1}}disabled{{end}}" >
|
||||
<a href="{{if eq $.pageInfo.CurPage 1}}javascript:;{{else}}{{sub $.pageInfo.CurPage | urlConcat $.url "page" }}{{end}}">
|
||||
<i class="fa fa-chevron-left">
|
||||
</i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{{range $i := N 1 .pageInfo.TotalPage}}
|
||||
{{if eq $i $.pageInfo.CurPage}}
|
||||
<li class="active">
|
||||
<a href="javascript:;">
|
||||
{{$i}}
|
||||
</a>
|
||||
</li>
|
||||
{{else}}
|
||||
<li class="">
|
||||
<a href="{{urlConcat $.url "page" $i}}">
|
||||
{{$i}}
|
||||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
<li class="{{if eq .pageInfo.CurPage .pageInfo.TotalPage}}disabled{{end}}" >
|
||||
<a href="{{if eq .pageInfo.CurPage .pageInfo.TotalPage}}javascript:;{{else}}{{add $.pageInfo.CurPage | urlConcat $.url "page" }}{{end}}">
|
||||
<i class="fa fa-chevron-right">
|
||||
</i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
@@ -12,11 +12,14 @@
|
||||
<ul class="list-group gutter list-group-lg list-group-sp sortable">
|
||||
{{range .singles}}
|
||||
<li class="list-group-item" draggable="true" data-id="{{.SingleId}}">
|
||||
<span class="pull-left media-xs"><i class="fa fa-sort text-muted fa m-r-sm"></i></span>
|
||||
<span class="pull-right">
|
||||
<a href="/member/blog/addOrUpdateSingle?singleId={{.SingleId}}"><i class="fa fa-pencil icon-muted fa-fw m-r-xs page-edit" data-id="{{.SingleId}}"></i></a>
|
||||
<a href="#"><i class="fa fa-times icon-muted fa-fw page-delete" data-id="{{.SingleId}}"></i></a>
|
||||
</span>
|
||||
<span class="pull-left media-xs"><i class="fa fa-sort text-muted fa m-r-sm"></i></span>
|
||||
<div class="pull-right" style="margin-right: 10px">
|
||||
固定链接: /single/<input data-id="{{.SingleId}}" class="url-title" type="text" value="{{if .UrlTitle}}{{.UrlTitle|decodeUrlValue}}{{else}}{{.SingleId}}{{end}}"/>
|
||||
</div>
|
||||
<div class="clear">
|
||||
{{.Title}}
|
||||
</div>
|
||||
@@ -63,6 +66,19 @@ $(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(".url-title").change(function(){
|
||||
var $t = $(this);
|
||||
var url = $t.val();
|
||||
var singleId = $t.data('id');
|
||||
ajaxPost("/member/blog/updateSingleUrlTitle", {singleId: singleId, urlTitle: url}, function(re){
|
||||
if(reIsOk(re)) {
|
||||
$t.val(re.Item);
|
||||
} else {
|
||||
art.alert(re.Msg || "error");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
127
app/views/member/blog/update_abstract.html
Normal file
127
app/views/member/blog/update_abstract.html
Normal file
@@ -0,0 +1,127 @@
|
||||
{{template "member/top.html" .}}
|
||||
|
||||
<style>
|
||||
.img-src {
|
||||
max-height: 200px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="m-b-md"> <h3 class="m-b-none">
|
||||
{{.note.Title}} - 摘要设置
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="/tinymce/skins/custom/skin.min.css" type="text/css">
|
||||
<div class="row">
|
||||
<div class="col-sm-10">
|
||||
<form id="formData">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
以下内容设置后, 以后修改笔记时将不自动获取. 若将该文章取消为博客后, 以下内容会自动获取.
|
||||
<hr />
|
||||
<div class="alert alert-danger" id="baseMsg" style="display: none"></div>
|
||||
<div class="form-group">
|
||||
<label>
|
||||
主图片
|
||||
<a class="btn btn-default btn-select-img">从笔记中自动获取下一张</a>
|
||||
</label>
|
||||
<div>
|
||||
<img src="{{.note.ImgSrc}}" class="img-src" id="imgSrc"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>描述</label>
|
||||
<textarea type="text" rows="6" class="form-control" id="desc" name="desc">{{.note.Desc}}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="content1">摘要</label>
|
||||
<div id="popularToolbar"></div>
|
||||
<textarea id="content1" name="content">{{.note.Abstract}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="panel-footer text-right bg-light lter">
|
||||
<button type="submit" id="submitBtn" class="btn btn-success">{{msg . "submit"}}</button>
|
||||
</footer>
|
||||
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
原文:
|
||||
</p>
|
||||
<div id="rawContent">
|
||||
{{.note.Content|raw}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{template "member/footer.html" .}}
|
||||
<script type="text/javascript" src="/tinymce/tinymce.js"></script>
|
||||
<script>
|
||||
var UrlPrefix = "{{.siteUrl}}";
|
||||
$(function() {
|
||||
tinymce.init({
|
||||
selector : "#content1",
|
||||
content_css : [ "/css/bootstrap.css", "/css/editor/editor.css" ],
|
||||
skin : "custom",
|
||||
language : "{{.locale}}",
|
||||
height : 300,
|
||||
width : "100%",
|
||||
skin : "custom",
|
||||
plugins : [
|
||||
"advlist autolink link leanote_image lists charmap hr ",
|
||||
"searchreplace visualblocks visualchars leanote_code tabfocus",
|
||||
"table contextmenu directionality textcolor paste fullpage textcolor"],
|
||||
toolbar1 : "formatselect |fontselect fontsizeselect| forecolor backcolor | bold italic underline strikethrough | bullist numlist | leanote_code",
|
||||
menubar : false,
|
||||
statusbar : false,
|
||||
font_formats : "Arial=arial,helvetica,sans-serif;"
|
||||
+ "Arial Black=arial black,avant garde;"
|
||||
+ "Times New Roman=times new roman,times;"
|
||||
+ "Courier New=courier new,courier;"
|
||||
+ "Tahoma=tahoma,arial,helvetica,sans-serif;"
|
||||
+ "Verdana=verdana,geneva;" + "宋体=SimSun;"
|
||||
+ "新宋体=NSimSun;" + "黑体=SimHei;"
|
||||
+ "微软雅黑=Microsoft YaHei",
|
||||
block_formats : "Header 1=h1;Header 2=h2;Header 3=h3; Header 4=h4;Pre=pre;Paragraph=p"
|
||||
});
|
||||
|
||||
// 提交
|
||||
$("#submitBtn").click(function(e) {
|
||||
e.preventDefault();
|
||||
var data = {
|
||||
noteId: "{{.noteId}}",
|
||||
imgSrc: $("#imgSrc").attr("src"),
|
||||
desc : $("#desc").val(),
|
||||
abstract : getEditorContent()
|
||||
}
|
||||
ajaxPost("/member/blog/doUpdateBlogAbstract/", data, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success");
|
||||
location.href = "/member/blog/index";
|
||||
} else {
|
||||
art.alert(re.Msg || "error")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 选择主图
|
||||
var $imgs = $("#rawContent").find("img");
|
||||
var imgLen = $imgs.length;
|
||||
var imgSeq = 0;
|
||||
var $imgSrc = $("#imgSrc");
|
||||
$(".btn-select-img").click(function() {
|
||||
if(imgLen == 0) {
|
||||
return;
|
||||
}
|
||||
imgSeq++;
|
||||
imgSeq = imgSeq%imgLen;
|
||||
$imgSrc.attr("src", $imgs.eq(imgSeq).attr("src"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "member/end.html" .}}
|
||||
220
app/views/member/group/index.html
Normal file
220
app/views/member/group/index.html
Normal file
@@ -0,0 +1,220 @@
|
||||
{{template "member/top.html" .}}
|
||||
<style>
|
||||
.group-title {
|
||||
color: #fff;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
width: 200px;
|
||||
}
|
||||
</style>
|
||||
<div class="m-b-md"> <h3 class="m-b-none">项目/成员</h3></div>
|
||||
|
||||
<p>
|
||||
<a class="btn btn-default btn-add-group"><span class="fa fa-plus"></span> 新建分组</a>
|
||||
</p>
|
||||
|
||||
|
||||
<script type="text/x-jsrender" id="tUser">
|
||||
<li class="list-group-item" data-id="[[:UserId]]">
|
||||
[[:Username]] [[if Email != Username]]([[:Email]])[[/if]]
|
||||
<span class="fa fa-remove pull-right text-xs m-t-sm"></span>
|
||||
</li>
|
||||
</script>
|
||||
|
||||
<script type="text/x-jsrender" id="tGroup">
|
||||
<div class="col-sm-4 each-group" data-id="[[:GroupId]]">
|
||||
<section class="panel panel-default">
|
||||
<header class="panel-heading bg-success lt no-border">
|
||||
<div class="clearfix">
|
||||
<div class="clear">
|
||||
<div class="h3 m-t-xs m-b-xs text-white">
|
||||
<input type="text" data-ever="[[:Title]]" value="[[:Title]]" class="group-title" />
|
||||
<a title="删除分组" class="delete-group">
|
||||
<i class="fa fa-remove text-white pull-right text-xs m-t-sm"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<ul class="list-group no-radius">
|
||||
<li class="list-group-item">
|
||||
<input type="text" class="add-user-input form-control" placeholder="输入用户名或邮箱添加成员" />
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div class="row" id="groups">
|
||||
{{range .groups}}
|
||||
<div class="col-sm-4 each-group" data-id="{{.GroupId.Hex}}">
|
||||
<section class="panel panel-default">
|
||||
<header class="panel-heading bg-success lt no-border">
|
||||
<div class="clearfix">
|
||||
<div class="clear">
|
||||
<div class="h3 m-t-xs m-b-xs text-white">
|
||||
<input type="text" data-ever="{{.Title}}" value="{{.Title}}" class="group-title" />
|
||||
<a title="删除分组" class="delete-group">
|
||||
<i class="fa fa-remove text-white pull-right text-xs m-t-sm"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<ul class="list-group no-radius group-users">
|
||||
{{range .Users}}
|
||||
<li class="list-group-item" data-id="{{.UserId.Hex}}">
|
||||
{{.Username}} {{if not (eq .Email .Username)}}({{.Email}}){{end}}
|
||||
<a title="删除成员" class="delete-user">
|
||||
<span class="fa fa-remove pull-right text-xs m-t-sm"></span>
|
||||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
<li class="list-group-item">
|
||||
<input type="text" class="add-user-input form-control" placeholder="输入用户名或邮箱添加成员" />
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
|
||||
{{template "member/footer.html" .}}
|
||||
<script src="http://leanote.com/public/blog/js/jsrender.js"></script>
|
||||
<script>
|
||||
var group = {
|
||||
tGroupO: $("#tGroup"),
|
||||
groupsO: $("#groups"),
|
||||
tUserO: $("#tUser"),
|
||||
init: function() {
|
||||
var self = this;
|
||||
self.addGroupEvent();
|
||||
self.updateGroupEvent();
|
||||
self.deleteGroupEvent();
|
||||
self.addUserEvent();
|
||||
self.deleteUserEvent();
|
||||
|
||||
var classes = ["bg-warning", "bg-danger", "bg-success", "bg-dark", "bg-primary"];
|
||||
var i = 0;
|
||||
var len = classes.length;
|
||||
$(".panel-heading").each(function() {
|
||||
$(this).removeClass("bg-success").addClass(classes[i%len]);
|
||||
i++;
|
||||
});
|
||||
},
|
||||
// 添加用户分组
|
||||
addGroupEvent: function() {
|
||||
var self = this;
|
||||
$('.btn-add-group').click(function() {
|
||||
ajaxPost("/member/group/addGroup", {title: "分组名"}, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
var group = re.Item;
|
||||
self.groupsO.prepend(self.tGroupO.render(group))
|
||||
self.groupsO.find(".group-title").eq(0).focus().select();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
// 修改
|
||||
updateGroupEvent: function() {
|
||||
var self = this;
|
||||
self.groupsO.on("blur", ".group-title", function() {
|
||||
var t = $(this);
|
||||
var ever = t.data('ever');
|
||||
var val = t.val();
|
||||
if(ever == val) {
|
||||
return;
|
||||
}
|
||||
console.log($(this).closest(".each-group"));
|
||||
var groupId = $(this).closest(".each-group").data("id");
|
||||
ajaxPost("/member/group/updateGroupTitle", {groupId: groupId, title: val}, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success")
|
||||
t.data('ever', val)
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
// 删除分组
|
||||
deleteGroupEvent: function() {
|
||||
var self = this;
|
||||
self.groupsO.on("click", ".delete-group", function() {
|
||||
var t = $(this);
|
||||
art.confirm("Are you sure ?", function() {
|
||||
var groupId = t.closest(".each-group").data("id");
|
||||
ajaxPost("/member/group/deleteGroup", {groupId: groupId}, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success");
|
||||
t.closest(".each-group").remove();
|
||||
} else {
|
||||
art.alert(re.Msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
// 添加好友分组
|
||||
addUserEvent: function() {
|
||||
var self = this;
|
||||
self.groupsO.on("keydown", ".add-user-input", function(e) {
|
||||
// enter
|
||||
if (e.keyCode == 13) {
|
||||
var t = $(this);
|
||||
var email = t.val();
|
||||
if(!email) {
|
||||
t.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是合法的email
|
||||
if(!isEmail(email)) {
|
||||
// art.tips("非法的email");
|
||||
// return;
|
||||
}
|
||||
var groupId = t.closest(".each-group").data("id");
|
||||
var p = t.closest("li");
|
||||
ajaxPost("/member/group/addUser", {groupId: groupId, email: email}, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success");
|
||||
var html = self.tUserO.render(re.Item)
|
||||
p.before(html);
|
||||
t.val("");
|
||||
} else {
|
||||
art.alert(re.Msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
// 删除用户
|
||||
deleteUserEvent: function() {
|
||||
var self = this;
|
||||
self.groupsO.on("click", ".delete-user", function() {
|
||||
var t = $(this);
|
||||
art.confirm("Are you sure ?", function() {
|
||||
var groupId = t.closest(".each-group").data("id");
|
||||
var userId = t.closest("li").data("id");
|
||||
ajaxPost("/member/group/deleteUser", {groupId: groupId, userId: userId}, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
art.tips("Success");
|
||||
t.closest("li").remove();
|
||||
} else {
|
||||
art.alert(re.Msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
$(function() {
|
||||
group.init();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
{{template "member/end.html" .}}
|
||||
@@ -89,6 +89,14 @@
|
||||
</span>
|
||||
</a>
|
||||
<ul class="nav lt">
|
||||
<li>
|
||||
<a href="/member/blog/index">
|
||||
<span>
|
||||
文章列表
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/member/blog/base">
|
||||
<span>
|
||||
@@ -133,5 +141,17 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="active">
|
||||
<a href="/member/group/index">
|
||||
<i class="fa fa-users icon">
|
||||
<b class="bg-success">
|
||||
</b>
|
||||
</i>
|
||||
<span>
|
||||
项目组/成员
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
@@ -152,7 +152,7 @@ function log(o) {
|
||||
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation">
|
||||
<a href="/member/blog/base" target="_blank">
|
||||
<a href="/member/blog/index" target="_blank">
|
||||
<i class="fa fa-bold"></i>
|
||||
{{msg . "blogSet"}}
|
||||
</a>
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
{{$noteOrNotebookId := .noteOrNotebookId}}
|
||||
|
||||
<div class="modal-body">
|
||||
<ul id="myTab" class="nav nav-tabs">
|
||||
<li class="active"><a href="#baseInfo" data-toggle="tab">分享给好友</a></li>
|
||||
<li class=""><a href="#groupInfo" data-toggle="tab">分享给项目组</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="baseInfo">
|
||||
<button class="btn btn-default" id="addShareNotebookBtn">{{msg . "addShare"}}</button>
|
||||
<div id="shareMsg" class="alert alert-danger" style="display: none; margin: 5px 0 0 0;"></div>
|
||||
<table class="table table-hover" id="shareNotebookTable">
|
||||
@@ -25,11 +32,11 @@
|
||||
<input id="friendsEmail" type="text" class="form-control" placeholder="{{msg . "friendEmail"}}">
|
||||
</td>
|
||||
<td>
|
||||
<label for="readPerm1"><input type="radio" name="perm1" checked="checked" value="0" id="readPerm1"> {{msg $ "readOnly"}}</label>
|
||||
<label for="writePerm1"><input type="radio" name="perm1" value="1" id="writePerm1"> {{msg $ "writable"}}</label>
|
||||
<label for="readPerm1"><input type="radio" name="perm1" checked="checked" value="0" id="readPerm1"> {{msg . "readOnly"}}</label>
|
||||
<label for="writePerm1"><input type="radio" name="perm1" value="1" id="writePerm1"> {{msg . "writable"}}</label>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-success" onclick="addShareNoteOrNotebook(1)">{{msg . "share"}}</button>
|
||||
<button class="btn btn-success" data-loading-text="..." onclick="addShareNoteOrNotebook(1)">{{msg . "share"}}</button>
|
||||
<button class="btn btn-warning" onclick="deleteShareNoteOrNotebook(1)">{{msg . "delete"}}</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -46,12 +53,50 @@
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" noteOrNotebookId="{{$noteOrNotebookId}}" toUserId="{{$toUserId}}" class="btn btn-warning delete-share">{{msg . "delete"}}</a>
|
||||
<a href="#" noteOrNotebookId="{{$noteOrNotebookId}}" toUserId="{{$toUserId}}" class="btn btn-warning delete-share">{{msg $ "delete"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="groupInfo">
|
||||
<p>
|
||||
将笔记/笔记本分享给项目组后, 该组下的用户便拥有了该笔记/笔记本. <a href="/member/group/index" target="_blank">项目组/成员管理</a>
|
||||
</p>
|
||||
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>分组名</th>
|
||||
<th>{{msg . "permission"}}</th>
|
||||
<th width="150px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $i, $share := .noteOrNotebookShareGroupInfos}}
|
||||
{{$groupId := $share.ToGroup.GroupId.Hex}}
|
||||
<tr data-id="{{$groupId}}" data-uid="{{$share.UserId.Hex}}">
|
||||
<td>
|
||||
{{$share.ToGroup.Title}}
|
||||
</td>
|
||||
<td>
|
||||
<label><input type="radio" name="perm_{{$groupId}}" {{if not $share.Perm}}checked="checked"{{end}} value="0" class="group-perm"> {{msg $ "readOnly"}}</label>
|
||||
<label><input type="radio" name="perm_{{$groupId}}" {{if $share.Perm}}checked="checked"{{end}} value="1" class="group-perm"> {{msg $ "writable"}}</label>
|
||||
</td>
|
||||
<td> <!-- 有userId 证明已分享 -->
|
||||
{{if $share.UserId}}
|
||||
<button class="btn btn-success btn-share-or-not">已分享</button>
|
||||
{{else}}
|
||||
<button class="btn btn-default btn-share-or-not">未分享</button>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
@@ -64,8 +109,75 @@
|
||||
Share.dialogIsNote = {{.isNote}};
|
||||
Share.dialogNoteOrNotebookId = '{{.noteOrNotebookId}}';
|
||||
$(function() {
|
||||
setTimeout(function() {
|
||||
$("#tr1 #friendsEmail").focus();
|
||||
}, 500);
|
||||
setTimeout(function() {
|
||||
$("#tr1 #friendsEmail").focus();
|
||||
}, 500);
|
||||
|
||||
// 分享/删除给分组
|
||||
$("#groupInfo").on("click", ".btn-share-or-not", function() {
|
||||
var $t = $(this);
|
||||
var $ptd = $t.closest("td");
|
||||
var $ptr = $t.closest("tr");
|
||||
var hasShared = $ptr.data('uid');
|
||||
var groupId = $ptr.data('id');
|
||||
var data = {groupId: groupId};
|
||||
var url = "";
|
||||
if(!hasShared) {
|
||||
var perm = $ptr.find("input:checked").val();
|
||||
data.perm = perm;
|
||||
if(Share.dialogIsNote) {
|
||||
data.noteId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/addShareNoteGroup";
|
||||
} else {
|
||||
data.notebookId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/addShareNotebookGroup";
|
||||
}
|
||||
} else {
|
||||
if(Share.dialogIsNote) {
|
||||
data.noteId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/deleteShareNoteGroup";
|
||||
} else {
|
||||
data.notebookId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/deleteShareNotebookGroup";
|
||||
}
|
||||
}
|
||||
ajaxPost(url, data, function(re) {
|
||||
if(reIsOk(re)) {
|
||||
if(!hasShared) {
|
||||
var text = '<button class="btn btn-success btn-share-or-not">已分享</button>';
|
||||
$ptr.data('uid', 'xxxxxx');
|
||||
} else {
|
||||
var text = '<button class="btn btn-default btn-share-or-not">未分享</button>';
|
||||
$ptr.data('uid', '');
|
||||
}
|
||||
$ptd.html(text);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".group-perm").click(function() {
|
||||
var $t = $(this);
|
||||
var $ptr = $t.closest("tr");
|
||||
var hasShared = $ptr.data('uid');
|
||||
if(!hasShared) {
|
||||
return;
|
||||
}
|
||||
var groupId = $ptr.data('id');
|
||||
var data = {groupId: groupId, perm: $t.val()};
|
||||
var url = ""
|
||||
if(Share.dialogIsNote) {
|
||||
data.noteId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/updateShareNoteGroupPerm";
|
||||
} else {
|
||||
data.notebookId = Share.dialogNoteOrNotebookId;
|
||||
url = "/share/updateShareNotebookGroupPerm";
|
||||
}
|
||||
ajaxPost(url, data, function(re) {
|
||||
if(!reIsOk(re)) {
|
||||
alert(re.Msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -23,6 +23,7 @@ GET /findPassword Auth.FindPassword
|
||||
POST /doFindPassword Auth.DoFindPassword
|
||||
POST /findPasswordUpdate Auth.FindPasswordUpdate
|
||||
|
||||
|
||||
# blog
|
||||
|
||||
GET /blog/getLikesAndComments Blog.GetLikesAndComments
|
||||
@@ -45,19 +46,25 @@ GET /blog/tag/:tag Blog.Tag
|
||||
GET /blog/search/:userIdOrEmail Blog.Search
|
||||
GET /blog/search Blog.Search
|
||||
|
||||
GET /blog/archive/:userIdOrEmail Blog.Archive
|
||||
GET /blog/archive Blog.Archive
|
||||
GET /blog/archives/:userIdOrEmail Blog.Archives
|
||||
GET /blog/archives Blog.Archives
|
||||
|
||||
GET /blog/post/:noteId Blog.Post
|
||||
GET /blog/post/:userIdOrEmail/:noteId Blog.Post
|
||||
GET /blog/view/:noteId Blog.Post
|
||||
|
||||
GET /blog/single/:userIdOrEmail/:singleId Blog.Single
|
||||
GET /blog/single/:singleId Blog.Single
|
||||
|
||||
GET /blog/cate/:notebookId Blog.Cate
|
||||
GET /blog/cate/:userIdOrEmail/:notebookId Blog.Cate
|
||||
|
||||
GET /blog/listCateLatest/:notebookId Blog.ListCateLatest
|
||||
GET /blog/:userIdOrEmail Blog.Index
|
||||
GET /blog Blog.Index
|
||||
GET /blog/* Blog.E()
|
||||
|
||||
|
||||
#---------------
|
||||
# preview
|
||||
GET /preview/tags/:userIdOrEmail Preview.Tags
|
||||
@@ -69,14 +76,20 @@ GET /preview/tag/:tag Preview.Tag
|
||||
GET /preview/search/:userIdOrEmail Preview.Search
|
||||
GET /preview/search Preview.Search
|
||||
|
||||
GET /preview/archive/:userIdOrEmail Preview.Archive
|
||||
GET /preview/archive Preview.Archive
|
||||
GET /preview/archives/:userIdOrEmail Preview.Archives
|
||||
GET /preview/archives Preview.Archives
|
||||
|
||||
GET /preview/view/:noteId Preview.Post
|
||||
|
||||
GET /preview/post/:noteId Preview.Post
|
||||
GET /preview/post/userIdOrEmail/:noteId Preview.Post
|
||||
|
||||
GET /preview/single/userIdOrEmail/:singleId Preview.Single
|
||||
GET /preview/single/:singleId Preview.Single
|
||||
|
||||
GET /preview/cate/:notebookId Preview.Cate
|
||||
GET /preview/cate/userIdOrEmail/:notebookId Preview.Cate
|
||||
|
||||
GET /preview/:userIdOrEmail Preview.Index
|
||||
GET /preview Preview.Index
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ hasAcount = Do not have an account?
|
||||
|
||||
# 注册
|
||||
registerSuccessAndRdirectToNote=Register success, redirecting...
|
||||
userHasBeenRegistered=%s has been registered
|
||||
|
||||
# 找回密码
|
||||
passwordTips=The length is at least 6
|
||||
|
||||
@@ -79,6 +79,7 @@ hasAcount = 还无帐户?
|
||||
|
||||
# 注册
|
||||
registerSuccessAndRdirectToNote=注册成功, 正在跳转...
|
||||
userHasBeenRegistered=%s已被注册
|
||||
|
||||
# 找回密码
|
||||
passwordTips=密码至少6位
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.attachs", "name" : "_id_" } ] }
|
||||
Binary file not shown.
Binary file not shown.
BIN
mongodb_backup/leanote_install_data/blog_singles.bson
Normal file
BIN
mongodb_backup/leanote_install_data/blog_singles.bson
Normal file
Binary file not shown.
@@ -1 +1 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.blog_likes", "name" : "_id_" } ] }
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote_beta2.blog_singles", "name" : "_id_" } ] }
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.email_logs", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.files", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.find_pwds", "name" : "_id_" } ] }
|
||||
BIN
mongodb_backup/leanote_install_data/group_users.bson
Normal file
BIN
mongodb_backup/leanote_install_data/group_users.bson
Normal file
Binary file not shown.
@@ -1 +1 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.blog_comments", "name" : "_id_" } ] }
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote_beta2.group_users", "name" : "_id_" } ] }
|
||||
BIN
mongodb_backup/leanote_install_data/groups.bson
Normal file
BIN
mongodb_backup/leanote_install_data/groups.bson
Normal file
Binary file not shown.
@@ -1 +1 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.configs", "name" : "_id_" } ] }
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote_beta2.groups", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.has_share_notes", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1, "ToUserId" : 1 }, "unique" : true, "ns" : "leanote.has_share_notes", "name" : "UserId_1_ToUserId_1" } ] }
|
||||
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.leanote.ShareNotes", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1, "ToUserId" : 1, "NoteId" : 1 }, "unique" : true, "ns" : "leanote.leanote.ShareNotes", "name" : "UserId_1_ToUserId_1_NoteId_1" } ] }
|
||||
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.leanote.has_share_notes", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1, "ToUserId" : 1 }, "unique" : true, "ns" : "leanote.leanote.has_share_notes", "name" : "UserId_1_ToUserId_1" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.note_content_histories", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.note_contents", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.note_images", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.notebooks", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1 }, "ns" : "leanote.notebooks", "name" : "UserId_1" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.notes", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1 }, "ns" : "leanote.notes", "name" : "UserId_1" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.reports", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.sessions", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.share_notebooks", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.share_notes", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1, "ToUserId" : 1, "NoteId" : 1 }, "unique" : true, "ns" : "leanote.share_notes", "name" : "UserId_1_ToUserId_1_NoteId_1" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.suggestions", "name" : "_id_" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.system.users", "name" : "_id_" }, { "v" : 1, "key" : { "user" : 1, "userSource" : 1 }, "unique" : true, "ns" : "leanote.system.users", "name" : "user_1_userSource_1" } ] }
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.tags", "name" : "_id_" }, { "v" : 1, "key" : { "UserId" : 1 }, "ns" : "leanote.tags", "name" : "UserId_1" } ] }
|
||||
BIN
mongodb_backup/leanote_install_data/themes.bson
Normal file
BIN
mongodb_backup/leanote_install_data/themes.bson
Normal file
Binary file not shown.
@@ -1 +1 @@
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote.albums", "name" : "_id_" } ] }
|
||||
{ "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "leanote_beta2.themes", "name" : "_id_" } ] }
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user