Fix lint errors
This commit is contained in:
parent
02bc365add
commit
80445e03cb
@ -68,7 +68,12 @@ func (app *Application) buffered_render_tweet_page(w http.ResponseWriter, tpl_fi
|
|||||||
partials = append(partials, tweet_partials...)
|
partials = append(partials, tweet_partials...)
|
||||||
|
|
||||||
tpl, err := template.New("does this matter at all? lol").Funcs(
|
tpl, err := template.New("does this matter at all? lol").Funcs(
|
||||||
template.FuncMap{"tweet": data.Tweet, "user": data.User, "active_user": app.get_active_user, "focused_tweet_id": data.FocusedTweetID},
|
template.FuncMap{
|
||||||
|
"tweet": data.Tweet,
|
||||||
|
"user": data.User,
|
||||||
|
"active_user": app.get_active_user,
|
||||||
|
"focused_tweet_id": data.FocusedTweetID,
|
||||||
|
},
|
||||||
).ParseFiles(append(partials, get_filepath(tpl_file))...)
|
).ParseFiles(append(partials, get_filepath(tpl_file))...)
|
||||||
panic_if(err)
|
panic_if(err)
|
||||||
|
|
||||||
|
@ -278,8 +278,8 @@ func (app *Application) Login(w http.ResponseWriter, r *http.Request) {
|
|||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
err := parse_form(r, &form)
|
err := parse_form(r, &form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.InfoLog.Print(err.Error())
|
app.InfoLog.Print("Form error parse: " + err.Error())
|
||||||
app.error_400_with_message(w, "Invalid form data")
|
app.error_400_with_message(w, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
form.Validate()
|
form.Validate()
|
||||||
@ -299,7 +299,13 @@ func (app *Application) Login(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get_default_user() scraper.User {
|
func get_default_user() scraper.User {
|
||||||
return scraper.User{ID: 0, Handle: "[nobody]", DisplayName: "[Not logged in]", ProfileImageLocalPath: path.Base(scraper.DEFAULT_PROFILE_IMAGE_URL), IsContentDownloaded: true}
|
return scraper.User{
|
||||||
|
ID: 0,
|
||||||
|
Handle: "[nobody]",
|
||||||
|
DisplayName: "[Not logged in]",
|
||||||
|
ProfileImageLocalPath: path.Base(scraper.DEFAULT_PROFILE_IMAGE_URL),
|
||||||
|
IsContentDownloaded: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *Application) ChangeSession(w http.ResponseWriter, r *http.Request) {
|
func (app *Application) ChangeSession(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -309,7 +315,8 @@ func (app *Application) ChangeSession(w http.ResponseWriter, r *http.Request) {
|
|||||||
}{}
|
}{}
|
||||||
err := parse_form(r, &form)
|
err := parse_form(r, &form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.error_400_with_message(w, "Invalid form data")
|
app.InfoLog.Print("Form error parse: " + err.Error())
|
||||||
|
app.error_400_with_message(w, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if form.AccountName == "no account" {
|
if form.AccountName == "no account" {
|
||||||
@ -335,6 +342,7 @@ func (app *Application) ChangeSession(w http.ResponseWriter, r *http.Request) {
|
|||||||
get_filepath("tpl/includes/nav_sidebar.tpl"),
|
get_filepath("tpl/includes/nav_sidebar.tpl"),
|
||||||
get_filepath("tpl/includes/author_info.tpl"),
|
get_filepath("tpl/includes/author_info.tpl"),
|
||||||
)
|
)
|
||||||
|
panic_if(err)
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
err = tpl.ExecuteTemplate(buf, "nav-sidebar", nil)
|
err = tpl.ExecuteTemplate(buf, "nav-sidebar", nil)
|
||||||
panic_if(err)
|
panic_if(err)
|
||||||
@ -344,12 +352,19 @@ func (app *Application) ChangeSession(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var formDecoder = form.NewDecoder()
|
var formDecoder = form.NewDecoder()
|
||||||
|
var (
|
||||||
|
ErrCorruptedFormData = errors.New("corrupted form data")
|
||||||
|
ErrIncorrectFormParams = errors.New("incorrect form parameters")
|
||||||
|
)
|
||||||
|
|
||||||
func parse_form(req *http.Request, result interface{}) error {
|
func parse_form(req *http.Request, result interface{}) error {
|
||||||
err := req.ParseForm()
|
err := req.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return ErrCorruptedFormData
|
||||||
}
|
}
|
||||||
|
|
||||||
return formDecoder.Decode(result, req.PostForm)
|
if err = formDecoder.Decode(result, req.PostForm); err != nil {
|
||||||
|
return ErrIncorrectFormParams
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user