refinerycms-news 0.9.7.3 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ protected
14
14
  end
15
15
 
16
16
  def find_page
17
- @page = Page.find_by_link_url("/news", :include => [:parts, :slugs])
17
+ @page = Page.find_by_link_url("/news")
18
18
  end
19
19
 
20
20
  end
@@ -1,13 +1,14 @@
1
1
  class NewsItem < ActiveRecord::Base
2
2
 
3
- validates_presence_of :title, :body, :publish_date
3
+ alias_attribute :content, :body
4
+ validates_presence_of :title, :content, :publish_date
4
5
 
5
6
  has_friendly_id :title, :use_slug => true
6
7
 
7
- acts_as_indexed :fields => [:title, :body],
8
- :index_file => %W(#{Rails.root} tmp index)
8
+ acts_as_indexed :fields => [:title, :body]
9
9
 
10
10
  default_scope :order => "publish_date DESC"
11
+
11
12
  # If you're using a named scope that includes a changing variable you need to wrap it in a lambda
12
13
  # This avoids the query being cached thus becoming unaffected by changes (i.e. Time.now is constant)
13
14
  named_scope :latest, lambda { { :conditions => ["publish_date < ?", Time.now], :limit => 10 } }
@@ -17,6 +18,7 @@ class NewsItem < ActiveRecord::Base
17
18
  publish_date > Time.now
18
19
  end
19
20
 
21
+ # for will_paginate
20
22
  def self.per_page
21
23
  20
22
24
  end
@@ -1,19 +1,25 @@
1
- <%= error_messages_for :news_item %>
2
1
  <% form_for [:admin, @news_item] do |f| %>
2
+ <%= f.error_messages %>
3
+
3
4
  <div class='field'>
4
5
  <%= f.label :title %>
5
- <%= f.text_field :title, :class => "larger", :style => 'width: 954px' %>
6
+ <%= f.text_field :title, :class => "larger widest" %>
6
7
  </div>
8
+
7
9
  <div class='field'>
8
10
  <%= f.label :publish_date %>
9
11
  <%= f.datetime_select :publish_date %>
10
12
  </div>
11
- <div class='clearfix' style='width:963px'>
12
- <div class='field'>
13
- <%= f.label :body %>
14
- <%= f.text_area :body, :rows => "20", :class => "wymeditor" %>
15
- </div>
13
+
14
+ <div class='field'>
15
+ <%= f.label :content %>
16
+ <%= f.text_area :content, :rows => "20", :class => "wymeditor widest" %>
16
17
  </div>
17
- <%= render :partial => "/shared/admin/form_actions", :locals => {:f => f,
18
- :continue_editing => true} %>
18
+
19
+ <%= render :partial => "/shared/admin/form_actions",
20
+ :locals => {
21
+ :f => f,
22
+ :continue_editing => true
23
+ } %>
24
+
19
25
  <% end %>
@@ -1,15 +1,16 @@
1
1
  <li class='clearfix record <%= cycle("on", "on-hover") %>'>
2
2
  <span class='title'>
3
- <span class='actions'>
4
- <%= link_to refinery_icon_tag('application_go.png'), news_item_url(news_item),
5
- :title => 'View this news item live <br/><em>(opens in a new window)</em>',
6
- :target => "_blank" %>
7
- <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_news_item_path(news_item),
8
- :title => 'Edit this news item' %>
9
- <%= link_to refinery_icon_tag('delete.png'), admin_news_item_path(news_item),
10
- :class => "cancel confirm-delete",
11
- :title => "Remove this news item forever" %>
12
- </span>
13
- <%=h news_item.title %> <span class="preview">&nbsp;</span>
3
+ <%=h news_item.title %>
4
+ <span class="preview">&nbsp;</span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%= link_to refinery_icon_tag('application_go.png'), news_item_url(news_item),
8
+ :title => t('.view_live'),
9
+ :target => "_blank" %>
10
+ <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_news_item_path(news_item),
11
+ :title => t('.edit') %>
12
+ <%= link_to refinery_icon_tag('delete.png'), admin_news_item_path(news_item),
13
+ :class => "cancel confirm-delete",
14
+ :title => t('.delete') %>
14
15
  </span>
15
16
  </li>
@@ -1 +1 @@
1
- <%= render :partial => "form" %>
1
+ <%= render :partial => "form" %>
@@ -4,12 +4,12 @@
4
4
  <%= render :partial => "/shared/admin/search", :locals => {:url => admin_news_items_url} %>
5
5
  </li>
6
6
  <li>
7
- <%= link_to "Create News Item", new_admin_news_item_url, :class => "add_icon" %>
7
+ <%= link_to t('.create'), new_admin_news_item_url, :class => "add_icon" %>
8
8
  </li>
9
9
  </ul>
10
10
  </div>
11
11
  <div id='records'>
12
- <%= "<h2>Search Results for \"#{params[:search]}\"</h2>" if searching? %>
12
+ <%= "<h2>#{t('admin.search_results_for', :query => params[:search])}</h2>" if searching? %>
13
13
  <% if @news_items.any? %>
14
14
  <%= will_paginate @news_items, :previous_label => '&laquo;', :next_label => '&raquo;' %>
15
15
  <ul>
@@ -19,13 +19,10 @@
19
19
  <% else %>
20
20
  <% unless searching? %>
21
21
  <p>
22
- <strong>
23
- There are no news items yet.
24
- Click "Create News Item" to add your first news item.
25
- </strong>
22
+ <strong><%= t('.no_items_yet') %></strong>
26
23
  </p>
27
24
  <% else %>
28
- <p>Sorry, no results found.</p>
25
+ <p><%= t('admin.search_no_results') %></p>
29
26
  <% end %>
30
27
  <% end %>
31
28
  </div>
@@ -1 +1 @@
1
- <%= render :partial => "form" %>
1
+ <%= render :partial => "form" %>
@@ -1,4 +1,4 @@
1
- <h2>Recent Posts</h2>
1
+ <h2><%= t('.recent_posts') %></h2>
2
2
  <ul>
3
3
  <% @news_items.each do |item| %>
4
4
  <li>
@@ -5,14 +5,19 @@
5
5
  <% @news_items.each do |item| %>
6
6
  <h3><%= link_to item.title, news_item_url(item) %></h3>
7
7
  <p>
8
- <small>Published <%= item.publish_date.strftime("%A %d of %B, %Y") %></small>
8
+ <small><%= t('.published') %> <%= l(item.publish_date) %></small>
9
9
  </p>
10
- <%= truncate(item.body, :length => 200, :omission => " ... #{link_to "Read more", news_item_url(item)}", :preserve_html_tags => true) %>
10
+ <%= truncate item.body, :length => 200,
11
+ :omission => " ... #{link_to t('.read_more'), news_item_url(item)}",
12
+ :preserve_html_tags => true %>
11
13
  <% end %>
14
+
12
15
  <%= will_paginate(@news_items) %>
13
16
  <% else %>
14
- <p><em>Sorry we haven't posted up any news yet.</em></p>
17
+ <p><em><%= t('.no_items_yet') %></em></p>
15
18
  <% end %>
16
- <% end %>
19
+ <% end -%>
20
+
17
21
  <% content_for :body_content_right, "&nbsp;" if @news_items.offset > 0 -%>
22
+
18
23
  <%= render :partial => "/shared/content_page" %>
@@ -1,11 +1,11 @@
1
1
  <% content_for :body_content_title, "<h1>#{@news_item.title}</h1>" %>
2
2
  <% content_for :body_content_left do %>
3
3
  <p>
4
- <small>Published <%= @news_item.publish_date.strftime("%A %d of %B, %Y") %></small>
4
+ <small><%= t('.published') %> <%= l(@news_item.publish_date, :format => :long) %></small>
5
5
  </p>
6
6
  <%= @news_item.body %>
7
7
  <p>
8
- <%= link_to "Back to all news", news_items_url %>
8
+ <%= link_to t('.back_to_index'), news_items_url %>
9
9
  </p>
10
10
  <% end %>
11
11
  <% content_for :body_content_right, render(:partial => 'recent_posts') %>
@@ -0,0 +1,34 @@
1
+ en:
2
+ plugins:
3
+ news:
4
+ title: News
5
+ admin:
6
+ news_items:
7
+ news_item:
8
+ view_live: "View this news item live <br/><em>(opens in a new window)</em>"
9
+ edit: "Edit this news item"
10
+ delete: "Remove this news item forever"
11
+ index:
12
+ actions: Actions
13
+ create: "Create News Item"
14
+ news_item: News
15
+ no_items: "Sorry, no results found."
16
+ no_items_yet: 'There are no news item entries yet. Click "Create News Item" to add your first news item entries.'
17
+ news_items:
18
+ show:
19
+ back_to_index: "Back to all news"
20
+ published: Published
21
+ no_items: "Sorry we haven't posted up any news yet."
22
+ read_more: Read more
23
+ recent_posts:
24
+ recent_posts: Recent Posts
25
+ index:
26
+ published: Published
27
+ activerecord:
28
+ attributes:
29
+ news_item:
30
+ title: Title
31
+ body: Body
32
+ publish_date: Publish date
33
+ models:
34
+ news_item: News Item
@@ -0,0 +1,33 @@
1
+ nl:
2
+ plugins:
3
+ news:
4
+ title: Nieuws
5
+ activerecord:
6
+ attributes:
7
+ news_item:
8
+ title: Titel
9
+ content: Inhoud
10
+ publish_date: Publiceer Datum
11
+ models:
12
+ news_item: Nieuws Item
13
+ admin:
14
+ news_items:
15
+ news_item:
16
+ view_live: Bekijk dit bericht op de website.<br/><em>(opent in een nieuw venster.)</em>
17
+ edit: Bewerk dit bericht
18
+ delete: Verwijder dit bericht permanent
19
+ index:
20
+ create: Maak een nieuw nieuwsbericht
21
+ no_items_yet: Er zijn nog geen nieuwsberichten. Klik op "Maak een nieuw niewsbericht" om het eerste bericht te maken.
22
+ news_items:
23
+ recent_posts:
24
+ recent_posts: Laatste nieuws item
25
+ index:
26
+ create: Maak Nieuws Item
27
+ published: "Gepubliceerd op"
28
+ read_more: Lees meer
29
+ no_items_yet: "Sorry, er zijn nog geen nieuwsberichten geplaatst."
30
+ show:
31
+ published: Gepubliceerd op
32
+ back_to_index: Terug naar de andere berichten
33
+
@@ -0,0 +1,34 @@
1
+ pt-BR:
2
+ plugins:
3
+ news:
4
+ title: Notícias
5
+ activerecord:
6
+ attributes:
7
+ news_item:
8
+ title: Título
9
+ content: Contéudo
10
+ publish_date: Data de publicação
11
+ models:
12
+ news_item: Notícia
13
+ admin:
14
+ news_items:
15
+ news_item:
16
+ view_live: "Ver esta notícia no site<br/><em>(abrirá em uma nova janela)</em>"
17
+ edit: "Alterar esta notícia"
18
+ delete: "Remover esta notícia para sempre"
19
+ index:
20
+ actions: Ações
21
+ create: "Criar Notícia"
22
+ news_item: Notícia
23
+ no_items: 'Não há notícias cadastradas.'
24
+ no_items_yet: 'Não há notícias cadastradas. Clique em "Criar Notícia" para cadastrar sua primeira notícia.'
25
+ news_items:
26
+ show:
27
+ back_to_index: "Voltar para todas as notícias"
28
+ published: Publicado
29
+ no_items: "Nos desculpe, nós não postamos nenhuma notícia ainda."
30
+ read_more: Leia mais
31
+ recent_posts:
32
+ recent_posts: Notícias recentes
33
+ index:
34
+ published: Publicado
@@ -0,0 +1,29 @@
1
+ class NewsGenerator < Rails::Generator::NamedBase
2
+
3
+ def initialize(*runtime_args)
4
+ # set first argument to the table's name so that the user doesn't have to pass it in.
5
+ runtime_args[0] = ["news_items"]
6
+ super(*runtime_args)
7
+ end
8
+
9
+ def banner
10
+ "Usage: script/generate news"
11
+ end
12
+
13
+ def manifest
14
+ record do |m|
15
+ m.migration_template 'migration.rb', 'db/migrate',
16
+ :migration_file_name => "create_structure_for_news",
17
+ :assigns => {
18
+ :migration_name => "CreateStructureForNews",
19
+ :table_name => "news_items",
20
+ :attributes => [
21
+ Rails::Generator::GeneratedAttribute.new("title", "string"),
22
+ Rails::Generator::GeneratedAttribute.new("body", "text"),
23
+ Rails::Generator::GeneratedAttribute.new("publish_date", "datetime")
24
+ ]
25
+ }
26
+ end
27
+ end
28
+
29
+ end if defined?(Rails::Generator::NamedBase)
@@ -0,0 +1,42 @@
1
+ class <%= migration_name %> < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :<%= table_name %> do |t|
5
+ <% attributes.each do |attribute| -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :<%= table_name %>, :id
12
+
13
+ User.find(:all).each do |user|
14
+ user.plugins.create(:name => "News", :position => (user.plugins.maximum(:position) || -1) + 1)
15
+ end
16
+
17
+ page = Page.create(:title => "News",
18
+ :link_url => "/news",
19
+ :menu_match => "^/news.*$",
20
+ :deletable => false,
21
+ :position => Page.count)
22
+
23
+ RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
24
+ page.parts.create(:title => default_page_part, :body => nil)
25
+ end
26
+
27
+ end
28
+
29
+ def self.down
30
+ UserPlugin.destroy_all({:title => "News"})
31
+
32
+ Page.find_all_by_link_url("/news").each do |page|
33
+ page.link_url, page.menu_match = nil
34
+ page.deletable = true
35
+ page.destroy
36
+ end
37
+ Page.destroy_all({:link_url => "/news"})
38
+
39
+ drop_table :<%= table_name %>
40
+ end
41
+
42
+ end
data/lib/gemspec.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.expand_path('../news.rb', __FILE__)
3
- version = Refinery::Portfolio::Version::STRING
3
+ version = ::Refinery::News.version
4
4
  raise "Could not get version so gemspec can not be built" if version.nil?
5
- files = %w( readme.md license.md )
6
- %w(app bin config db lib public rails test vendor).each do |dir|
7
- files += Dir.glob("#{dir}/**/*") if File.directory?(dir)
5
+ files = Dir.glob("**/*").flatten.reject do |file|
6
+ file =~ /\.gem(spec)?$/
8
7
  end
9
8
 
10
9
  gemspec = <<EOF
@@ -16,9 +15,8 @@ Gem::Specification.new do |s|
16
15
  s.summary = %q{Ruby on Rails news engine for RefineryCMS.}
17
16
  s.email = %q{info@refinerycms.com}
18
17
  s.homepage = %q{http://refinerycms.com}
19
- s.authors = %w(Resolve\\ Digital Philip\\ Arndt David\\ Jones)
18
+ s.authors = %w(Resolve\\ Digital)
20
19
  s.require_paths = %w(lib)
21
- s.executables = %w()
22
20
 
23
21
  s.files = [
24
22
  '#{files.join("',\n '")}'
@@ -29,11 +27,4 @@ Gem::Specification.new do |s|
29
27
  end
30
28
  EOF
31
29
 
32
- if (save = ARGV.delete('-s'))
33
- if File.exist?(file = File.expand_path("../../refinerycms-news.gemspec", __FILE__))
34
- File.delete(file)
35
- end
36
- File.open(file, 'w') { |f| f.puts gemspec }
37
- else
38
- puts gemspec
39
- end
30
+ File.open(File.expand_path("../../refinerycms-news.gemspec", __FILE__), 'w').puts(gemspec)
data/lib/news.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  module Refinery
2
- module Portfolio
3
- class Version
4
- MAJOR = 0
5
- MINOR = 9
6
- TINY = 7
7
- BUILD = 3
8
-
9
- STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
2
+ module News
3
+ class << self
4
+ def version
5
+ %q{0.9.8}
6
+ end
10
7
  end
11
8
  end
12
9
  end
data/rails/init.rb CHANGED
@@ -2,10 +2,12 @@ Refinery::Plugin.register do |plugin|
2
2
  plugin.title = "News"
3
3
  plugin.description = "Provides a blog-like news section"
4
4
  plugin.version = 1.0
5
- plugin.menu_match = /admin\/news(_items)?$/
5
+ plugin.menu_match = /(admin|refinery)\/news(_items)?$/
6
+ plugin.url = '/refinery/news'
6
7
  plugin.activity = {
7
8
  :class => NewsItem,
8
9
  :title => 'title',
9
10
  :url_prefix => 'edit'
10
11
  }
12
+ plugin.directory = directory
11
13
  end
data/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # News
2
2
 
3
- ![Refinery News](http://refinerycms.com/system/images/0000/0646/news.png)
3
+ ![Refinery News](http://refinerycms.com/system/images/0000/0876/news.png)
4
4
 
5
5
  ## About
6
6
 
@@ -15,21 +15,25 @@ Key features:
15
15
 
16
16
  To install the news engine, you can either include the gem or install as a plugin.
17
17
 
18
- ### RubyGems Installation
18
+ ## Requirements
19
19
 
20
- Include the latest (gem)[http://rubygems.org/gems/refinerycms-news] into your config/application.rb file like so:
20
+ [RefineryCMS](http://refinerycms.com) version 0.9.6 or later.
21
21
 
22
- config.gem "refinerycms-news", :lib => "news", :source => "rubygems.org", :version => "~> 0.9.7.1"
22
+ ### Gem Installation using Bundler
23
+
24
+ Include the latest [gem](http://rubygems.org/gems/refinerycms-news) into your Refinery CMS application's Gemfile:
25
+
26
+ gem "refinerycms-news", '~> 0.9.8', :require => "news"
23
27
 
24
28
  Then type the following at command line inside your Refinery CMS application's root directory:
25
29
 
26
- rake gems:install
30
+ bundle install
27
31
  script/generate news
28
32
  rake db:migrate
29
33
 
30
34
  ### Rails Engine Installation
31
35
 
32
- If you do not want to install the engine via RubyGems then you can install it as an engine inside your application's vendor directory.
36
+ If you do not want to install the engine via bundler then you can install it as an engine inside your application's vendor directory.
33
37
  Type the following at command line inside your Refinery CMS application's root directory:
34
38
 
35
39
  script/plugin install git://github.com/resolve/refinerycms-news.git
@@ -0,0 +1,14 @@
1
+ website_launched:
2
+ title: New website launched!
3
+ body: Oh yes our brand new website is here and it is running on Refinery CMS.
4
+ publish_date: <%= Date.today - 4.days %>
5
+
6
+ new_team_member:
7
+ title: Amanda joins Resolve Digital
8
+ body: Welcome Amanda to the Resolve Digital team.
9
+ publish_date: <%= Date.today - 2.days %>
10
+
11
+ product_launch:
12
+ title: Secret new product launched
13
+ body: Oh yes our brand new website is here and it is running on Refinery CMS.
14
+ publish_date: <%= Date.today.tomorrow %>
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+
3
+ class NewsItemsTest < ActiveSupport::TestCase
4
+
5
+ self.fixture_path = File.expand_path("../../fixtures", __FILE__)
6
+ fixtures :news_items
7
+
8
+ def setup
9
+ @new_news_item = NewsItem.new
10
+ @new_valid_news_item = NewsItem.new(:title => "valid post", :content => "yep looks valid", :publish_date => Date.today)
11
+ end
12
+
13
+ def test_should_not_save_without_title_and_body
14
+ assert !@new_news_item.save
15
+
16
+ assert_equal "can't be blank", @new_news_item.errors.on('title')
17
+ assert_equal "can't be blank", @new_news_item.errors.on('content')
18
+ assert_equal "can't be blank", @new_news_item.errors.on('publish_date')
19
+
20
+ assert @new_valid_news_item.save
21
+ end
22
+
23
+ def test_per_page
24
+ assert_equal 20, NewsItem.per_page
25
+ end
26
+
27
+ def test_named_scopes
28
+ assert_equal 2, NewsItem.published.size
29
+ assert NewsItem.latest.size < 10
30
+
31
+ assert_equal news_items(:new_team_member), NewsItem.latest.first
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,23 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-news
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 43
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 7
9
- - 3
10
- version: 0.9.7.3
9
+ - 8
10
+ version: 0.9.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Resolve Digital
14
- - Philip Arndt
15
- - David Jones
16
14
  autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-06-15 00:00:00 +12:00
18
+ date: 2010-07-12 00:00:00 +12:00
21
19
  default_executable:
22
20
  dependencies: []
23
21
 
@@ -30,8 +28,6 @@ extensions: []
30
28
  extra_rdoc_files: []
31
29
 
32
30
  files:
33
- - readme.md
34
- - license.md
35
31
  - app/controllers/admin/news_items_controller.rb
36
32
  - app/controllers/news_items_controller.rb
37
33
  - app/models/news_item.rb
@@ -44,11 +40,19 @@ files:
44
40
  - app/views/news_items/index.html.erb
45
41
  - app/views/news_items/index.rss.builder
46
42
  - app/views/news_items/show.html.erb
47
- - config/locale/en.yml
43
+ - config/locales/en.yml
44
+ - config/locales/nl.yml
45
+ - config/locales/pt-BR.yml
48
46
  - config/routes.rb
47
+ - generators/news/news_generator.rb
48
+ - generators/news/templates/migration.rb
49
49
  - lib/gemspec.rb
50
50
  - lib/news.rb
51
+ - license.md
51
52
  - rails/init.rb
53
+ - readme.md
54
+ - test/fixtures/news_items.yml
55
+ - test/unit/news_items_test.rb
52
56
  has_rdoc: true
53
57
  homepage: http://refinerycms.com
54
58
  licenses: []
@@ -63,6 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
67
  requirements:
64
68
  - - ">="
65
69
  - !ruby/object:Gem::Version
70
+ hash: 3
66
71
  segments:
67
72
  - 0
68
73
  version: "0"
@@ -71,6 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
76
  requirements:
72
77
  - - ">="
73
78
  - !ruby/object:Gem::Version
79
+ hash: 3
74
80
  segments:
75
81
  - 0
76
82
  version: "0"
@@ -81,5 +87,5 @@ rubygems_version: 1.3.7
81
87
  signing_key:
82
88
  specification_version: 3
83
89
  summary: Ruby on Rails news engine for RefineryCMS.
84
- test_files: []
85
-
90
+ test_files:
91
+ - test/unit/news_items_test.rb
data/config/locale/en.yml DELETED
File without changes