Documentation ¶
Index ¶
- Constants
- func AllowsDraft(content_type_options map[string]interface{}, user_level int, typ string) error
- func BuildDraft(db *mgo.Database, draft_typ, draft_id_str string) (map[string]interface{}, error)
- func CanModifyComment(db *mgo.Database, inp map[string][]string, correction_level int, ...) error
- func CanModifyContent(db *mgo.Database, inp map[string][]string, correction_level int, ...) error
- func ChangeHead(db *mgo.Database, ev ifaces.Event, inp map[string][]string, ...) error
- func ContentTimeline(db *mgo.Database, content_doc map[string]interface{}) ([]interface{}, error)
- func Delete(db *mgo.Database, ev ifaces.Event, id []string, user_id bson.ObjectId) []error
- func DeleteComment(db *mgo.Database, ev ifaces.Event, inp map[string][]string, ...) error
- func DeleteTag(db *mgo.Database, tag_id string) error
- func DraftTimeline(db *mgo.Database, draft_id bson.ObjectId) ([]interface{}, error)
- func FindContent(db *mgo.Database, keys []string, val string) (map[string]interface{}, bool)
- func FindTag(db *mgo.Database, field string, value interface{}) (map[string]interface{}, error)
- func FindVersion(db *mgo.Database, id bson.ObjectId) (map[string]interface{}, error)
- func GenerateKeywords(s string) []string
- func GenerateQuery(s string) []interface{}
- func GetFamily(db *mgo.Database, root bson.ObjectId) ([]interface{}, error)
- func GetParent(db *mgo.Database, coll string, draft map[string]interface{}) (map[string]interface{}, error)
- func GetUpToDateDraft(db *mgo.Database, content_id bson.ObjectId, content map[string]interface{}) map[string]interface{}
- func HaveUpToDateDrafts(db *mgo.Database, content_list []interface{}) error
- func Insert(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) (bson.ObjectId, error)
- func InsertComment(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) error
- func InsertWithFix(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) (bson.ObjectId, error)
- func Install(db *mgo.Database, id bson.ObjectId) error
- func IsDraftUpToDate(db *mgo.Database, draft, parent map[string]interface{}) (bool, error)
- func MoveToFinal(db *mgo.Database, comment_id bson.ObjectId) error
- func MoveToFinalWE(db *mgo.Database, inp map[string][]string) error
- func MoveToModeration(db *mgo.Database, content_id, comment_id bson.ObjectId) error
- func PullTagFromAll(db *mgo.Database, tag_id string) error
- func PullTags(db *mgo.Database, content_id string, tag_ids []string) error
- func RegenerateFulltext(db *mgo.Database) error
- func SaveDraft(db *mgo.Database, content_rules map[string]interface{}, ...) (bson.ObjectId, error)
- func SavePersonalTypeConfig(db *mgo.Database, inp map[string][]string, user_id bson.ObjectId) error
- func SaveTypeConfig(db *mgo.Database, inp map[string][]string) error
- func TagSearchQuery(fieldname, val string) map[string]interface{}
- func TypeOf(db *mgo.Database, content_id bson.ObjectId) (string, error)
- func Uninstall(db *mgo.Database, id bson.ObjectId) error
- func Update(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) error
- func UpdateComment(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) error
- func UpdateWithFix(db *mgo.Database, ev ifaces.Event, rule map[string]interface{}, ...) error
Constants ¶
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" )
const ( Draft_collection_postfix = "_draft" Parent_content_field = "draft_of" Parent_draft_field = "draft_id" )
const (
Cname = "contents"
)
Variables ¶
This section is empty.
Functions ¶
func AllowsDraft ¶
content_type_options: Modules.content.types.[type]
func BuildDraft ¶
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 ¶
*1. Temporary solution. With helper collections we could do the sorting with mongodb. Unfortunately, now versions and drafts reside in two separate collections.
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 DraftTimeline ¶
See *1
func FindContent ¶
Called from Front hook. Find slug value by given key.
func FindVersion ¶
Find version by id.
func GenerateKeywords ¶
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 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 ¶
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 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 IsDraftUpToDate ¶
Takes a draft, and a parent content and decides if the draft is up to date or not.
func MoveToFinal ¶
Moves a comment to its final destination (into the valid comments) from moderation queue.
func MoveToFinalWE ¶
MoveToFinal with extract.
func MoveToModeration ¶
Maybe we should just delete the comment in this case? Think about it and implement it later.
func PullTags ¶
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 ¶
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 TagSearchQuery ¶
Types ¶
This section is empty.