當前位置: 首頁>>代碼示例>>Golang>>正文


Golang info.NewRe函數代碼示例

本文整理匯總了Golang中github.com/leanote/leanote/app/info.NewRe函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewRe函數的具體用法?Golang NewRe怎麽用?Golang NewRe使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewRe函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LikeComment

// jsonp
func (c Blog) LikeComment(commentId string, callback string) revel.Result {
	re := info.NewRe()
	ok, isILikeIt, num := blogService.LikeComment(commentId, c.GetUserId())
	re.Ok = ok
	re.Item = bson.M{"IsILikeIt": isILikeIt, "Num": num}
	return c.RenderJsonP(callback, re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:8,代碼來源:BlogController.go

示例2: DoRegister

func (c Auth) DoRegister(email, pwd, iu string) revel.Result {
	if !configService.IsOpenRegister() {
		return c.Redirect("/index")
	}

	re := info.NewRe()

	if re.Ok, re.Msg = Vd("email", email); !re.Ok {
		return c.RenderRe(re)
	}
	if re.Ok, re.Msg = Vd("password", pwd); !re.Ok {
		return c.RenderRe(re)
	}

	email = strings.ToLower(email)

	// 注冊
	re.Ok, re.Msg = authService.Register(email, pwd, iu)

	// 注冊成功, 則立即登錄之
	if re.Ok {
		c.doLogin(email, pwd)
	}

	return c.RenderRe(re)
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:26,代碼來源:AuthController.go

示例3: ListCateLatest

// 顯示分類的最近博客, jsonp
func (c Blog) ListCateLatest(notebookId, callback string) revel.Result {
	if notebookId == "" {
		return c.e404("")
	}
	// 自定義域名
	hasDomain, userBlog := c.domain()
	userId := ""
	if hasDomain {
		userId = userBlog.UserId.Hex()
	}

	var notebook info.Notebook
	notebook = notebookService.GetNotebookById(notebookId)
	if !notebook.IsBlog {
		return c.e404(userBlog.ThemePath)
	}
	if userId != "" && userId != notebook.UserId.Hex() {
		return c.e404(userBlog.ThemePath)
	}
	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 := 1
	_, blogs := blogService.ListBlogs(userId, notebookId, page, 5, userBlog.SortField, userBlog.IsAsc)
	re := info.NewRe()
	re.Ok = true
	re.List = blogs
	return c.RenderJsonP(callback, re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:35,代碼來源:BlogController.go

示例4: CopyHttpImage

// 複製外網的圖片, 成公共圖片 放在/upload下
// 都要好好的計算大小
func (c File) CopyHttpImage(src string) revel.Result {
	re := info.NewRe()
	fileUrlPath := "upload/" + c.GetUserId() + "/images"
	dir := revel.BasePath + "/public/" + fileUrlPath
	err := os.MkdirAll(dir, 0755)
	if err != nil {
		return c.RenderJson(re)
	}
	filesize, filename, _, ok := netutil.WriteUrl(src, dir)

	if !ok {
		re.Msg = "copy error"
		return c.RenderJson(re)
	}

	// File
	fileInfo := info.File{Name: filename,
		Title: filename,
		Path:  fileUrlPath + "/" + filename,
		Size:  filesize}

	id := bson.NewObjectId()
	fileInfo.FileId = id

	re.Id = id.Hex()
	re.Item = fileInfo.Path
	re.Ok, re.Msg = fileService.AddImage(fileInfo, "", c.GetUserId(), true)

	return c.RenderJson(re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:32,代碼來源:FileController.go

示例5: AddAccount

//------------
// 第三方賬號添加leanote賬號
func (c User) AddAccount(email, pwd string) revel.Result {
	re := info.NewRe()

	if email == "" {
		re.Msg = "請輸入郵箱"
		return c.RenderJson(re)
	} else if !IsEmail(email) {
		re.Msg = "請輸入正確的郵箱"
		return c.RenderJson(re)
	}

	// 密碼
	if pwd == "" {
		re.Msg = "請輸入密碼"
		return c.RenderJson(re)
	} else if len(pwd) < 6 {
		re.Msg = "密碼長度至少6位"
		return c.RenderJson(re)
	}

	re.Ok, re.Msg = userService.ThirdAddUser(c.GetUserId(), email, pwd)

	if re.Ok {
		c.UpdateSession("Email", email)
	}

	return c.RenderJson(re)
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:30,代碼來源:UserController.go

示例6: Html2Image

//-----------------
// html2image
func (c Note) Html2Image(noteId string) revel.Result {
	re := info.NewRe()
	userId := c.GetUserId()
	note := noteService.GetNote(noteId, userId)
	if note.NoteId == "" {
		return c.RenderJson(re)
	}
	content := noteService.GetNoteContent(noteId, userId)

	// path 判斷是否需要重新生成之
	fileUrlPath := "/upload/" + userId + "/images/weibo"
	dir := revel.BasePath + "/public/" + fileUrlPath
	if !ClearDir(dir) {
		return c.RenderJson(re)
	}

	filename := note.NoteId.Hex() + ".png"
	path := dir + "/" + filename

	// 生成之
	html2image.ToImage(userId, c.GetUsername(), noteId, note.Title, content.Content, path)

	re.Ok = true
	re.Id = fileUrlPath + "/" + filename
	return c.RenderJson(re)
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:28,代碼來源:NoteController.go

示例7: DoRegister

func (c Auth) DoRegister(email, pwd string) revel.Result {
	if !openRegister {
		return c.Redirect("/index")
	}

	re := info.NewRe()

	if email == "" {
		re.Msg = c.Message("inputEmail")
		return c.RenderJson(re)
	} else if !IsEmail(email) {
		re.Msg = c.Message("wrongEmail")
		return c.RenderJson(re)
	}

	// 密碼
	if pwd == "" {
		re.Msg = c.Message("inputPassword")
		return c.RenderJson(re)
	} else if len(pwd) < 6 {
		re.Msg = c.Message("wrongPassword")
		return c.RenderJson(re)
	}

	// 注冊
	re.Ok, re.Msg = authService.Register(email, pwd)

	// 注冊成功, 則立即登錄之
	if re.Ok {
		c.DoLogin(email, pwd)
	}

	return c.RenderJson(re)
}
開發者ID:bigxing,項目名稱:leanote,代碼行數:34,代碼來源:AuthController.go

示例8: Mongodb

func (c AdminSetting) Mongodb(mongodumpPath, mongorestorePath string) revel.Result {
	re := info.NewRe()
	re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "mongodumpPath", mongodumpPath)
	re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "mongorestorePath", mongorestorePath)

	return c.RenderJson(re)
}
開發者ID:ZypcGroup,項目名稱:leanote,代碼行數:7,代碼來源:AdminSettingController.go

示例9: SendToUsers

func (c AdminEmail) SendToUsers(userFilterEmail, userFilterWhiteList, userFilterBlackList, latestEmailSubject, latestEmailBody string, verified, saveAsOldEmail bool) revel.Result {
	re := info.NewRe()

	c.updateConfig([]string{"userFilterEmail", "userFilterWhiteList", "userFilterBlackList", "latestEmailSubject", "latestEmailBody"})

	if latestEmailSubject == "" || latestEmailBody == "" {
		re.Msg = "subject or body is blank"
		return c.RenderJson(re)
	}

	if saveAsOldEmail {
		oldEmails := configService.GetGlobalMapConfig("oldEmails")
		oldEmails[latestEmailSubject] = latestEmailBody
		configService.UpdateGlobalMapConfig(c.GetUserId(), "oldEmails", oldEmails)
	}

	users := userService.GetAllUserByFilter(userFilterEmail, userFilterWhiteList, userFilterBlackList, verified)

	if users == nil || len(users) == 0 {
		re.Ok = false
		re.Msg = "no users"
		return c.RenderJson(re)
	}

	re.Ok, re.Msg = emailService.SendEmailToUsers(users, latestEmailSubject, latestEmailBody)
	if !re.Ok {
		return c.RenderJson(re)
	}

	re.Ok = true
	re.Msg = "users:" + strconv.Itoa(len(users))

	return c.RenderJson(re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:34,代碼來源:AdminEmailController.go

示例10: AuthInterceptor

func AuthInterceptor(c *revel.Controller) revel.Result {
	// 全部變成首字大寫
	/*
		var controller = strings.Title(c.Name)
		var method = strings.Title(c.MethodName)
		// 是否需要驗證?
		if !needValidate(controller, method) {
			return nil
		}
	*/

	// 驗證是否已登錄
	// 必須是管理員
	if username, ok := c.Session["Username"]; ok && username == configService.GetAdminUsername() {
		return nil // 已登錄
	}

	// 沒有登錄, 判斷是否是ajax操作
	if c.Request.Header.Get("X-Requested-With") == "XMLHttpRequest" {
		re := info.NewRe()
		re.Msg = "NOTLOGIN"
		return c.RenderJson(re)
	}

	return c.Redirect("/login")
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:26,代碼來源:init.go

示例11: Template

func (c AdminEmail) Template() revel.Result {
	re := info.NewRe()

	keys := []string{"emailTemplateHeader", "emailTemplateFooter",
		"emailTemplateRegisterSubject",
		"emailTemplateRegister",
		"emailTemplateFindPasswordSubject",
		"emailTemplateFindPassword",
		"emailTemplateUpdateEmailSubject",
		"emailTemplateUpdateEmail",
		"emailTemplateInviteSubject",
		"emailTemplateInvite",
		"emailTemplateCommentSubject",
		"emailTemplateComment",
	}

	userId := c.GetUserId()
	for _, key := range keys {
		v := c.Params.Values.Get(key)
		if v != "" {
			ok, msg := emailService.ValidTpl(v)
			if !ok {
				re.Ok = false
				re.Msg = "Error key: " + key + "<br />" + msg
				return c.RenderJson(re)
			} else {
				configService.UpdateGlobalStringConfig(userId, key, v)
			}
		}
	}

	re.Ok = true
	return c.RenderJson(re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:34,代碼來源:AdminEmailController.go

示例12: SendToUsers2

// 發送Email
func (c AdminEmail) SendToUsers2(emails, latestEmailSubject, latestEmailBody string, verified, saveAsOldEmail bool) revel.Result {
	re := info.NewRe()

	c.updateConfig([]string{"sendEmails", "latestEmailSubject", "latestEmailBody"})

	if latestEmailSubject == "" || latestEmailBody == "" {
		re.Msg = "subject or body is blank"
		return c.RenderJson(re)
	}

	if saveAsOldEmail {
		oldEmails := configService.GetGlobalMapConfig("oldEmails")
		oldEmails[latestEmailSubject] = latestEmailBody
		configService.UpdateGlobalMapConfig(c.GetUserId(), "oldEmails", oldEmails)
	}

	emails = strings.Replace(emails, "\r", "", -1)
	emailsArr := strings.Split(emails, "\n")

	users := userService.ListUserInfosByEmails(emailsArr)
	LogJ(emailsArr)

	re.Ok, re.Msg = emailService.SendEmailToUsers(users, latestEmailSubject, latestEmailBody)

	return c.RenderJson(re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:27,代碼來源:AdminEmailController.go

示例13: GetPostStat

// 得到博客統計信息
func (c Blog) GetPostStat(noteId string) revel.Result {
	re := info.NewRe()
	re.Ok = true
	statInfo := blogService.GetBlogStat(noteId)
	re.Item = statInfo
	return c.RenderJson(re)
}
開發者ID:intZz,項目名稱:leanote,代碼行數:8,代碼來源:BlogController.go

示例14: GetTplContent

// 得到文件內容
func (c MemberBlog) GetTplContent(themeId string, filename string) revel.Result {
	re := info.NewRe()
	re.Ok = true
	re.Item = themeService.GetTplContent(c.GetUserId(), themeId, filename)

	return c.RenderJson(re)
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:8,代碼來源:MemberBlogController.go

示例15: CopyHttpImage

// 複製外網的圖片
// 都要好好的計算大小
func (c File) CopyHttpImage(src string) revel.Result {
	re := info.NewRe()

	// 生成上傳路徑
	newGuid := NewGuid()
	userId := c.GetUserId()
	// fileUrlPath := "files/" + Digest3(userId) + "/" + userId + "/" + Digest2(newGuid) + "/images"
	fileUrlPath := "files/" + GetRandomFilePath(userId, newGuid) + "/images"
	dir := revel.BasePath + "/" + fileUrlPath
	err := os.MkdirAll(dir, 0755)
	if err != nil {
		return c.RenderJson(re)
	}
	filesize, filename, _, ok := netutil.WriteUrl(src, dir)

	if !ok {
		re.Msg = "copy error"
		return c.RenderJson(re)
	}

	// File
	fileInfo := info.File{Name: filename,
		Title: filename,
		Path:  fileUrlPath + "/" + filename,
		Size:  filesize}

	id := bson.NewObjectId()
	fileInfo.FileId = id

	re.Id = id.Hex()
	//	re.Item = fileInfo.Path
	re.Ok, re.Msg = fileService.AddImage(fileInfo, "", c.GetUserId(), true)

	return c.RenderJson(re)
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:37,代碼來源:FileController.go


注:本文中的github.com/leanote/leanote/app/info.NewRe函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。