|
@ -6,6 +6,7 @@ import ( |
|
|
"strconv" |
|
|
"strconv" |
|
|
|
|
|
|
|
|
"PersonalWebsite/Database" |
|
|
"PersonalWebsite/Database" |
|
|
|
|
|
"PersonalWebsite/Helper" |
|
|
|
|
|
|
|
|
"github.com/gorilla/mux" |
|
|
"github.com/gorilla/mux" |
|
|
) |
|
|
) |
|
@ -22,9 +23,15 @@ func ViewPost(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
post, e = Database.GetPostById(urlParams["id"]) |
|
|
post, e = Database.GetPostById(urlParams["id"]) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
// TODO: Forward 404
|
|
|
|
|
|
log.Println("Could not get post") |
|
|
|
|
|
http.Error(w, "Error", http.StatusInternalServerError) |
|
|
|
|
|
|
|
|
log.Println(e) |
|
|
|
|
|
http.Redirect(w, r, "/error", 302) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
post.Body, e = Helper.GetFileContents(post.HtmlPath) |
|
|
|
|
|
if e != nil { |
|
|
|
|
|
log.Println(e) |
|
|
|
|
|
http.Redirect(w, r, "/error", 302) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -58,8 +65,8 @@ func ViewPostList(w http.ResponseWriter, r *http.Request, subject string) { |
|
|
} else { |
|
|
} else { |
|
|
page, e = strconv.Atoi(keys[0]) |
|
|
page, e = strconv.Atoi(keys[0]) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
// TODO: Handle this
|
|
|
|
|
|
http.Error(w, "Error", http.StatusInternalServerError) |
|
|
|
|
|
|
|
|
log.Println(e) |
|
|
|
|
|
http.Redirect(w, r, "/error", 302) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -68,15 +75,15 @@ func ViewPostList(w http.ResponseWriter, r *http.Request, subject string) { |
|
|
|
|
|
|
|
|
posts, e = Database.GetPostsListBySubject(limit, offset, subject) |
|
|
posts, e = Database.GetPostsListBySubject(limit, offset, subject) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
// TODO: Handle this
|
|
|
|
|
|
http.Error(w, "Error", http.StatusInternalServerError) |
|
|
|
|
|
|
|
|
log.Println(e) |
|
|
|
|
|
http.Redirect(w, r, "/error", 302) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
postsCount, e = Database.GetPostCountBySubject(subject) |
|
|
postsCount, e = Database.GetPostCountBySubject(subject) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
// TODO: Handle this
|
|
|
|
|
|
http.Error(w, "Error", http.StatusInternalServerError) |
|
|
|
|
|
|
|
|
log.Println(e) |
|
|
|
|
|
http.Redirect(w, r, "/error", 302) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|