refinerycms-news 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.travis.yml +23 -10
- data/Gemfile +23 -54
- data/Rakefile +2 -0
- data/app/controllers/refinery/news/items_controller.rb +8 -11
- data/app/helpers/refinery/news/items_helper.rb +14 -17
- data/app/models/refinery/news/item.rb +9 -4
- data/app/views/refinery/news/admin/items/_form.html.erb +9 -16
- data/app/views/refinery/news/admin/items/_item.html.erb +6 -3
- data/app/views/refinery/news/admin/items/edit.html.erb +1 -1
- data/app/views/refinery/news/admin/items/index.html.erb +1 -1
- data/app/views/refinery/news/admin/items/new.html.erb +1 -1
- data/app/views/refinery/news/items/archive.html.erb +6 -6
- data/app/views/refinery/news/items/index.html.erb +3 -3
- data/app/views/refinery/news/items/show.html.erb +3 -3
- data/app/views/refinery/news/items/widgets/_news_archive.html.erb +1 -5
- data/app/views/refinery/news/shared/_body_content_right.html.erb +1 -1
- data/config/locales/bg.yml +18 -18
- data/config/locales/cs.yml +19 -19
- data/config/locales/da.yml +47 -0
- data/config/locales/de.yml +18 -18
- data/config/locales/en.yml +3 -2
- data/config/locales/es-MX.yml +18 -18
- data/config/locales/es.yml +19 -19
- data/config/locales/fr.yml +31 -19
- data/config/locales/it.yml +18 -18
- data/config/locales/ja.yml +48 -0
- data/config/locales/lv.yml +20 -18
- data/config/locales/nb.yml +18 -18
- data/config/locales/nl.yml +30 -18
- data/config/locales/pl.yml +29 -18
- data/config/locales/ru.yml +18 -18
- data/config/locales/sk.yml +31 -19
- data/config/locales/sl.yml +0 -2
- data/config/locales/zh-CN.yml +18 -18
- data/config/locales/zh-TW.yml +29 -29
- data/config/routes.rb +2 -2
- data/readme.md +51 -2
- data/refinerycms-news.gemspec +4 -5
- data/spec/controllers/refinery/news/items_controller_spec.rb +67 -0
- data/spec/{requests → features}/manage_news_items_spec.rb +6 -6
- data/spec/{requests → features}/news_archive.rb +0 -0
- data/spec/{requests → features}/visit_news_items_spec.rb +5 -7
- data/spec/helpers/refinery/news/items_helper_spec.rb +34 -0
- data/spec/models/refinery/news/item_spec.rb +38 -14
- data/spec/spec_helper.rb +20 -46
- metadata +26 -30
- data/Guardfile +0 -20
- data/app/views/refinery/news/admin/items/_locale_picker.html.erb +0 -11
- data/config/locales/jp.yml +0 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a5eb03c40be74b743440b65a5f321d684a27fbaa
|
4
|
+
data.tar.gz: 5dec817e08d7d98232ea21d4301d53c36054f1b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d6ac165e91096cf87e2e776e21308c176e753ed6997b3cbd6c16195dd0a7ad99d14ee5e52c45afdcc24efbd90cc76d2d481baadd3a37383d4b848a7b674843d
|
7
|
+
data.tar.gz: 207bde8a3c45dae4f7848765340cabbb0938a7e10ef5d2b8d267beed061acb6ae0beb64a0fdf023a78265af431f2e844890c79bcd215c1f16c783894f582b41d
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
CHANGED
@@ -1,17 +1,30 @@
|
|
1
|
+
language: ruby
|
2
|
+
bundler_args: --without development
|
1
3
|
before_script:
|
2
|
-
- "
|
3
|
-
|
4
|
+
- "sh -e /etc/init.d/xvfb start"
|
5
|
+
- "bundle exec rake refinery:testing:dummy_app"
|
6
|
+
script:
|
7
|
+
- "DISPLAY=:99.0 bundle exec rspec spec"
|
4
8
|
notifications:
|
5
|
-
email:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
email: true
|
10
|
+
irc:
|
11
|
+
use_notice: true
|
12
|
+
skip_join: true
|
13
|
+
channels:
|
14
|
+
- "irc.freenode.org#refinerycms"
|
15
|
+
campfire:
|
16
|
+
on_success: always
|
17
|
+
on_failure: always
|
18
|
+
rooms:
|
19
|
+
- secure: "JaX+Ckvdd2wqL2bD6t8PHvMDBHxWBlCrkBKPcDKxV0t0DOwzzzwxMryVqcRi\nPsmM/zvmWFATDyRmivhNOpu4lRg9RytSroxZ9nkmbLDqjCyEAZ6tv4yZXME/\nPaxPwmfwgS9g8TKjj3lSWS7rEpqqg0D5S0XIfIHrj6KB6LUmFHc="
|
9
20
|
env:
|
10
21
|
- DB=postgresql
|
11
22
|
- DB=mysql
|
23
|
+
matrix:
|
24
|
+
allow_failures:
|
25
|
+
- rvm: rbx-19mode
|
12
26
|
rvm:
|
13
|
-
-
|
14
|
-
- 1.9.2
|
27
|
+
- 2.0.0
|
15
28
|
- 1.9.3
|
16
|
-
- rbx
|
17
|
-
- jruby
|
29
|
+
- rbx-19mode
|
30
|
+
- jruby-19mode
|
data/Gemfile
CHANGED
@@ -2,63 +2,29 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'refinerycms', '~> 2.0
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem 'activerecord-jdbcpostgresql-adapter'
|
15
|
-
gem 'jruby-openssl'
|
16
|
-
end
|
17
|
-
|
18
|
-
unless defined?(JRUBY_VERSION)
|
19
|
-
gem 'sqlite3'
|
20
|
-
gem 'mysql2'
|
21
|
-
gem 'pg'
|
22
|
-
end
|
23
|
-
|
24
|
-
platforms :mswin, :mingw do
|
25
|
-
gem 'win32console'
|
26
|
-
gem 'rb-fchange', '~> 0.0.5'
|
27
|
-
gem 'rb-notifu', '~> 0.0.4'
|
28
|
-
end
|
29
|
-
|
30
|
-
platforms :ruby do
|
31
|
-
gem 'spork', '~> 0.9.0.rc'
|
32
|
-
gem 'guard-spork'
|
5
|
+
gem 'refinerycms', '~> 2.1.0'
|
6
|
+
gem 'refinerycms-settings', :github => 'refinery/refinerycms-settings'
|
7
|
+
gem 'refinerycms-testing', '~> 2.1.0', :group => :test
|
8
|
+
|
9
|
+
# Database Configuration
|
10
|
+
unless ENV['TRAVIS']
|
11
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
12
|
+
gem 'sqlite3', :platform => :ruby
|
13
|
+
end
|
33
14
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
41
|
-
gem 'rb-inotify', '>= 0.5.1'
|
42
|
-
gem 'libnotify', '~> 0.1.3'
|
43
|
-
gem 'therubyracer', '~> 0.9.9'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
15
|
+
if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
|
16
|
+
gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
|
17
|
+
gem 'jdbc-mysql', '= 5.1.13', :platform => :jruby
|
18
|
+
gem 'mysql2', :platform => :ruby
|
19
|
+
end
|
47
20
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
52
|
-
gem 'ruby_gntp'
|
53
|
-
end
|
54
|
-
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
55
|
-
gem 'rb-inotify', '>= 0.5.1'
|
56
|
-
gem 'libnotify', '~> 0.1.3'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
21
|
+
if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql'
|
22
|
+
gem 'activerecord-jdbcpostgresql-adapter', :platform => :jruby
|
23
|
+
gem 'pg', :platform => :ruby
|
60
24
|
end
|
61
25
|
|
26
|
+
gem 'jruby-openssl', :platform => :jruby
|
27
|
+
|
62
28
|
# Refinery/rails should pull in the proper versions of these
|
63
29
|
group :assets do
|
64
30
|
gem 'sass-rails'
|
@@ -66,4 +32,7 @@ group :assets do
|
|
66
32
|
gem 'uglifier'
|
67
33
|
end
|
68
34
|
|
69
|
-
|
35
|
+
# Load local gems according to Refinery developer preference.
|
36
|
+
if File.exist? local_gemfile = File.expand_path('../.gemfile', __FILE__)
|
37
|
+
eval File.read(local_gemfile)
|
38
|
+
end
|
data/Rakefile
CHANGED
@@ -15,30 +15,27 @@ module Refinery
|
|
15
15
|
|
16
16
|
def archive
|
17
17
|
if params[:month].present?
|
18
|
-
|
19
|
-
@archive_date = Time.parse(
|
20
|
-
@
|
21
|
-
@items = Refinery::News::Item.live.by_archive(@archive_date).page(params[:page])
|
18
|
+
@archive_for_month = true
|
19
|
+
@archive_date = Time.parse("#{params[:month]}/#{params[:year]}")
|
20
|
+
@items = Item.archived.translated.by_archive(@archive_date).page(params[:page])
|
22
21
|
else
|
23
|
-
|
24
|
-
@
|
25
|
-
@date_title = @archive_date.strftime('%Y')
|
26
|
-
@items = Refinery::News::Item.live.by_year(@archive_date).page(params[:page])
|
22
|
+
@archive_date = Time.parse("01/#{params[:year]}")
|
23
|
+
@items = Item.archived.translated.by_year(@archive_date).page(params[:page])
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
30
27
|
protected
|
31
28
|
|
32
29
|
def find_latest_news_items
|
33
|
-
@items =
|
30
|
+
@items = Item.latest.translated
|
34
31
|
end
|
35
32
|
|
36
33
|
def find_published_news_items
|
37
|
-
@items =
|
34
|
+
@items = Item.published.translated.page(params[:page])
|
38
35
|
end
|
39
36
|
|
40
37
|
def find_news_item
|
41
|
-
@item =
|
38
|
+
@item = Item.published.translated.find(params[:id])
|
42
39
|
end
|
43
40
|
|
44
41
|
def find_page
|
@@ -5,7 +5,7 @@ module Refinery
|
|
5
5
|
items = Refinery::News::Item.select('publish_date').all_previous
|
6
6
|
return nil if items.blank?
|
7
7
|
|
8
|
-
render
|
8
|
+
render "/refinery/news/items/widgets/news_archive", :items => items
|
9
9
|
end
|
10
10
|
alias_method :news_archive_list, :news_item_archive_widget
|
11
11
|
|
@@ -28,23 +28,20 @@ module Refinery
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
link_to(text, refinery.news_items_archive_path(:year => year, :month => month))
|
40
|
-
else
|
41
|
-
post_date = post.publish_date.strftime('01/%Y')
|
42
|
-
year = post_date.split('/')[1]
|
43
|
-
count = Refinery::News::Item.by_year(Time.parse(post_date)).size
|
44
|
-
text = "#{year} (#{count})"
|
45
|
-
|
46
|
-
link_to(text, refinery.news_items_archive_path(:year => year))
|
31
|
+
def news_item_archive_links
|
32
|
+
html = ''
|
33
|
+
item_months = ::Refinery::News::Item.archived.group_by {|i| i.publish_date.beginning_of_month}
|
34
|
+
item_months.each do |month, items|
|
35
|
+
if items.present?
|
36
|
+
text = "#{t("date.month_names")[month.month]} #{month.year} (#{items.count})"
|
37
|
+
html += "<li>#{link_to(text, refinery.news_items_archive_path(:year => month.year, :month => month.month))}</li>"
|
38
|
+
end
|
47
39
|
end
|
40
|
+
content_tag('ul', raw(html))
|
41
|
+
end
|
42
|
+
|
43
|
+
def archive_date_format(date_for_month)
|
44
|
+
date_for_month ? "%B %Y" : "%Y"
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'acts_as_indexed'
|
2
|
+
|
1
3
|
module Refinery
|
2
4
|
module News
|
3
5
|
class Item < Refinery::Core::BaseModel
|
@@ -6,7 +8,6 @@ module Refinery
|
|
6
8
|
translates :title, :body
|
7
9
|
|
8
10
|
attr_accessor :locale # to hold temporarily
|
9
|
-
|
10
11
|
attr_accessible :title, :body, :content, :source, :publish_date, :expiration_date
|
11
12
|
class Translation
|
12
13
|
attr_accessible :locale
|
@@ -35,11 +36,11 @@ module Refinery
|
|
35
36
|
|
36
37
|
class << self
|
37
38
|
def by_archive(archive_date)
|
38
|
-
where(
|
39
|
+
where(:publish_date => archive_date.beginning_of_month..archive_date.end_of_month)
|
39
40
|
end
|
40
41
|
|
41
42
|
def by_year(archive_year)
|
42
|
-
where(
|
43
|
+
where(:publish_date => archive_year.beginning_of_year..archive_year.end_of_year)
|
43
44
|
end
|
44
45
|
|
45
46
|
def all_previous
|
@@ -69,7 +70,11 @@ module Refinery
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def live
|
72
|
-
not_expired.where(
|
73
|
+
not_expired.where("publish_date <= ?", Time.now)
|
74
|
+
end
|
75
|
+
|
76
|
+
def archived
|
77
|
+
where("publish_date <= ?", Time.now)
|
73
78
|
end
|
74
79
|
|
75
80
|
# rejects any page that has not been translated to the current locale.
|
@@ -1,14 +1,9 @@
|
|
1
1
|
<%= form_for [refinery, :news, :admin, @item] do |f| %>
|
2
|
-
<%= render
|
3
|
-
:
|
4
|
-
|
5
|
-
:include_object_name => true
|
6
|
-
} %>
|
2
|
+
<%= render "/refinery/admin/error_messages",
|
3
|
+
:object => @item,
|
4
|
+
:include_object_name => true %>
|
7
5
|
|
8
|
-
<%= render :
|
9
|
-
:locals => {
|
10
|
-
:current_locale => Thread.current[:globalize_locale]
|
11
|
-
} if defined?(::Refinery::I18n) %>
|
6
|
+
<%= render '/refinery/admin/locale_picker', :current_locale => Globalize.locale %>
|
12
7
|
|
13
8
|
<div class='field'>
|
14
9
|
<%= f.label :title %>
|
@@ -36,12 +31,10 @@
|
|
36
31
|
<%= f.text_field :source, :class => "larger widest" %>
|
37
32
|
</div>
|
38
33
|
|
39
|
-
<%= render
|
40
|
-
:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
:delete_confirmation => t('shared.admin.delete.message', :title => @item.title)
|
45
|
-
} %>
|
34
|
+
<%= render "/refinery/admin/form_actions",
|
35
|
+
:f => f,
|
36
|
+
:continue_editing => true,
|
37
|
+
:delete_title => t('admin.news.items.item.delete'),
|
38
|
+
:delete_confirmation => t('shared.admin.delete.message', :title => @item.title) %>
|
46
39
|
|
47
40
|
<% end %>
|
@@ -4,11 +4,12 @@
|
|
4
4
|
<span class="preview">
|
5
5
|
<%= t('.published') %> <%= l(item.publish_date, :format => :short) %>
|
6
6
|
</span>
|
7
|
-
<% if
|
7
|
+
<% if Refinery::I18n.frontend_locales.many? and
|
8
8
|
(locales = item.translations.collect{|t| t.locale}).present? %>
|
9
9
|
<span class='preview'>
|
10
10
|
<% locales.each do |locale| %>
|
11
|
-
<%= refinery_icon_tag
|
11
|
+
<%= link_to refinery_icon_tag("flags/#{locale}.png", :size => '16x11'), refinery.edit_news_admin_item_path(item, :switch_locale => locale),
|
12
|
+
:class => "locale" %>
|
12
13
|
<% end %>
|
13
14
|
</span>
|
14
15
|
<% end %>
|
@@ -23,6 +24,8 @@
|
|
23
24
|
:class => "cancel confirm-delete",
|
24
25
|
:title => t('.delete'),
|
25
26
|
:method => :delete,
|
26
|
-
:
|
27
|
+
:data => {
|
28
|
+
:confirm => t('refinery.admin.delete.message', :title => item.title)
|
29
|
+
} %>
|
27
30
|
</span>
|
28
31
|
</li>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render
|
1
|
+
<%= render "form" %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id='actions'>
|
2
2
|
<ul>
|
3
3
|
<li>
|
4
|
-
<%= render
|
4
|
+
<%= render "/refinery/admin/search", :url => refinery.news_admin_items_path %>
|
5
5
|
</li>
|
6
6
|
<li>
|
7
7
|
<%= link_to t('.create'), refinery.new_news_admin_item_path, :class => "add_icon" %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render
|
1
|
+
<%= render "form" %>
|
@@ -1,17 +1,17 @@
|
|
1
|
-
<% content_for :title, "#{t('.news_item_archive_for', :date => @archive_date
|
1
|
+
<% content_for :title, "#{t('.news_item_archive_for', :date => l(@archive_date, :format => archive_date_format(@archive_for_month)))}" %>
|
2
2
|
|
3
|
-
<% content_for :
|
4
|
-
<h1><%= t('.news_item_archive_for', :date => @archive_date
|
3
|
+
<% content_for :body do %>
|
4
|
+
<h1><%= t('.news_item_archive_for', :date => l(@archive_date, :format => archive_date_format(@archive_for_month))) %></h1>
|
5
5
|
<% if @items.any? %>
|
6
6
|
<section id="news_items">
|
7
7
|
<%= render :partial => "/refinery/news/shared/item", :collection => @items %>
|
8
8
|
</section>
|
9
9
|
<% else %>
|
10
|
-
<p><%= t('.no_news_item_articles_posted', :date => @archive_date
|
10
|
+
<p><%= t('.no_news_item_articles_posted', :date => l(@archive_date, :format => '%B %Y')) %></p>
|
11
11
|
<% end %>
|
12
12
|
<% end %>
|
13
13
|
|
14
|
-
<%= render
|
14
|
+
<%= render '/refinery/news/shared/body_content_right' %>
|
15
15
|
|
16
|
-
<%= render
|
16
|
+
<%= render "/refinery/content_page" %>
|
17
17
|
<% content_for :stylesheets, stylesheet_link_tag('refinery/news/frontend') %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% content_for :
|
1
|
+
<% content_for :body do %>
|
2
2
|
<%=raw @page.content_for(Refinery::Pages.default_parts.first.to_sym) unless params[:page] %>
|
3
3
|
|
4
4
|
<% if @items.any? %>
|
@@ -23,6 +23,6 @@
|
|
23
23
|
<% content_for :body_content_right_prepend do -%>
|
24
24
|
<%= raw @page.content_for(::Refinery::Pages.default_parts.second.to_sym) %>
|
25
25
|
<% end if ::Refinery::Pages.default_parts.many? -%>
|
26
|
-
<%= render
|
26
|
+
<%= render '/refinery/news/shared/body_content_right' %>
|
27
27
|
|
28
|
-
<%= render
|
28
|
+
<%= render "/refinery/content_page" %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% content_for :body_content_title, @item.title %>
|
2
|
-
<% content_for :
|
2
|
+
<% content_for :body do %>
|
3
3
|
<article class="news_item">
|
4
4
|
<p>
|
5
5
|
<small><%= t('.published') %> <%= l(@item.publish_date, :format => :long) %></small>
|
@@ -15,6 +15,6 @@
|
|
15
15
|
</p>
|
16
16
|
</article>
|
17
17
|
<% end %>
|
18
|
-
<% content_for :
|
18
|
+
<% content_for :side_body, render(:partial => 'recent_posts') %>
|
19
19
|
|
20
|
-
<%= render
|
20
|
+
<%= render "/refinery/content_page" %>
|
@@ -1,10 +1,6 @@
|
|
1
1
|
<section id="news_archive_widget">
|
2
2
|
<h2><%= t('archives', :scope => 'refinery.news.shared') %></h2>
|
3
3
|
<nav>
|
4
|
-
|
5
|
-
<% items.each do |item| %>
|
6
|
-
<li><%= news_item_archive_link(item) %></li>
|
7
|
-
<% end %>
|
8
|
-
</ul>
|
4
|
+
<%= news_item_archive_links %>
|
9
5
|
</nav>
|
10
6
|
</section>
|