about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 11:46:13 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 11:46:13 -0400
commite11dedec034c4180985adf4a9f176b07121f0a41 (patch)
tree7f4320d562f37775cbc8ae390540da03a2d92d77 /app/controllers
parentd48adb741c5c30ba3f2d3c039a7e342b43add352 (diff)
downloadthoughts-e11dedec034c4180985adf4a9f176b07121f0a41.tar.gz
thoughts-e11dedec034c4180985adf4a9f176b07121f0a41.tar.bz2
thoughts-e11dedec034c4180985adf4a9f176b07121f0a41.zip
Blog drafts no longer require slugs
They do still technically require titles, but the engine will fill in "Untitled draft" if it is left blank. Unpublished posts can be viewed at a different URL than published posts would be. Quick links to view published and unpublished posts have been added to the admin panel.

refs #1
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/blogs_controller.rb10
-rw-r--r--app/controllers/blogs_controller.rb2
2 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index 9706df3..1035c12 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -9,6 +9,16 @@ class Admin::BlogsController < Admin::AdminController
9 @blogs = Blog.where(published: false).order(updated_at: :desc) 9 @blogs = Blog.where(published: false).order(updated_at: :desc)
10 end 10 end
11 11
12 def show
13 @blog = Blog.find(params[:id])
14
15 if @blog.published
16 redirect_to blog_url(@blog.slug)
17 else
18 render layout: "application"
19 end
20 end
21
12 def new 22 def new
13 @blog = Blog.new 23 @blog = Blog.new
14 end 24 end
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index f31287b..8ee472e 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb
@@ -4,7 +4,7 @@ class BlogsController < ApplicationController
4 @blog = Blog.find_by_slug(params[:slug]) 4 @blog = Blog.find_by_slug(params[:slug])
5 5
6 raise ActiveRecord::RecordNotFound unless @blog 6 raise ActiveRecord::RecordNotFound unless @blog
7 raise ActiveRecord::RecordNotFound unless @blog.published or user_signed_in? 7 raise ActiveRecord::RecordNotFound unless @blog.published
8 end 8 end
9 9
10end 10end