aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/blog/posts_controller.rb34
-rw-r--r--app/helpers/blog_posts_helper.rb4
-rw-r--r--app/models/blog_comment.rb23
-rw-r--r--app/models/blog_post.rb30
-rw-r--r--app/views/admin/blog/_submenu.html.erb15
-rw-r--r--app/views/admin/blog/comments/show.html.erb7
-rw-r--r--app/views/admin/blog/posts/_form.css.erb7
-rw-r--r--app/views/admin/blog/posts/_form.html.erb30
-rw-r--r--app/views/admin/blog/posts/_form.js.erb13
-rw-r--r--app/views/blog/categories/show.html.erb2
-rw-r--r--app/views/blog/posts/_nav.html.erb13
-rw-r--r--app/views/blog/posts/_post.html.erb33
-rw-r--r--app/views/blog/posts/archive.html.erb2
-rw-r--r--app/views/blog/posts/index.html.erb2
-rw-r--r--app/views/blog/posts/show.html.erb54
15 files changed, 182 insertions, 87 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index 071bc68..95ccbbe 100644
--- a/app/controllers/blog/posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -1,19 +1,32 @@
class Blog::PostsController < BlogController
- before_filter :find_page
before_filter :find_all_blog_posts, :except => [:archive]
- before_filter :find_blog_post, :only => [:show, :comment]
+ before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
+
+ respond_to :html, :js, :rss if Rails.version >= '3.0.0'
def index
- respond_to do |format|
- format.html
- format.rss
+ if Rails.version < '3.0.0'
+ # TODO: respond_to block
+ else
+ respond_with (@blog_posts) do |format|
+ format.html
+ format.rss
+ end
end
end
def show
@blog_comment = BlogComment.new
- present(@page)
+
+ if Rails.version < '3.0.0'
+ # TODO: respond_to block
+ else
+ respond_with (@blog_post) do |format|
+ format.html { present(@page) }
+ format.js { render :partial => 'post', :layout => false }
+ end
+ end
end
def comment
@@ -50,6 +63,11 @@ class Blog::PostsController < BlogController
:page => params[:page],
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
})
+ if Rails.version < '3.0.0'
+ # TODO: respond_to block
+ else
+ respond_with (@blog_posts)
+ end
end
protected
@@ -64,9 +82,5 @@ protected
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
})
end
-
- def find_page
- @page = Page.find_by_link_url('/blog')
- end
end
diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb
index fb90e94..a74ec33 100644
--- a/app/helpers/blog_posts_helper.rb
+++ b/app/helpers/blog_posts_helper.rb
@@ -19,4 +19,8 @@ module BlogPostsHelper
html += '</nav></section>'
html.html_safe
end
+
+ def next_or_previous?(post)
+ post.next.present? or post.prev.present?
+ end
end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index b888e35..9b84ece 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -60,11 +60,16 @@ class BlogComment < ActiveRecord::Base
end
def toggle!
- RefinerySetting[:comment_moderation] = {
- :value => !self.enabled?,
+ new_value = {
+ :value => !BlogComment::Moderation.enabled?,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_moderation, new_value)
+ else
+ RefinerySetting[:comment_moderation] = new_value
+ end
end
end
end
@@ -80,11 +85,16 @@ class BlogComment < ActiveRecord::Base
end
def recipients=(emails)
- RefinerySetting[:comment_notification_recipients] = {
+ new_value = {
:value => emails,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_notification_recipients, new_value)
+ else
+ RefinerySetting[:comment_notification_recipients] = new_value
+ end
end
def subject
@@ -95,11 +105,16 @@ class BlogComment < ActiveRecord::Base
end
def subject=(subject_line)
- RefinerySetting[:comment_notification_subject] = {
+ new_value = {
:value => subject_line,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_notification_subject, new_value)
+ else
+ RefinerySetting[:comment_notification_subject] = new_value
+ end
end
end
end
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb
index 562a9b9..471be72 100644
--- a/app/models/blog_post.rb
+++ b/app/models/blog_post.rb
@@ -9,27 +9,41 @@ class BlogPost < ActiveRecord::Base
validates_uniqueness_of :title
has_friendly_id :title, :use_slug => true
-
- default_scope :order => "published_at DESC"
if Rails.version < '3.0.0'
- named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]} }
+ named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month], :order => "published_at DESC"} }
else
scope :by_archive, lambda { |archive_date|
- where ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]
+ where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]).order("published_at DESC")
}
end
if Rails.version < '3.0.0'
- named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month]
+ named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month], :order => "published_at DESC"
else
- scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month])
+ scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month]).order("published_at DESC")
end
if Rails.version < '3.0.0'
- named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false]} }
+ named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false], :order => "published_at DESC"} }
+ else
+ scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false).order("published_at DESC") }
+ end
+
+ if Rails.version < '3.0.0'
+ named_scope :previous, lambda { |i| { :conditions => ["published_at < ?", i.published_at], :order => "published_at DESC", :limit => 1 } }
+ named_scope :next, lambda { |i| { :condtions => ["published_at > ?", i.published_at], :order => "published_at ASC", :limit => 1 } }
else
- scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false) }
+ scope :previous, lambda { |i| where(["published_at < ?", i.published_at]).order("published_at DESC").limit(1) }
+ scope :next, lambda { |i| where(["published_at > ?", i.published_at]).order("published_at ASC").limit(1) }
+ end
+
+ def next
+ self.class.next(self).first
+ end
+
+ def prev
+ self.class.previous(self).first
end
def live?
diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb
index c7da051..a966f5b 100644
--- a/app/views/admin/blog/_submenu.html.erb
+++ b/app/views/admin/blog/_submenu.html.erb
@@ -78,9 +78,12 @@
</ul>
</nav>
-<% content_for :head do %>
- <%= stylesheet_link_tag 'refinery/refinerycms-blog' %>
-<% end %>
-<% content_for :javascripts do %>
- <%= javascript_include_tag 'refinery/refinerycms-blog' %>
-<% end %>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head do %>
+ <%= stylesheet_link_tag('refinery/refinerycms-blog') %>
+ <%# this javascript is not even required in >= 0.9.9 because we made this sort of menu core. %>
+ <%= javascript_link_tag('refinery/refinerycms-blog') %>
+ <% end %>
+<% else %>
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog')%>
+<% end %> \ No newline at end of file
diff --git a/app/views/admin/blog/comments/show.html.erb b/app/views/admin/blog/comments/show.html.erb
index 21cb405..82a5f6f 100644
--- a/app/views/admin/blog/comments/show.html.erb
+++ b/app/views/admin/blog/comments/show.html.erb
@@ -59,5 +59,8 @@
</tr>
</table>
</div>
-
-<% content_for :head, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% else %>
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% end %> \ No newline at end of file
diff --git a/app/views/admin/blog/posts/_form.css.erb b/app/views/admin/blog/posts/_form.css.erb
new file mode 100644
index 0000000..d6f2c20
--- /dev/null
+++ b/app/views/admin/blog/posts/_form.css.erb
@@ -0,0 +1,7 @@
+<style type='text/css'>
+ ul.blog_categories, ul.blog_categories li {
+ list-style: none;
+ margin: 0px;
+ padding: 0px;
+ }
+</style> \ No newline at end of file
diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb
index 692dafa..5779e4c 100644
--- a/app/views/admin/blog/posts/_form.html.erb
+++ b/app/views/admin/blog/posts/_form.html.erb
@@ -57,27 +57,13 @@
:delete_title => t('admin.blog.posts.post.delete')
} %>
<% end -%>
-<% content_for :head do %>
- <style type='text/css'>
- ul.blog_categories, ul.blog_categories li {
- list-style: none;
- margin: 0px;
- padding: 0px;
- }
- </style>
-<% end %>
-<% content_for :javascripts do %>
- <script type='text/javascript'>
- $(document).ready(function(){
- $('#toggle_advanced_options').click(function(e){
- e.preventDefault();
-
- $('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
- $('html,body').animate({
- scrollTop: $('#toggle_advanced_options').parent().offset().top
- }, 250);
- });
- });
- </script>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head do %>
+ <%= render :partial => 'form.css' %>
+ <%= render :partial => 'form.js' %>
+ <% end %>
+<% else %>
+ <% content_for :stylesheets, render(:partial => 'form.css') -%>
+ <% content_for :javascripts, render(:partial => 'form.js') -%>
<% end %>
diff --git a/app/views/admin/blog/posts/_form.js.erb b/app/views/admin/blog/posts/_form.js.erb
new file mode 100644
index 0000000..394975f
--- /dev/null
+++ b/app/views/admin/blog/posts/_form.js.erb
@@ -0,0 +1,13 @@
+<script>
+ $(document).ready(function(){
+ $('#toggle_advanced_options').click(function(e){
+ e.preventDefault();
+
+ $('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
+
+ $('html,body').animate({
+ scrollTop: $('#toggle_advanced_options').parent().offset().top
+ }, 250);
+ });
+ });
+</script> \ No newline at end of file
diff --git a/app/views/blog/categories/show.html.erb b/app/views/blog/categories/show.html.erb
index 3b4a966..54b5169 100644
--- a/app/views/blog/categories/show.html.erb
+++ b/app/views/blog/categories/show.html.erb
@@ -17,4 +17,4 @@
<% end %>
<%= render :partial => "/shared/content_page" %>
-<% content_for :head, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
+<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
diff --git a/app/views/blog/posts/_nav.html.erb b/app/views/blog/posts/_nav.html.erb
new file mode 100644
index 0000000..309cd64
--- /dev/null
+++ b/app/views/blog/posts/_nav.html.erb
@@ -0,0 +1,13 @@
+<% if next_or_previous?(@blog_post) -%>
+ <nav id="next_prev_article">
+ <% if @blog_post.next.present? -%>
+ <%= link_to raw(truncate(@blog_post.next.title) + "&nbsp;&#187;"), @blog_post.next, :class => 'next', :"data-nav-url" => update_blog_nav_path(@blog_post.next) %>
+ <% end -%>
+
+ <%= link_to 'Blog Home', blog_root_path, :class => 'home' %>
+
+ <% if @blog_post.prev.present? -%>
+ <%= link_to "&#171;&nbsp;".html_safe + truncate(@blog_post.prev.title), @blog_post.prev, :class => 'prev', :"data-nav-url" => update_blog_nav_path(@blog_post.prev) %>
+ <% end -%>
+ </nav><!-- /next_prev_article -->
+<% end -%> \ No newline at end of file
diff --git a/app/views/blog/posts/_post.html.erb b/app/views/blog/posts/_post.html.erb
new file mode 100644
index 0000000..3af89a8
--- /dev/null
+++ b/app/views/blog/posts/_post.html.erb
@@ -0,0 +1,33 @@
+<% flash.each do |key, value| %>
+ <div id='flash' class="flash flash_<%= key %>">
+ <%= value %>
+ </div>
+<% end %>
+<article id="blog_post">
+ <header>
+ <h1><%= @blog_post.title %></h1>
+ <details>
+ <time datetime="<%= @blog_post.published_at.strftime('%Y-%m-%d') %>" class='posted_at'>
+ <%= t('blog.shared.posts.created_at', :when => @blog_post.published_at.strftime('%d %B %Y')) %>.
+ </time>
+ <% if (categories = @blog_post.categories).any? %>
+ <aside class='filed_in'>
+ <%= t('.filed_in') %>
+ <% categories.each_with_index do |category, index| %>
+ <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
+ <% end %>
+ </aside>
+ <% end %>
+ </details>
+ </header>
+ <%= @blog_post.body.html_safe %>
+
+ <% if BlogPost::ShareThis.enabled? %>
+ <span class="st_sharethis" displayText="ShareThis"></span>
+ <% end %>
+</article>
+<% if next_or_previous?(@blog_post) -%>
+ <nav id="next_prev_article">
+ <%= render 'nav' %>
+ </nav><!-- /next_prev_article -->
+<% end -%> \ No newline at end of file
diff --git a/app/views/blog/posts/archive.html.erb b/app/views/blog/posts/archive.html.erb
index 8283f0a..a5354ab 100644
--- a/app/views/blog/posts/archive.html.erb
+++ b/app/views/blog/posts/archive.html.erb
@@ -16,4 +16,4 @@
<% end %>
<%= render :partial => "/shared/content_page" %>
-<% content_for :head, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
+<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
diff --git a/app/views/blog/posts/index.html.erb b/app/views/blog/posts/index.html.erb
index 9e63ac2..1d054e1 100644
--- a/app/views/blog/posts/index.html.erb
+++ b/app/views/blog/posts/index.html.erb
@@ -17,4 +17,4 @@
<% end %>
<%= render :partial => "/shared/content_page" %>
-<% content_for :head, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
+<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %> \ No newline at end of file
diff --git a/app/views/blog/posts/show.html.erb b/app/views/blog/posts/show.html.erb
index d959956..603a44f 100644
--- a/app/views/blog/posts/show.html.erb
+++ b/app/views/blog/posts/show.html.erb
@@ -1,36 +1,8 @@
-<% content_for :javascripts do %>
- <% if BlogPost::ShareThis.enabled? %>
- <script src="http://w.sharethis.com/button/buttons.js"></script>
- <script>
- stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});
- </script>
- <% end %>
-<% end %>
-
<% content_for :body_content_left do %>
- <article class="blog_post" id="show_blog_post">
- <header>
- <h1><%= @blog_post.title %></h1>
- <details>
- <time datetime="<%= @blog_post.published_at.strftime('%Y-%m-%d') %>" class='posted_at'>
- <%= t('blog.shared.posts.created_at', :when => @blog_post.published_at.strftime('%d %B %Y')) %>.
- </time>
- <% if (categories = @blog_post.categories).any? %>
- <aside class='filed_in'>
- <%= t('.filed_in') %>
- <% categories.each_with_index do |category, index| %>
- <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
- <% end %>
- </aside>
- <% end %>
- </details>
- </header>
- <%= @blog_post.body.html_safe %>
+ <div id="show_blog_post">
+ <%= render 'post' %>
+ </div>
- <% if BlogPost::ShareThis.enabled? %>
- <span class="st_sharethis" displayText="ShareThis"></span>
- <% end %>
- </article>
<% if BlogPost.comments_allowed? %>
<aside id="comments">
<h2><%= t('.comments.title') %></h2>
@@ -92,4 +64,22 @@
<% end %>
<%= render :partial => "/shared/content_page", :locals => { :remove_automatic_sections => true } %>
-<% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
+
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head_libraries, jquery_include_tags(:jquery_ui => false) %>
+ <% content_for :head do %>
+ <%= stylesheet_link_tag 'refinerycms-blog' %>
+ <%= javascript_include_tag('refinerycms-blog') %>
+ <% if BlogPost::ShareThis.enabled? %>
+ <script src="http://w.sharethis.com/button/buttons.js"></script>
+ <script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
+ <% end %>
+<% else %>
+ <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
+ <% content_for :before_javascript_libraries, jquery_include_tags(:jquery_ui => false) %>
+ <% content_for :javascripts do %>
+ <%= javascript_include_tag 'refinerycms-blog' %>
+ <script src="http://w.sharethis.com/button/buttons.js"></script>
+ <script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
+ <% end if BlogPost::ShareThis.enabled? %>
+<% end %> \ No newline at end of file