Documentation
¶
Index ¶
- func BeautifulName(uglyName string) string
- func CanonicalName(name string) string
- func HTTP200Page(w http.ResponseWriter, page string)
- func HTTP404Page(w http.ResponseWriter, page string)
- func HyphaNameFromRq(rq *http.Request, actions ...string) string
- func IsProfileName(hyphaName string) bool
- func IsRevHash(revHash string) bool
- func PrepareRq(rq *http.Request)
- func RandomString(n int) (string, error)
- func ShorterPath(path string) string
- type FormData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeautifulName ¶
BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case.
func CanonicalName ¶
CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores.
func HTTP200Page ¶
func HTTP200Page(w http.ResponseWriter, page string)
HTTP200Page wraps some frequently used things for successful 200 responses. TODO: demolish
func HTTP404Page ¶
func HTTP404Page(w http.ResponseWriter, page string)
HTTP404Page writes a 404 error in the status, needed when no content is found on the page. TODO: demolish
func HyphaNameFromRq ¶ added in v1.2.0
HyphaNameFromRq extracts hypha name from http request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha".
func IsProfileName ¶ added in v1.8.0
IsProfileName if the given hypha name is a profile name. It takes configuration into consideration.
With default configuration, u/ is the prefix such names have. For example, u/wikimind matches. Note that u/wikimind/sub does not.
func PrepareRq ¶ added in v1.2.0
PrepareRq strips the trailing / in rq.URL.Path. In the future it might do more stuff for making all request structs uniform.
func RandomString ¶
RandomString generates a random string of the given length. It is cryptographically secure to some extent.
func ShorterPath ¶
ShorterPath is used by handlerList to display shorter path to the files. It simply strips the hyphae directory name.
Types ¶
type FormData ¶ added in v1.3.0
type FormData struct {
// contains filtered or unexported fields
}
FormData is a convenient struct for passing user input and errors to HTML forms and showing to the user.
func FormDataFromRequest ¶ added in v1.3.0
FormDataFromRequest extracts a form data from request, using a set of keys.
func NewFormData ¶ added in v1.3.0
func NewFormData() FormData
NewFormData constructs empty form data instance.
func (FormData) Error ¶ added in v1.3.0
Error returns an error text or empty string, if there are no errors in form data.