content_model

package
v0.0.0-...-076d96f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2012 License: BSD-2-Clause-Views Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Tag_fieldname           = "_tags" // goes to database
	Tag_fieldname_displayed = "tags"  // comes from user interface, it is in the rules
	Tag_cname               = "tags"
	Count_fieldname         = "count"
)
View Source
const (
	Draft_collection_postfix = "_draft"
	Parent_content_field     = "draft_of"
	Parent_draft_field       = "draft_id"
)
View Source
const (
	Cname = "contents"
)

Variables

This section is empty.

Functions

func AllowsDraft

func AllowsDraft(content_type_options map[string]interface{}, user_level int, typ string) error

content_type_options: Modules.content.types.[type]

func BuildDraft

func BuildDraft(db *mgo.Database, draft_typ, draft_id_str string) (map[string]interface{}, error)

Queries a draft and rebuilds it. Queries its parent too, and merges it with the input fields saved in "data". The returned draft will be like a simple draft in the database, but in the data field it will contain fields of the parent plus the fresher saved input data. draft_typ example: blog_draft Only

func CanModifyComment

func CanModifyComment(db *mgo.Database, inp map[string][]string, correction_level int, user_id bson.ObjectId, user_level int) error

Only called when doing update or delete. At inserting, user.OkayToDoAction is sufficient. This needs additional action: you can only update or delete a given comment only if it's yours (under a certain level).

func CanModifyContent

func CanModifyContent(db *mgo.Database, inp map[string][]string, correction_level int, user_id bson.ObjectId, user_level int) error

Returns true if one is entitled to modify the given content.

func ChangeHead

func ChangeHead(db *mgo.Database, ev ifaces.Event, inp map[string][]string, non_versioned_fields []string) error

Implementation of versioning is in basic.InudVersion.

func ContentTimeline

func ContentTimeline(db *mgo.Database, content_doc map[string]interface{}) ([]interface{}, error)

*1. Temporary solution. With helper collections we could do the sorting with mongodb. Unfortunately, now versions and drafts reside in two separate collections.

func Delete

func Delete(db *mgo.Database, ev ifaces.Event, id []string, user_id bson.ObjectId) []error

func DeleteComment

func DeleteComment(db *mgo.Database, ev ifaces.Event, inp map[string][]string, user_id bson.ObjectId) error

Two mandatory fields must come from UI: "content_id" and "comment_id"

func DeleteTag

func DeleteTag(db *mgo.Database, tag_id string) error

Deletes a tag entirely.

func DraftTimeline

func DraftTimeline(db *mgo.Database, draft_id bson.ObjectId) ([]interface{}, error)

See *1

func FindContent

func FindContent(db *mgo.Database, keys []string, val string) (map[string]interface{}, bool)

Called from Front hook. Find slug value by given key.

func FindTag

func FindTag(db *mgo.Database, field string, value interface{}) (map[string]interface{}, error)

func FindVersion

func FindVersion(db *mgo.Database, id bson.ObjectId) (map[string]interface{}, error)

Find version by id.

func GenerateKeywords

func GenerateKeywords(s string) []string

func GenerateQuery

func GenerateQuery(s string) []interface{}

Generates [{"fulltext": \^keyword1\}, {"fulltext": \^keyword2\}] With this query we can create a good enough full text search, which can search at the beginning of the keywords. We could write regexes which searches in the middle of the words too, but that query could not uzilize the btree indexes of mongodb. This solution must be efficient, assuming mongodb does the expected sane things: utilizing indexes with ^ regexes, "$and" queries and arrays.

func GetFamily

func GetFamily(db *mgo.Database, root bson.ObjectId) ([]interface{}, error)

func GetParent

func GetParent(db *mgo.Database, coll string, draft map[string]interface{}) (map[string]interface{}, error)

Takes a draft and gets.

func GetUpToDateDraft

func GetUpToDateDraft(db *mgo.Database, content_id bson.ObjectId, content map[string]interface{}) map[string]interface{}

Takes a content id and gives back the up to date draft of it if it has one. Gives back nil if it does not have one.

func HaveUpToDateDrafts

func HaveUpToDateDrafts(db *mgo.Database, content_list []interface{}) error

Takes a content list and connects an up to date draft to each content if it exists. A draft is up to date if it is newer than the last saved comment, and newer than any other draft.

func Insert

func Insert(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, dat map[string][]string, user_id bson.ObjectId) (bson.ObjectId, error)

func InsertComment

func InsertComment(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, inp map[string][]string, user_id bson.ObjectId, typ string, moderate_first bool) error

Apart from rule, there is one mandatory field which must come from the UI: "content_id" moderate_first should be read as "moderate first if it is a valid, spam protection passed comment" Spam protection happens outside of this anyway.

func InsertWithFix

func InsertWithFix(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, dat map[string][]string, user_id bson.ObjectId, fixvals map[string]interface{}) (bson.ObjectId, error)

func Install

func Install(db *mgo.Database, id bson.ObjectId) error

func IsDraftUpToDate

func IsDraftUpToDate(db *mgo.Database, draft, parent map[string]interface{}) (bool, error)

Takes a draft, and a parent content and decides if the draft is up to date or not.

func MoveToFinal

func MoveToFinal(db *mgo.Database, comment_id bson.ObjectId) error

Moves a comment to its final destination (into the valid comments) from moderation queue.

func MoveToFinalWE

func MoveToFinalWE(db *mgo.Database, inp map[string][]string) error

MoveToFinal with extract.

func MoveToModeration

func MoveToModeration(db *mgo.Database, content_id, comment_id bson.ObjectId) error

Maybe we should just delete the comment in this case? Think about it and implement it later.

func PullTagFromAll

func PullTagFromAll(db *mgo.Database, tag_id string) error

func PullTags

func PullTags(db *mgo.Database, content_id string, tag_ids []string) error

Removes tag(s) from a given content, so the content will no longer belong to that category(s) (tag(s)). Pulls one or more tag ids from a content and decrements the tag counters.

func RegenerateFulltext

func RegenerateFulltext(db *mgo.Database) error

Mostly for in-development use. Iterates trough all contents in the contents collection and regenerates their fulltext field.

func SaveDraft

func SaveDraft(db *mgo.Database, content_rules map[string]interface{}, inp map[string][]string) (bson.ObjectId, error)

We never update drafts, we always insert a new one. A draft will have the next fields: id, type, created, up_to_date, parent_content/draft_content/none/both, data. The saved input resides in the data.

func SavePersonalTypeConfig

func SavePersonalTypeConfig(db *mgo.Database, inp map[string][]string, user_id bson.ObjectId) error

func SaveTypeConfig

func SaveTypeConfig(db *mgo.Database, inp map[string][]string) error

func TagSearchQuery

func TagSearchQuery(fieldname, val string) map[string]interface{}

func TypeOf

func TypeOf(db *mgo.Database, content_id bson.ObjectId) (string, error)

Returns the type of a given content.

func Uninstall

func Uninstall(db *mgo.Database, id bson.ObjectId) error

func Update

func Update(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, dat map[string][]string, user_id bson.ObjectId) error

func UpdateComment

func UpdateComment(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, inp map[string][]string, user_id bson.ObjectId) error

Apart from rule, there are two mandatory field which must come from the UI: "content_id" and "comment_id"

func UpdateWithFix

func UpdateWithFix(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, dat map[string][]string, user_id bson.ObjectId, fixvals map[string]interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL