refinerycms-news 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/db/migrate/1_create_news_items.rb +23 -0
- data/db/migrate/2_add_external_url_to_news_items.rb +15 -0
- data/db/migrate/3_translate_news_items.rb +24 -0
- data/db/migrate/4_add_image_id_to_news_items.rb +13 -0
- data/db/seeds/refinerycms_news.rb +24 -0
- data/lib/gemspec.rb +1 -1
- data/lib/generators/refinerycms_news_generator.rb +4 -48
- data/lib/news.rb +1 -1
- data/license.md +5 -5
- data/readme.md +2 -2
- metadata +9 -6
- data/lib/generators/refinerycms_news/templates/db/migrate/migration_number_create_singular_name.rb +0 -29
- data/lib/generators/refinerycms_news/templates/db/seeds/seed.rb +0 -16
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateNewsItems < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table ::NewsItem.table_name, :id => true do |t|
|
5
|
+
t.string :title
|
6
|
+
t.text :body
|
7
|
+
t.datetime :publish_date
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index ::NewsItem.table_name, :id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
::UserPlugin.destroy_all :name => "refinerycms_news"
|
17
|
+
|
18
|
+
::Page.delete_all :link_url => "/news"
|
19
|
+
|
20
|
+
drop_table ::NewsItem.table_name
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddExternalUrlToNewsItems < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
unless ::NewsItem.column_names.map(&:to_sym).include?(:external_url)
|
5
|
+
add_column ::NewsItem.table_name, :external_url, :string
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
if ::NewsItem.column_names.map(&:to_sym).include?(:external_url)
|
11
|
+
remove_column ::NewsItem.table_name, :external_url
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class TranslateNewsItems < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
::NewsItem.reset_column_information
|
5
|
+
unless defined?(::NewsItem::Translation) && ::NewsItem::Translation.table_exists?
|
6
|
+
::NewsItem.create_translation_table!({
|
7
|
+
:title => :string,
|
8
|
+
:body => :text,
|
9
|
+
:external_url => :string
|
10
|
+
}, {
|
11
|
+
:migrate_data => true
|
12
|
+
})
|
13
|
+
end
|
14
|
+
|
15
|
+
load(Rails.root.join('db', 'seeds', 'refinerycms_news.rb').to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
::NewsItem.reset_column_information
|
20
|
+
|
21
|
+
::NewsItem.drop_translation_table!
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddImageIdToNewsItems < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
unless ::NewsItem.column_names.map(&:to_sym).include?(:image_id)
|
5
|
+
add_column ::NewsItem.table_name, :image_id, :integer
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
remove_column ::NewsItem.table_name, :image_id
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
if defined?(::User)
|
2
|
+
User.all.each do |user|
|
3
|
+
if user.plugins.where(:name => 'refinerycms_news').blank?
|
4
|
+
user.plugins.create(:name => 'refinerycms_news',
|
5
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(::Page)
|
11
|
+
unless Page.where(:menu_match => "^/news.*$").any?
|
12
|
+
page = Page.create(
|
13
|
+
:title => "News",
|
14
|
+
:link_url => "/news",
|
15
|
+
:deletable => false,
|
16
|
+
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
|
17
|
+
:menu_match => "^/news.*$"
|
18
|
+
)
|
19
|
+
|
20
|
+
Page.default_parts.each do |default_page_part|
|
21
|
+
page.parts.create(:title => default_page_part, :body => nil)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/gemspec.rb
CHANGED
@@ -1,52 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'refinery/generators'
|
2
2
|
|
3
|
-
class RefinerycmsNewsGenerator <
|
4
|
-
include Rails::Generators::Migration
|
3
|
+
class RefinerycmsNewsGenerator < ::Refinery::Generators::EngineInstaller
|
5
4
|
|
6
|
-
source_root File.expand_path('
|
7
|
-
|
8
|
-
argument :attributes, :type => :array, :default => ["title:string", "body:text", "publish_date:datetime", "image_id:integer", "external_url:string"]
|
5
|
+
source_root File.expand_path('../../../', __FILE__)
|
6
|
+
engine_name "news"
|
9
7
|
|
10
|
-
def generate
|
11
|
-
# seed file
|
12
|
-
template 'db/seeds/seed.rb', Rails.root.join('db/seeds/refinerycms_news.rb')
|
13
|
-
|
14
|
-
next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
|
15
|
-
template('db/migrate/migration_number_create_singular_name.rb',
|
16
|
-
Rails.root.join("db/migrate/#{next_migration_number}_create_#{plural_name}.rb"))
|
17
|
-
|
18
|
-
unless self.behavior == :revoke
|
19
|
-
puts "------------------------"
|
20
|
-
puts "Now run:"
|
21
|
-
puts "rake db:migrate"
|
22
|
-
puts "------------------------"
|
23
|
-
end
|
24
|
-
end
|
25
8
|
end
|
26
|
-
|
27
|
-
# Below is a hack until this issue:
|
28
|
-
# https://rails.lighthouseapp.com/projects/8994/tickets/3820-make-railsgeneratorsmigrationnext_migration_number-method-a-class-method-so-it-possible-to-use-it-in-custom-generators
|
29
|
-
# is fixed on the Rails project.
|
30
|
-
|
31
|
-
require 'rails/generators/named_base'
|
32
|
-
require 'rails/generators/migration'
|
33
|
-
require 'rails/generators/active_model'
|
34
|
-
require 'active_record'
|
35
|
-
|
36
|
-
module ActiveRecord
|
37
|
-
module Generators
|
38
|
-
class Base < Rails::Generators::NamedBase #:nodoc:
|
39
|
-
include Rails::Generators::Migration
|
40
|
-
|
41
|
-
# Implement the required interface for Rails::Generators::Migration.
|
42
|
-
def self.next_migration_number(dirname) #:nodoc:
|
43
|
-
next_migration_number = current_migration_number(dirname) + 1
|
44
|
-
if ActiveRecord::Base.timestamped_migrations
|
45
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
46
|
-
else
|
47
|
-
"%.3d" % next_migration_number
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/news.rb
CHANGED
data/license.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2005-
|
4
|
-
|
2
|
+
|
3
|
+
Copyright (c) 2005-2011 [Resolve Digital Ltd.](http://www.resolvedigital.co.nz)
|
4
|
+
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
7
7
|
in the Software without restriction, including without limitation the rights
|
8
8
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
|
-
|
11
|
+
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
13
13
|
copies or substantial portions of the Software.
|
14
|
-
|
14
|
+
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
data/readme.md
CHANGED
@@ -13,13 +13,13 @@ Key features:
|
|
13
13
|
|
14
14
|
## Requirements
|
15
15
|
|
16
|
-
[RefineryCMS](http://refinerycms.com) version 0.9.
|
16
|
+
[RefineryCMS](http://refinerycms.com) "core" engine version 0.9.9.15 or later.
|
17
17
|
|
18
18
|
### Gem Installation using Bundler (The very best way)
|
19
19
|
|
20
20
|
Include the latest [gem](http://rubygems.org/gems/refinerycms-news) into your Refinery CMS application's Gemfile:
|
21
21
|
|
22
|
-
gem "refinerycms-news", '~> 1.
|
22
|
+
gem "refinerycms-news", '~> 1.1'
|
23
23
|
|
24
24
|
Then type the following at command line inside your Refinery CMS application's root directory:
|
25
25
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: refinerycms-news
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Resolve Digital
|
@@ -10,18 +10,18 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-07 00:00:00 +12:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name: refinerycms
|
17
|
+
name: refinerycms-core
|
18
18
|
prerelease: false
|
19
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.9.
|
24
|
+
version: 0.9.9.15
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
description: A really straightforward open source Ruby on Rails news engine designed for integration with RefineryCMS.
|
@@ -61,14 +61,17 @@ files:
|
|
61
61
|
- config/locales/sk.yml
|
62
62
|
- config/locales/sl.yml
|
63
63
|
- 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/seeds/refinerycms_news.rb
|
64
69
|
- features/manage_news_items.feature
|
65
70
|
- features/step_definitions/news_steps.rb
|
66
71
|
- features/support/factories.rb
|
67
72
|
- features/support/paths.rb
|
68
73
|
- features/visit_news_items.feature
|
69
74
|
- lib/gemspec.rb
|
70
|
-
- lib/generators/refinerycms_news/templates/db/migrate/migration_number_create_singular_name.rb
|
71
|
-
- lib/generators/refinerycms_news/templates/db/seeds/seed.rb
|
72
75
|
- lib/generators/refinerycms_news_generator.rb
|
73
76
|
- lib/news.rb
|
74
77
|
- lib/refinerycms-news.rb
|
data/lib/generators/refinerycms_news/templates/db/migrate/migration_number_create_singular_name.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
class Create<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def self.up
|
4
|
-
create_table :<%= table_name %>, :id => true 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
|
-
<% translated_attributes = attributes.find_all { |attr| [:string, :text].include? attr.type } %>
|
14
|
-
<%= class_name %>.create_translation_table! <%= translated_attributes.map { |a| ":#{a.name} => :#{a.type}"}.join(', ') %>
|
15
|
-
|
16
|
-
load(Rails.root.join('db', 'seeds', 'refinerycms_news.rb').to_s)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.down
|
20
|
-
UserPlugin.destroy_all({:name => "refinerycms_news"})
|
21
|
-
|
22
|
-
Page.delete_all({:link_url => "/news"})
|
23
|
-
|
24
|
-
<%= class_name %>.drop_translation_table!
|
25
|
-
|
26
|
-
drop_table :<%= table_name %>
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
User.find(:all).each do |user|
|
2
|
-
user.plugins.create(:name => "refinerycms_news",
|
3
|
-
:position => (user.plugins.maximum(:position) || -1) +1)
|
4
|
-
end
|
5
|
-
|
6
|
-
page = Page.create(
|
7
|
-
:title => "News",
|
8
|
-
:link_url => "/news",
|
9
|
-
:deletable => false,
|
10
|
-
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
|
11
|
-
:menu_match => "^/news.*$"
|
12
|
-
)
|
13
|
-
|
14
|
-
Page.default_parts.each do |default_page_part|
|
15
|
-
page.parts.create(:title => default_page_part, :body => nil)
|
16
|
-
end
|