refinerycms-news 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +17 -0
  3. data/Gemfile +69 -0
  4. data/Guardfile +20 -0
  5. data/Rakefile +19 -0
  6. data/app/controllers/refinery/news/admin/items_controller.rb +11 -0
  7. data/app/controllers/refinery/news/items_controller.rb +50 -0
  8. data/app/helpers/refinery/news/items_helper.rb +51 -0
  9. data/app/models/refinery/news/item.rb +91 -0
  10. data/app/views/{admin/news_items → refinery/news/admin/items}/_form.html.erb +13 -8
  11. data/app/views/{admin/news_items/_news_item.html.erb → refinery/news/admin/items/_item.html.erb} +8 -8
  12. data/app/views/{admin/news_items → refinery/news/admin/items}/_locale_picker.html.erb +1 -1
  13. data/app/views/{admin/news_items → refinery/news/admin/items}/edit.html.erb +0 -0
  14. data/app/views/refinery/news/admin/items/index.html.erb +30 -0
  15. data/app/views/{admin/news_items → refinery/news/admin/items}/new.html.erb +0 -0
  16. data/app/views/{news_items → refinery/news/items}/_recent_posts.html.erb +2 -2
  17. data/app/views/refinery/news/items/archive.html.erb +17 -0
  18. data/app/views/refinery/news/items/index.html.erb +28 -0
  19. data/app/views/{news_items → refinery/news/items}/index.rss.builder +5 -5
  20. data/app/views/refinery/news/items/show.html.erb +20 -0
  21. data/app/views/refinery/news/items/widgets/_news_archive.html.erb +10 -0
  22. data/app/views/refinery/news/shared/_body_content_right.html.erb +5 -0
  23. data/app/views/refinery/news/shared/_item.html.erb +22 -0
  24. data/config/locales/bg.yml +37 -0
  25. data/config/locales/cs.yml +29 -28
  26. data/config/locales/de.yml +27 -27
  27. data/config/locales/en.yml +39 -29
  28. data/config/locales/es-MX.yml +26 -26
  29. data/config/locales/es.yml +29 -27
  30. data/config/locales/fr.yml +28 -28
  31. data/config/locales/it.yml +27 -27
  32. data/config/locales/jp.yml +36 -0
  33. data/config/locales/lv.yml +28 -26
  34. data/config/locales/nb.yml +27 -27
  35. data/config/locales/nl.yml +27 -27
  36. data/config/locales/pl.yml +37 -0
  37. data/config/locales/pt-BR.yml +28 -28
  38. data/config/locales/ru.yml +26 -26
  39. data/config/locales/sk.yml +28 -28
  40. data/config/locales/sl.yml +31 -29
  41. data/config/locales/zh-CN.yml +37 -0
  42. data/config/locales/zh-TW.yml +37 -0
  43. data/config/routes.rb +13 -5
  44. data/db/migrate/20110817203701_create_news_items.rb +23 -0
  45. data/db/migrate/20110817203702_add_external_url_to_news_items.rb +15 -0
  46. data/db/migrate/20110817203703_translate_news_items.rb +21 -0
  47. data/db/migrate/20110817203704_add_image_id_to_news_items.rb +13 -0
  48. data/db/migrate/20110817203705_add_expiration_date_to_news_items.rb +15 -0
  49. data/db/migrate/20110817203706_remove_image_id_and_external_url_from_news.rb +19 -0
  50. data/db/migrate/20120129230838_add_source_to_news_items.rb +16 -0
  51. data/db/migrate/20120129230839_translate_source.rb +16 -0
  52. data/db/migrate/20120228150250_add_slug_to_news_items.rb +5 -0
  53. data/db/seeds.rb +22 -0
  54. data/lib/generators/refinery/news_generator.rb +19 -0
  55. data/lib/refinery/news.rb +22 -0
  56. data/lib/refinery/news/engine.rb +23 -0
  57. data/lib/refinerycms-news.rb +1 -23
  58. data/readme.md +10 -8
  59. data/refinerycms-news.gemspec +20 -0
  60. data/spec/factories/news.rb +7 -0
  61. data/spec/models/refinery/news/item_spec.rb +91 -0
  62. data/spec/requests/manage_news_items_spec.rb +90 -0
  63. data/spec/requests/news_archive.rb +12 -0
  64. data/spec/requests/visit_news_items_spec.rb +37 -0
  65. data/spec/spec_helper.rb +56 -0
  66. data/tasks/rspec.rake +4 -0
  67. metadata +113 -40
  68. data/app/controllers/admin/news_items_controller.rb +0 -5
  69. data/app/controllers/news_items_controller.rb +0 -33
  70. data/app/models/news_item.rb +0 -46
  71. data/app/views/admin/news_items/index.html.erb +0 -30
  72. data/app/views/news_items/index.html.erb +0 -23
  73. data/app/views/news_items/show.html.erb +0 -15
  74. data/db/migrate/1_create_news_items.rb +0 -23
  75. data/db/migrate/2_add_external_url_to_news_items.rb +0 -15
  76. data/db/migrate/3_translate_news_items.rb +0 -24
  77. data/db/migrate/4_add_image_id_to_news_items.rb +0 -13
  78. data/db/migrate/5_add_expiration_date_to_news_items.rb +0 -15
  79. data/db/migrate/6_remove_image_id_and_external_url_from_news.rb +0 -19
  80. data/db/seeds/refinerycms_news.rb +0 -24
  81. data/features/manage_news_items.feature +0 -56
  82. data/features/step_definitions/news_steps.rb +0 -25
  83. data/features/support/factories.rb +0 -7
  84. data/features/support/paths.rb +0 -26
  85. data/features/visit_news_items.feature +0 -27
  86. data/lib/gemspec.rb +0 -29
  87. data/lib/generators/refinerycms_news_generator.rb +0 -8
  88. data/lib/news.rb +0 -9
  89. data/spec/models/news_item_spec.rb +0 -89
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe "visit news items" do
4
+ login_refinery_user
5
+
6
+ before(:each) do
7
+ Factory.create(:page, :link_url => "/")
8
+ Factory.create(:page, :link_url => "/news", :title => "News")
9
+ @published_news_item = Factory.create(:news_item, :title => "published", :source => "http://refinerycms.com", :publish_date => 1.hour.ago)
10
+ @unpublished_news_item = Factory.create(:news_item, :title => "unpublished", :publish_date => 1.day.from_now)
11
+ end
12
+
13
+ it "shows news link in menu" do
14
+ visit "/"
15
+
16
+ within "#menu" do
17
+ page.should have_content("News")
18
+ page.should have_selector("a[href='/news']")
19
+ end
20
+ end
21
+
22
+ it "shows news item" do
23
+ visit refinery.news_items_path
24
+
25
+ page.should have_content("published")
26
+ page.should have_selector("a[href='/news/published']")
27
+
28
+ page.should have_no_content("unpublished")
29
+ page.should have_no_selector("a[href='/news/unpublished']")
30
+ end
31
+
32
+ it "has a source on the news item" do
33
+ visit refinery.news_item_path(@published_news_item)
34
+
35
+ page.should have_content("Source http://refinerycms.com")
36
+ end
37
+ end
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+
3
+ def setup_environment
4
+ # Configure Rails Environment
5
+ ENV["RAILS_ENV"] ||= 'test'
6
+
7
+ require File.expand_path("../dummy/config/environment", __FILE__)
8
+
9
+ require 'rspec/rails'
10
+ require 'capybara/rspec'
11
+ require 'factory_girl_rails'
12
+
13
+ Rails.backtrace_cleaner.remove_silencers!
14
+
15
+ RSpec.configure do |config|
16
+ config.mock_with :rspec
17
+ config.treat_symbols_as_metadata_keys_with_true_values = true
18
+ config.filter_run :focus => true
19
+ config.run_all_when_everything_filtered = true
20
+ end
21
+
22
+ # set javascript driver for capybara
23
+ Capybara.javascript_driver = :selenium
24
+ end
25
+
26
+ def each_run
27
+ ActiveSupport::Dependencies.clear
28
+
29
+ FactoryGirl.reload
30
+
31
+ # Requires supporting files with custom matchers and macros, etc,
32
+ # in ./support/ and its subdirectories including factories.
33
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
34
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
35
+ }.flatten.sort.each do |support_file|
36
+ require support_file
37
+ end
38
+ end
39
+
40
+ # If spork is available in the Gemfile it'll be used but we don't force it.
41
+ unless (begin; require 'spork'; rescue LoadError; nil end).nil?
42
+ Spork.prefork do
43
+ # Loading more in this block will cause your tests to run faster. However,
44
+ # if you change any configuration or code from libraries loaded here, you'll
45
+ # need to restart spork for it take effect.
46
+ setup_environment
47
+ end
48
+
49
+ Spork.each_run do
50
+ # This code will be run each time you run your specs.
51
+ each_run
52
+ end
53
+ else
54
+ setup_environment
55
+ each_run
56
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run specs"
4
+ RSpec::Core::RakeTask.new
metadata CHANGED
@@ -1,17 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-news
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 15
4
5
  prerelease:
5
- version: 1.2.0
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
6
11
  platform: ruby
7
12
  authors:
8
- - Resolve Digital
13
+ - Philip Arndt
14
+ - "U\xC4\xA3is Ozols"
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2011-05-27 00:00:00 +12:00
14
- default_executable:
19
+ date: 2012-03-13 00:00:00 Z
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: refinerycms-core
@@ -21,10 +26,47 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
24
- version: 1.0.0
29
+ hash: 13
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 1
34
+ version: 2.0.1
25
35
  type: :runtime
26
36
  version_requirements: *id001
27
- description: A really straightforward open source Ruby on Rails news engine designed for integration with RefineryCMS.
37
+ - !ruby/object:Gem::Dependency
38
+ name: refinerycms-settings
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 2
48
+ - 0
49
+ - 0
50
+ version: 2.0.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: friendly_id
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 61
62
+ segments:
63
+ - 4
64
+ - 0
65
+ - 1
66
+ version: 4.0.1
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ description: A really straightforward open source Ruby on Rails news engine designed for integration with Refinery CMS.
28
70
  email: info@refinerycms.com
29
71
  executables: []
30
72
 
@@ -33,19 +75,30 @@ extensions: []
33
75
  extra_rdoc_files: []
34
76
 
35
77
  files:
36
- - app/controllers/admin/news_items_controller.rb
37
- - app/controllers/news_items_controller.rb
38
- - app/models/news_item.rb
39
- - app/views/admin/news_items/_form.html.erb
40
- - app/views/admin/news_items/_locale_picker.html.erb
41
- - app/views/admin/news_items/_news_item.html.erb
42
- - app/views/admin/news_items/edit.html.erb
43
- - app/views/admin/news_items/index.html.erb
44
- - app/views/admin/news_items/new.html.erb
45
- - app/views/news_items/_recent_posts.html.erb
46
- - app/views/news_items/index.html.erb
47
- - app/views/news_items/index.rss.builder
48
- - app/views/news_items/show.html.erb
78
+ - .gitignore
79
+ - .travis.yml
80
+ - Gemfile
81
+ - Guardfile
82
+ - Rakefile
83
+ - app/controllers/refinery/news/admin/items_controller.rb
84
+ - app/controllers/refinery/news/items_controller.rb
85
+ - app/helpers/refinery/news/items_helper.rb
86
+ - app/models/refinery/news/item.rb
87
+ - app/views/refinery/news/admin/items/_form.html.erb
88
+ - app/views/refinery/news/admin/items/_item.html.erb
89
+ - app/views/refinery/news/admin/items/_locale_picker.html.erb
90
+ - app/views/refinery/news/admin/items/edit.html.erb
91
+ - app/views/refinery/news/admin/items/index.html.erb
92
+ - app/views/refinery/news/admin/items/new.html.erb
93
+ - app/views/refinery/news/items/_recent_posts.html.erb
94
+ - app/views/refinery/news/items/archive.html.erb
95
+ - app/views/refinery/news/items/index.html.erb
96
+ - app/views/refinery/news/items/index.rss.builder
97
+ - app/views/refinery/news/items/show.html.erb
98
+ - app/views/refinery/news/items/widgets/_news_archive.html.erb
99
+ - app/views/refinery/news/shared/_body_content_right.html.erb
100
+ - app/views/refinery/news/shared/_item.html.erb
101
+ - config/locales/bg.yml
49
102
  - config/locales/cs.yml
50
103
  - config/locales/de.yml
51
104
  - config/locales/en.yml
@@ -53,34 +106,42 @@ files:
53
106
  - config/locales/es.yml
54
107
  - config/locales/fr.yml
55
108
  - config/locales/it.yml
109
+ - config/locales/jp.yml
56
110
  - config/locales/lv.yml
57
111
  - config/locales/nb.yml
58
112
  - config/locales/nl.yml
113
+ - config/locales/pl.yml
59
114
  - config/locales/pt-BR.yml
60
115
  - config/locales/ru.yml
61
116
  - config/locales/sk.yml
62
117
  - config/locales/sl.yml
118
+ - config/locales/zh-CN.yml
119
+ - config/locales/zh-TW.yml
63
120
  - config/routes.rb
64
- - db/migrate/1_create_news_items.rb
65
- - db/migrate/2_add_external_url_to_news_items.rb
66
- - db/migrate/3_translate_news_items.rb
67
- - db/migrate/4_add_image_id_to_news_items.rb
68
- - db/migrate/5_add_expiration_date_to_news_items.rb
69
- - db/migrate/6_remove_image_id_and_external_url_from_news.rb
70
- - db/seeds/refinerycms_news.rb
71
- - features/manage_news_items.feature
72
- - features/step_definitions/news_steps.rb
73
- - features/support/factories.rb
74
- - features/support/paths.rb
75
- - features/visit_news_items.feature
76
- - lib/gemspec.rb
77
- - lib/generators/refinerycms_news_generator.rb
78
- - lib/news.rb
121
+ - db/migrate/20110817203701_create_news_items.rb
122
+ - db/migrate/20110817203702_add_external_url_to_news_items.rb
123
+ - db/migrate/20110817203703_translate_news_items.rb
124
+ - db/migrate/20110817203704_add_image_id_to_news_items.rb
125
+ - db/migrate/20110817203705_add_expiration_date_to_news_items.rb
126
+ - db/migrate/20110817203706_remove_image_id_and_external_url_from_news.rb
127
+ - db/migrate/20120129230838_add_source_to_news_items.rb
128
+ - db/migrate/20120129230839_translate_source.rb
129
+ - db/migrate/20120228150250_add_slug_to_news_items.rb
130
+ - db/seeds.rb
131
+ - lib/generators/refinery/news_generator.rb
132
+ - lib/refinery/news.rb
133
+ - lib/refinery/news/engine.rb
79
134
  - lib/refinerycms-news.rb
80
135
  - license.md
81
136
  - readme.md
82
- - spec/models/news_item_spec.rb
83
- has_rdoc: true
137
+ - refinerycms-news.gemspec
138
+ - spec/factories/news.rb
139
+ - spec/models/refinery/news/item_spec.rb
140
+ - spec/requests/manage_news_items_spec.rb
141
+ - spec/requests/news_archive.rb
142
+ - spec/requests/visit_news_items_spec.rb
143
+ - spec/spec_helper.rb
144
+ - tasks/rspec.rake
84
145
  homepage: http://refinerycms.com
85
146
  licenses: []
86
147
 
@@ -94,19 +155,31 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
155
  requirements:
95
156
  - - ">="
96
157
  - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
160
+ - 0
97
161
  version: "0"
98
162
  required_rubygems_version: !ruby/object:Gem::Requirement
99
163
  none: false
100
164
  requirements:
101
165
  - - ">="
102
166
  - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
169
+ - 0
103
170
  version: "0"
104
171
  requirements: []
105
172
 
106
173
  rubyforge_project:
107
- rubygems_version: 1.6.2
174
+ rubygems_version: 1.8.17
108
175
  signing_key:
109
176
  specification_version: 3
110
- summary: Ruby on Rails news engine for RefineryCMS.
111
- test_files: []
112
-
177
+ summary: Ruby on Rails news engine for Refinery CMS.
178
+ test_files:
179
+ - spec/factories/news.rb
180
+ - spec/models/refinery/news/item_spec.rb
181
+ - spec/requests/manage_news_items_spec.rb
182
+ - spec/requests/news_archive.rb
183
+ - spec/requests/visit_news_items_spec.rb
184
+ - spec/spec_helper.rb
185
+ has_rdoc:
@@ -1,5 +0,0 @@
1
- class Admin::NewsItemsController < Admin::BaseController
2
-
3
- crudify :news_item, :order => "publish_date DESC"
4
-
5
- end
@@ -1,33 +0,0 @@
1
- class NewsItemsController < ApplicationController
2
- before_filter :find_page
3
- before_filter :find_published_news_items, :only => [:index]
4
- before_filter :find_news_item, :find_latest_news_items, :only => [:show]
5
-
6
- def index
7
- # render 'index'
8
- end
9
-
10
- def show
11
- # render 'show'
12
- end
13
-
14
- protected
15
-
16
- def find_latest_news_items
17
- @news_items = NewsItem.latest.translated
18
- end
19
-
20
- def find_published_news_items
21
- @news_items = NewsItem.published.translated.paginate(:page => params[:page],
22
- :per_page => NewsItem.per_page)
23
- end
24
-
25
- def find_news_item
26
- @news_item = NewsItem.published.translated.find(params[:id])
27
- end
28
-
29
- def find_page
30
- @page = Page.find_by_link_url("/news")
31
- end
32
-
33
- end
@@ -1,46 +0,0 @@
1
- class NewsItem < ActiveRecord::Base
2
- translates :title, :body, :external_url
3
-
4
- attr_accessor :locale # to hold temporarily
5
-
6
- alias_attribute :content, :body
7
- validates :title, :content, :publish_date, :presence => true
8
-
9
- has_friendly_id :title, :use_slug => true
10
-
11
- acts_as_indexed :fields => [:title, :body]
12
-
13
- default_scope :order => "publish_date DESC"
14
-
15
- # If you're using a named scope that includes a changing variable you need to wrap it in a lambda
16
- # This avoids the query being cached thus becoming unaffected by changes (i.e. Time.now is constant)
17
- scope :not_expired, lambda {
18
- news_items = Arel::Table.new(NewsItem.table_name)
19
- where(news_items[:expiration_date].eq(nil).or(news_items[:expiration_date].gt(Time.now)))
20
- }
21
- scope :published, lambda {
22
- not_expired.where("publish_date < ?", Time.now)
23
- }
24
- scope :latest, lambda { |*l_params|
25
- published.limit( l_params.first || 10)
26
- }
27
-
28
- # rejects any page that has not been translated to the current locale.
29
- scope :translated, lambda {
30
- pages = Arel::Table.new(NewsItem.table_name)
31
- translations = Arel::Table.new(NewsItem.translations_table_name)
32
-
33
- includes(:translations).where(
34
- translations[:locale].eq(Globalize.locale)).where(pages[:id].eq(translations[:news_item_id]))
35
- }
36
-
37
- def not_published? # has the published date not yet arrived?
38
- publish_date > Time.now
39
- end
40
-
41
- # for will_paginate
42
- def self.per_page
43
- 20
44
- end
45
-
46
- end
@@ -1,30 +0,0 @@
1
- <div id='actions'>
2
- <ul>
3
- <li>
4
- <%= render :partial => "/shared/admin/search", :locals => {:url => admin_news_items_url} %>
5
- </li>
6
- <li>
7
- <%= link_to t('.create'), new_admin_news_item_url, :class => "add_icon" %>
8
- </li>
9
- </ul>
10
- </div>
11
- <div id='records'>
12
- <% if searching? %>
13
- <h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
14
- <% end %>
15
- <% if @news_items.any? %>
16
- <%= will_paginate @news_items %>
17
- <ul>
18
- <%= render :partial => "news_item", :collection => @news_items %>
19
- </ul>
20
- <%= will_paginate @news_items %>
21
- <% else %>
22
- <p>
23
- <% unless searching? %>
24
- <strong><%= t('.no_items_yet') %></strong>
25
- <% else %>
26
- <%= t('shared.admin.search.no_results') %>
27
- <% end %>
28
- </p>
29
- <% end %>
30
- </div>
@@ -1,23 +0,0 @@
1
- <% content_for :body_content_left do %>
2
- <%=raw @page[:body] if @news_items.offset == 0 %>
3
-
4
- <% if @news_items.any? %>
5
- <% @news_items.each do |item| %>
6
- <article class="news_item_truncated">
7
- <h3><%= link_to item.title, news_item_url(item) %></h3>
8
- <p>
9
- <small><%= t('.published') %> <%= l(item.publish_date, :format => :long) %></small>
10
- </p>
11
- <%= truncate item.body, :length => 200,
12
- :omission => " ... #{link_to t('.read_more'), news_item_url(item)}",
13
- :preserve_html_tags => true %>
14
- </article>
15
- <% end %>
16
-
17
- <%= will_paginate(@news_items) %>
18
- <% else %>
19
- <p><em><%= t('.no_items_yet') %></em></p>
20
- <% end %>
21
- <% end -%>
22
-
23
- <%= render :partial => "/shared/content_page" %>