From e11dedec034c4180985adf4a9f176b07121f0a41 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Jul 2018 11:46:13 -0400 Subject: 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 --- app/views/admin/blogs/_form.html.haml | 6 ++++++ app/views/admin/blogs/drafts.html.haml | 5 ++++- app/views/admin/blogs/index.html.haml | 5 ++++- app/views/admin/blogs/show.html.haml | 5 +++++ app/views/blogs/show.html.haml | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 app/views/admin/blogs/show.html.haml (limited to 'app/views') diff --git a/app/views/admin/blogs/_form.html.haml b/app/views/admin/blogs/_form.html.haml index 2066aed..12f7a82 100644 --- a/app/views/admin/blogs/_form.html.haml +++ b/app/views/admin/blogs/_form.html.haml @@ -15,6 +15,12 @@ %ul - f.object.errors.full_messages.each do |error| %li= error + - unless f.object.new_record? + #entry-preview-link.details-module + - if f.object.published + = link_to "View post", blog_url(f.object.slug_was), target: "entry-preview" + - else + = link_to "Preview post", admin_blog_url(f.object), target: "entry-preview" .details-module .published-field = f.check_box :published diff --git a/app/views/admin/blogs/drafts.html.haml b/app/views/admin/blogs/drafts.html.haml index 91d3214..8f2d369 100644 --- a/app/views/admin/blogs/drafts.html.haml +++ b/app/views/admin/blogs/drafts.html.haml @@ -7,4 +7,7 @@ %tr{ class: cycle("even", "odd") } %td= blog.title %td= blog.updated_at.strftime("%B %d, %Y, %l:%M%P") - %td= link_to "Edit", edit_admin_blog_url(blog) + %td + %ul.admin-actions + %li= link_to "Preview", admin_blog_url(blog) + %li= link_to "Edit", edit_admin_blog_url(blog) diff --git a/app/views/admin/blogs/index.html.haml b/app/views/admin/blogs/index.html.haml index c5db4f1..427d922 100644 --- a/app/views/admin/blogs/index.html.haml +++ b/app/views/admin/blogs/index.html.haml @@ -7,4 +7,7 @@ %tr{ class: cycle("even", "odd") } %td= blog.title %td= blog.published_at.strftime("%B %d, %Y, %l:%M%P") - %td= link_to "Edit", edit_admin_blog_url(blog) + %td + %ul.admin-actions + %li= link_to "View", blog_url(blog.slug) + %li= link_to "Edit", edit_admin_blog_url(blog) diff --git a/app/views/admin/blogs/show.html.haml b/app/views/admin/blogs/show.html.haml new file mode 100644 index 0000000..7875cab --- /dev/null +++ b/app/views/admin/blogs/show.html.haml @@ -0,0 +1,5 @@ += render partial: "blogs/blog", object: @blog +%footer#blog-footer + This draft was last updated on + = succeed "." do + %time= @blog.updated_at.strftime("%B #{@blog.updated_at.day.ordinalize}, %Y at %-I:%M:%S%P") diff --git a/app/views/blogs/show.html.haml b/app/views/blogs/show.html.haml index 48c07dc..8ab4523 100644 --- a/app/views/blogs/show.html.haml +++ b/app/views/blogs/show.html.haml @@ -3,4 +3,4 @@ %footer#blog-footer This entry was posted on = succeed "." do - %time= @blog.posted_at.strftime("%B #{@blog.posted_at.day.ordinalize}, %Y at %-I:%M:%S%P") + %time= @blog.published_at.strftime("%B #{@blog.published_at.day.ordinalize}, %Y at %-I:%M:%S%P") -- cgit 1.4.1