forked from slate-studio/activeadmin-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
160 lines (115 loc) · 3.62 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/sh
# === activeadmin-mongoid-blog ===
# https://github.com/alexkravets/activeadmin-blog
#
# Description:
# Blog app on the top of activeadmin and mongoid.
#
# Installation:
# export project_name=new_blog ; curl https://raw.github.com/alexkravets/activeadmin-blog/master/install.sh | sh
set -e
rails new $project_name -T -O --skip-bundle
cd $project_name
# Gems
echo '
# Activeadmin
gem "bson_ext"
gem "mongoid"
gem "devise"
gem "activeadmin-mongoid"
# Blog
gem "activeadmin-blog"
# Bootstrap styles
gem "therubyracer"
gem "twitter-bootstrap-rails"
# Assets
gem "asset_sync"
' >> Gemfile
bundle
rails g mongoid:config
rails g devise:install
rails g active_admin:install
rails g activeadmin_settings:install
rails g activeadmin_blog:install blog
rails g bootstrap:install
# Add blog settings
echo '\nGeneral:
Blog Title:
description: You can change blog title with this setting
default_value: <%= Rails.application.class.parent_name %>
Delivered By:
description: Link in the footer of the website
default_value: (Slate Studio) http://slatestudio.com
type: link' >> config/activeadmin_settings.yml
# Tweak application.css.scss
echo '/*
*= require bootstrap_and_overrides
*= require_self
*/
.pagination .page.current {
float:left;
padding:0 14px;
line-height:34px;
text-decoration:none;
border:1px solid #DDD;
border-left-width:0;
color:#999;
cursor:default;
background-color:whiteSmoke;
}
.pagination span:first-child, .pagination .first a { border-left-width:1px; }' > app/assets/stylesheets/application.css
# Tweak application.js
echo '//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require bootstrap
' > app/assets/javascripts/application.js
# Fix default mongoid.yml
echo 'development:
host: localhost
database: '$project_name'
test:
host: localhost
database: '$project_name'_test
production:
uri: <%= ENV["MONGO_URL"] %>' > config/mongoid.yml
# Remove migrations, we don't need them with mongoid
rm -Rfd db/migrate
# Fix seeds.rb file to generate first admin user
echo 'puts "EMPTY THE MONGODB DATABASE"
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
puts "SETTING UP DEFAULT ADMIN USER"
Rake::Task["activeadmin:settings:create_admin"].invoke
' > db/seeds.rb
# Create default admin user
rake db:seed
# Create carrierwave default configuration
echo 'CarrierWave.configure do |config|
config.cache_dir = File.join(Rails.root, "tmp", "uploads")
config.storage = :fog
config.fog_credentials = {
:provider => "AWS",
:aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
}
case Rails.env.to_sym
when :development
config.storage = :file
when :production
config.fog_directory = ENV["FOG_MEDIA_DIRECTORY"]
config.fog_host = "//#{ ENV["FOG_MEDIA_DIRECTORY"] }.s3.amazonaws.com"
config.fog_attributes = {"Cache-Control"=>"max-age=315576000"} # optional, defaults to {}
end
end' > config/initializers/carrierwave.rb
# Fix production assets to include all required files
mv config/environments/production.rb config/environments/production-old.rb
sed '/# config.assets.precompile += %w( search.js )/ a\
config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor/css/style.css"]' config/environments/production-old.rb 1> config/environments/production.rb
rm config/environments/production-old.rb
echo ""
echo "Please make sure you've set Heroku environment settings:"
echo " FOG_MEDIA_DIRECTORY"
echo " AWS_ACCESS_KEY_ID"
echo " AWS_SECRET_ACCESS_KEY"
echo " MONGO_URL"
echo ""