diff --git a/modules/auth/auth.go b/modules/auth/auth.go index 38e4bad..ff4bf32 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -59,7 +59,7 @@ func CanRegistered(userName string, email string) (bool, bool, error) { return e1, e2, nil } -// check if exist user by username or email +// HasUser checks if exist user by username or email func HasUser(user *models.User, username string) bool { var err error qs := orm.NewOrm() @@ -76,7 +76,7 @@ func HasUser(user *models.User, username string) bool { return false } -// register create user +// RegisterUser: register create user func RegisterUser(user *models.User, username, email, password string) error { // use random salt encode password salt := models.GetUserSalt() @@ -97,14 +97,14 @@ func RegisterUser(user *models.User, username, email, password string) error { return user.Insert() } -// set a new password to user +// SaveNewPassword: set a new password to user func SaveNewPassword(user *models.User, password string) error { salt := models.GetUserSalt() user.Password = fmt.Sprintf("%s$%s", salt, utils.EncodePassword(password, salt)) return user.Update("Password", "Rands", "Updated") } -// get login redirect url from cookie +// GetLoginRedirect gets login redirect url from cookie func GetLoginRedirect(ctx *context.Context) string { loginRedirect := strings.TrimSpace(ctx.GetCookie("login_to")) if utils.IsMatchHost(loginRedirect) == false { @@ -115,7 +115,7 @@ func GetLoginRedirect(ctx *context.Context) string { return loginRedirect } -// login user +// LoginUser: login user func LoginUser(user *models.User, ctx *context.Context, remember bool) { // werid way of beego session regenerate id... ctx.Input.CruSession.SessionRelease(ctx.ResponseWriter) @@ -167,7 +167,7 @@ func LoginUserFromRememberCookie(user *models.User, ctx *context.Context) (succe return true } -// logout user +// LogoutUser: logout user func LogoutUser(ctx *context.Context) { DeleteRememberCookie(ctx) ctx.Input.CruSession.Delete("auth_user_id") @@ -182,7 +182,7 @@ func GetUserIdFromSession(sess session.Store) int { return 0 } -// get user if key exist in session +// GetUserFromSession gets user if key exist in session func GetUserFromSession(user *models.User, sess session.Store) bool { id := GetUserIdFromSession(sess) if id > 0 { @@ -196,7 +196,7 @@ func GetUserFromSession(user *models.User, sess session.Store) bool { return false } -// verify username/email and password +// VerifyUser: verify username/email and password func VerifyUser(user *models.User, username, password string) (success bool) { // search user by username or email if HasUser(user, username) == false { @@ -217,7 +217,7 @@ func VerifyUser(user *models.User, username, password string) (success bool) { return } -// compare raw password and encoded password +// VerifyPassword compares raw password and encoded password func VerifyPassword(rawPwd, encodedPwd string) bool { // for discuz accounts @@ -255,7 +255,7 @@ func getVerifyUser(user *models.User, code string) bool { return false } -// verify active code when active account +// VerifyUserActiveCode: verify active code when active account func VerifyUserActiveCode(user *models.User, code string) bool { minutes := setting.ActiveCodeLives @@ -270,7 +270,7 @@ func VerifyUserActiveCode(user *models.User, code string) bool { return false } -// create a time limit code for user active +// CreateUserActiveCode: create a time limit code for user active func CreateUserActiveCode(user *models.User, startInf interface{}) string { minutes := setting.ActiveCodeLives data := utils.ToStr(user.Id) + user.Email + user.UserName + user.Password + user.Rands @@ -281,7 +281,7 @@ func CreateUserActiveCode(user *models.User, startInf interface{}) string { return code } -// verify code when reset password +// VerifyUserResetPwdCode: verify code when reset password func VerifyUserResetPwdCode(user *models.User, code string) bool { minutes := setting.ResetPwdCodeLives @@ -296,7 +296,7 @@ func VerifyUserResetPwdCode(user *models.User, code string) bool { return false } -// create a time limit code for user reset password +// CreateUserResetPwdCode: create a time limit code for user reset password func CreateUserResetPwdCode(user *models.User, startInf interface{}) string { minutes := setting.ResetPwdCodeLives data := utils.ToStr(user.Id) + user.Email + user.UserName + user.Password + user.Rands + user.Updated.String() diff --git a/modules/auth/mail.go b/modules/auth/mail.go index 06404b5..f9edd55 100644 --- a/modules/auth/mail.go +++ b/modules/auth/mail.go @@ -24,7 +24,7 @@ import ( "github.com/beego/wetalk/modules/utils" ) -// Send user register mail with active code +// SendRegisterMail: Send user register mail with active code func SendRegisterMail(locale i18n.Locale, user *models.User) { code := CreateUserActiveCode(user, nil) @@ -41,7 +41,7 @@ func SendRegisterMail(locale i18n.Locale, user *models.User) { mailer.SendAsync(msg) } -// Send user reset password mail with verify code +// SendResetPwdMail: Send user reset password mail with verify code func SendResetPwdMail(locale i18n.Locale, user *models.User) { code := CreateUserResetPwdCode(user, nil) @@ -58,7 +58,7 @@ func SendResetPwdMail(locale i18n.Locale, user *models.User) { mailer.SendAsync(msg) } -// Send email verify active email. +// SendActiveMail: Send email verify active email. func SendActiveMail(locale i18n.Locale, user *models.User) { code := CreateUserActiveCode(user, nil) diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go index 9e83583..db2bdda 100644 --- a/modules/mailer/mail.go +++ b/modules/mailer/mail.go @@ -19,7 +19,7 @@ import ( "github.com/beego/wetalk/setting" ) -// Create New mail message use MailFrom and MailUser +// NewMailMessage: Create New mail message use MailFrom and MailUser func NewMailMessage(To []string, subject, body string) Message { msg := NewHtmlMessage(To, setting.MailFrom, subject, body) msg.User = setting.MailUser diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 2a79d8b..4b0f1a4 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -35,7 +35,7 @@ type Message struct { Info string } -// create mail content +// Content: create mail content func (m Message) Content() string { // set mail type contentType := "text/plain; charset=UTF-8" @@ -49,7 +49,7 @@ func (m Message) Content() string { return content } -// Direct Send mail message +// Send: Direct Send mail message func Send(msg Message) (int, error) { host := strings.Split(setting.MailHost, ":") @@ -91,7 +91,7 @@ func Send(msg Message) (int, error) { } } -// Async Send mail message +// SendAsync: Async Send mail message func SendAsync(msg Message) { // TODO may be need pools limit concurrent nums go func() { @@ -107,7 +107,7 @@ func SendAsync(msg Message) { }() } -// Create html mail message +// NewHtmlMessage: Create html mail message func NewHtmlMessage(To []string, From, Subject, Body string) Message { return Message{ To: To, diff --git a/modules/models/auth.go b/modules/models/auth.go index 21381f2..64fb672 100644 --- a/modules/models/auth.go +++ b/modules/models/auth.go @@ -188,7 +188,7 @@ func init() { orm.RegisterModel(new(Setting), new(User), new(Follow)) } -// return a user salt token +// GetUserSalt returns a user salt token func GetUserSalt() string { return utils.GetRandomString(10) } diff --git a/modules/utils/forms.go b/modules/utils/forms.go index 030721a..0be8247 100644 --- a/modules/utils/forms.go +++ b/modules/utils/forms.go @@ -66,12 +66,12 @@ func (*fakeLocale) Tr(text string, args ...interface{}) string { var fakeLocaler FormLocaler = new(fakeLocale) -// register a custom label/input creater +// RegisterFieldCreater: register a custom label/input creater func RegisterFieldCreater(name string, field FieldCreater) { customCreaters[name] = field } -// register a custom label/input creater +// RegisterFieldFilter: register a custom label/input creater func RegisterFieldFilter(name string, field FieldFilter) { customFilters[name] = field } @@ -114,7 +114,7 @@ func (this *FormSets) SetError(fieldName, errMsg string) { } } -// create formSets for generate label/field html code +// NewFormSets: create formSets for generate label/field html code func NewFormSets(form interface{}, errs map[string]*validation.Error, locale FormLocaler) *FormSets { fSets := new(FormSets) fSets.errs = errs @@ -476,7 +476,7 @@ func initExtraField() { }) } -// parse request.Form values to form +// ParseForm: parse request.Form values to form func ParseForm(form interface{}, values url.Values) { val := reflect.ValueOf(form) elm := reflect.Indirect(val) @@ -558,7 +558,7 @@ func panicAssertStructPtr(val reflect.Value) { panic(fmt.Errorf("%s must be a struct pointer", val.Type().Name())) } -// set values from one struct to other struct +// SetFormValues: set values from one struct to other struct // both need ptr struct func SetFormValues(from interface{}, to interface{}, skips ...string) { val := reflect.ValueOf(from) @@ -632,7 +632,7 @@ outFor: } } -// compare field values between two struct pointer +// FormChanges compares field values between two struct pointer // return changed field names func FormChanges(base interface{}, modified interface{}, skips ...string) (fields []string) { val := reflect.ValueOf(base) diff --git a/modules/utils/tools.go b/modules/utils/tools.go index fcc3fcf..0956ada 100644 --- a/modules/utils/tools.go +++ b/modules/utils/tools.go @@ -63,7 +63,7 @@ func NumberDecode(token string, alphabet []byte) string { return x.String() } -// Random generate string +// GetRandomString: Random generate string func GetRandomString(n int) string { const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" var bytes = make([]byte, n) @@ -112,7 +112,7 @@ func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte return dk[:keyLen] } -// verify time limit code +// VerifyTimeLimitCode: verify time limit code func VerifyTimeLimitCode(data string, minutes int, code string) bool { if len(code) <= 18 { return false @@ -140,7 +140,7 @@ func VerifyTimeLimitCode(data string, minutes int, code string) bool { const TimeLimitCodeLength = 12 + 6 + 40 -// create a time limit code +// CreateTimeLimitCode: create a time limit code // code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string { format := "YmdHi" @@ -171,14 +171,14 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string return code } -// Encode string to md5 hex value +// EncodeMd5: Encode string to md5 hex value func EncodeMd5(str string) string { m := md5.New() m.Write([]byte(str)) return hex.EncodeToString(m.Sum(nil)) } -// use pbkdf2 encode password +// EncodePassword: use pbkdf2 encode password func EncodePassword(rawPwd string, salt string) string { pwd := PBKDF2([]byte(rawPwd), []byte(salt), 10000, 50, sha256.New) return hex.EncodeToString(pwd) @@ -308,7 +308,7 @@ func (f StrTo) String() string { return "" } -// convert any type to string +// ToStr: convert any type to string func ToStr(value interface{}, args ...int) (s string) { switch v := value.(type) { case bool: @@ -347,7 +347,7 @@ func ToStr(value interface{}, args ...int) (s string) { return s } -// convert any numeric value to int64 +// ToInt64: convert any numeric value to int64 func ToInt64(value interface{}) (d int64, err error) { val := reflect.ValueOf(value) switch value.(type) { diff --git a/routers/admin/admin_article.go b/routers/admin/admin_article.go index ff901bf..adcb197 100644 --- a/routers/admin/admin_article.go +++ b/routers/admin/admin_article.go @@ -38,7 +38,7 @@ func (this *ArticleAdminRouter) ObjectQs() orm.QuerySeter { return models.Articles().RelatedSel() } -// view for list model data +// List: view for list model data func (this *ArticleAdminRouter) List() { var articles []models.Article qs := models.Articles().RelatedSel() @@ -48,13 +48,13 @@ func (this *ArticleAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *ArticleAdminRouter) Create() { form := article.ArticleAdminForm{Create: true} this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *ArticleAdminRouter) Save() { form := article.ArticleAdminForm{Create: true} if !this.ValidFormSets(&form) { @@ -72,14 +72,14 @@ func (this *ArticleAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *ArticleAdminRouter) Edit() { form := article.ArticleAdminForm{} form.SetFromArticle(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *ArticleAdminRouter) Update() { form := article.ArticleAdminForm{} if this.ValidFormSets(&form) == false { @@ -106,11 +106,11 @@ func (this *ArticleAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *ArticleAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *ArticleAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/admin/admin_base.go b/routers/admin/admin_base.go index 67b68f9..201501b 100644 --- a/routers/admin/admin_base.go +++ b/routers/admin/admin_base.go @@ -98,7 +98,7 @@ func (this *ModelAdminRouter) ModelPrepare() { } } -// query objects and set to template +// SetObjects: query objects and set to template func (this *ModelAdminRouter) SetObjects(qs orm.QuerySeter, objects interface{}) error { cnt, err := qs.Count() if err != nil { @@ -115,7 +115,7 @@ func (this *ModelAdminRouter) SetObjects(qs orm.QuerySeter, objects interface{}) return nil } -// query object and set to template +// QueryObject: query object and set to template func (this *ModelAdminRouter) QueryObject() bool { id, _ := utils.StrTo(this.GetString(":id")).Int() if id <= 0 { diff --git a/routers/admin/admin_category.go b/routers/admin/admin_category.go index 7685d38..8ba9486 100644 --- a/routers/admin/admin_category.go +++ b/routers/admin/admin_category.go @@ -38,7 +38,7 @@ func (this *CategoryAdminRouter) ObjectQs() orm.QuerySeter { return models.Categories().RelatedSel() } -// view for list model data +// List: view for list model data func (this *CategoryAdminRouter) List() { var cats []models.Category qs := models.Categories().RelatedSel() @@ -48,13 +48,13 @@ func (this *CategoryAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *CategoryAdminRouter) Create() { form := post.CategoryAdminForm{Create: true} this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *CategoryAdminRouter) Save() { form := post.CategoryAdminForm{Create: true} if this.ValidFormSets(&form) == false { @@ -72,14 +72,14 @@ func (this *CategoryAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *CategoryAdminRouter) Edit() { form := post.CategoryAdminForm{} form.SetFromCategory(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *CategoryAdminRouter) Update() { form := post.CategoryAdminForm{Id: this.object.Id} if this.ValidFormSets(&form) == false { @@ -106,11 +106,11 @@ func (this *CategoryAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *CategoryAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *CategoryAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/admin/admin_comment.go b/routers/admin/admin_comment.go index 92b4cee..15742e2 100644 --- a/routers/admin/admin_comment.go +++ b/routers/admin/admin_comment.go @@ -38,7 +38,7 @@ func (this *CommentAdminRouter) ObjectQs() orm.QuerySeter { return models.Comments().RelatedSel() } -// view for list model data +// List: view for list model data func (this *CommentAdminRouter) List() { var comments []models.Comment qs := models.Comments().RelatedSel() @@ -48,13 +48,13 @@ func (this *CommentAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *CommentAdminRouter) Create() { form := post.CommentAdminForm{Create: true} this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *CommentAdminRouter) Save() { form := post.CommentAdminForm{Create: true} if this.ValidFormSets(&form) == false { @@ -72,14 +72,14 @@ func (this *CommentAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *CommentAdminRouter) Edit() { form := post.CommentAdminForm{} form.SetFromComment(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *CommentAdminRouter) Update() { form := post.CommentAdminForm{} if this.ValidFormSets(&form) == false { @@ -106,11 +106,11 @@ func (this *CommentAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *CommentAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *CommentAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/admin/admin_post.go b/routers/admin/admin_post.go index 95d26a9..9ccfb85 100644 --- a/routers/admin/admin_post.go +++ b/routers/admin/admin_post.go @@ -45,7 +45,7 @@ func (this *PostAdminRouter) GetForm(create bool) post.PostAdminForm { return form } -// view for list model data +// List: view for list model data func (this *PostAdminRouter) List() { var posts []models.Post qs := models.Posts().RelatedSel() @@ -55,13 +55,13 @@ func (this *PostAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *PostAdminRouter) Create() { form := this.GetForm(true) this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *PostAdminRouter) Save() { form := this.GetForm(true) if !this.ValidFormSets(&form) { @@ -79,14 +79,14 @@ func (this *PostAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *PostAdminRouter) Edit() { form := this.GetForm(false) form.SetFromPost(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *PostAdminRouter) Update() { form := this.GetForm(false) if this.ValidFormSets(&form) == false { @@ -113,11 +113,11 @@ func (this *PostAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *PostAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *PostAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/admin/admin_topic.go b/routers/admin/admin_topic.go index e6011fe..253caed 100644 --- a/routers/admin/admin_topic.go +++ b/routers/admin/admin_topic.go @@ -38,7 +38,7 @@ func (this *TopicAdminRouter) ObjectQs() orm.QuerySeter { return models.Topics().RelatedSel() } -// view for list model data +// List: view for list model data func (this *TopicAdminRouter) List() { var topics []models.Topic qs := models.Topics().RelatedSel() @@ -48,13 +48,13 @@ func (this *TopicAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *TopicAdminRouter) Create() { form := post.TopicAdminForm{Create: true} this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *TopicAdminRouter) Save() { form := post.TopicAdminForm{Create: true} if this.ValidFormSets(&form) == false { @@ -72,14 +72,14 @@ func (this *TopicAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *TopicAdminRouter) Edit() { form := post.TopicAdminForm{} form.SetFromTopic(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *TopicAdminRouter) Update() { form := post.TopicAdminForm{Id: this.object.Id} if this.ValidFormSets(&form) == false { @@ -106,11 +106,11 @@ func (this *TopicAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *TopicAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *TopicAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/admin/admin_user.go b/routers/admin/admin_user.go index f489be4..0261663 100644 --- a/routers/admin/admin_user.go +++ b/routers/admin/admin_user.go @@ -38,7 +38,7 @@ func (this *UserAdminRouter) ObjectQs() orm.QuerySeter { return models.Users().RelatedSel() } -// view for list model data +// List: view for list model data func (this *UserAdminRouter) List() { var users []models.User qs := models.Users() @@ -48,13 +48,13 @@ func (this *UserAdminRouter) List() { } } -// view for create object +// Create: view for create object func (this *UserAdminRouter) Create() { form := auth.UserAdminForm{Create: true} this.SetFormSets(&form) } -// view for new object save +// Save: view for new object save func (this *UserAdminRouter) Save() { form := auth.UserAdminForm{Create: true} if this.ValidFormSets(&form) == false { @@ -72,14 +72,14 @@ func (this *UserAdminRouter) Save() { } } -// view for edit object +// Edit: view for edit object func (this *UserAdminRouter) Edit() { form := auth.UserAdminForm{} form.SetFromUser(&this.object) this.SetFormSets(&form) } -// view for update object +// Update: view for update object func (this *UserAdminRouter) Update() { form := auth.UserAdminForm{Id: this.object.Id} if this.ValidFormSets(&form) == false { @@ -106,11 +106,11 @@ func (this *UserAdminRouter) Update() { } } -// view for confirm delete object +// Confirm: view for confirm delete object func (this *UserAdminRouter) Confirm() { } -// view for delete object +// Delete: view for delete object func (this *UserAdminRouter) Delete() { if this.FormOnceNotMatch() { return diff --git a/routers/auth/auth.go b/routers/auth/auth.go index d701229..4eae215 100644 --- a/routers/auth/auth.go +++ b/routers/auth/auth.go @@ -237,7 +237,7 @@ func (this *ForgotRouter) Get() { this.SetFormSets(&form) } -// Get implemented Post method for ForgotRouter. +// Post gets implemented Post method for ForgotRouter. func (this *ForgotRouter) Post() { this.TplName = "auth/forgot.html" @@ -277,7 +277,7 @@ func (this *ForgotRouter) Reset() { } } -// Reset implemented user password reset. +// ResetPost: Reset implemented user password reset. func (this *ForgotRouter) ResetPost() { this.TplName = "auth/reset.html" diff --git a/routers/base/base.go b/routers/base/base.go index b060cfe..c04192e 100644 --- a/routers/base/base.go +++ b/routers/base/base.go @@ -126,7 +126,7 @@ func (this *BaseRouter) Prepare() { } } -// on router finished +// Finish: on router finished func (this *BaseRouter) Finish() { } @@ -147,7 +147,7 @@ func (this *BaseRouter) LoginUser(user *models.User, remember bool) string { return loginRedirect } -// check if user not active then redirect +// CheckActiveRedirect checks if user not active then redirect func (this *BaseRouter) CheckActiveRedirect(args ...interface{}) bool { var redirect_to string code := 302 @@ -188,7 +188,7 @@ func (this *BaseRouter) CheckActiveRedirect(args ...interface{}) bool { } -// check if not login then redirect +// CheckLoginRedirect checks if not login then redirect func (this *BaseRouter) CheckLoginRedirect(args ...interface{}) bool { var redirect_to string code := 302 @@ -232,7 +232,7 @@ func (this *BaseRouter) CheckLoginRedirect(args ...interface{}) bool { return false } -// read beego flash message +// FlashRead reads beego flash message func (this *BaseRouter) FlashRead(key string) (string, bool) { if data, ok := this.Data["flash"].(map[string]string); ok { value, ok := data[key] @@ -241,14 +241,14 @@ func (this *BaseRouter) FlashRead(key string) (string, bool) { return "", false } -// write beego flash message +// FlashWrite writes beego flash message func (this *BaseRouter) FlashWrite(key string, value string) { flash := beego.NewFlash() flash.Data[key] = value flash.Store(&this.Controller) } -// check flash redirect, ensure browser redirect to uri and display flash message. +// CheckFlashRedirect checks flash redirect, ensure browser redirect to uri and display flash message. func (this *BaseRouter) CheckFlashRedirect(value string) (match bool, redirect bool) { v := this.GetSession("on_redirect") if params, ok := v.([]interface{}); ok { @@ -290,7 +290,7 @@ end: return match, redirect } -// set flash redirect +// FlashRedirect: set flash redirect func (this *BaseRouter) FlashRedirect(uri string, code int, flag string, args ...interface{}) { flagVal := "true" times := 0 @@ -314,12 +314,12 @@ func (this *BaseRouter) FlashRedirect(uri string, code int, flag string, args .. this.Redirect(uri, code) } -// clear flash redirect +// EndFlashRedirect clears flash redirect func (this *BaseRouter) EndFlashRedirect() { this.DelSession("on_redirect") } -// check form once, void re-submit +// FormOnceNotMatch checks form once, void re-submit func (this *BaseRouter) FormOnceNotMatch() bool { notMatch := false recreat := false @@ -347,7 +347,7 @@ func (this *BaseRouter) FormOnceNotMatch() bool { return notMatch } -// create form once html +// FormOnceCreate: create form once html func (this *BaseRouter) FormOnceCreate(args ...bool) { var value string var creat bool @@ -395,13 +395,13 @@ func (this *BaseRouter) validForm(form interface{}, names ...string) (bool, map[ return true, nil } -// valid form and put errors to tempalte context +// ValidForm: valid form and put errors to tempalte context func (this *BaseRouter) ValidForm(form interface{}, names ...string) bool { valid, _ := this.validForm(form, names...) return valid } -// valid form and put errors to tempalte context +// ValidFormSets: valid form and put errors to tempalte context func (this *BaseRouter) ValidFormSets(form interface{}, names ...string) bool { valid, errs := this.validForm(form, names...) this.setFormSets(form, errs, names...) @@ -424,7 +424,7 @@ func (this *BaseRouter) setFormSets(form interface{}, errs map[string]*validatio return formSets } -// add valid error to FormError +// SetFormError adds valid error to FormError func (this *BaseRouter) SetFormError(form interface{}, fieldName, errMsg string, names ...string) { name := reflect.ValueOf(form).Elem().Type().Name() if len(names) > 0 { @@ -442,7 +442,7 @@ func (this *BaseRouter) SetFormError(form interface{}, fieldName, errMsg string, } } -// check xsrf and show a friendly page +// CheckXsrfCookie checks xsrf and show a friendly page func (this *BaseRouter) CheckXsrfCookie() bool { return this.Controller.CheckXSRFCookie() } diff --git a/routers/post/post.go b/routers/post/post.go index 94112e1..7079067 100644 --- a/routers/post/post.go +++ b/routers/post/post.go @@ -51,7 +51,7 @@ func (this *PostListRouter) postsFilter(qs orm.QuerySeter) orm.QuerySeter { return qs } -// Get implemented Get method for HomeRouter. +// Home gets implemented Get method for HomeRouter. func (this *PostListRouter) Home() { this.Data["IsHome"] = true this.TplName = "post/home.html" @@ -73,7 +73,7 @@ func (this *PostListRouter) Home() { this.Data["Topics"] = topics } -// Get implemented Get method for HomeRouter. +// Category gets implemented Get method for HomeRouter. func (this *PostListRouter) Category() { this.TplName = "post/category.html" @@ -109,7 +109,7 @@ func (this *PostListRouter) Category() { this.setTopicsOfCat(&topics, &cat) } -// Get implemented Get method for HomeRouter. +// Navs gets implemented Get method for HomeRouter. func (this *PostListRouter) Navs() { slug := this.GetString(":slug") @@ -209,7 +209,7 @@ func (this *PostListRouter) Navs() { this.Data["Posts"] = posts } -// Get implemented Get method for HomeRouter. +// Topic gets implemented Get method for HomeRouter. func (this *PostListRouter) Topic() { slug := this.GetString(":slug") @@ -247,7 +247,7 @@ func (this *PostListRouter) Topic() { } } -// Get implemented Get method for HomeRouter. +// TopicSubmit gets implemented Get method for HomeRouter. func (this *PostListRouter) TopicSubmit() { slug := this.GetString(":slug")