refinerycms-blog 1.0.rc16 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/app/controllers/blog/categories_controller.rb +2 -2
  2. data/app/controllers/blog/posts_controller.rb +23 -13
  3. data/app/controllers/blog_controller.rb +3 -2
  4. data/app/helpers/blog_posts_helper.rb +28 -0
  5. data/app/models/blog/comment_mailer.rb +1 -1
  6. data/app/models/blog_category.rb +4 -4
  7. data/app/models/blog_comment.rb +29 -20
  8. data/app/models/blog_post.rb +21 -12
  9. data/app/views/admin/blog/_submenu.html.erb +9 -4
  10. data/app/views/admin/blog/categories/_form.html.erb +3 -11
  11. data/app/views/admin/blog/categories/edit.html.erb +1 -1
  12. data/app/views/admin/blog/categories/index.html.erb +1 -1
  13. data/app/views/admin/blog/categories/new.html.erb +1 -1
  14. data/app/views/admin/blog/comments/_comment.html.erb +2 -2
  15. data/app/views/admin/blog/comments/index.html.erb +5 -5
  16. data/app/views/admin/blog/comments/show.html.erb +5 -2
  17. data/app/views/admin/blog/posts/_form.css.erb +7 -0
  18. data/app/views/admin/blog/posts/_form.html.erb +10 -30
  19. data/app/views/admin/blog/posts/_form.js.erb +13 -0
  20. data/app/views/admin/blog/posts/index.html.erb +1 -1
  21. data/app/views/blog/categories/show.html.erb +1 -1
  22. data/app/views/blog/posts/_nav.html.erb +13 -0
  23. data/app/views/blog/posts/_post.html.erb +34 -0
  24. data/app/views/blog/posts/archive.html.erb +19 -0
  25. data/app/views/blog/posts/index.html.erb +4 -1
  26. data/app/views/blog/posts/show.html.erb +28 -47
  27. data/app/views/blog/shared/_categories.html.erb +1 -1
  28. data/app/views/blog/shared/_post.html.erb +16 -6
  29. data/app/views/blog/shared/_posts.html.erb +1 -1
  30. data/app/views/blog/shared/_rss_feed.html.erb +1 -1
  31. data/config/routes.rb +26 -64
  32. data/{spec → features/support}/factories/blog_categories.rb +2 -2
  33. data/{spec → features/support}/factories/blog_comments.rb +1 -1
  34. data/{spec → features/support}/factories/blog_posts.rb +1 -1
  35. data/features/support/paths.rb +24 -0
  36. data/generators/{refinery_blog/refinery_blog_generator.rb → refinerycms_blog/refinerycms_blog_generator.rb} +4 -4
  37. data/generators/{refinery_blog → refinerycms_blog}/templates/db/migrate/migration.rb +0 -0
  38. data/generators/{refinery_blog → refinerycms_blog}/templates/db/seeds/seed.rb +0 -0
  39. data/lib/gemspec.rb +2 -2
  40. data/lib/generators/{refinery_blog → refinerycms_blog}/templates/db/migrate/migration_number_create_singular_name.rb +0 -0
  41. data/lib/generators/{refinery_blog → refinerycms_blog}/templates/db/seeds/seed.rb +0 -0
  42. data/lib/generators/{refinery_blog_generator.rb → refinerycms_blog_generator.rb} +3 -3
  43. data/lib/refinerycms-blog.rb +2 -2
  44. data/public/javascripts/refinerycms-blog.js +25 -0
  45. data/public/stylesheets/refinerycms-blog.css +72 -1
  46. data/readme.md +18 -8
  47. data/spec/models/blog_categories_spec.rb +7 -6
  48. data/spec/models/blog_comments_spec.rb +7 -6
  49. data/spec/models/blog_posts_spec.rb +2 -1
  50. metadata +25 -24
@@ -0,0 +1,13 @@
1
+ <script>
2
+ $(document).ready(function(){
3
+ $('#toggle_advanced_options').click(function(e){
4
+ e.preventDefault();
5
+
6
+ $('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
7
+
8
+ $('html,body').animate({
9
+ scrollTop: $('#toggle_advanced_options').parent().offset().top
10
+ }, 250);
11
+ });
12
+ });
13
+ </script>
@@ -27,4 +27,4 @@
27
27
  </p>
28
28
  <% end %>
29
29
  <% end %>
30
- </div>
30
+ </div>
@@ -17,4 +17,4 @@
17
17
  <% end %>
18
18
 
19
19
  <%= render :partial => "/shared/content_page" %>
20
- <% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
20
+ <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
@@ -0,0 +1,13 @@
1
+ <% if next_or_previous?(@blog_post) -%>
2
+ <nav id="next_prev_article">
3
+ <% if @blog_post.next.present? -%>
4
+ <%= link_to raw(truncate(@blog_post.next.title) + "&nbsp;&#187;"), @blog_post.next, :class => 'next' %>
5
+ <% end -%>
6
+
7
+ <%= link_to 'Blog Home', blog_root_path, :class => 'home' %>
8
+
9
+ <% if @blog_post.prev.present? -%>
10
+ <%= link_to "&#171;&nbsp;".html_safe + truncate(@blog_post.prev.title), @blog_post.prev, :class => 'prev' %>
11
+ <% end -%>
12
+ </nav><!-- /next_prev_article -->
13
+ <% end -%>
@@ -0,0 +1,34 @@
1
+ <% flash.each do |key, value| %>
2
+ <div id='flash' class="flash flash_<%= key %>">
3
+ <%= value %>
4
+ </div>
5
+ <% end %>
6
+ <article id="blog_post">
7
+ <header>
8
+ <h1><%= @blog_post.title %></h1>
9
+ <details>
10
+ <time datetime="<%= @blog_post.published_at.strftime('%Y-%m-%d') %>" class='posted_at'>
11
+ <%= t('blog.shared.posts.created_at', :when => @blog_post.published_at.strftime('%d %B %Y')) %>.
12
+ </time>
13
+ <% if (categories = @blog_post.categories).any? %>
14
+ <aside class='filed_in'>
15
+ <%= t('.filed_in') %>
16
+ <% categories.each_with_index do |category, index| %>
17
+ <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
18
+ <% end %>
19
+ </aside>
20
+ <% end %>
21
+ </details>
22
+ </header>
23
+ <%= @blog_post.body.html_safe %>
24
+
25
+ <% if BlogPost::ShareThis.enabled? %>
26
+ <span class="st_sharethis" displayText="ShareThis"></span>
27
+ <% end %>
28
+ </article>
29
+ <%= render :partial => '/shared/draft_page_message' unless @blog_post.nil? or @blog_post.live? -%>
30
+ <% if next_or_previous?(@blog_post) -%>
31
+ <nav id="next_prev_article">
32
+ <%= render 'nav' %>
33
+ </nav><!-- /next_prev_article -->
34
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ <% content_for :body_content_left do %>
2
+ <%= @page[Page.default_parts.first.to_sym] %>
3
+ <h1>Blog Archive for <%= @archive_date.strftime('%B %Y') %></h1>
4
+ <section id="blog_posts">
5
+ <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
6
+ </section>
7
+ <%= "There are no blog articles posted for #{@archive_date.strftime('%B %Y')}. Stay tuned." unless @blog_posts.any? %>
8
+ <%# TODO: Add locale logic here - hubble is a n00b at that %>
9
+ <% end %>
10
+
11
+ <% content_for :body_content_right do %>
12
+ <%= @page[Page.default_parts.second.to_sym] %>
13
+ <%= render :partial => "/blog/shared/categories" %>
14
+ <%= render :partial => "/blog/shared/rss_feed" %>
15
+ <%= blog_archive_list %>
16
+ <% end %>
17
+
18
+ <%= render :partial => "/shared/content_page" %>
19
+ <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
@@ -4,6 +4,8 @@
4
4
  <section id="blog_posts">
5
5
  <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
6
6
  </section>
7
+ <%= "<p>There are no blog articles posted yet. Stay tuned.</p>".html_safe unless @blog_posts.any? %>
8
+ <%# TODO: Add locale logic here - hubble is a n00b at that %>
7
9
  <% end %>
8
10
 
9
11
  <% content_for :body_content_right do %>
@@ -11,7 +13,8 @@
11
13
 
12
14
  <%= render :partial => "/blog/shared/categories" %>
13
15
  <%= render :partial => "/blog/shared/rss_feed" %>
16
+ <%= blog_archive_list %>
14
17
  <% end %>
15
18
 
16
19
  <%= render :partial => "/shared/content_page" %>
17
- <% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
20
+ <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
@@ -1,36 +1,8 @@
1
- <% content_for :head do %>
2
- <% if BlogPost::ShareThis.enabled? %>
3
- <script src="http://w.sharethis.com/button/buttons.js"></script>
4
- <script>
5
- stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});
6
- </script>
7
- <% end %>
8
- <% end %>
9
-
10
- <% content_for :body_content_title, @blog_post.title %>
11
-
12
1
  <% content_for :body_content_left do %>
13
- <article id="show_blog_post">
14
- <header>
15
- <p class='posted_at'>
16
- <%= t('blog.shared.posts.created_at', :when => @blog_post.published_at.strftime('%d %B %Y')) %>.
17
-
18
- <% if (categories = @blog_post.categories).any? %>
19
- <span class='filed_in'>
20
- <%= t('.filed_in') %>
21
- <% categories.each_with_index do |category, index| %>
22
- <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
23
- <% end %>
24
- </span>
25
- <% end %>
26
- </p>
27
- </header>
28
- <%= @blog_post.body.html_safe %>
2
+ <div id="show_blog_post">
3
+ <%= render 'post' %>
4
+ </div>
29
5
 
30
- <% if BlogPost::ShareThis.enabled? %>
31
- <span class="st_sharethis" displayText="ShareThis"></span>
32
- <% end %>
33
- </article>
34
6
  <% if BlogPost.comments_allowed? %>
35
7
  <aside id="comments">
36
8
  <h2><%= t('.comments.title') %></h2>
@@ -51,26 +23,15 @@
51
23
 
52
24
  <h2><%= t('.comments.add') %></h2>
53
25
  <% form_for [:blog_post, @blog_comment] do |f| %>
54
- <% if Rails.version < '3.0.0'%>
55
- <%= f.error_messages %>
56
- <% else %>
57
- <%= render :partial => "/shared/admin/error_messages",
58
- :locals => {
59
- :object => f.object,
60
- :include_object_name => true
61
- } %>
62
- <% end %>
26
+ <%= f.error_messages %>
27
+
63
28
  <div class='field'>
64
29
  <%= f.label :name %>
65
30
  <%= f.text_field :name %>
66
31
  </div>
67
32
  <div class='field'>
68
33
  <%= f.label :email %>
69
- <% if Rails.version > '3.0.0' %>
70
- <%= f.email_field :email %>
71
- <% else %>
72
- <%= f.text_field :email %>
73
- <% end %>
34
+ <%= f.text_field :email %>
74
35
  </div>
75
36
  <div class='field message_field'>
76
37
  <%= f.label :message %>
@@ -88,7 +49,27 @@
88
49
  <%= render :partial => "/blog/shared/categories" %>
89
50
  <%= render :partial => "/blog/shared/posts" %>
90
51
  <%= render :partial => "/blog/shared/rss_feed" %>
52
+ <%= blog_archive_list %>
91
53
  <% end %>
92
54
 
93
- <%= render :partial => "/shared/content_page" %>
94
- <% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
55
+ <%= render :partial => "/shared/content_page", :locals => { :remove_automatic_sections => true } %>
56
+
57
+ <% if Refinery.version < '0.9.9' %>
58
+ <% content_for :head_libraries, jquery_include_tags(:jquery_ui => false) %>
59
+ <% content_for :head do %>
60
+ <%= stylesheet_link_tag 'refinerycms-blog' %>
61
+ <%= javascript_include_tag('refinerycms-blog') %>
62
+ <% if BlogPost::ShareThis.enabled? %>
63
+ <script src="http://w.sharethis.com/button/buttons.js"></script>
64
+ <script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
65
+ <% end %>
66
+ <% end %>
67
+ <% else %>
68
+ <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
69
+ <% content_for :before_javascript_libraries, jquery_include_tags(:jquery_ui => false) %>
70
+ <% content_for :javascripts do %>
71
+ <%= javascript_include_tag 'refinerycms-blog' %>
72
+ <script src="http://w.sharethis.com/button/buttons.js"></script>
73
+ <script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
74
+ <% end if BlogPost::ShareThis.enabled? %>
75
+ <% end %>
@@ -5,4 +5,4 @@
5
5
  <%= link_to "#{category.title} (#{category.post_count})", blog_category_url(category) %>
6
6
  </li>
7
7
  <% end %>
8
- </ul>
8
+ </ul>
@@ -2,9 +2,19 @@
2
2
  <article class="blog_post" id="<%= dom_id(post) %>">
3
3
  <header>
4
4
  <h1><%= link_to post.title, blog_post_url(post) %></h1>
5
- <p class='posted_at'>
6
- <%= t('blog.shared.posts.created_at', :when => post.published_at.strftime('%d %B %Y')) %>
7
- </p>
5
+ <details>
6
+ <time datetime="<%= post.published_at.strftime('%Y-%m-%d') %>" class='posted_at'>
7
+ <%= t('blog.shared.posts.created_at', :when => post.published_at.strftime('%d %B %Y')) %>.
8
+ </time>
9
+ <% if (categories = post.categories).any? %>
10
+ <aside class='filed_in'>
11
+ <%= t('filed_in', :scope => 'blog.posts.show') %>
12
+ <% categories.each_with_index do |category, index| %>
13
+ <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
14
+ <% end %>
15
+ </aside>
16
+ <% end %>
17
+ </details>
8
18
  </header>
9
19
  <section class='clearfix'>
10
20
  <%= truncate(post.body,
@@ -15,14 +25,14 @@
15
25
  <p>
16
26
  <%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %>
17
27
 
18
- <span class='comment_count'>
28
+ <aside class='comment_count'>
19
29
  <% if post.comments.any? %>
20
30
  (<%= pluralize(post.comments.approved.count, t('blog.shared.comments.singular')) %>)
21
31
  <% else %>
22
32
  (<%= t('blog.shared.comments.none') %>)
23
33
  <% end %>
24
- </span>
34
+ </aside>
25
35
  </p>
26
36
  </footer>
27
37
  </article>
28
- <% end %>
38
+ <% end %>
@@ -5,4 +5,4 @@
5
5
  <%= link_to blog_post.title, blog_post_url(blog_post) %>
6
6
  </li>
7
7
  <% end %>
8
- </ul>
8
+ </ul>
@@ -1,2 +1,2 @@
1
1
  <h2><%= t('.title') %></h2>
2
- <%= link_to "Subscribe", blog_rss_feed_url, :id => "rss_feed_subscribe"%>
2
+ <%= link_to "Subscribe", blog_rss_feed_url, :id => "rss_feed_subscribe"%>
@@ -1,71 +1,33 @@
1
- if Rails.version < '3.0.0'
2
- ActionController::Routing::Routes.draw do |map|
3
- map.namespace(:blog) do |blog|
4
- blog.rss_feed 'feed.rss', :controller => 'posts', :action => 'index', :format => 'rss'
5
- blog.root :controller => "posts", :action => 'index'
6
- blog.post ':id', :controller => "posts", :action => 'show'
7
- blog.category 'categories/:id', :controller => "categories", :action => 'show'
8
- blog.post_blog_comments ':id/comments', :controller => 'posts', :action => 'comment'
9
- end
10
-
11
- map.namespace(:admin, :path_prefix => 'refinery') do |admin|
12
- admin.namespace :blog do |blog|
13
- blog.resources :posts
14
-
15
- blog.resources :categories
16
-
17
- blog.resources :comments, :collection => {
18
- :approved => :get,
19
- :rejected => :get
20
- }, :member => {
21
- :approved => :get,
22
- :rejected => :get
23
- }
24
-
25
- blog.resources :settings, :collection => {
26
- :notification_recipients => [:get, :post],
27
- :moderation => :get
28
- }
29
- end
30
- end
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.namespace(:blog) do |blog|
3
+ blog.rss_feed 'feed.rss', :controller => 'posts', :action => 'index', :format => 'rss'
4
+ blog.root :controller => "posts", :action => 'index'
5
+ blog.post ':id', :controller => "posts", :action => 'show'
6
+ blog.category 'categories/:id', :controller => "categories", :action => 'show'
7
+ blog.post_blog_comments ':id/comments', :controller => 'posts', :action => 'comment'
8
+
9
+ ## TODO: what is the rails2 syntax for this? sorry ;__;
10
+ # get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
31
11
  end
32
- else
33
- Refinery::Application.routes.draw do
34
- scope(:path => 'blog', :module => 'blog') do
35
- root :to => 'posts#index', :as => 'blog_root'
36
- match 'feed.rss', :to => 'posts#index.rss', :as => 'blog_rss_feed'
37
- match ':id', :to => 'posts#show', :as => 'blog_post'
38
- match 'categories/:id', :to => 'categories#show', :as => 'blog_category'
39
- match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments'
40
- end
41
-
42
- scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
43
- scope(:path => 'blog', :name_prefix => 'admin', :as => 'blog', :module => 'blog') do
44
- root :to => 'posts#index'
45
- resources :posts
46
12
 
47
- resources :categories
13
+ map.namespace(:admin, :path_prefix => 'refinery') do |admin|
14
+ admin.namespace :blog do |blog|
15
+ blog.resources :posts
48
16
 
49
- resources :comments do
50
- collection do
51
- get :approved
52
- get :rejected
53
- end
54
- member do
55
- get :approved
56
- get :rejected
57
- end
58
- end
17
+ blog.resources :categories
59
18
 
60
- resources :settings do
61
- collection do
62
- get :notification_recipients
63
- post :notification_recipients
19
+ blog.resources :comments, :collection => {
20
+ :approved => :get,
21
+ :rejected => :get
22
+ }, :member => {
23
+ :approved => :get,
24
+ :rejected => :get
25
+ }
64
26
 
65
- get :moderation
66
- end
67
- end
68
- end
27
+ blog.resources :settings, :collection => {
28
+ :notification_recipients => [:get, :post],
29
+ :moderation => :get
30
+ }
69
31
  end
70
32
  end
71
- end
33
+ end
@@ -1,4 +1,4 @@
1
1
  Factory.define(:blog_category) do |f|
2
2
  f.title "Shopping"
3
- f.posts {|p| [p.association :post]}
4
- end
3
+ f.posts {|p| [p.association(:post)]}
4
+ end
@@ -7,4 +7,4 @@ Factory.define(:blog_comment) do |f|
7
7
  f.email { Factory.next(:email) }
8
8
  f.body "Which one is the best for picking up new shoes?"
9
9
  f.association :post
10
- end
10
+ end
@@ -1,4 +1,4 @@
1
1
  Factory.define(:post, :class => BlogPost) do |f|
2
2
  f.title "Top Ten Shopping Centers in Chicago"
3
3
  f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
4
- end
4
+ end
@@ -0,0 +1,24 @@
1
+ module NavigationHelpers
2
+ module Refinery
3
+ module Blog
4
+ def path_to(page_name)
5
+ case page_name
6
+ when /the list of blog posts/
7
+ admin_blog_posts_path
8
+ when /the new blog posts? form/
9
+ new_admin_blog_post_path
10
+ else
11
+ begin
12
+ if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
13
+ self.url_for(page.url)
14
+ else
15
+ nil
16
+ end
17
+ rescue
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,4 @@
1
- class RefineryBlogGenerator < Rails::Generator::NamedBase
1
+ class RefinerycmsBlogGenerator < Rails::Generator::NamedBase
2
2
 
3
3
  def initialize(*runtime_args)
4
4
  # set argument for the user.
@@ -7,7 +7,7 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
7
7
  end
8
8
 
9
9
  def banner
10
- 'Usage: script/generate refinery_blog'
10
+ 'Usage: script/generate refinerycms_blog'
11
11
  end
12
12
 
13
13
  def manifest
@@ -24,7 +24,7 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
24
24
  path = (%w(public) | image.split('public/').last.split('/'))[0...-1].join('/')
25
25
  m.template "../../../#{path}/#{image.split('/').last}", "#{path}/#{image.split('/').last}"
26
26
  end
27
-
27
+
28
28
  m.directory('db/seeds')
29
29
  m.template('db/seeds/seed.rb', 'db/seeds/refinerycms_blog.rb')
30
30
 
@@ -66,4 +66,4 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
66
66
  end
67
67
  end
68
68
 
69
- end if defined?(Rails::Generator::NamedBase)
69
+ end if defined?(Rails::Generator::NamedBase)