refinerycms-blog 1.2 → 1.3
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.
- data/db/migrate/1_create_blog_structure.rb +54 -0
- data/{lib/generators/refinerycms_blog/templates/db/migrate/migration_number_add_user_id_to_blog_posts.rb → db/migrate/2_add_user_id_to_blog_posts.rb} +0 -0
- data/{lib/generators/refinerycms_blog/templates/db/seeds/seed.rb → db/seeds/refinerycms_blog.rb} +0 -0
- data/lib/generators/refinerycms_blog_generator.rb +5 -84
- data/lib/refinerycms-blog.rb +1 -1
- data/readme.md +1 -1
- metadata +6 -10
- data/generators/refinerycms_blog/refinerycms_blog_generator.rb +0 -69
- data/generators/refinerycms_blog/templates/db/migrate/migration.rb +0 -26
- data/generators/refinerycms_blog/templates/db/seeds/seed.rb +0 -16
- data/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb +0 -26
- data/rails/init.rb +0 -10
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class CreateBlogStructure < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :blog_posts, :id => true do |t|
|
|
5
|
+
t.string :title
|
|
6
|
+
t.text :body
|
|
7
|
+
t.boolean :draft
|
|
8
|
+
t.datetime :published_at
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
add_index :blog_posts, :id
|
|
13
|
+
|
|
14
|
+
create_table :blog_comments, :id => true do |t|
|
|
15
|
+
t.integer :blog_post_id
|
|
16
|
+
t.boolean :spam
|
|
17
|
+
t.string :name
|
|
18
|
+
t.string :email
|
|
19
|
+
t.text :body
|
|
20
|
+
t.string :state
|
|
21
|
+
t.timestamps
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :blog_comments, :id
|
|
25
|
+
|
|
26
|
+
create_table :blog_categories, :id => true do |t|
|
|
27
|
+
t.string :title
|
|
28
|
+
t.timestamps
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
add_index :blog_categories, :id
|
|
32
|
+
|
|
33
|
+
create_table :blog_categories_blog_posts, :id => false do |t|
|
|
34
|
+
t.integer :blog_category_id
|
|
35
|
+
t.integer :blog_post_id
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
|
|
39
|
+
|
|
40
|
+
load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.down
|
|
44
|
+
UserPlugin.destroy_all({:name => "refinerycms_blog"})
|
|
45
|
+
|
|
46
|
+
Page.delete_all({:link_url => "/blog"})
|
|
47
|
+
|
|
48
|
+
drop_table :blog_posts
|
|
49
|
+
drop_table :blog_comments
|
|
50
|
+
drop_table :blog_categories
|
|
51
|
+
drop_table :blog_categories_blog_posts
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
File without changes
|
data/{lib/generators/refinerycms_blog/templates/db/seeds/seed.rb → db/seeds/refinerycms_blog.rb}
RENAMED
|
File without changes
|
|
@@ -1,87 +1,8 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'refinery/generators'
|
|
2
2
|
|
|
3
|
-
class RefinerycmsBlogGenerator <
|
|
4
|
-
include Rails::Generators::Migration
|
|
3
|
+
class RefinerycmsBlogGenerator < ::Refinery::Generators::EngineInstaller
|
|
5
4
|
|
|
6
|
-
source_root File.expand_path('
|
|
7
|
-
|
|
5
|
+
source_root File.expand_path('../../../', __FILE__)
|
|
6
|
+
engine_name "refinerycms-blog"
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
# seed file
|
|
11
|
-
template 'db/seeds/seed.rb', Rails.root.join('db/seeds/refinerycms_blog.rb')
|
|
12
|
-
|
|
13
|
-
# migration file
|
|
14
|
-
@refinerycms_blog_tables = [{
|
|
15
|
-
:table_name => 'blog_posts',
|
|
16
|
-
:attributes => [
|
|
17
|
-
Rails::Generators::GeneratedAttribute.new('title', 'string'),
|
|
18
|
-
Rails::Generators::GeneratedAttribute.new('body', 'text'),
|
|
19
|
-
Rails::Generators::GeneratedAttribute.new('draft', 'boolean'),
|
|
20
|
-
Rails::Generators::GeneratedAttribute.new('published_at', 'datetime')
|
|
21
|
-
], :id => true
|
|
22
|
-
},{
|
|
23
|
-
:table_name => 'blog_comments',
|
|
24
|
-
:attributes => [
|
|
25
|
-
Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer'),
|
|
26
|
-
Rails::Generators::GeneratedAttribute.new('spam', 'boolean'),
|
|
27
|
-
Rails::Generators::GeneratedAttribute.new('name', 'string'),
|
|
28
|
-
Rails::Generators::GeneratedAttribute.new('email', 'string'),
|
|
29
|
-
Rails::Generators::GeneratedAttribute.new('body', 'text'),
|
|
30
|
-
Rails::Generators::GeneratedAttribute.new('state', 'string'),
|
|
31
|
-
], :id => true
|
|
32
|
-
},{
|
|
33
|
-
:table_name => 'blog_categories',
|
|
34
|
-
:attributes => [
|
|
35
|
-
Rails::Generators::GeneratedAttribute.new('title', 'string')
|
|
36
|
-
], :id => true
|
|
37
|
-
},{
|
|
38
|
-
:table_name => 'blog_categories_blog_posts',
|
|
39
|
-
:attributes => [
|
|
40
|
-
Rails::Generators::GeneratedAttribute.new('blog_category_id', 'integer'),
|
|
41
|
-
Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer')
|
|
42
|
-
], :id => false
|
|
43
|
-
}]
|
|
44
|
-
unless Pathname.glob(Rails.root.join('db', 'migrate', "*_create_#{singular_name}.rb")).any?
|
|
45
|
-
next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
|
|
46
|
-
template('db/migrate/migration_number_create_singular_name.rb',
|
|
47
|
-
Rails.root.join("db/migrate/#{next_migration_number}_create_#{singular_name}.rb"))
|
|
48
|
-
end
|
|
49
|
-
unless Pathname.glob(Rails.root.join('db', 'migrate', "*_add_user_id_to_blog_posts.rb")).any?
|
|
50
|
-
next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
|
|
51
|
-
template('db/migrate/migration_number_add_user_id_to_blog_posts.rb',
|
|
52
|
-
Rails.root.join('db', 'migrate', "#{next_migration_number}_add_user_id_to_blog_posts.rb"))
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
puts "------------------------"
|
|
56
|
-
puts "Now run:"
|
|
57
|
-
puts "rake db:migrate"
|
|
58
|
-
puts "------------------------"
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Below is a hack until this issue:
|
|
63
|
-
# 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
|
|
64
|
-
# is fixed on the Rails project.
|
|
65
|
-
|
|
66
|
-
require 'rails/generators/named_base'
|
|
67
|
-
require 'rails/generators/migration'
|
|
68
|
-
require 'rails/generators/active_model'
|
|
69
|
-
require 'active_record'
|
|
70
|
-
|
|
71
|
-
module ActiveRecord
|
|
72
|
-
module Generators
|
|
73
|
-
class Base < Rails::Generators::NamedBase #:nodoc:
|
|
74
|
-
include Rails::Generators::Migration
|
|
75
|
-
|
|
76
|
-
# Implement the required interface for Rails::Generators::Migration.
|
|
77
|
-
def self.next_migration_number(dirname) #:nodoc:
|
|
78
|
-
next_migration_number = current_migration_number(dirname) + 1
|
|
79
|
-
if ActiveRecord::Base.timestamped_migrations
|
|
80
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
|
81
|
-
else
|
|
82
|
-
"%.3d" % next_migration_number
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
8
|
+
end
|
data/lib/refinerycms-blog.rb
CHANGED
data/readme.md
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: refinerycms-blog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: "1.
|
|
5
|
+
version: "1.3"
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Resolve Digital
|
|
@@ -11,7 +11,7 @@ autorequire:
|
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
13
|
|
|
14
|
-
date: 2011-03-
|
|
14
|
+
date: 2011-03-04 00:00:00 +13:00
|
|
15
15
|
default_executable:
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
@@ -105,19 +105,16 @@ files:
|
|
|
105
105
|
- config/locales/pt-BR.yml
|
|
106
106
|
- config/locales/ru.yml
|
|
107
107
|
- config/routes.rb
|
|
108
|
+
- db/migrate/1_create_blog_structure.rb
|
|
109
|
+
- db/migrate/2_add_user_id_to_blog_posts.rb
|
|
110
|
+
- db/seeds/refinerycms_blog.rb
|
|
108
111
|
- features/authors.feature
|
|
109
112
|
- features/support/factories/blog_categories.rb
|
|
110
113
|
- features/support/factories/blog_comments.rb
|
|
111
114
|
- features/support/factories/blog_posts.rb
|
|
112
115
|
- features/support/paths.rb
|
|
113
116
|
- features/support/step_definitions/authors_steps.rb
|
|
114
|
-
- generators/refinerycms_blog/refinerycms_blog_generator.rb
|
|
115
|
-
- generators/refinerycms_blog/templates/db/migrate/migration.rb
|
|
116
|
-
- generators/refinerycms_blog/templates/db/seeds/seed.rb
|
|
117
117
|
- lib/gemspec.rb
|
|
118
|
-
- lib/generators/refinerycms_blog/templates/db/migrate/migration_number_add_user_id_to_blog_posts.rb
|
|
119
|
-
- lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
|
|
120
|
-
- lib/generators/refinerycms_blog/templates/db/seeds/seed.rb
|
|
121
118
|
- lib/generators/refinerycms_blog_generator.rb
|
|
122
119
|
- lib/refinerycms-blog.rb
|
|
123
120
|
- public/images/refinerycms-blog/icons/cog.png
|
|
@@ -138,7 +135,6 @@ files:
|
|
|
138
135
|
- public/javascripts/refinerycms-blog.js
|
|
139
136
|
- public/stylesheets/refinery/refinerycms-blog.css
|
|
140
137
|
- public/stylesheets/refinerycms-blog.css
|
|
141
|
-
- rails/init.rb
|
|
142
138
|
- readme.md
|
|
143
139
|
- spec/models/blog_categories_spec.rb
|
|
144
140
|
- spec/models/blog_comments_spec.rb
|
|
@@ -167,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
167
163
|
requirements: []
|
|
168
164
|
|
|
169
165
|
rubyforge_project:
|
|
170
|
-
rubygems_version: 1.
|
|
166
|
+
rubygems_version: 1.6.0
|
|
171
167
|
signing_key:
|
|
172
168
|
specification_version: 3
|
|
173
169
|
summary: Ruby on Rails blogging engine for RefineryCMS.
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
class RefinerycmsBlogGenerator < Rails::Generator::NamedBase
|
|
2
|
-
|
|
3
|
-
def initialize(*runtime_args)
|
|
4
|
-
# set argument for the user.
|
|
5
|
-
runtime_args[0] = %w(refinerycms_blog)
|
|
6
|
-
super(*runtime_args)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def banner
|
|
10
|
-
'Usage: script/generate refinerycms_blog'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def manifest
|
|
14
|
-
record do |m|
|
|
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('/'))
|
|
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')
|
|
30
|
-
|
|
31
|
-
m.migration_template('db/migrate/migration.rb', 'db/migrate',
|
|
32
|
-
:migration_file_name => 'create_blog_structure',
|
|
33
|
-
:assigns => {
|
|
34
|
-
:migration_name => 'CreateBlogStructure',
|
|
35
|
-
:tables => [{
|
|
36
|
-
:table_name => 'blog_posts',
|
|
37
|
-
:attributes => [
|
|
38
|
-
Rails::Generator::GeneratedAttribute.new('title', 'string'),
|
|
39
|
-
Rails::Generator::GeneratedAttribute.new('body', 'text'),
|
|
40
|
-
Rails::Generator::GeneratedAttribute.new('draft', 'boolean'),
|
|
41
|
-
Rails::Generator::GeneratedAttribute.new('published_at', 'datetime')
|
|
42
|
-
], :id => true
|
|
43
|
-
},{
|
|
44
|
-
:table_name => 'blog_comments',
|
|
45
|
-
:attributes => [
|
|
46
|
-
Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer'),
|
|
47
|
-
Rails::Generator::GeneratedAttribute.new('spam', 'boolean'),
|
|
48
|
-
Rails::Generator::GeneratedAttribute.new('name', 'string'),
|
|
49
|
-
Rails::Generator::GeneratedAttribute.new('email', 'string'),
|
|
50
|
-
Rails::Generator::GeneratedAttribute.new('body', 'text'),
|
|
51
|
-
Rails::Generator::GeneratedAttribute.new('state', 'string'),
|
|
52
|
-
], :id => true
|
|
53
|
-
},{
|
|
54
|
-
:table_name => 'blog_categories',
|
|
55
|
-
:attributes => [
|
|
56
|
-
Rails::Generator::GeneratedAttribute.new('title', 'string')
|
|
57
|
-
], :id => true
|
|
58
|
-
},{
|
|
59
|
-
:table_name => 'blog_categories_blog_posts',
|
|
60
|
-
:attributes => [
|
|
61
|
-
Rails::Generator::GeneratedAttribute.new('blog_category_id', 'integer'),
|
|
62
|
-
Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer')
|
|
63
|
-
], :id => false
|
|
64
|
-
}]
|
|
65
|
-
})
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end if defined?(Rails::Generator::NamedBase)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
|
2
|
-
|
|
3
|
-
def self.up<% 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
|
-
<% tables.each do |table| -%>
|
|
22
|
-
drop_table :<%= table[:table_name] %>
|
|
23
|
-
<% end -%>
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
RefinerySetting.find_or_set(:default_page_parts, %w(Body Side\ Body)).each do |default_page_part|
|
|
15
|
-
page.parts.create(:title => default_page_part, :body => nil)
|
|
16
|
-
end
|
data/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
data/rails/init.rb
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../lib/refinerycms-blog', __FILE__)
|
|
2
|
-
|
|
3
|
-
Refinery::Plugin.register do |plugin|
|
|
4
|
-
plugin.name = "refinerycms_blog"
|
|
5
|
-
plugin.url = {:controller => '/admin/blog/posts', :action => 'index'}
|
|
6
|
-
plugin.menu_match = /^\/?(admin|refinery)\/blog\/?(posts|comments|categories)?/
|
|
7
|
-
plugin.activity = {
|
|
8
|
-
:class => BlogPost
|
|
9
|
-
}
|
|
10
|
-
end
|