Skip to content

Commit

Permalink
add content draft status support
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxiaohei committed Jan 30, 2014
1 parent e9b9dd4 commit 3fbaf51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/handler/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Article(context *GoInk.Context) {
id, _ := strconv.Atoi(context.Param("id"))
slug := context.Param("slug")
article := model.GetContentById(id)
if article == nil {
if article == nil || article.Status != "publish"{
context.Redirect("/")
return
}
Expand All @@ -91,7 +91,7 @@ func Page(context *GoInk.Context) {
id, _ := strconv.Atoi(context.Param("id"))
slug := context.Param("slug")
article := model.GetContentById(id)
if article == nil {
if article == nil || article.Status != "publish"{
context.Redirect("/")
return
}
Expand All @@ -110,7 +110,7 @@ func Page(context *GoInk.Context) {
func TopPage(context *GoInk.Context) {
slug := context.Param("slug")
page := model.GetContentBySlug(slug)
if page == nil {
if page == nil || page.Status != "publish"{
context.Redirect("/")
return
}
Expand Down
3 changes: 3 additions & 0 deletions app/model/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func (cnt *Content) TagString() string {

// get content link.
func (cnt *Content) Link() string {
if cnt.Status != "publish"{
return "#"
}
if cnt.IsLinked {
return "/" + cnt.Slug + ".html"
}
Expand Down

0 comments on commit 3fbaf51

Please sign in to comment.