Documentation
¶
Overview ¶
Package aurora is a minimalistic social network library.
Index ¶
- Variables
- func ComposeLoginForm() gforms.ModelForm
- func ComposeProfileForm() gforms.ModelForm
- func ComposeRegisterForm() gforms.ModelForm
- func CreateAccount(db nutz.Storage, a Account, bucket string) error
- func CreateProfile(db nutz.Storage, p *Profile, bucket string, nest ...string) error
- func GetAllUsers(db nutz.Storage, bucket string, nest ...string) ([]string, error)
- func UpdateProfile(db nutz.Storage, p *Profile, bucket string, nest ...string) error
- type Account
- type BirthDateValidator
- type CustomValidator
- type EqualValidator
- type FileUpload
- type Flash
- type ISO3166Entry
- type InfoMSG
- type MSG
- type Messenger
- type Photo
- type Profile
- type Remix
- func (rx *Remix) Home(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Login(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Logout(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Profile(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Register(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Routes() *mux.Router
- func (rx *Remix) ServeImages(w http.ResponseWriter, r *http.Request)
- func (rx *Remix) Uploads(w http.ResponseWriter, r *http.Request)
- type RemixConfig
- type Session
- func (s *Session) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *Session) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *Session) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *Session) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // MsgRequired is the error message for required validation. MsgRequired = "hili eneo halitakiwi kuachwa wazi" // MsgName is the error message displayed for a name validation MsgName = "hili eneo linatakiwa liwe mchanganyiko wa herufi na namba" //MsgEmail is the error message displayed for email validation MsgEmail = "email sio sahihi. mfano gernest@aurora.com" // MsgMinLength is the error message for a minimum length validation MsgMinLength = "namba ya siri inatakiwa kuanzia herufi 6 na kuendelea" // MsgEqual is the error message for equality validation MsgEqual = "%s inatakiwa iwe sawa na %s" // MsgMinAge the minimum age linit MsgMinAge = "umri unatakiwa uwe zaidi ya miaka %d" )
var ISO3166List = []ISO3166Entry{}/* 249 elements not displayed */
ISO3166List based on https://www.iso.org/obp/ui/#search/code/ Code Type "Officially Assigned Codes"
var SupportedCountries = []ISO3166Entry{
{"Tanzania, United Republic of", "Tanzanie, République-Unie de", "TZ", "TZA", "834"},
}
SupportedCountries these are the coutries supported by aurora
Functions ¶
func ComposeLoginForm ¶
ComposeLoginForm builds a login form for validation( with gforms)
func ComposeProfileForm ¶
ComposeProfileForm builds a profile form for validation (using gform)
func ComposeRegisterForm ¶
ComposeRegisterForm builds a registration form for validation(with gforms)
func CreateAccount ¶
CreateAccount creates a new account, where id will be the value returned by invoking Email() method.
func CreateProfile ¶
CreateProfile creates a new profile using Profile.ID as the jey
func GetAllUsers ¶
GetAllUsers returns a slice of all users.
Types ¶
type BirthDateValidator ¶
BirthDateValidator validates the birth date, handy to keep minors offsite
func (BirthDateValidator) Validate ¶
func (vl BirthDateValidator) Validate(fi *gforms.FieldInstance, fo *gforms.FormInstance) error
Validate checks if the given field instance esceeds the Limit attribute
type CustomValidator ¶
CustomValidator a custom validator for gforms
func (CustomValidator) Validate ¶
func (vl CustomValidator) Validate(fi *gforms.FieldInstance, fo *gforms.FormInstance) error
Validate validates fields
type EqualValidator ¶
type EqualValidator struct { gforms.Validator Message string // contains filtered or unexported fields }
EqualValidator checks if the two fields are equal. The to attribute is the name of the field whose value must be equal to the current field
func (EqualValidator) Validate ¶
func (vl EqualValidator) Validate(fi *gforms.FieldInstance, fo *gforms.FormInstance) error
Validate checks if the given field is egual to the field in the to attribute
type FileUpload ¶
FileUpload represents the uploaded file
func GetFileUpload ¶
func GetFileUpload(r *http.Request, fieldName string) (*FileUpload, error)
GetFileUpload retrieves uploaded file from a request.This function, returns only the first file that matches, thus retrieving a single file only. the fieldName parameter is the name of the field which holds the file data.
func GetMultipleFileUpload ¶
func GetMultipleFileUpload(r *http.Request, fieldName string) ([]*FileUpload, error)
GetMultipleFileUpload retrieves multiple files uploaded on a single request. The fieldName parameter is the form field containing the files
type Flash ¶
type Flash struct {
Data map[string]interface{}
}
Flash is a helper for storing and retrieving flash messages TODO : Move this to another file, it just don't look like it belongs here
type ISO3166Entry ¶
type ISO3166Entry struct { EnglishShortName string `json:"eglish_short_name"` FrenchShortName string `json:"french_short_name"` Alpha2Code string `json:"alpha2code"` Alpha3Code string `json:"alpha3code"` Numeric string `json:"numeric"` }
ISO3166Entry stores country codes
type InfoMSG ¶
type InfoMSG struct { Title string `json:"title"` Body string `json:"body"` Sender string `json:"sender"` }
InfoMSG this is for sharing information across the messenger nodes
type MSG ¶
type MSG struct { ID string `json:"id"` SenderID string `json:"sender_id"` RecipientID string `json:"recepient_id"` Text string `json:"text"` SentAt time.Time `json:"sent_at"` ReceivedAt time.Time `json:"received_at"` Status int `json:"status"` SenderName string `json:"sender_name"` }
MSG this is the base message exchanged between users
type Messenger ¶
type Messenger struct {
// contains filtered or unexported fields
}
Messenger the messanger from the gods
type Photo ¶
type Photo struct { ID string `json:"id"` // Type is the photo's file extension e.g jpeg or png Type string `json:"type"` //Size is the size of the photo. Size int `json:"size"` //UploadedBy is the ID of the user who uploaded the photo UploadedBy string `json:"uploaded_by"` UploadedAt time.Time `json:"uploaded_at"` // UpdatedAt is the time the photo was updated. I keep this filed so as // to provide, last modified time when serving the photo. UpdatedAt time.Time `json:"updated_at"` }
Photo is the metadata of an uploaded image file
func SaveUploadFile ¶
SaveUploadFile saves the uploaded photos to the profile database. In aurora, every user has his/her own personal database.
The db argument should be the user's database. The uploaded file is storesd in two versions meta, and data. The meta, is the metadata about the uploaded file, in our case a Photo object. The photo object is marshalled and stored in a metaBucket.
The data part is the actual encoded file, its stored in the dataBucket.
type Profile ¶
type Profile struct { ID string `json:"id" gforms:"-"` FirstName string `json:"first_name" gforms:"first_name"` LastName string `json:"last_name" gforms:"last_name"` Picture *Photo `json:"picture" gforms:"-"` Age int `json:"age" gforms:"age"` IsUpdate bool `json:"is_update" gforms:"-"` BirthDate time.Time `json:"birth_date" gforms:"birth_date"` Gender int `json:"gender" gforms:"gender"` Photos []*Photo `json:"photos" gforms:"-"` City string `json:"city" gforms:"city"` Country string `json:"country" gforms:"country"` Street string `json:"street" gforms:"street"` CreatedAt time.Time `json:"created_at" gforms:"-"` UpdatedAt time.Time `json:"update_at" gforms:"-"` }
Profile contains additional information about the user
func GetProfile ¶
GetProfile retrives a profile with a given id
func (*Profile) MyBirthDay ¶
type Remix ¶
type Remix struct {
// contains filtered or unexported fields
}
Remix all the fun is here
func NewRemix ¶
func NewRemix(cfg *RemixConfig) *Remix
NewRemix iitialize a *Remix instance using the given cfg
func (*Remix) Home ¶
func (rx *Remix) Home(w http.ResponseWriter, r *http.Request)
Home is where the homepage is
func (*Remix) Login ¶
func (rx *Remix) Login(w http.ResponseWriter, r *http.Request)
Login creates new session for a user
func (*Remix) Logout ¶
func (rx *Remix) Logout(w http.ResponseWriter, r *http.Request)
Logout deletes current session
func (*Remix) Profile ¶
func (rx *Remix) Profile(w http.ResponseWriter, r *http.Request)
Profile viewing and updating profile
func (*Remix) Register ¶
func (rx *Remix) Register(w http.ResponseWriter, r *http.Request)
Register creates a new user account
func (*Remix) ServeImages ¶
func (rx *Remix) ServeImages(w http.ResponseWriter, r *http.Request)
ServeImages serves images uploaded by users
type RemixConfig ¶
type RemixConfig struct { AppName string `json:"name"` AppURL string `json:"url"` CdnMode bool `json:"cdn_mode"` RunMode string `json:"run_mode"` AppTitle string `json:"title"` AppDescription string `json:"description"` // path to the directory where databases will be stored DBDir string `json:"database_dir"` AccountsBucket string `json:"accounts_bucket"` AccountsDB string `json:"accounts_database"` DBExtension string `json:"database_extension"` ProfilesBucket string `json:"profiles_bucket"` SessionName string `json:"sessions_name"` SessionsDB string `json:"sessions_database"` SessionsBucket string `json:"sessions_bucket"` SessMaxAge int `json:"sessions_max_age"` SessionPath string `json:"session_path"` // The path to point to when login is success LoginRedirect string `json:"login_redirect"` ProfilePicField string `json:"profile_pic_field"` PhotosField string `json:"photos_field"` MessagesBucket string `json:"messages_bucket"` TemplatesExtensions []string `json:"templates_extensions"` TemplatesDir string `json:"templates_dir"` DevMode bool `json:"dev_mode"` }
RemixConfig contain configuration values for Remix
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session implemets gorilla session store interface
func NewSessStore ¶
func NewSessStore(db nutz.Storage, bucket string, duration int, opts *sessions.Options, secrets ...[]byte) *Session
NewSessStore creates a new session store
type User ¶
type User struct { UUID string `json:"uuid" gforms:"-"` FirstName string `json:"first_name" gforms:"first_name"` LastName string `json:"last_name" gforms:"last_name"` EmailAddress string `json:"email" gforms:"email_address"` Pass string `json:"password" gforms:"pass"` ConfirmPass string `json:"-" gforms:"confirm_pass"` CreatedAt time.Time `json:"created_at" gforms:"-"` UpdatedAt time.Time `json:"updated_at" gforms:"-"` }
User contains details about a user