Documentation
¶
Overview ¶
Package scut contains a somewhat ugly but useful collection of frequently appearing patterns to allow faster prototyping. Methods here are mainly related to view- or conroller-like parts.
Index ¶
- func GetFile(root, fi string, opt map[string]interface{}, host string, ...) ([]byte, error)
- func GetModTPath(filename string) []string
- func GetTPath(opt map[string]interface{}, host string) string
- func Host(host string, opt map[string]interface{}) string
- func IdsToStrings(v interface{})
- func IsAdmin(user interface{}) bool
- func IsGuest(user interface{}) bool
- func IsModerator(user interface{}) bool
- func IsRegistered(user interface{}) bool
- func IsStranger(user interface{}) bool
- func Merge(a map[string]interface{}, b map[string]interface{})
- func NotAdmin(user interface{}) bool
- func OnlyAdmin(dat map[string]interface{})
- func OrderKeys(d map[string]interface{}) []interface{}
- func PossibleModPath(filep string) bool
- func RulesToFields(rule interface{}, dat interface{}) ([]map[string]interface{}, error)
- func SolvedPuzzles(user interface{}) bool
- func TemplateName(opt map[string]interface{}) string
- func TemplateType(opt map[string]interface{}) string
- func Ulev(useri interface{}) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFile ¶
func GetFile(root, fi string, opt map[string]interface{}, host string, file_reader func(string) ([]byte, error)) ([]byte, error)
TODO: Implement file caching here. Reads the fi relative filepath from either the current template, or the fallback module tpl folder if fi has at least one slash in it. file_reader is optional, falls back to simple ioutil.ReadFile if not given. file_reader will be a custom file_reader with caching soon.
func GetModTPath ¶
Inp: "admin/this/that.txt" []string{ "modules/admin/tpl", "this/that.txt"}
func GetTPath ¶
Observes opt and gives you back the path of your template eg "templates/public/template_name" or "templates/private/hostname/template_name"
func Host ¶
CanonicalHost(uni.Req.Host, uni.Opt) Gives you back the canonical address of the site so it can be made available from different domains.
func IdsToStrings ¶
func IdsToStrings(v interface{})
Converts all bson.ObjectId s to string. Usually called before displaying a database query result. Input is the result from the database.
func IsModerator ¶
func IsModerator(user interface{}) bool
func IsRegistered ¶
func IsRegistered(user interface{}) bool
func IsStranger ¶
func IsStranger(user interface{}) bool
func OrderKeys ¶
func OrderKeys(d map[string]interface{}) []interface{}
A more generic version of abcKeys. Takes a map[string]interface{} and puts every element of that into an []interface{}, ordered by keys alphabetically. TODO: find the intersecting parts between the two functions and refactor.
func PossibleModPath ¶
Decides if a given relative filepath (filep) is a possible module filepath. This may be deprecated in the future since it seems so restrictive.
func RulesToFields ¶
Takes an extraction/validation rule, a document and from that creates a slice which can be easily displayed by a templating engine as a html form. Takes interface{}s and not map[string]interface{}s to include type checking here, and avoid that boilerplate in caller.
func SolvedPuzzles ¶
func SolvedPuzzles(user interface{}) bool
func TemplateName ¶
Gives you back the name of the current template in use.
func TemplateType ¶
Gives you back the type of the currently used template (either "private" or public).
Types ¶
This section is empty.