• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang wikit.SelectWiki函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/rhinoman/wikifeat/wikis/wiki_service/wikit.SelectWiki函数的典型用法代码示例。如果您正苦于以下问题:Golang SelectWiki函数的具体用法?Golang SelectWiki怎么用?Golang SelectWiki使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了SelectWiki函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Delete

//Delete a page.  Returns the revision, if successful
func (pm *PageManager) Delete(wiki string, pageId string,
	pageRev string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	//Load the page
	thePage := wikit.Page{}
	if _, err := theWiki.ReadPage(pageId, &thePage); err != nil {
		return "", err
	} else if thePage.OwningPage != pageId {
		//Thou shalt not delete historical revisions
		return "", BadRequestError()
	}
	//check if this is a 'home page'
	wm := WikiManager{}
	wr := WikiRecord{}
	if wRev, err := wm.Read(wiki, &wr, curUser); err != nil {
		return "", err
	} else if wr.HomePageId == pageId {
		//This is a home page, so clear the Wiki Record's home page Id
		wr.HomePageId = ""
		_, err = wm.Update(wiki, wRev, &wr, curUser)
		if err != nil {
			return "", err
		}
	}
	return theWiki.DeletePage(pageId, pageRev)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:28,代码来源:pages_manager.go


示例2: SaveFileRecord

//Saves a File Record (not the attachment)
func (fm *FileManager) SaveFileRecord(wiki string, file *wikit.File,
	id string, rev string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	uploadedBy := curUser.User.UserName
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.SaveFileRecord(file, id, rev, uploadedBy)
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:8,代码来源:file_manager.go


示例3: GetComments

//Gets a list of all comments for a page
func (pm *PageManager) GetComments(wiki string, pageId string,
	pageNum int, numPerPage int,
	curUser *CurrentUserInfo) (*wikit.CommentIndexViewResponse, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.GetCommentsForPage(pageId, pageNum, numPerPage)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:8,代码来源:pages_manager.go


示例4: DeleteFile

//Deletes a File Record
func (fm *FileManager) DeleteFile(wiki string,
	id string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	theFile := wikit.File{}
	if rev, err := theWiki.GetFileRecord(id, &theFile); err != nil {
		return "", err
	} else {
		return theWiki.DeleteFileRecord(id, rev)
	}
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:12,代码来源:file_manager.go


示例5: Save

//Creates or Updates a page
//Returns the revision number, if successful
func (pm *PageManager) Save(wiki string, page *wikit.Page,
	pageId string, pageRev string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theUser := curUser.User
	//Read the content from the page
	//parse the markdown to Html
	out := make(chan string)
	//Convert (Sanitized) Markdown to HTML
	go processMarkdown(page.Content.Raw, out)
	page.Content.Formatted = <-out
	//Store the thing, if you have the auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.SavePage(page, pageId, pageRev, theUser.UserName)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:16,代码来源:pages_manager.go


示例6: DeleteComment

//Delete a comment.  Returns the revision if successful
func (pm *PageManager) DeleteComment(wiki string, commentId string,
	curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	if pm.allowedToUpdateComment(wiki, commentId, curUser) {
		comment := wikit.Comment{}
		commentRev, err := pm.ReadComment(wiki, commentId, &comment, curUser)
		if err != nil {
			return "", err
		}
		return theWiki.DeleteComment(commentId, commentRev)
	} else {
		return "", errors.New("[Error]:403: Not Authorized")
	}
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:16,代码来源:pages_manager.go


示例7: SaveComment

//Creates or updates a comment
func (pm *PageManager) SaveComment(wiki string, pageId string, comment *wikit.Comment,
	commentId string, commentRev string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theUser := curUser.User
	//First, if this is an update, check if this user can update the comment
	if commentRev != "" {
		if cu := pm.allowedToUpdateComment(wiki, commentId, curUser); cu == false {
			return "", errors.New("[Error]:403: Not Authorized")
		}
	}
	//Read the content from the comment
	//parse the markdown to Html
	out := make(chan string)
	//Convert (Sanitized) Markdown to HTML
	go processMarkdown(comment.Content.Raw, out)
	comment.Content.Formatted = <-out
	//Store it
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.SaveComment(comment, commentId, commentRev, pageId, theUser.UserName)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:21,代码来源:pages_manager.go


示例8: GetBreadcrumbs

//Gets a list of breadcrumbs for the current page
func (pm *PageManager) GetBreadcrumbs(wiki string, pageId string,
	curUser *CurrentUserInfo) ([]Breadcrumb, error) {
	thePage := wikit.Page{}
	if _, err := pm.Read(wiki, pageId, &thePage, curUser); err == nil {
		crumbs := []Breadcrumb{}
		response := wikit.MultiPageResponse{}
		theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), curUser.Auth)
		if szLineage := len(thePage.Lineage); szLineage > 1 {
			lineage := thePage.Lineage[0 : szLineage-1]
			if err = theWiki.ReadMultiplePages(lineage, &response); err != nil {
				return nil, err
			}
		}
		//Add the current page to the end of the list
		currentPageRow := wikit.MultiPageRow{
			Id:  pageId,
			Doc: thePage,
		}
		rows := append(response.Rows, currentPageRow)
		for _, row := range rows {
			theDoc := row.Doc
			parent := ""
			if len(theDoc.Lineage) >= 2 {
				parent = theDoc.Lineage[len(theDoc.Lineage)-2]
			}
			crumb := Breadcrumb{
				Name:   theDoc.Title,
				PageId: row.Id,
				WikiId: wiki,
				Parent: parent,
			}
			crumbs = append(crumbs, crumb)
		}
		return crumbs, nil
	} else {
		return nil, err
	}

}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:40,代码来源:pages_manager.go


示例9: ReadBySlug

// Read a page by its slug.
// Assume the wiki Id passed in is a slug also
// Returns the WikiId, the Page Rev, and an error
func (pm *PageManager) ReadBySlug(wikiSlug string, pageSlug string,
	page *wikit.Page, curUser *CurrentUserInfo) (string, string, error) {
	// Need to get the true wiki Id from the slug
	auth := curUser.Auth
	mainDbName := MainDbName()
	mainDb := Connection.SelectDB(mainDbName, auth)
	response := WikiSlugViewResponse{}
	err := mainDb.GetView("wiki_query",
		"getWikiBySlug",
		&response,
		wikit.SetKey(wikiSlug))
	if err != nil {
		return "", "", err
	}
	if len(response.Rows) > 0 {
		wikiId := response.Rows[0].Id
		theWiki := wikit.SelectWiki(Connection, wikiDbString(wikiId), auth)
		pageRev, err := theWiki.ReadPageBySlug(pageSlug, page)
		return wikiId, pageRev, err
	} else {
		return "", "", NotFoundError()
	}
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:26,代码来源:pages_manager.go


示例10: allowedToUpdateComment

func (pm *PageManager) allowedToUpdateComment(wiki string, commentId string,
	curUser *CurrentUserInfo) bool {
	userName := curUser.User.UserName
	userRoles := curUser.User.Roles
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	//First, we need to read the comment record
	comment := wikit.Comment{}
	_, err := theWiki.ReadComment(commentId, &comment)
	if err != nil {
		return false
	}
	//Only admins and the original comment author may update/delete
	isAdmin := util.HasRole(userRoles, AdminRole(wiki)) ||
		util.HasRole(userRoles, AdminRole(MainDbName())) ||
		util.HasRole(userRoles, MasterRole())
	if comment.Author == userName || isAdmin {
		return true
	} else {
		return false
	}

}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:23,代码来源:pages_manager.go


示例11: GetFileAttachment

//Get file attachment
func (fm *FileManager) GetFileAttachment(wiki, id, rev,
	attType, attName string, curUser *CurrentUserInfo) (io.ReadCloser, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.GetFileAttachment(id, rev, attType, attName)
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:7,代码来源:file_manager.go


示例12: SaveFileAttachment

//Saves a File's Attachment
func (fm *FileManager) SaveFileAttachment(wiki, id, rev, attName, attType string,
	attContent io.Reader, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.SaveFileAttachment(id, rev, attName, attType, attContent)
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:7,代码来源:file_manager.go


示例13: ReadFileRecord

//Reads a File Record (but not the attachment)
func (fm *FileManager) ReadFileRecord(wiki string,
	file *wikit.File, id string, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.GetFileRecord(id, file)
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:7,代码来源:file_manager.go


示例14: Index

//Gets a list of all 'files' in a wiki
func (fm *FileManager) Index(wiki string, fileType string, pageNum int, numPerPage int,
	curUser *CurrentUserInfo) (*wikit.FileIndexViewResponse, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.GetFileIndex(fileType, pageNum, numPerPage)
}
开发者ID:shawnps,项目名称:wikifeat,代码行数:7,代码来源:file_manager.go


示例15: ChildIndex

//Gets a list of child pages for a given document
func (pm *PageManager) ChildIndex(wiki string, pageId string,
	curUser *CurrentUserInfo) (wikit.PageIndex, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.GetChildPageIndex(pageId)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:7,代码来源:pages_manager.go


示例16: Read

//Read a page
//Pass an empty page to hold the data. returns the revision
func (pm *PageManager) Read(wiki string, pageId string,
	page *wikit.Page, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.ReadPage(pageId, page)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:8,代码来源:pages_manager.go


示例17: ReadComment

//Read a comment
func (pm *PageManager) ReadComment(wiki string, commentId string,
	comment *wikit.Comment, curUser *CurrentUserInfo) (string, error) {
	auth := curUser.Auth
	theWiki := wikit.SelectWiki(Connection, wikiDbString(wiki), auth)
	return theWiki.ReadComment(commentId, comment)
}
开发者ID:rhinoman,项目名称:wikifeat,代码行数:7,代码来源:pages_manager.go



注:本文中的github.com/rhinoman/wikifeat/wikis/wiki_service/wikit.SelectWiki函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang accounts.User类代码示例发布时间:2022-05-28
下一篇:
Golang context.Background函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap