added 500 error screen, and adjusted index:
This commit is contained in:
@@ -49,7 +49,12 @@ func RegisterBlogGroup(r *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
func RenderBlogPage(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "blog.tmpl", *GetAllBlogPosts())
|
||||
posts := GetAllBlogPosts()
|
||||
if posts == nil {
|
||||
c.HTML(http.StatusInternalServerError, "internal_server_error.tmpl", gin.H{})
|
||||
} else {
|
||||
c.HTML(http.StatusOK, "blog.tmpl", posts)
|
||||
}
|
||||
}
|
||||
|
||||
func RenderIndividualBlogPost(c *gin.Context) {
|
||||
@@ -118,7 +123,10 @@ func GetAllBlogPosts() *[]models.BlogPost {
|
||||
var posts []models.BlogPost
|
||||
// Select title, date, and url fields from the blog post records an store them in posts.
|
||||
// This is so we don't grab the entire blog post when we render them on the overview page. Saves a couple ms.
|
||||
db.Model(&models.BlogPost{}).Select("title, date, url").Take(&posts)
|
||||
err := db.Model(&models.BlogPost{}).Select("title, date, url").Take(&posts).Error
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &posts
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
I am an independent software engineer, and self proclaimed systems administrator from Canada. Currently, I am pursuing a degree in Computer Science, with hopes of participating in a graduate program later down the road.
|
||||
</p>
|
||||
<p>
|
||||
I am a GNU/Linux and OpenBSD enthusiast. You'll find me active in the Debian Linux, Void Linux and OpenBSD communities. My favourite programming languages are Go and Clojure. You can check out my work on <a href="https://gitlab.com/rawleyIfowler">GitLab</a>. Currently, I am working on my <a href="https://gitlab.com/rawleyIfowler/rawleydotxyz">website</a>, and an open-source community based blogging network called <a href="https://gitlab.com/xrn">xrn</a>.
|
||||
I am a GNU/Linux and OpenBSD enthusiast. You'll find me active in the Debian Linux, Void Linux and OpenBSD communities. My favourite programming languages are Go and Clojure. Currently, I am working on my <a href="https://gitlab.com/rawleyIfowler/rawleydotxyz">website</a>, and an open-source community based blogging network called <a href="https://gitlab.com/xrn">xrn</a>. You can check out my work on <a href="https://gitlab.com/rawleyIfowler">GitLab</a>.
|
||||
</p>
|
||||
<p>
|
||||
When I'm not programming, I'm either reading, cooking, playing table-top games, or walking my dog.
|
||||
|
||||
4
templates/internal_server_error.tmpl
Normal file
4
templates/internal_server_error.tmpl
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ template "header.tmpl" . }}
|
||||
<h2>500 Internal server error :(</h2>
|
||||
<p>Click <a href="/">here</a> to return home.</p>
|
||||
{{ template "footer.tmpl" . }}
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--not_found.html-->
|
||||
{{ template "header.tmpl" . }}
|
||||
<h2>404 Not Found :(</h2>
|
||||
<h2>404 Not found :(</h2>
|
||||
<p>
|
||||
Click <a href="/">here</a> to return home.
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user