refinerycms-blog 0.9.8.0.rc2 → 1.0.rc10

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 (48) hide show
  1. data/app/controllers/admin/blog/comments_controller.rb +18 -4
  2. data/app/controllers/admin/blog/settings_controller.rb +9 -2
  3. data/app/controllers/blog/categories_controller.rb +7 -0
  4. data/app/controllers/blog/posts_controller.rb +43 -0
  5. data/app/controllers/blog_controller.rb +15 -0
  6. data/app/models/blog_comment.rb +47 -13
  7. data/app/models/blog_post.rb +22 -1
  8. data/app/views/admin/blog/_submenu.html.erb +6 -1
  9. data/app/views/admin/blog/categories/_category.html.erb +4 -2
  10. data/app/views/admin/blog/categories/_form.html.erb +10 -2
  11. data/app/views/admin/blog/comments/_comment.html.erb +13 -10
  12. data/app/views/admin/blog/comments/index.html.erb +1 -1
  13. data/app/views/admin/blog/comments/show.html.erb +63 -0
  14. data/app/views/admin/blog/posts/_form.html.erb +9 -1
  15. data/app/views/admin/blog/posts/_post.html.erb +3 -1
  16. data/app/views/blog/categories/show.html.erb +20 -0
  17. data/app/views/blog/posts/_comment.html.erb +9 -0
  18. data/app/views/blog/posts/index.html.erb +17 -0
  19. data/app/views/blog/posts/index.rss.builder +17 -0
  20. data/app/views/blog/posts/show.html.erb +85 -0
  21. data/app/views/blog/shared/_categories.html.erb +8 -0
  22. data/app/views/blog/shared/_post.html.erb +22 -0
  23. data/app/views/blog/shared/_posts.html.erb +8 -0
  24. data/app/views/blog/shared/_rss_feed.html.erb +2 -0
  25. data/config/locales/en.yml +54 -18
  26. data/config/routes.rb +51 -5
  27. data/generators/refinery_blog/refinery_blog_generator.rb +15 -16
  28. data/generators/refinery_blog/templates/{migration.rb → db/migrate/migration.rb} +0 -0
  29. data/generators/refinery_blog/templates/{seed.rb → db/seeds/seed.rb} +0 -0
  30. data/lib/gemspec.rb +1 -1
  31. data/lib/generators/refinery_blog/templates/db/migrate/migration_number_create_singular_name.rb +26 -0
  32. data/lib/generators/refinery_blog/templates/db/seeds/seed.rb +16 -0
  33. data/lib/generators/refinery_blog_generator.rb +79 -0
  34. data/lib/refinerycms-blog.rb +23 -3
  35. data/public/images/refinerycms-blog/icons/down.gif +0 -0
  36. data/public/images/refinerycms-blog/icons/up.gif +0 -0
  37. data/public/images/refinerycms-blog/rss-feed.png +0 -0
  38. data/public/javascripts/refinery/refinerycms-blog.js +14 -4
  39. data/public/stylesheets/refinery/refinerycms-blog.css +18 -0
  40. data/public/stylesheets/refinerycms-blog.css +5 -0
  41. data/readme.md +24 -1
  42. metadata +27 -16
  43. data/app/controllers/blog_posts_controller.rb +0 -62
  44. data/app/views/blog_posts/_categories.html.erb +0 -0
  45. data/app/views/blog_posts/_comments.html.erb +0 -0
  46. data/app/views/blog_posts/_side_bar.html.erb +0 -8
  47. data/app/views/blog_posts/index.html.erb +0 -27
  48. data/app/views/blog_posts/show.html.erb +0 -76
@@ -0,0 +1,9 @@
1
+ <div class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'>
2
+ <p>
3
+ <%= comment.message.to_s.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>") %>
4
+ </p>
5
+ </div>
6
+ <p class='blog_comment_author'>
7
+ <%= t('blog.posts.comments.by', :who => comment.name) %>,
8
+ <%= t('blog.posts.comments.time_ago', :time => time_ago_in_words(comment.created_at)) %>
9
+ </p>
@@ -0,0 +1,17 @@
1
+ <% content_for :body_content_left do %>
2
+ <%= @page[Page.default_parts.first.to_sym] %>
3
+
4
+ <ul id="blog_posts">
5
+ <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
6
+ </ul>
7
+ <% end %>
8
+
9
+ <% content_for :body_content_right do %>
10
+ <%= @page[Page.default_parts.second.to_sym] %>
11
+
12
+ <%= render :partial => "/blog/shared/categories" %>
13
+ <%= render :partial => "/blog/shared/rss_feed" %>
14
+ <% end %>
15
+
16
+ <%= render :partial => "/shared/content_page" %>
17
+ <% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
@@ -0,0 +1,17 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title RefinerySetting.find_or_set(:site_name, "Company Name")
5
+ xml.description RefinerySetting.find_or_set(:site_name, "Company Name") + " Blog Posts"
6
+ xml.link blog_root_url
7
+
8
+ @blog_posts.each do |post|
9
+ xml.item do
10
+ xml.title post.title
11
+ xml.description post.body
12
+ xml.pubDate post.created_at.to_s(:rfc822)
13
+ xml.link blog_post_url(post)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,85 @@
1
+ <% content_for :head do %>
2
+ <% if BlogPost::ShareThis.enabled? %>
3
+ <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
4
+ <script type="text/javascript">
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
+ <% content_for :body_content_left do %>
13
+ <p class='posted_at'>
14
+ <%= t('blog.shared.posts.created_at', :when => @blog_post.created_at.strftime('%d %B %Y')) %>.
15
+
16
+ <% if (categories = @blog_post.categories).any? %>
17
+ <span class='filed_in'>
18
+ <%= t('.filed_in') %>
19
+ <% categories.each_with_index do |category, index| %>
20
+ <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
21
+ <% end %>
22
+ </span>
23
+ <% end %>
24
+ </p>
25
+ <%= @blog_post.body %>
26
+
27
+ <% if BlogPost::ShareThis.enabled? %>
28
+ <span class="st_sharethis" displayText="ShareThis"></span>
29
+ <% end %>
30
+
31
+ <% if BlogPost.comments_allowed? %>
32
+ <h2><%= t('.comments.title') %></h2>
33
+
34
+ <% if (comments = @blog_post.comments.approved).any? %>
35
+ <%= render :partial => "comment", :collection => comments %>
36
+ <% else %>
37
+ <p>
38
+ <%= t('blog.shared.comments.none') %>.
39
+ </p>
40
+ <% end %>
41
+
42
+ <% flash.each do |key, value| %>
43
+ <div id='flash' class="flash flash_<%= key %>">
44
+ <%= value %>
45
+ </div>
46
+ <% end %>
47
+
48
+ <h2><%= t('.comments.add') %></h2>
49
+ <% form_for [:blog_post, @blog_comment] do |f| %>
50
+ <% if Rails.version < '3.0.0'%>
51
+ <%= f.error_messages %>
52
+ <% else %>
53
+ <%= render :partial => "/shared/admin/error_messages",
54
+ :locals => {
55
+ :object => f.object,
56
+ :include_object_name => true
57
+ } %>
58
+ <% end %>
59
+ <div class='field'>
60
+ <%= f.label :name %>
61
+ <%= f.text_field :name %>
62
+ </div>
63
+ <div class='field'>
64
+ <%= f.label :email %>
65
+ <%= f.text_field :email %>
66
+ </div>
67
+ <div class='field message_field'>
68
+ <%= f.label :message %>
69
+ <%= f.text_area :message, :rows => 6 %>
70
+ </div>
71
+ <div class='field form-actions'>
72
+ <%= f.submit t('.submit') %>
73
+ </div>
74
+ <% end %>
75
+ <% end %>
76
+ <% end %>
77
+
78
+ <% content_for :body_content_right do %>
79
+ <%= render :partial => "/blog/shared/categories" %>
80
+ <%= render :partial => "/blog/shared/posts" %>
81
+ <%= render :partial => "/blog/shared/rss_feed" %>
82
+ <% end %>
83
+
84
+ <%= render :partial => "/shared/content_page" %>
85
+ <% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
@@ -0,0 +1,8 @@
1
+ <h2><%= t('.title') %></h2>
2
+ <ul id='categories'>
3
+ <% @blog_categories.each do |category| %>
4
+ <li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
5
+ <%= link_to "#{category.title} (#{category.posts.count})", blog_category_url(category) %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
@@ -0,0 +1,22 @@
1
+ <li>
2
+ <h2><%= link_to post.title, blog_post_url(post) %></h2>
3
+ <p class='posted_at'>
4
+ <%= t('blog.shared.posts.created_at', :when => post.created_at.strftime('%d %B %Y')) %>
5
+ </p>
6
+ <div clas='clearfix'>
7
+ <%= truncate(post.body,
8
+ :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
9
+ :preserve_html_tags => true) %>
10
+ </div>
11
+ <p>
12
+ <%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %>
13
+
14
+ <span class='comment_count'>
15
+ <% if post.comments.any? %>
16
+ (<%= pluralize(post.comments.count, t('blog.shared.comments.singular')) %>)
17
+ <% else %>
18
+ (<%= t('blog.shared.comments.none') %>)
19
+ <% end %>
20
+ </span>
21
+ </p>
22
+ </li>
@@ -0,0 +1,8 @@
1
+ <h2><%= t('.other') %></h2>
2
+ <ul id="blog_posts">
3
+ <% @blog_posts.each do |blog_post| %>
4
+ <li>
5
+ <%= link_to blog_post.title, blog_post_url(blog_post) %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
@@ -0,0 +1,2 @@
1
+ <h2><%= t('.title') %></h2>
2
+ <%= link_to "Subscribe", blog_rss_feed_url, :id => "rss_feed_subscribe"%>
@@ -9,17 +9,36 @@ en:
9
9
  edit: Edit this category
10
10
  delete: Delete this category forever
11
11
  index:
12
- no_items_yet: There are no categories yet. Click "{{create}}" to add your first category.
12
+ no_items_yet: 'There are no categories yet. Click "{{create}}" to add your first category.'
13
13
  comments:
14
+ approved: 'The comment from "{{author}}" has been approved.'
15
+ comment:
16
+ view_live: View this comment live <br/><em>(opens in a new window)</em>
17
+ read: Read this comment
18
+ reject: Reject this comment
19
+ approve: Approve this comment
20
+ rejected: 'The comment from "{{author}}" has been rejected.'
14
21
  index:
15
- no_items_yet: There are no {{type}} comments yet.
22
+ no_items_yet: 'There are no {{type}} comments.'
23
+ show:
24
+ comment: Comment
25
+ blog_post: Blog Post
26
+ from: Posted by
27
+ date: Posted at
28
+ message: Comment
29
+ details: Details
30
+ age: Age
31
+ actions: Actions
32
+ back: Back to all comments
33
+ reject: Reject this comment
34
+ approve: Approve this comment
16
35
  posts:
17
36
  form:
18
37
  advanced_options: Advanced Options
19
38
  toggle_advanced_options: Click to access meta tag settings and menu options
20
39
  save_as_draft: Save as Draft
21
40
  index:
22
- no_items_yet: There are no Blog Posts yet. Click "{{create}}" to add your first blog post.
41
+ no_items_yet: 'There are no Blog Posts yet. Click "{{create}}" to add your first blog post.'
23
42
  post:
24
43
  view_live: View this blog post live <br/><em>(opens in a new window)</em>
25
44
  edit: Edit this blog post
@@ -27,9 +46,10 @@ en:
27
46
  settings:
28
47
  notification_recipients:
29
48
  value: Send notifications to
30
- explanation: Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment.
31
- hint: When a new comment is added, Refinery will send an email notification to you.
49
+ explanation: 'Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment.'
50
+ hint: 'When a new comment is added, Refinery will send an email notification to you.'
32
51
  example: "Enter your email address(es) like: jack@work.com, jill@office.com"
52
+ updated: 'Notification recipients have been set to "{{recipients}}"'
33
53
  submenu:
34
54
  categories:
35
55
  title: Categories
@@ -37,6 +57,7 @@ en:
37
57
  new: Create new category
38
58
  comments:
39
59
  title: Comments
60
+ title_with_count: 'Comments ({{new_count}} new)'
40
61
  new: New
41
62
  unmoderated: New
42
63
  approved: Approved
@@ -49,18 +70,33 @@ en:
49
70
  title: Settings
50
71
  moderation: Moderation
51
72
  update_notified: Update who gets notified
52
- blog_posts:
53
- side_bar:
54
- categories: Categories
55
- index:
56
- read_more: Read more
57
- show:
73
+ blog:
74
+ shared:
75
+ categories:
76
+ title: Categories
77
+ rss_feed:
78
+ title: RSS Feed
79
+ posts:
80
+ other: Other Posts
81
+ created_at: 'Posted on {{when}}'
82
+ read_more: Read more
83
+ comments:
84
+ singular: comment
85
+ none: no comments
86
+ categories:
87
+ show:
88
+ no_posts: There are no posts here yet.
89
+ posts:
90
+ comment: comment
58
91
  comments:
59
- title: Comments
60
- by: Posted by {{who}}
92
+ by: 'Posted by {{who}}'
61
93
  time_ago: '{{time}} ago'
62
- other: Other Blog Posts
63
- filed_in: Filed in
64
- created_at_title: Publishing Date
65
- created_at: Posted on {{when}}
66
- submit: Send comment
94
+ thank_you: 'Thank you for commenting.'
95
+ thank_you_moderated: 'Thank you for commenting. Your message has been placed in the moderation queue and will appear shortly.'
96
+ show:
97
+ comments:
98
+ title: Comments
99
+ add: Make a Comment
100
+ other: Other Blog Posts
101
+ filed_in: Filed in
102
+ submit: Send comment
@@ -1,18 +1,27 @@
1
1
  if Rails.version < '3.0.0'
2
2
  ActionController::Routing::Routes.draw do |map|
3
- map.blog_post '/blog', :controller => :blog_posts, :action => :index
4
- map.blog_post '/blog/:id', :controller => :blog_posts, :action => :show
5
- map.blog_category '/blog/categories/:category_id', :controller => :blog_posts, :action => :index
6
- map.blog_post_blog_comments '/blog/:id/comments', :controller => :blog_posts, :action => :comment
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
7
10
 
8
11
  map.namespace(:admin, :path_prefix => 'refinery') do |admin|
9
12
  admin.namespace :blog do |blog|
10
13
  blog.resources :posts
14
+
11
15
  blog.resources :categories
16
+
12
17
  blog.resources :comments, :collection => {
13
18
  :approved => :get,
14
19
  :rejected => :get
20
+ }, :member => {
21
+ :approved => :get,
22
+ :rejected => :get
15
23
  }
24
+
16
25
  blog.resources :settings, :collection => {
17
26
  :notification_recipients => [:get, :post],
18
27
  :moderation => :get
@@ -21,5 +30,42 @@ if Rails.version < '3.0.0'
21
30
  end
22
31
  end
23
32
  else
24
- # route for rails3 here.
33
+ Refinery::Application.routes.draw do
34
+ scope(:path => 'blog', :module => 'blog') do
35
+ root :to => 'posts#index'
36
+ match 'feed.rss', :to => 'posts#index.rss', :as => '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
+
47
+ resources :categories
48
+
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
59
+
60
+ resources :settings do
61
+ collection do
62
+ get :notification_recipients
63
+ post :notification_recipients
64
+
65
+ get :moderation
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
25
71
  end
@@ -12,24 +12,23 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
12
12
 
13
13
  def manifest
14
14
  record do |m|
15
- if Rails.version < '3.0.0'
16
- matches = Dir[
17
- File.expand_path('../../../public/images/**/*', __FILE__),
18
- File.expand_path('../../../public/stylesheets/**/*', __FILE__),
19
- File.expand_path('../../../public/javascripts/**/*', __FILE__),
20
- ]
21
- matches.reject{|d| !File.directory?(d)}.each do |dir|
22
- m.directory((%w(public) | dir.split('public/').last.split('/')).join('/'))
23
- end
24
- matches.reject{|f| File.directory?(f)}.each do |image|
25
- path = (%w(public) | image.split('public/').last.split('/'))[0...-1].join('/')
26
- m.template "../../../#{path}/#{image.split('/').last}", "#{path}/#{image.split('/').last}"
27
- end
15
+ matches = Dir[
16
+ File.expand_path('../../../public/images/**/*', __FILE__),
17
+ File.expand_path('../../../public/stylesheets/**/*', __FILE__),
18
+ File.expand_path('../../../public/javascripts/**/*', __FILE__),
19
+ ]
20
+ matches.reject{|d| !File.directory?(d)}.each do |dir|
21
+ m.directory((%w(public) | dir.split('public/').last.split('/')).join('/'))
28
22
  end
23
+ matches.reject{|f| File.directory?(f)}.each do |image|
24
+ path = (%w(public) | image.split('public/').last.split('/'))[0...-1].join('/')
25
+ m.template "../../../#{path}/#{image.split('/').last}", "#{path}/#{image.split('/').last}"
26
+ end
27
+
28
+ m.directory('db/seeds')
29
+ m.template('db/seeds/seed.rb', 'db/seeds/refinerycms_blog.rb')
29
30
 
30
- m.template('seed.rb', 'db/seeds/refinerycms_blog.rb')
31
-
32
- m.migration_template('migration.rb', 'db/migrate',
31
+ m.migration_template('db/migrate/migration.rb', 'db/migrate',
33
32
  :migration_file_name => 'create_blog_structure',
34
33
  :assigns => {
35
34
  :migration_name => 'CreateBlogStructure',
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.homepage = %q{http://refinerycms.com}
18
18
  s.authors = %w(Resolve\\ Digital Neoteric\\ Design)
19
19
  s.require_paths = %w(lib)
20
- s.add_dependency 'refinerycms', '~> 0.9.7.13'
20
+ s.add_dependency 'refinerycms', '>= 0.9.7.13'
21
21
  s.add_dependency 'filters_spam', '~> 0.2'
22
22
 
23
23
  s.files = %w(
@@ -0,0 +1,26 @@
1
+ class Create<%= singular_name.camelize %> < ActiveRecord::Migration
2
+
3
+ def self.up<% @refinerycms_blog_tables.each do |table| %>
4
+ create_table :<%= table[:table_name] %>, :id => <%= table[:id].to_s %> do |t|
5
+ <% table[:attributes].each do |attribute| -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+ <%= 't.timestamps' if table[:id] %>
9
+ end
10
+
11
+ <%= "add_index :#{table[:table_name]}, :id" if table[:id] %>
12
+ <% end -%>
13
+ load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
14
+ end
15
+
16
+ def self.down
17
+ UserPlugin.destroy_all({:name => "refinerycms_blog"})
18
+
19
+ Page.delete_all({:link_url => "/blog"})
20
+
21
+ <% @refinerycms_blog_tables.each do |table| -%>
22
+ drop_table :<%= table[:table_name] %>
23
+ <% end -%>
24
+ end
25
+
26
+ end
@@ -0,0 +1,16 @@
1
+ User.find(:all).each do |user|
2
+ user.plugins.create(:name => "<%= singular_name %>",
3
+ :position => (user.plugins.maximum(:position) || -1) +1)
4
+ end
5
+
6
+ page = Page.create(
7
+ :title => "Blog",
8
+ :link_url => "/blog",
9
+ :deletable => false,
10
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
11
+ :menu_match => "^/blogs?(\/|\/.+?|)$"
12
+ )
13
+
14
+ Page.default_parts.each do |default_page_part|
15
+ page.parts.create(:title => default_page_part, :body => nil)
16
+ end