Added support for new code in Refinery CMS since resolve/refinerycms#1234

This commit is contained in:
Philip Arndt 2012-02-01 16:34:06 +13:00
parent 30ebf2d338
commit 33bfa4dd23
35 changed files with 182 additions and 197 deletions

View file

@ -2,7 +2,7 @@ module Refinery
module Blog module Blog
module Admin module Admin
class CommentsController < ::Refinery::AdminController class CommentsController < ::Refinery::AdminController
cache_sweeper Refinery::BlogSweeper cache_sweeper Refinery::BlogSweeper
crudify :'refinery/blog/comment', crudify :'refinery/blog/comment',
@ -11,35 +11,35 @@ module Refinery
def index def index
@comments = Refinery::Blog::Comment.unmoderated.page(params[:page]) @comments = Refinery::Blog::Comment.unmoderated.page(params[:page])
render :action => 'index' render :action => 'index'
end end
def approved def approved
unless params[:id].present? unless params[:id].present?
@comments = Refinery::Blog::Comment.approved.page(params[:page]) @comments = Refinery::Blog::Comment.approved.page(params[:page])
render :action => 'index' render :action => 'index'
else else
@comment = Refinery::Blog::Comment.find(params[:id]) @comment = Refinery::Blog::Comment.find(params[:id])
@comment.approve! @comment.approve!
flash[:notice] = t('approved', :scope => 'refinery.blog.admin.comments', :author => @comment.name) flash[:notice] = t('approved', :scope => 'refinery.blog.admin.comments', :author => @comment.name)
redirect_to main_app.url_for(:action => params[:return_to] || 'index') redirect_to refinery.url_for(:action => params[:return_to] || 'index', :id => nil)
end end
end end
def rejected def rejected
unless params[:id].present? unless params[:id].present?
@comments = Refinery::Blog::Comment.rejected.page(params[:page]) @comments = Refinery::Blog::Comment.rejected.page(params[:page])
render :action => 'index' render :action => 'index'
else else
@comment = Refinery::Blog::Comment.find(params[:id]) @comment = Refinery::Blog::Comment.find(params[:id])
@comment.reject! @comment.reject!
flash[:notice] = t('rejected', :scope => 'refinery.blog.admin.comments', :author => @comment.name) flash[:notice] = t('rejected', :scope => 'refinery.blog.admin.comments', :author => @comment.name)
redirect_to main_app.url_for(:action => params[:return_to] || 'index') redirect_to refinery.url_for(:action => params[:return_to] || 'index', :id => nil)
end end
end end

View file

@ -8,7 +8,7 @@ module Refinery
crudify :'refinery/blog/post', crudify :'refinery/blog/post',
:title_attribute => :title, :title_attribute => :title,
:order => 'published_at DESC', :order => 'published_at DESC',
:redirect_to_url => "main_app.refinery_blog_admin_posts_path" :redirect_to_url => "refinery.blog_admin_posts_path"
before_filter :find_all_categories, before_filter :find_all_categories,
:only => [:new, :edit, :create, :update] :only => [:new, :edit, :create, :update]
@ -54,7 +54,7 @@ module Refinery
unless from_dialog? unless from_dialog?
unless params[:continue_editing] =~ /true|on|1/ unless params[:continue_editing] =~ /true|on|1/
redirect_back_or_default(main_app.refinery_blog_admin_posts_path) redirect_back_or_default(refinery.blog_admin_posts_path)
else else
unless request.xhr? unless request.xhr?
redirect_to :back redirect_to :back
@ -63,7 +63,7 @@ module Refinery
end end
end end
else else
render :text => "<script>parent.window.location = '#{main_app.refinery_blog_admin_posts_url}';</script>" render :text => "<script>parent.window.location = '#{refinery.blog_admin_posts_url}';</script>"
end end
else else
unless request.xhr? unless request.xhr?

View file

@ -11,9 +11,9 @@ module Refinery
flash[:notice] = t('updated', :scope => 'admin.blog.settings.notification_recipients', flash[:notice] = t('updated', :scope => 'admin.blog.settings.notification_recipients',
:recipients => Refinery::Blog::Comment::Notification.recipients) :recipients => Refinery::Blog::Comment::Notification.recipients)
unless request.xhr? or from_dialog? unless request.xhr? or from_dialog?
redirect_back_or_default(main_app.refinery_blog_admin_posts_path) redirect_back_or_default(refinery.blog_admin_posts_path)
else else
render :text => "<script type='text/javascript'>parent.window.location = '#{main_app.refinery_blog_admin_posts_path}';</script>", render :text => "<script type='text/javascript'>parent.window.location = '#{refinery.blog_admin_posts_path}';</script>",
:layout => false :layout => false
end end
end end
@ -22,7 +22,7 @@ module Refinery
def moderation def moderation
enabled = Refinery::Blog::Comment::Moderation.toggle! enabled = Refinery::Blog::Comment::Moderation.toggle!
unless request.xhr? unless request.xhr?
redirect_back_or_default(main_app.refinery_blog_admin_posts_path) redirect_back_or_default(refinery.blog_admin_posts_path)
else else
render :json => {:enabled => enabled}, render :json => {:enabled => enabled},
:layout => false :layout => false
@ -32,7 +32,7 @@ module Refinery
def comments def comments
enabled = Refinery::Blog::Comment.toggle! enabled = Refinery::Blog::Comment.toggle!
unless request.xhr? unless request.xhr?
redirect_back_or_default(main_app.refinery_blog_admin_posts_path) redirect_back_or_default(refinery.blog_admin_posts_path)
else else
render :json => {:enabled => enabled}, render :json => {:enabled => enabled},
:layout => false :layout => false
@ -42,7 +42,7 @@ module Refinery
def teasers def teasers
enabled = Refinery::Blog::Post.teaser_enabled_toggle! enabled = Refinery::Blog::Post.teaser_enabled_toggle!
unless request.xhr? unless request.xhr?
redirect_back_or_default(main_app.refinery_blog_admin_posts_path) redirect_back_or_default(refinery.blog_admin_posts_path)
else else
render :json => {:enabled => enabled}, render :json => {:enabled => enabled},
:layout => false :layout => false

View file

@ -42,10 +42,10 @@ module Refinery
if Comment::Moderation.enabled? if Comment::Moderation.enabled?
flash[:notice] = t('thank_you_moderated', :scope => 'refinery.blog.posts.comments') flash[:notice] = t('thank_you_moderated', :scope => 'refinery.blog.posts.comments')
redirect_to main_app.refinery_blog_post_url(params[:id]) redirect_to refinery.blog_post_url(params[:id])
else else
flash[:notice] = t('thank_you', :scope => 'refinery.blog.posts.comments') flash[:notice] = t('thank_you', :scope => 'refinery.blog.posts.comments')
redirect_to main_app.refinery_blog_post_url(params[:id], redirect_to refinery.blog_post_url(params[:id],
:anchor => "comment-#{@comment.to_param}") :anchor => "comment-#{@comment.to_param}")
end end
else else

View file

@ -36,14 +36,14 @@ module Refinery
count = Blog::Post.by_archive(Time.parse(post_date)).size count = Blog::Post.by_archive(Time.parse(post_date)).size
text = t("date.month_names")[month.to_i] + " #{year} (#{count})" text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
link_to(text, main_app.refinery_blog_archive_posts_path(:year => year, :month => month)) link_to(text, refinery.blog_archive_posts_path(:year => year, :month => month))
else else
post_date = post.published_at.strftime('01/%Y') post_date = post.published_at.strftime('01/%Y')
year = post_date.split('/')[1] year = post_date.split('/')[1]
count = Refinery::Blog::Post.by_year(Time.parse(post_date)).size count = Refinery::Blog::Post.by_year(Time.parse(post_date)).size
text = "#{year} (#{count})" text = "#{year} (#{count})"
link_to(text, main_app.refinery_blog_archive_posts_path(:year => year)) link_to(text, refinery.blog_archive_posts_path(:year => year))
end end
end end
end end

View file

@ -3,7 +3,7 @@
<li class='not_a_link'> <li class='not_a_link'>
<%= render :partial => "/refinery/admin/search", <%= render :partial => "/refinery/admin/search",
:locals => { :locals => {
:url => main_app.refinery_blog_admin_posts_path :url => refinery.blog_admin_posts_path
} %> } %>
</li> </li>
</ul> </ul>
@ -14,15 +14,15 @@
:class => 'page_copy_icon' %> :class => 'page_copy_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.posts.manage'), main_app.refinery_blog_admin_posts_path, <%= link_to t('.posts.manage'), refinery.blog_admin_posts_path,
:class => 'page_icon' %> :class => 'page_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.posts.uncategorized'), main_app.uncategorized_refinery_blog_admin_posts_path, <%= link_to t('.posts.uncategorized'), refinery.uncategorized_blog_admin_posts_path,
:class => 'page_icon' %> :class => 'page_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.posts.new'), main_app.new_refinery_blog_admin_post_path, <%= link_to t('.posts.new'), refinery.new_blog_admin_post_path,
:class => 'page_add_icon' %> :class => 'page_add_icon' %>
</li> </li>
</ul> </ul>
@ -38,15 +38,15 @@
:class => 'comments_icon' %> :class => 'comments_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.comments.new'), main_app.refinery_blog_admin_comments_path, <%= link_to t('.comments.new'), refinery.blog_admin_comments_path,
:class => 'comment_icon' %> :class => 'comment_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.comments.approved'), main_app.approved_refinery_blog_admin_comments_path, <%= link_to t('.comments.approved'), refinery.approved_blog_admin_comments_path,
:class => 'comment_tick_icon' %> :class => 'comment_tick_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.comments.rejected'), main_app.rejected_refinery_blog_admin_comments_path, <%= link_to t('.comments.rejected'), refinery.rejected_blog_admin_comments_path,
:class => 'comment_cross_icon' %> :class => 'comment_cross_icon' %>
</li> </li>
</ul> </ul>
@ -58,36 +58,36 @@
:class => 'folder_icon' %> :class => 'folder_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.categories.manage'), main_app.refinery_blog_admin_categories_path, <%= link_to t('.categories.manage'), refinery.blog_admin_categories_path,
:class => 'folder_edit_icon' %> :class => 'folder_edit_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.categories.new'), main_app.new_refinery_blog_admin_category_path(:dialog => true, :height => 325), <%= link_to t('.categories.new'), refinery.new_blog_admin_category_path(:dialog => true, :height => 325),
:class => 'folder_add_icon' %> :class => 'folder_add_icon' %>
</li> </li>
</ul> </ul>
<ul class='collapsible_menu'> <ul class='collapsible_menu'>
<li class='not_a_link'> <li class='not_a_link'>
<%= link_to t('.settings.title'), main_app.refinery_blog_admin_settings_path, <%= link_to t('.settings.title'), refinery.blog_admin_settings_path,
:class => 'settings_icon' %> :class => 'settings_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.settings.comments'), main_app.comments_refinery_blog_admin_settings_path, <%= link_to t('.settings.comments'), refinery.comments_blog_admin_settings_path,
:class => "#{Refinery::Blog::Post.comments_allowed? ? 'success' : 'failure'}_icon" %> :class => "#{Refinery::Blog::Post.comments_allowed? ? 'success' : 'failure'}_icon" %>
</li> </li>
<li> <li>
<%= link_to t('.settings.moderation'), main_app.moderation_refinery_blog_admin_settings_path, <%= link_to t('.settings.moderation'), refinery.moderation_blog_admin_settings_path,
:class => "#{Refinery::Blog::Comment::Moderation.enabled? ? 'success' : 'failure'}_icon" %> :class => "#{Refinery::Blog::Comment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
</li> </li>
<li> <li>
<%= link_to t('.settings.update_notified'), <%= link_to t('.settings.update_notified'),
main_app.notification_recipients_refinery_blog_admin_settings_path(:dialog => true, :height => 400), refinery.notification_recipients_blog_admin_settings_path(:dialog => true, :height => 400),
:class => 'user_comment_icon' %> :class => 'user_comment_icon' %>
</li> </li>
<li> <li>
<%= link_to t('.settings.teasers'), <%= link_to t('.settings.teasers'),
main_app.teasers_refinery_blog_admin_settings_path, :class => "#{Refinery::Blog::Post.teasers_enabled? ? 'success' : 'failure'}_icon" %> refinery.teasers_blog_admin_settings_path, :class => "#{Refinery::Blog::Post.teasers_enabled? ? 'success' : 'failure'}_icon" %>
</li> </li>
</ul> </ul>

View file

@ -5,11 +5,11 @@
</span> </span>
<span class='actions'> <span class='actions'>
<%= link_to refinery_icon_tag("application_edit.png"), <%= link_to refinery_icon_tag("application_edit.png"),
main_app.edit_refinery_blog_admin_category_path(category, refinery.edit_blog_admin_category_path(category,
:dialog => true, :dialog => true,
:height => 325), :height => 325),
:title => t('.edit') %> :title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), main_app.refinery_blog_admin_category_path(category), <%= link_to refinery_icon_tag("delete.png"), refinery.blog_admin_category_path(category),
:class => "cancel confirm-delete", :class => "cancel confirm-delete",
:title => t('.delete'), :title => t('.delete'),
:method => :delete, :method => :delete,

View file

@ -1,4 +1,4 @@
<%= form_for [main_app, :refinery_blog_admin, @category] do |f| -%> <%= form_for [refinery, :blog_admin, @category] do |f| -%>
<%= render :partial => "/refinery/admin/error_messages", <%= render :partial => "/refinery/admin/error_messages",
:locals => { :locals => {
:object => f.object, :object => f.object,

View file

@ -5,16 +5,16 @@
</span> </span>
<span class='actions'> <span class='actions'>
<%= link_to refinery_icon_tag("application_go.png"), <%= link_to refinery_icon_tag("application_go.png"),
main_app.refinery_blog_post_path(comment.post, :anchor => "comment-#{comment.to_param}"), refinery.blog_post_path(comment.post, :anchor => "comment-#{comment.to_param}"),
:title => t('.view_live_html'), :title => t('.view_live_html'),
:target => "_blank" unless comment.unmoderated? %> :target => "_blank" unless comment.unmoderated? %>
<%= link_to refinery_icon_tag('zoom.png'), main_app.refinery_blog_admin_comment_path(comment), <%= link_to refinery_icon_tag('zoom.png'), refinery.blog_admin_comment_path(comment),
:title => t('.read') %> :title => t('.read') %>
<%= link_to refinery_icon_tag("cross.png"), <%= link_to refinery_icon_tag("cross.png"),
main_app.rejected_refinery_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')), refinery.rejected_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
:title => t('.reject') unless comment.rejected? %> :title => t('.reject') unless comment.rejected? %>
<%= link_to refinery_icon_tag("tick.png"), <%= link_to refinery_icon_tag("tick.png"),
main_app.approved_refinery_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')), refinery.approved_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
:title => t('.approve') unless comment.approved? %> :title => t('.approve') unless comment.approved? %>
</span> </span>
</li> </li>

View file

@ -23,8 +23,7 @@
<%= will_paginate @comments %> <%= will_paginate @comments %>
<% else %> <% else %>
<h3> <h3>
<%= t('.no_items_yet', <%= t('.no_items_yet', :type => action_name.gsub('index', 'new').downcase) %>
:type => action_name.gsub('index', 'new')).downcase %>
</h3> </h3>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -6,14 +6,14 @@
<h2><%= t('.actions') %></h2> <h2><%= t('.actions') %></h2>
<ul> <ul>
<li> <li>
<%= link_to t('.back'), main_app.refinery_blog_admin_comments_path, :class => "back_icon" %> <%= link_to t('.back'), refinery.blog_admin_comments_path, :class => "back_icon" %>
</li> </li>
<li> <li>
<%= link_to t('.reject'), main_app.rejected_refinery_blog_admin_comment_path(@comment, :return_to => 'rejected'), <%= link_to t('.reject'), refinery.rejected_blog_admin_comment_path(@comment, :return_to => 'rejected'),
:class => 'comment_cross_icon' unless @comment.rejected? %> :class => 'comment_cross_icon' unless @comment.rejected? %>
</li> </li>
<li> <li>
<%= link_to t('.approve'), main_app.approved_refinery_blog_admin_comment_path(@comment, :return_to => 'approved'), <%= link_to t('.approve'), refinery.approved_blog_admin_comment_path(@comment, :return_to => 'approved'),
:class => 'comment_tick_icon' unless @comment.approved? %> :class => 'comment_tick_icon' unless @comment.approved? %>
</li> </li>
</ul> </ul>
@ -27,7 +27,7 @@
</td> </td>
<td> <td>
<%= link_to @comment.post.title, <%= link_to @comment.post.title,
main_app.refinery_blog_post_path(@comment.post, :anchor => "comment-#{@comment.to_param}"), refinery.blog_post_path(@comment.post, :anchor => "comment-#{@comment.to_param}"),
:target => '_blank' %> :target => '_blank' %>
</td> </td>
</tr> </tr>

View file

@ -1,4 +1,4 @@
<%= form_for [main_app, :refinery_blog_admin, @post] do |f| -%> <%= form_for [refinery, :blog_admin, @post] do |f| -%>
<%= render :partial => "/refinery/admin/error_messages", <%= render :partial => "/refinery/admin/error_messages",
:locals => { :locals => {
:object => f.object, :object => f.object,
@ -121,4 +121,4 @@
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %> <% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %>
<% content_for :javascripts, javascript_include_tag('refinery/blog/backend') %> <% content_for :javascripts, javascript_include_tag('refinery/blog/backend') %>
<%= render 'refinery/shared/admin/autocomplete', :dom_id => '#blog_post_tag_list', :url => main_app.tags_refinery_blog_admin_posts_url %> <%= render 'refinery/shared/admin/autocomplete', :dom_id => '#blog_post_tag_list', :url => refinery.tags_blog_admin_posts_url %>

View file

@ -7,12 +7,12 @@
</span> </span>
</span> </span>
<span class='actions'> <span class='actions'>
<%= link_to refinery_icon_tag("application_go.png"), main_app.refinery_blog_post_path(post), <%= link_to refinery_icon_tag("application_go.png"), refinery.blog_post_path(post),
:title => t('.view_live_html'), :title => t('.view_live_html'),
:target => "_blank" %> :target => "_blank" %>
<%= link_to refinery_icon_tag("application_edit.png"), main_app.edit_refinery_blog_admin_post_path(post), <%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_blog_admin_post_path(post),
:title => t('.edit') %> :title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), main_app.refinery_blog_admin_post_path(post), <%= link_to refinery_icon_tag("delete.png"), refinery.blog_admin_post_path(post),
:class => "cancel confirm-delete", :class => "cancel confirm-delete",
:title => t('.delete'), :title => t('.delete'),
:method => :delete, :method => :delete,

View file

@ -1,4 +1,4 @@
<%= form_tag main_app.notification_recipients_refinery_blog_admin_settings_path do %> <%= form_tag refinery.notification_recipients_blog_admin_settings_path do %>
<div class='field'> <div class='field'>
<span class='label_with_help'> <span class='label_with_help'>
@ -18,7 +18,7 @@
:locals => { :locals => {
:f => nil, :f => nil,
:continue_editing => false, :continue_editing => false,
:cancel_url => main_app.refinery_blog_admin_posts_url, :cancel_url => refinery.blog_admin_posts_url,
:hide_delete => true :hide_delete => true
} %> } %>
<% end %> <% end %>

View file

@ -15,7 +15,7 @@
<% end %> <% end %>
<h2><%= t('add', :scope => 'refinery.blog.posts.show.comments') %></h2> <h2><%= t('add', :scope => 'refinery.blog.posts.show.comments') %></h2>
<%= form_for [main_app, :refinery_blog, @comment] do |f| %> <%= form_for [refinery, :blog, @comment] do |f| %>
<%= render :partial => "/refinery/admin/error_messages", <%= render :partial => "/refinery/admin/error_messages",
:locals => { :locals => {
:object => f.object, :object => f.object,

View file

@ -1,17 +1,17 @@
<nav id="next_prev_article"> <nav id="next_prev_article">
<% if @post.next.present? -%> <% if @post.next.present? -%>
<%= link_to (truncate(@post.next.title) + " &#187;").html_safe, <%= link_to (truncate(@post.next.title) + " &#187;").html_safe,
main_app.refinery_blog_post_path(@post.next), refinery.blog_post_path(@post.next),
:class => 'next' %> :class => 'next' %>
<% end -%> <% end -%>
<%= link_to t('blog_home', :scope => 'refinery.blog.posts.show'), <%= link_to t('blog_home', :scope => 'refinery.blog.posts.show'),
main_app.refinery_blog_root_path, refinery.blog_root_path,
:class => 'home' %> :class => 'home' %>
<% if @post.prev.present? -%> <% if @post.prev.present? -%>
<%= link_to ("&#171; " + truncate(@post.prev.title)).html_safe, <%= link_to ("&#171; " + truncate(@post.prev.title)).html_safe,
main_app.refinery_blog_post_path(@post.prev), refinery.blog_post_path(@post.prev),
:class => 'prev' %> :class => 'prev' %>
<% end -%> <% end -%>
</nav><!-- /next_prev_article --> </nav><!-- /next_prev_article -->

View file

@ -21,7 +21,7 @@
<aside class='filed_in'> <aside class='filed_in'>
<%= t('filed_in', :scope => 'refinery.blog.posts.show') %> <%= t('filed_in', :scope => 'refinery.blog.posts.show') %>
<% categories.each_with_index do |category, index| %> <% categories.each_with_index do |category, index| %>
<%= link_to category.title, main_app.refinery_blog_category_path(category) -%><%= ',' if index < ((categories.length) - 1) %> <%= link_to category.title, refinery.blog_category_path(category) -%><%= ',' if index < ((categories.length) - 1) %>
<% end %> <% end %>
</aside> </aside>
<% end %> <% end %>

View file

@ -3,14 +3,14 @@ xml.rss :version => "2.0" do
xml.channel do xml.channel do
xml.title Refinery::Core.config.site_name xml.title Refinery::Core.config.site_name
xml.description Refinery::Core.config.site_name + " Blog Posts" xml.description Refinery::Core.config.site_name + " Blog Posts"
xml.link main_app.refinery_blog_root_url xml.link refinery.blog_root_url
@posts.each do |post| @posts.each do |post|
xml.item do xml.item do
xml.title post.title xml.title post.title
xml.description post.body xml.description post.body
xml.pubDate post.published_at.to_s(:rfc822) xml.pubDate post.published_at.to_s(:rfc822)
xml.link main_app.refinery_blog_post_url(post) xml.link refinery.blog_post_url(post)
end end
end end
end end

View file

@ -3,7 +3,7 @@
<ul id='categories'> <ul id='categories'>
<% @categories.each do |category| %> <% @categories.each do |category| %>
<li<%= " class='selected'" if @category.present? and @category.id == category.id %>> <li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
<%= link_to "#{category.title} (#{category.post_count})", main_app.refinery_blog_category_path(category) %> <%= link_to "#{category.title} (#{category.post_count})", refinery.blog_category_path(category) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View file

@ -1,7 +1,7 @@
<% if post.live? %> <% if post.live? %>
<article class="blog_post" id="<%= dom_id(post) %>"> <article class="blog_post" id="<%= dom_id(post) %>">
<header> <header>
<h1><%= link_to post.title, main_app.refinery_blog_post_path(post) %></h1> <h1><%= link_to post.title, refinery.blog_post_path(post) %></h1>
<section class='details'> <section class='details'>
<time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'> <time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'>
<%= t('created_at', :scope => 'refinery.blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %> <%= t('created_at', :scope => 'refinery.blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %>
@ -10,13 +10,13 @@
<% if (categories = post.categories).any? %> <% if (categories = post.categories).any? %>
<aside class='filed_in'> <aside class='filed_in'>
<%= t('filed_in', :scope => 'refinery.blog.posts.show') %> <%= t('filed_in', :scope => 'refinery.blog.posts.show') %>
<%=raw categories.collect { |category| link_to category.title, main_app.refinery_blog_category_path(category) }.to_sentence %> <%=raw categories.collect { |category| link_to category.title, refinery.blog_category_path(category) }.to_sentence %>
</aside> </aside>
<% end %> <% end %>
<% if (tags = post.tags).any? %> <% if (tags = post.tags).any? %>
<aside class='tagged'> <aside class='tagged'>
<%= t('tagged', :scope => 'refinery.blog.posts.show') %> <%= t('tagged', :scope => 'refinery.blog.posts.show') %>
<%=raw tags.collect { |tag| link_to tag, main_app.refinery_blog_tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %> <%=raw tags.collect { |tag| link_to tag, refinery.blog_tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
</aside> </aside>
<% end %> <% end %>
</section> </section>
@ -30,7 +30,7 @@
</section> </section>
<footer> <footer>
<p> <p>
<%= link_to t('read_more', :scope => 'refinery.blog.shared.posts'), main_app.refinery_blog_post_path(post) if blog_post_teaser_enabled? %> <%= link_to t('read_more', :scope => 'refinery.blog.shared.posts'), refinery.blog_post_path(post) if blog_post_teaser_enabled? %>
</p> </p>
<aside class='comment_count'> <aside class='comment_count'>
<% if Refinery::Blog::Post.comments_allowed? %> <% if Refinery::Blog::Post.comments_allowed? %>

View file

@ -3,7 +3,7 @@
<ul id="blog_posts"> <ul id="blog_posts">
<% @posts.each do |blog_post| %> <% @posts.each do |blog_post| %>
<li class='clearfix'> <li class='clearfix'>
<%= link_to blog_post.title, main_app.refinery_blog_post_path(blog_post) %> <%= link_to blog_post.title, refinery.blog_post_path(blog_post) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View file

@ -1,2 +1,2 @@
<h2><%= t('.title') %></h2> <h2><%= t('.title') %></h2>
<%= link_to t('.subscribe'), main_app.refinery_blog_rss_feed_path, :id => "rss_feed_subscribe"%> <%= link_to t('.subscribe'), refinery.blog_rss_feed_path, :id => "rss_feed_subscribe"%>

View file

@ -2,7 +2,7 @@
<h2><%= t('.title') %></h2> <h2><%= t('.title') %></h2>
<nav id='tags'> <nav id='tags'>
<% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %> <% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
<%= link_to tag.name, main_app.refinery_blog_tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %> <%= link_to tag.name, refinery.blog_tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
<% end %> <% end %>
</nav> </nav>
<% end %> <% end %>

View file

@ -1,21 +1,19 @@
Rails.application.routes.draw do Refinery::Core::Engine.routes.draw do
namespace :refinery, :path => '' do namespace :blog, :path => '' do
namespace :blog do root :to => "posts#index"
root :to => "posts#index" resources :posts, :only => [:show]
resources :posts, :only => [:show] match 'feed.rss', :to => 'posts#index', :as => 'rss_feed', :defaults => {:format => "rss"}
match 'categories/:id', :to => 'categories#show', :as => 'category'
match ':id/comments', :to => 'posts#comment', :as => 'comments'
get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_posts'
get 'tagged/:tag_id(/:tag_name)' => 'posts#tagged', :as => 'tagged_posts'
match 'feed.rss', :to => 'posts#index', :as => 'rss_feed', :defaults => {:format => "rss"}
match 'categories/:id', :to => 'categories#show', :as => 'category'
match ':id/comments', :to => 'posts#comment', :as => 'comments'
get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_posts'
get 'tagged/:tag_id(/:tag_name)' => 'posts#tagged', :as => 'tagged_posts'
end
end end
namespace :refinery do namespace :blog, :path => '' do
namespace :blog do namespace :admin, :path => 'refinery' do
namespace :admin, :path =>'' do scope :path => 'blog' do
root :to => "posts#index" root :to => "posts#index"
resources :posts do resources :posts do

View file

@ -9,7 +9,7 @@ module Refinery
end end
it "sets the correct path for activity entries" do it "sets the correct path for activity entries" do
activity.url.should eq("edit_refinery_blog_admin_post_path") activity.url.should eq("refinery.edit_blog_admin_post_path")
end end
end end

View file

@ -6,7 +6,7 @@ describe "Categories admin" do
let(:title) { "lol" } let(:title) { "lol" }
it "can create categories" do it "can create categories" do
visit refinery_admin_root_path visit refinery.admin_root_path
within("nav#menu") { click_link "Blog" } within("nav#menu") { click_link "Blog" }
within("nav.multilist") { click_link "Create new category" } within("nav.multilist") { click_link "Create new category" }

View file

@ -5,115 +5,113 @@ module Refinery
module Admin module Admin
describe Comment do describe Comment do
login_refinery_user login_refinery_user
describe "#index" do describe "#index" do
context "when has no new unapproved comments" do context "when has no new unapproved comments" do
before(:each) do before(:each) do
subject.class.delete_all subject.class.delete_all
visit refinery_blog_admin_comments_path visit refinery.blog_admin_comments_path
end end
it "should list no comments" do it "should list no comments" do
visit refinery_blog_admin_comments_path visit refinery.blog_admin_comments_path
page.should have_content('there are no new comments') page.should have_content('There are no new comments')
end end
end end
context "when has new unapproved comments" do context "when has new unapproved comments" do
let!(:blog_comment) { FactoryGirl.create(:blog_comment) } let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
before(:each) { visit refinery_blog_admin_comments_path } before(:each) { visit refinery.blog_admin_comments_path }
it "should list comments" do it "should list comments" do
page.should have_content(blog_comment.body) page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name) page.should have_content(blog_comment.name)
end end
it "should allow me to approve a comment" do it "should allow me to approve a comment" do
click_link "Approve this comment" click_link "Approve this comment"
page.should have_content("has been approved") page.should have_content("has been approved")
end end
it "should allow me to reject a comment" do it "should allow me to reject a comment" do
click_link "Reject this comment" click_link "Reject this comment"
page.should have_content("has been rejected") page.should have_content("has been rejected")
end end
end end
end end
describe "#approved" do describe "#approved" do
context "when has no approved comments" do context "when has no approved comments" do
before(:each) do before(:each) do
subject.class.delete_all subject.class.delete_all
visit approved_refinery_blog_admin_comments_path visit refinery.approved_blog_admin_comments_path
end end
it "should list no comments" do it "should list no comments" do
page.should have_content('there are no approved comments') page.should have_content('There are no approved comments')
end end
end end
context "when has approved comments" do context "when has approved comments" do
let!(:blog_comment) do let!(:blog_comment) do
FactoryGirl.create(:blog_comment, FactoryGirl.create(:blog_comment, :state => 'approved')
:state => 'approved')
end end
before(:each) { visit approved_refinery_blog_admin_comments_path } before(:each) { visit refinery.approved_blog_admin_comments_path }
it "should list comments" do it "should list comments" do
page.should have_content(blog_comment.body) page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name) page.should have_content(blog_comment.name)
end end
it "should allow me to reject a comment" do it "should allow me to reject a comment" do
click_link "Reject this comment" click_link "Reject this comment"
page.should have_content("has been rejected") page.should have_content("has been rejected")
end end
end end
end end
describe "#rejected" do describe "#rejected" do
context "when has no rejected comments" do context "when has no rejected comments" do
before(:each) do before(:each) do
subject.class.delete_all subject.class.delete_all
visit rejected_refinery_blog_admin_comments_path visit refinery.rejected_blog_admin_comments_path
end end
it "should list no comments" do it "should list no comments" do
page.should have_content('there are no rejected comments') page.should have_content('There are no rejected comments')
end end
end end
context "when has rejected comments" do context "when has rejected comments" do
let!(:blog_comment) do let!(:blog_comment) do
FactoryGirl.create(:blog_comment, FactoryGirl.create(:blog_comment, :state => 'rejected')
:state => 'rejected')
end end
before(:each) { visit rejected_refinery_blog_admin_comments_path } before(:each) { visit refinery.rejected_blog_admin_comments_path }
it "should list comments" do it "should list comments" do
page.should have_content(blog_comment.body) page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name) page.should have_content(blog_comment.name)
end end
it "should allow me to approve a comment" do it "should allow me to approve a comment" do
click_link "Approve this comment" click_link "Approve this comment"
page.should have_content("has been approved") page.should have_content("has been approved")
end end
end end
end end
describe "#show" do describe "#show" do
let!(:blog_comment) { FactoryGirl.create(:blog_comment) } let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
before(:each) { visit refinery_blog_admin_comment_path(blog_comment) } before(:each) { visit refinery.blog_admin_comment_path(blog_comment) }
it "should display the comment" do it "should display the comment" do
page.should have_content(blog_comment.body) page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name) page.should have_content(blog_comment.name)
end end
it "should allow me to approve the comment" do it "should allow me to approve the comment" do
click_link "Approve this comment" click_link "Approve this comment"
page.should have_content("has been approved") page.should have_content("has been approved")
end end
end end

View file

@ -4,7 +4,7 @@ describe "Blog menu entry" do
login_refinery_user login_refinery_user
it "is highlighted when managing the blog" do it "is highlighted when managing the blog" do
visit refinery_admin_root_path visit refinery.admin_root_path
within("#menu") { click_link "Blog" } within("#menu") { click_link "Blog" }

View file

@ -12,7 +12,7 @@ module Refinery
before(:each) { subject.class.destroy_all } before(:each) { subject.class.destroy_all }
describe "blog post listing" do describe "blog post listing" do
before(:each) { visit refinery_blog_admin_posts_path } before(:each) { visit refinery.blog_admin_posts_path }
it "invites to create new post" do it "invites to create new post" do
page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.") page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
@ -21,7 +21,7 @@ module Refinery
describe "new blog post form" do describe "new blog post form" do
before(:each) do before(:each) do
visit refinery_blog_admin_posts_path visit refinery.blog_admin_posts_path
click_link "Create new post" click_link "Create new post"
end end
@ -53,7 +53,7 @@ module Refinery
subject.class.first.author.should eq(::Refinery::User.last) subject.class.first.author.should eq(::Refinery::User.last)
end end
it "should save categories", :focus => true do it "should save categories" do
subject.class.last.categories.count.should eq(1) subject.class.last.categories.count.should eq(1)
subject.class.last.categories.first.title.should eq(blog_category.title) subject.class.last.categories.first.title.should eq(blog_category.title)
end end
@ -87,14 +87,14 @@ module Refinery
let!(:blog_post) { FactoryGirl.create(:blog_post) } let!(:blog_post) { FactoryGirl.create(:blog_post) }
describe "blog post listing" do describe "blog post listing" do
before(:each) { visit refinery_blog_admin_posts_path } before(:each) { visit refinery.blog_admin_posts_path }
describe "edit blog post" do describe "edit blog post" do
it "should succeed" do it "should succeed" do
page.should have_content(blog_post.title) page.should have_content(blog_post.title)
click_link("Edit this blog post") click_link("Edit this blog post")
current_path.should == edit_refinery_blog_admin_post_path(blog_post) current_path.should == refinery.edit_blog_admin_post_path(blog_post)
fill_in "Title", :with => "hax0r" fill_in "Title", :with => "hax0r"
click_button "Save" click_button "Save"
@ -118,7 +118,7 @@ module Refinery
it "redirects to blog post in the frontend" do it "redirects to blog post in the frontend" do
click_link "View this blog post live" click_link "View this blog post live"
current_path.should == refinery_blog_post_path(blog_post) current_path.should == refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title) page.should have_content(blog_post.title)
end end
end end
@ -126,7 +126,7 @@ module Refinery
context "when uncategorized post" do context "when uncategorized post" do
it "shows up in the list" do it "shows up in the list" do
visit uncategorized_refinery_blog_admin_posts_path visit refinery.uncategorized_blog_admin_posts_path
page.should have_content(blog_post.title) page.should have_content(blog_post.title)
end end
end end
@ -136,7 +136,7 @@ module Refinery
blog_post.categories << blog_category blog_post.categories << blog_category
blog_post.save! blog_post.save!
visit uncategorized_refinery_blog_admin_posts_path visit refinery.uncategorized_blog_admin_posts_path
page.should_not have_content(blog_post.title) page.should_not have_content(blog_post.title)
end end
end end
@ -147,7 +147,7 @@ module Refinery
describe "create blog post with alternate author" do describe "create blog post with alternate author" do
before(:each) do before(:each) do
visit refinery_blog_admin_posts_path visit refinery.blog_admin_posts_path
click_link "Create new post" click_link "Create new post"
fill_in "Title", :with => "This is some other guy's blog post" fill_in "Title", :with => "This is some other guy's blog post"

View file

@ -13,7 +13,7 @@ module Refinery
end end
describe "show categories blog posts" do describe "show categories blog posts" do
before(:each) { visit refinery_blog_category_path(@category) } before(:each) { visit refinery.blog_category_path(@category) }
it "should displays categories blog posts" do it "should displays categories blog posts" do
page.should have_content("Refinery CMS blog post") page.should have_content("Refinery CMS blog post")
page.should have_content("Video Games") page.should have_content("Video Games")

View file

@ -8,13 +8,13 @@ module Refinery
let!(:blog_post) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") } let!(:blog_post) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") }
it "should display blog post" do it "should display blog post" do
visit refinery_blog_post_path(blog_post) visit refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title) page.should have_content(blog_post.title)
end end
it "should display the blog rss feed" do it "should display the blog rss feed" do
get refinery_blog_rss_feed_path get refinery.blog_rss_feed_path
response.should be_success response.should be_success
response.content_type.should eq("application/rss+xml") response.content_type.should eq("application/rss+xml")
@ -31,7 +31,7 @@ module Refinery
@tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first @tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
end end
it "should have one tagged post" do it "should have one tagged post" do
visit refinery_blog_tagged_posts_path(@tag.id, @tag_name.parameterize) visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
page.should have_content(@tag_name) page.should have_content(@tag_name)
page.should have_content(@post.title) page.should have_content(@post.title)
@ -44,7 +44,7 @@ module Refinery
let(:blog_post) { FactoryGirl.create(:blog_post) } let(:blog_post) { FactoryGirl.create(:blog_post) }
it "should display the blog post" do it "should display the blog post" do
visit refinery_blog_post_path(blog_post) visit refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title) page.should have_content(blog_post.title)
page.should have_content(blog_post.body) page.should have_content(blog_post.body)
end end
@ -53,7 +53,7 @@ module Refinery
let(:approved_comment) { FactoryGirl.create(:approved_comment) } let(:approved_comment) { FactoryGirl.create(:approved_comment) }
it "should display the comments" do it "should display the comments" do
visit refinery_blog_post_path(approved_comment.post) visit refinery.blog_post_path(approved_comment.post)
page.should have_content(approved_comment.body) page.should have_content(approved_comment.body)
page.should have_content("Posted by #{approved_comment.name}") page.should have_content("Posted by #{approved_comment.name}")
@ -63,7 +63,7 @@ module Refinery
let(:rejected_comment) { FactoryGirl.create(:rejected_comment) } let(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
it "should not display the comments" do it "should not display the comments" do
visit refinery_blog_post_path(rejected_comment.post) visit refinery.blog_post_path(rejected_comment.post)
page.should_not have_content(rejected_comment.body) page.should_not have_content(rejected_comment.body)
end end
@ -72,7 +72,7 @@ module Refinery
let(:blog_comment) { FactoryGirl.create(:blog_comment) } let(:blog_comment) { FactoryGirl.create(:blog_comment) }
it "should not display the comments" do it "should not display the comments" do
visit refinery_blog_post_path(blog_comment.post) visit refinery.blog_post_path(blog_comment.post)
page.should_not have_content(blog_comment.body) page.should_not have_content(blog_comment.body)
end end
@ -85,7 +85,7 @@ module Refinery
let(:body) { "Witty comment." } let(:body) { "Witty comment." }
before do before do
visit refinery_blog_post_path(blog_post) visit refinery.blog_post_path(blog_post)
fill_in "Name", :with => name fill_in "Name", :with => name
fill_in "Email", :with => email fill_in "Email", :with => email
@ -107,16 +107,16 @@ module Refinery
let(:blog_post) { FactoryGirl.create(:blog_post_draft) } let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
context "when logged in as admin" do context "when logged in as admin" do
it "should display the draft notification" do it "should display the draft notification" do
visit refinery_blog_post_path(blog_post) visit refinery.blog_post_path(blog_post)
page.should have_content('This page is NOT live for public viewing.') page.should have_content('This page is NOT live for public viewing.')
end end
end end
context "when not logged in as an admin" do context "when not logged in as an admin" do
before(:each) { visit destroy_refinery_user_session_path } before(:each) { visit refinery.destroy_refinery_user_session_path }
it "should not display the blog post" do it "should not display the blog post" do
visit refinery_blog_post_path(blog_post) visit refinery.blog_post_path(blog_post)
page.should have_content("The page you were looking for doesn't exist (404)") page.should have_content("The page you were looking for doesn't exist (404)")
end end

View file

@ -1,37 +1,58 @@
require 'rubygems' require 'rubygems'
def load_all(*patterns) def setup_environment
patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
end
def setup_environment
# Configure Rails Environment # Configure Rails Environment
ENV["RAILS_ENV"] = 'test' ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'capybara/rspec' require 'capybara/rspec'
require 'factory_girl_rails' require 'factory_girl_rails'
Rails.backtrace_cleaner.remove_silencers! Rails.backtrace_cleaner.remove_silencers!
RSpec.configure do |config| RSpec.configure do |config|
config.mock_with :rspec config.mock_with :rspec
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end end
# set javascript driver for capybara
Capybara.javascript_driver = :selenium
# minimize password hashing stretches
Devise.stretches = 1
end end
def each_run def each_run
FactoryGirl.reload
ActiveSupport::Dependencies.clear ActiveSupport::Dependencies.clear
load_all 'spec/support/**/*.rb' FactoryGirl.reload
load_all 'spec/factories/**/*.rb' if FactoryGirl.factories.none?
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories including factories.
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
}.flatten.sort.each do |support_file|
require support_file
end
end end
# If spork is available in the Gemfile it'll be used but we don't force it. # If spork is available in the Gemfile it'll be used but we don't force it.
unless (begin; require 'spork'; rescue LoadError; nil end).nil? unless (begin; require 'spork'; rescue LoadError; nil end).nil?
Spork.prefork { setup_environment } Spork.prefork do
Spork.each_run { each_run } # Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
setup_environment
end
Spork.each_run do
# This code will be run each time you run your specs.
each_run
end
else else
setup_environment setup_environment
each_run each_run

View file

@ -1,17 +0,0 @@
require 'database_cleaner'
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end

View file

@ -1,8 +0,0 @@
require 'devise'
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
config.include Devise::TestHelpers, :type => :controller
end

View file

@ -1,6 +0,0 @@
require 'refinerycms-testing'
RSpec.configure do |config|
config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller
config.extend Refinery::Testing::RequestMacros::Authentication, :type => :request
end