From 610cd865f27c458921e76ab340de41a642823cba Mon Sep 17 00:00:00 2001 From: Kyle Wilkinson Date: Tue, 21 Jun 2011 02:48:07 -0700 Subject: Allow custom_teaser field to be updated via forms. --- app/models/blog_post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index a010d98..2126827 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -26,7 +26,7 @@ class BlogPost < ActiveRecord::Base :approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => 'blog'), :strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => 'blog') - attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url + attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url, :custom_teaser scope :by_archive, lambda { |archive_date| where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]) -- cgit v1.2.3 From 3c0412bfaa3c2dc3fff319af0c812f7a9fb286a3 Mon Sep 17 00:00:00 2001 From: Kyle Wilkinson Date: Tue, 21 Jun 2011 02:48:48 -0700 Subject: Add tab field for the custom teaser. Currently, width is set to zero for teaser editor... need to debug. --- app/views/admin/blog/posts/_form.html.erb | 8 ++++++++ app/views/admin/blog/posts/_teaser_part.html.erb | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 app/views/admin/blog/posts/_teaser_part.html.erb (limited to 'app') diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb index abff4f2..4eb4cf4 100644 --- a/app/views/admin/blog/posts/_form.html.erb +++ b/app/views/admin/blog/posts/_form.html.erb @@ -16,6 +16,9 @@
  • <%= link_to "Body", "#page_part_body" %>
  • +
  • + <%= link_to "Teaser", "#page_part_teaser" %> +
  • <% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
  • <%= link_to tab.name.titleize, "#custom_tab_#{tab_index}" %> @@ -31,6 +34,11 @@ :f => f, :part_index => (part_index += 1), } -%> + <%= render :partial => 'teaser_part', + :locals => { + :f => f, + :part_index => (part_index += 1), + } -%> <% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
    <%= render :partial => tab.partial, :locals => {:f => f} %> diff --git a/app/views/admin/blog/posts/_teaser_part.html.erb b/app/views/admin/blog/posts/_teaser_part.html.erb new file mode 100644 index 0000000..22711a9 --- /dev/null +++ b/app/views/admin/blog/posts/_teaser_part.html.erb @@ -0,0 +1,4 @@ +
    + <%= f.text_area :custom_teaser, :rows => 20, :class => 'wymeditor widest' -%> +
    + -- cgit v1.2.3 From 6086e618c34aee1db1c43866539b6a3b1ccdc40f Mon Sep 17 00:00:00 2001 From: Kyle Wilkinson Date: Tue, 21 Jun 2011 02:49:28 -0700 Subject: Add helper for finding the teaser to display for a blog post. Use this when displaying short version of blog posts. --- app/helpers/blog_posts_helper.rb | 12 ++++++++++++ app/views/blog/shared/_post.html.erb | 4 +--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb index 6b4066a..1922862 100644 --- a/app/helpers/blog_posts_helper.rb +++ b/app/helpers/blog_posts_helper.rb @@ -41,4 +41,16 @@ module BlogPostsHelper def next_or_previous?(post) post.next.present? or post.prev.present? end + + def blog_post_teaser(post) + if post.custom_teaser.present? + post.custom_teaser.html_safe + else + truncate( + post.body, + :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250), + :preserve_html_tags => true + ) + end + end end diff --git a/app/views/blog/shared/_post.html.erb b/app/views/blog/shared/_post.html.erb index e3ce714..3b91930 100644 --- a/app/views/blog/shared/_post.html.erb +++ b/app/views/blog/shared/_post.html.erb @@ -21,9 +21,7 @@
    - <%= truncate(post.body, - :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250), - :preserve_html_tags => true) %> + <%= blog_post_teaser(post) %>