activeadmin-mongoid-blog 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  Blog app on the top of activeadmin and mongoid, using redactor and select2 plugins. Could be useful for almost every activeadmin based project.
4
4
 
5
- ### Quick new blog
5
+
6
+ ## Quick install
6
7
 
7
8
  Replace `new_blog` name with the real one and run:
8
9
 
9
10
  export project_name=new_blog ; curl https://raw.github.com/alexkravets/activeadmin-mongoid-blog/master/install.sh | sh
10
11
 
12
+ This command creates new rails project fully configured and ready for Heroku deploy.
13
+
14
+
15
+ ## Manual Installation
16
+
11
17
  ### Start a new rails project
12
18
 
13
19
  $ rails new appname -T -O
@@ -16,14 +22,17 @@ Replace `new_blog` name with the real one and run:
16
22
 
17
23
  Add these gems to Gemfile and run `bundle` command:
18
24
 
19
- gem 'bson_ext'
20
- gem 'mongoid'
21
- gem 'devise'
22
- gem 'activeadmin-mongoid'
23
- gem 'activeadmin-mongoid-blog'
24
- gem 'therubyracer'
25
- gem 'twitter-bootstrap-rails'
26
-
25
+ gem "bson_ext"
26
+ gem "mongoid"
27
+ gem "devise"
28
+ gem "activeadmin-mongoid"
29
+ gem "redactor-rails", :git => "git://github.com/alexkravets/redactor-rails.git"
30
+ gem "activeadmin-mongoid-blog"
31
+ gem "therubyracer"
32
+ gem "twitter-bootstrap-rails"
33
+ gem "aws-s3"
34
+ gem "fog"
35
+ gem "asset_sync"
27
36
 
28
37
  Run generators to and check settings in `/config/mongoid.yml`, `/config/initializers/active_admin.rb`:
29
38
 
@@ -44,16 +53,16 @@ At this point **activeadmin** should be ready to work. Run `rails s` and check o
44
53
 
45
54
  ### Setup activeadmin-mongoid-blog
46
55
 
56
+ As blog post editor `redactor.js` is used. It comes with a image uploading featured supported by **carrierwave**, install `Picture` model with command:
57
+
58
+ $ rails g redactor:install
59
+
47
60
  Install blog models, admin files, routes and blog controller, replace `blog` value with a prefix you want the blog be accessible at (e.g. `http://localhost:3000/blog`):
48
61
 
49
62
  $ rails g active_admin:blog:install blog
50
63
 
51
64
  Run `bundle` to install new gems.
52
65
 
53
- As blog post editor `redactor.js` is used. It comes with a image uploading featured supported by **carrierwave**, install `Picture` model with command:
54
-
55
- $ rails g redactor:install
56
-
57
66
  Add to your `active_admin.js.coffee`:
58
67
 
59
68
  #= require activeadmin_mongoid_blog
@@ -105,6 +114,62 @@ In `application.css` include:
105
114
  }
106
115
  .pagination span:first-child, .pagination .first a { border-left-width:1px; }
107
116
 
117
+
118
+ ## Heroku
119
+
120
+ #### Mongoid
121
+
122
+ Configure local and production `config/mongoid.yml` settings to look like this:
123
+
124
+ development:
125
+ host: localhost
126
+ database: supercaliblog
127
+
128
+ test:
129
+ host: localhost
130
+ database: supercaliblog_test
131
+
132
+ production:
133
+ uri: <%= ENV["MONGO_URL"] %>
134
+
135
+ #### Carrierwave
136
+
137
+ Create an S3 bucket for redactor image uploading feature and configure `config/initializers/carrierwave.rb`:
138
+
139
+ CarrierWave.configure do |config|
140
+ config.cache_dir = File.join(Rails.root, "tmp", "uploads")
141
+ config.storage = :fog
142
+
143
+ config.fog_credentials = {
144
+ :provider => "AWS",
145
+ :aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
146
+ :aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
147
+ }
148
+
149
+ case Rails.env.to_sym
150
+ when :development
151
+ config.storage = :file
152
+ when :production
153
+ config.fog_directory = ENV["FOG_MEDIA_DIRECTORY"]
154
+ config.fog_host = "//#{ ENV["FOG_MEDIA_DIRECTORY"] }.s3.amazonaws.com"
155
+ config.fog_attributes = {"Cache-Control"=>"max-age=315576000"} # optional, defaults to {}
156
+ end
157
+ end
158
+
159
+ Make sure you've set Heroku environtment variables:
160
+
161
+ FOG_MEDIA_DIRECTORY
162
+ AWS_ACCESS_KEY_ID
163
+ AWS_SECRET_ACCESS_KEY
164
+ MONGO_URL
165
+
166
+ #### Production assets
167
+
168
+ Add the following line to `config/environments/production.rb`:
169
+
170
+ config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor-rails/css/style.css"]
171
+
172
+
108
173
  ### The End
109
174
 
110
175
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'activeadmin-mongoid-blog'
6
- gem.version = '0.3.4'
6
+ gem.version = '0.3.5'
7
7
  gem.summary = 'Blog app on the top of activeadmin and mongoid, using redactor and select2 plugins.'
8
8
  gem.description = ''
9
9
  gem.license = 'MIT'
@@ -1,5 +1,5 @@
1
1
  <header style="margin-bottom:2em;">
2
- <h1>This is a new blog</h1>
2
+ <h1><%= Rails.application.class.parent_name %></h1>
3
3
  <p>
4
4
  <ul>
5
5
  <li><a href="<%= blog_path %>" title="All Posts">All Posts</a></li>
data/install.sh CHANGED
@@ -14,19 +14,38 @@
14
14
 
15
15
  set -e
16
16
 
17
- rails new $project_name -T -O
17
+ rails new $project_name -T -O --skip-bundle
18
18
  cd $project_name
19
19
 
20
20
 
21
21
  # Gems
22
22
  echo '
23
+ # Activeadmin
23
24
  gem "bson_ext"
24
25
  gem "mongoid"
25
26
  gem "devise"
26
27
  gem "activeadmin-mongoid"
28
+
29
+ # Blog
30
+ gem "mongoid_slug"
31
+ gem "mongoid_search"
32
+ gem "nokogiri"
33
+ gem "select2-rails"
34
+ gem "redactor-rails", :git => "git://github.com/alexkravets/redactor-rails.git"
35
+ gem "carrierwave-mongoid", :require => "carrierwave/mongoid"
36
+ gem "mini_magick"
37
+ gem "activeadmin-mongoid-reorder"
27
38
  gem "activeadmin-mongoid-blog"
39
+
40
+ # Default styles
28
41
  gem "therubyracer"
29
- gem "twitter-bootstrap-rails"' >> Gemfile
42
+ gem "twitter-bootstrap-rails"
43
+
44
+ # Assets
45
+ gem "aws-s3"
46
+ gem "fog"
47
+ gem "asset_sync"
48
+ ' >> Gemfile
30
49
 
31
50
 
32
51
  bundle
@@ -35,18 +54,15 @@ bundle
35
54
  rails g mongoid:config
36
55
  rails g devise:install
37
56
  rails g active_admin:install
38
- rails g active_admin:blog:install blog
39
-
40
-
41
- bundle
42
-
43
-
44
57
  rails g redactor:install
58
+ rails g active_admin:blog:install blog
59
+ rails g bootstrap:install
45
60
 
46
61
 
47
62
  # Tweak active_admin.js
48
63
  echo '//= require activeadmin_mongoid_blog' >> app/assets/javascripts/active_admin.js
49
64
 
65
+
50
66
  # Tweak active_admin.css.scss
51
67
  cat app/assets/stylesheets/active_admin.css.scss > temp_file.tmp
52
68
  echo '//= require activeadmin_mongoid_blog' > app/assets/stylesheets/active_admin.css.scss
@@ -54,8 +70,7 @@ cat temp_file.tmp >> app/assets/stylesheets/active_admin.css.scss
54
70
  rm temp_file.tmp
55
71
 
56
72
 
57
- rails g bootstrap:install
58
-
73
+ # Tweak application.css.scss
59
74
  echo '/*
60
75
  *= require bootstrap_and_overrides
61
76
  *= require_self
@@ -74,6 +89,8 @@ echo '/*
74
89
  }
75
90
  .pagination span:first-child, .pagination .first a { border-left-width:1px; }' > app/assets/stylesheets/application.css
76
91
 
92
+
93
+ # Tweak application.js
77
94
  echo '//= require jquery
78
95
  //= require jquery_ujs
79
96
  //= require twitter/bootstrap
@@ -81,9 +98,73 @@ echo '//= require jquery
81
98
  ' > app/assets/javascripts/application.js
82
99
 
83
100
 
84
- echo "\n\n\n"
85
- echo "$ rails c"
86
- echo ">> AdminUser.create :email => 'admin@example.com', :password => 'password', :password_confirmation => 'password'"
87
- echo "\n\n\n"
101
+ # Fix default mongoid.yml
102
+ echo 'development:
103
+ host: localhost
104
+ database: '$project_name'
105
+
106
+ test:
107
+ host: localhost
108
+ database: '$project_name'_test
109
+
110
+ production:
111
+ uri: <%= ENV["MONGO_URL"] %>' > config/mongoid.yml
112
+
113
+
114
+ # Remove migrations, we don't need them with mongoid
115
+ rm -Rfd db/migrate
116
+
117
+
118
+ # Fix seeds.rb file to generate first admin user
119
+ echo 'puts "EMPTY THE MONGODB DATABASE"
120
+ Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
121
+
122
+ puts "SETTING UP DEFAULT ADMIN USER"
123
+ AdminUser.create!(:email => "admin@example.com", :password => "password", :password_confirmation => "password")
124
+ ' > db/seeds.rb
125
+
126
+
127
+ # Create default admin user
128
+ rake db:seed
129
+
130
+
131
+ # Create carrierwave default configuration
132
+ echo 'CarrierWave.configure do |config|
133
+ config.cache_dir = File.join(Rails.root, "tmp", "uploads")
134
+ config.storage = :fog
135
+
136
+ config.fog_credentials = {
137
+ :provider => "AWS",
138
+ :aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
139
+ :aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
140
+ }
141
+
142
+ case Rails.env.to_sym
143
+ when :development
144
+ config.storage = :file
145
+ when :production
146
+ config.fog_directory = ENV["FOG_MEDIA_DIRECTORY"]
147
+ config.fog_host = "//#{ ENV["FOG_MEDIA_DIRECTORY"] }.s3.amazonaws.com"
148
+ config.fog_attributes = {"Cache-Control"=>"max-age=315576000"} # optional, defaults to {}
149
+ end
150
+ end' > config/initializers/carrierwave.rb
151
+
152
+
153
+ # Fix production assets to include all required files
154
+ mv config/environments/production.rb config/environments/production-old.rb
155
+ sed '/# config.assets.precompile += %w( search.js )/ a\
156
+ config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor-rails/css/style.css"]' config/environments/production-old.rb 1> config/environments/production.rb
157
+ rm config/environments/production-old.rb
158
+
159
+
160
+ echo ""
161
+ echo "Please make sure you've set Heroku environment settings:"
162
+ echo " FOG_MEDIA_DIRECTORY"
163
+ echo " AWS_ACCESS_KEY_ID"
164
+ echo " AWS_SECRET_ACCESS_KEY"
165
+ echo " MONGO_URL"
166
+ echo ""
167
+
168
+
88
169
 
89
170
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-mongoid-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-07-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ''
15
15
  email: santyor@gmail.com
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  segments:
57
57
  - 0
58
- hash: -3072008541518925790
58
+ hash: 3442984480607517607
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  none: false
61
61
  requirements: