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