// NewPostBookmark handles the request and creates a new bookmark for the post
6444
func NewPostBookmark() echo.HandlerFunc {

	// swagger:route POST /users/{id}/posts/{pid}/bookmarks users post vote NewUserPostBookmark
	//
	// Adds a new bookmark on the current post
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:write
	//
	//	Responses:
	//		default: UsersIdPostsPidBookmarks

	return func(c echo.Context) error {
		if !rest.IsGranted("profile_messages:write", c) {
			return rest.InvalidScopeResponse("profile_messages:write", c)
		}

		// Send it
		me := c.Get("me").(*nerdz.User)
		post := c.Get("post").(*nerdz.UserPost)
		bookmark, err := me.Bookmark(post)
		if err != nil {
			errstr := err.Error()
			c.JSON(http.StatusBadRequest, &rest.Response{
				Data:         nil,
				HumanMessage: errstr,
				Message:      errstr,
				Status:       http.StatusBadRequest,
				Success:      false,
			})
			return errors.New(errstr)
		}
		// Extract the TO from the new post and return
		// selected fields.
		return rest.SelectFields(bookmark.(*nerdz.UserPostBookmark).GetTO(me), c)
	}
}
274277
func NewPoint(name string, tags Tags, fields Fields, t time.Time) (Point, error) {
	key, err := pointKey(name, tags, fields, t)
	if err != nil {
		return nil, err
	}

	return &point{
		key:    key,
		time:   t,
		fields: fields.MarshalBinary(),
	}, nil
}
739591
func New(apiDef *raml.APIDefinition, r *raml.Resource, endpoint string, sortMethod bool) Resource {
	name := func() string {
		if r.DisplayName == "" {
			return commons.NormalizeIdentifier(strings.Title(commons.NormalizeURI(endpoint)))
		}
		return strings.Title(commons.DisplayNameToFuncName(r.DisplayName))
	}()

	res := Resource{
		Endpoint: endpoint,
		APIDef:   apiDef,
		Name:     name,
		Resource: r,
	}

	res.generateMethods(r)
	if sortMethod {
		sort.Sort(byEndpoint(res.Methods))
	}
	return res
}
1214045
func NewEntryPoint(ctx context.Context, t *tracing.Tracing, entryPointName string, next http.Handler) http.Handler {
	middlewares.GetLogger(ctx, "tracing", entryPointTypeName).Debug("Creating middleware")

	return &entryPointMiddleware{
		entryPoint: entryPointName,
		Tracing:    t,
		next:       next,
	}
}
124355
func PostLurks() echo.HandlerFunc {

	// swagger:route GET /me/posts/{pid}/lurks me post bookmarks GetMePostLurks
	//
	// List the lurks of the post
	//
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:read
	//
	//	Responses:
	//		default: MePostsPidLurks

	return func(c echo.Context) error {
		return user.PostLurks()(c)
	}
}
1369412
func NewFileBookmarks(file string) (*FileBookmarks, error) {
	var bookmarks BookmarksMap = nil
	if !util.FileExists(file) {
		bookmarks = make(BookmarksMap, initialBookmarksCapacity)
	} else {
		fin, err := ioutil.ReadFile(file)
		if err != nil {
			return nil, err
		}
		err = json.Unmarshal(fin, &bookmarks)
		if err != nil {
			return nil, err
		}
	}

	return &FileBookmarks{
		bookmarks: bookmarks,
		file:      file,
	}, nil
}
540183
func NewPaperDocRequestAccessType(Description string) *PaperDocRequestAccessType {
	s := new(PaperDocRequestAccessType)
	s.Description = Description
	return s
}
242879
func NewPostLock() echo.HandlerFunc {

	// swagger:route POST /me/posts/{pid}/locks me post vote NewMePostLock
	//
	// Adds a new lock on the current post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:write
	//
	//	Responses:
	//		default: MePostsPidLocks

	return func(c echo.Context) error {
		return user.NewPostLock()(c)
	}
}
245534
func NewPostRef(client ClientInterface, post *MiniPost) *PostRef {
	return &PostRef{
		client:   client,
		MiniPost: *post,
	}
}
6582
func (post *UserPost) Bookmarks() *[]Bookmark {
	ret := []UserPostBookmark{}
	Db().Model(UserPostBookmark{}).Where(&UserPostBookmark{Hpid: post.ID()}).Scan(&ret)
	var retBookmarks []Bookmark
	for _, b := range ret {
		bookmark := b
		retBookmarks = append(retBookmarks, Bookmark(&bookmark))
	}

	return &retBookmarks
}
469882
func NewPoint(init ...*Point) *Point {
	var o *Point
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(Point)
	}
	return o
}
461310
func (g *Generator) ClearPostStartHooks() {
	if g.Config == nil || g.Config.Hooks == nil {
		return
	}
	g.Config.Hooks.Poststart = []rspec.Hook{}
}
1100683
func (bookmark *ProjectPostBookmark) Reference() Reference {
	post, _ := NewProjectPost(bookmark.Hpid)
	return post
}
1367432
func NewProjectPost(hpid uint64) (*ProjectPost, error) {
	return NewProjectPostWhere(&ProjectPost{Post{Hpid: hpid}})
}
93896
func NewPoint(tags core.TagSlice) (*Point, error) {
	point := new(Point)

	// set defaults
	point.ExtrusionDirection = core.Point{X: 0.0, Y: 0.0, Z: 1.0}

	point.InitBaseEntityParser()
	point.Update(map[int]core.TypeParser{

		10:  core.NewFloatTypeParserToVar(&point.Location.X),
		20:  core.NewFloatTypeParserToVar(&point.Location.Y),
		30:  core.NewFloatTypeParserToVar(&point.Location.Z),
		39:  core.NewFloatTypeParserToVar(&point.Thickness),
		50:  core.NewFloatTypeParserToVar(&point.XAxisAngle),
		210: core.NewFloatTypeParserToVar(&point.ExtrusionDirection.X),
		220: core.NewFloatTypeParserToVar(&point.ExtrusionDirection.Y),
		230: core.NewFloatTypeParserToVar(&point.ExtrusionDirection.Z),
	})

	err := point.Parse(tags)
	return point, err
}
636660
func (g *Generator) AddPostStopHook(postStopHook rspec.Hook) error {
	g.initConfigHooks()
	g.Config.Hooks.Poststop = append(g.Config.Hooks.Poststop, postStopHook)
	return nil
}
1206344
func (itr *resultsItr) GetBookmarkAndClose() string {
	returnBookmark := ""
	if queryResultIterator, ok := itr.dbItr.(statedb.QueryResultsIterator); ok {
		returnBookmark = queryResultIterator.GetBookmarkAndClose()
	}
	return returnBookmark
}