activeadmin-blog 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/.gitignore +20 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +215 -0
  4. data/README.md +162 -0
  5. data/Rakefile +7 -0
  6. data/activeadmin-blog.gemspec +30 -0
  7. data/app/controllers/activeadmin_blog/posts_controller.rb +50 -0
  8. data/app/models/activeadmin_blog/blog_category.rb +23 -0
  9. data/app/models/activeadmin_blog/blog_post.rb +81 -0
  10. data/app/views/activeadmin_blog/posts/_footer.html.erb +10 -0
  11. data/app/views/activeadmin_blog/posts/_header.html.erb +11 -0
  12. data/app/views/activeadmin_blog/posts/_post.html.erb +31 -0
  13. data/app/views/activeadmin_blog/posts/archive.html.erb +9 -0
  14. data/app/views/activeadmin_blog/posts/category.html.erb +9 -0
  15. data/app/views/activeadmin_blog/posts/feed.rss.builder +18 -0
  16. data/app/views/activeadmin_blog/posts/index.html.erb +9 -0
  17. data/app/views/activeadmin_blog/posts/search.html.erb +9 -0
  18. data/app/views/activeadmin_blog/posts/show.html.erb +35 -0
  19. data/app/views/activeadmin_blog/posts/tag.html.erb +9 -0
  20. data/app/views/admin/categories/_form.html.erb +26 -0
  21. data/app/views/admin/posts/_categories.html.erb +18 -0
  22. data/config/routes.rb +9 -0
  23. data/install.sh +160 -0
  24. data/lib/activeadmin-blog.rb +8 -0
  25. data/lib/activeadmin-blog/engine.rb +5 -0
  26. data/lib/activeadmin-blog/version.rb +3 -0
  27. data/lib/generators/activeadmin_blog/install_generator.rb +40 -0
  28. data/lib/generators/activeadmin_blog/templates/README +5 -0
  29. data/lib/generators/activeadmin_blog/templates/admin/blog_categories.rb +86 -0
  30. data/lib/generators/activeadmin_blog/templates/admin/blog_posts.rb +101 -0
  31. data/lib/generators/activeadmin_blog/views_generator.rb +16 -0
  32. data/vendor/assets/javascripts/activeadmin_blog.js.coffee +56 -0
  33. data/vendor/assets/stylesheets/activeadmin_blog.css.scss +51 -0
  34. metadata +180 -0
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ /.bundle
7
+ /vendor/bundle
8
+ /log/*
9
+ /tmp/*
10
+ /db/*.sqlite3
11
+ /public/system/*
12
+ /coverage/
13
+ /spec/tmp/*
14
+ **.orig
15
+ rerun.txt
16
+ pickle-email-*.html
17
+ pkg
18
+ *.swp
19
+ *.swo
20
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activeadmin-blog.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,215 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activeadmin-blog (0.4.0)
5
+ activeadmin-mongoid
6
+ activeadmin-mongoid-reorder
7
+ activeadmin-settings
8
+ mongoid_search (~> 0.2.8)
9
+ mongoid_slug
10
+ nokogiri
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (3.2.8)
16
+ actionpack (= 3.2.8)
17
+ mail (~> 2.4.4)
18
+ actionpack (3.2.8)
19
+ activemodel (= 3.2.8)
20
+ activesupport (= 3.2.8)
21
+ builder (~> 3.0.0)
22
+ erubis (~> 2.7.0)
23
+ journey (~> 1.0.4)
24
+ rack (~> 1.4.0)
25
+ rack-cache (~> 1.2)
26
+ rack-test (~> 0.6.1)
27
+ sprockets (~> 2.1.3)
28
+ activeadmin (0.4.4)
29
+ bourbon (>= 1.0.0)
30
+ devise (>= 1.1.2)
31
+ fastercsv
32
+ formtastic (~> 2.1.1)
33
+ inherited_resources (>= 1.3.1)
34
+ jquery-rails (>= 1.0.0)
35
+ kaminari (>= 0.13.0)
36
+ meta_search (>= 0.9.2)
37
+ rails (>= 3.0.0)
38
+ sass (>= 3.1.0)
39
+ activeadmin-mongoid (0.0.1)
40
+ activeadmin (~> 0.4)
41
+ meta_search (>= 1.1.0.pre)
42
+ mongoid (~> 2.0)
43
+ sass-rails (~> 3.1, >= 3.1.4)
44
+ activeadmin-mongoid-reorder (0.2.1)
45
+ activeadmin-settings (0.3.1)
46
+ aws-s3
47
+ carrierwave-mongoid
48
+ fog
49
+ heroku-mongo-backup
50
+ mini_magick
51
+ mongoid_globalize
52
+ select2-rails
53
+ activemodel (3.2.8)
54
+ activesupport (= 3.2.8)
55
+ builder (~> 3.0.0)
56
+ activerecord (3.2.8)
57
+ activemodel (= 3.2.8)
58
+ activesupport (= 3.2.8)
59
+ arel (~> 3.0.2)
60
+ tzinfo (~> 0.3.29)
61
+ activeresource (3.2.8)
62
+ activemodel (= 3.2.8)
63
+ activesupport (= 3.2.8)
64
+ activesupport (3.2.8)
65
+ i18n (~> 0.6)
66
+ multi_json (~> 1.0)
67
+ arel (3.0.2)
68
+ aws-s3 (0.6.3)
69
+ builder
70
+ mime-types
71
+ xml-simple
72
+ bcrypt-ruby (3.0.1)
73
+ bourbon (2.1.1)
74
+ sass (>= 3.1)
75
+ bson (1.6.4)
76
+ bson_ext (1.6.4)
77
+ bson (~> 1.6.4)
78
+ builder (3.0.0)
79
+ carrierwave (0.6.2)
80
+ activemodel (>= 3.2.0)
81
+ activesupport (>= 3.2.0)
82
+ carrierwave-mongoid (0.2.1)
83
+ carrierwave (~> 0.6.1)
84
+ mongoid (~> 2.1)
85
+ devise (2.1.2)
86
+ bcrypt-ruby (~> 3.0)
87
+ orm_adapter (~> 0.1)
88
+ railties (~> 3.1)
89
+ warden (~> 1.2.1)
90
+ erubis (2.7.0)
91
+ excon (0.15.5)
92
+ fast-stemmer (1.0.1)
93
+ fastercsv (1.5.5)
94
+ fog (1.5.0)
95
+ builder
96
+ excon (~> 0.14)
97
+ formatador (~> 0.2.0)
98
+ mime-types
99
+ multi_json (~> 1.0)
100
+ net-scp (~> 1.0.4)
101
+ net-ssh (>= 2.1.3)
102
+ nokogiri (~> 1.5.0)
103
+ ruby-hmac
104
+ formatador (0.2.3)
105
+ formtastic (2.1.1)
106
+ actionpack (~> 3.0)
107
+ has_scope (0.5.1)
108
+ heroku-mongo-backup (0.3.9)
109
+ hike (1.2.1)
110
+ i18n (0.6.0)
111
+ inherited_resources (1.3.1)
112
+ has_scope (~> 0.5.0)
113
+ responders (~> 0.6)
114
+ journey (1.0.4)
115
+ jquery-rails (2.0.2)
116
+ railties (>= 3.2.0, < 5.0)
117
+ thor (~> 0.14)
118
+ json (1.7.4)
119
+ kaminari (0.13.0)
120
+ actionpack (>= 3.0.0)
121
+ activesupport (>= 3.0.0)
122
+ railties (>= 3.0.0)
123
+ mail (2.4.4)
124
+ i18n (>= 0.4.0)
125
+ mime-types (~> 1.16)
126
+ treetop (~> 1.4.8)
127
+ meta_search (1.1.3)
128
+ actionpack (~> 3.1)
129
+ activerecord (~> 3.1)
130
+ activesupport (~> 3.1)
131
+ polyamorous (~> 0.5.0)
132
+ mime-types (1.19)
133
+ mini_magick (3.4)
134
+ subexec (~> 0.2.1)
135
+ mongo (1.6.2)
136
+ bson (~> 1.6.2)
137
+ mongoid (2.4.12)
138
+ activemodel (~> 3.1)
139
+ mongo (<= 1.6.2)
140
+ tzinfo (~> 0.3.22)
141
+ mongoid_globalize (0.2.1)
142
+ bson_ext (~> 1.5)
143
+ mongoid (~> 2.4)
144
+ mongoid_search (0.2.8)
145
+ bson_ext (>= 1.2)
146
+ fast-stemmer (~> 1.0.0)
147
+ mongoid (>= 2.0.0)
148
+ mongoid_slug (0.10.0)
149
+ mongoid (~> 2.0)
150
+ stringex (~> 1.3)
151
+ multi_json (1.3.6)
152
+ net-scp (1.0.4)
153
+ net-ssh (>= 1.99.1)
154
+ net-ssh (2.5.2)
155
+ nokogiri (1.5.5)
156
+ orm_adapter (0.4.0)
157
+ polyamorous (0.5.0)
158
+ activerecord (~> 3.0)
159
+ polyglot (0.3.3)
160
+ rack (1.4.1)
161
+ rack-cache (1.2)
162
+ rack (>= 0.4)
163
+ rack-ssl (1.3.2)
164
+ rack
165
+ rack-test (0.6.1)
166
+ rack (>= 1.0)
167
+ rails (3.2.8)
168
+ actionmailer (= 3.2.8)
169
+ actionpack (= 3.2.8)
170
+ activerecord (= 3.2.8)
171
+ activeresource (= 3.2.8)
172
+ activesupport (= 3.2.8)
173
+ bundler (~> 1.0)
174
+ railties (= 3.2.8)
175
+ railties (3.2.8)
176
+ actionpack (= 3.2.8)
177
+ activesupport (= 3.2.8)
178
+ rack-ssl (~> 1.3.2)
179
+ rake (>= 0.8.7)
180
+ rdoc (~> 3.4)
181
+ thor (>= 0.14.6, < 2.0)
182
+ rake (0.9.2.2)
183
+ rdoc (3.12)
184
+ json (~> 1.4)
185
+ responders (0.9.2)
186
+ railties (~> 3.1)
187
+ ruby-hmac (0.4.0)
188
+ sass (3.2.0)
189
+ sass-rails (3.2.5)
190
+ railties (~> 3.2.0)
191
+ sass (>= 3.1.10)
192
+ tilt (~> 1.3)
193
+ select2-rails (3.0.0)
194
+ thor (~> 0.14)
195
+ sprockets (2.1.3)
196
+ hike (~> 1.2)
197
+ rack (~> 1.0)
198
+ tilt (~> 1.1, != 1.3.0)
199
+ stringex (1.4.0)
200
+ subexec (0.2.2)
201
+ thor (0.15.4)
202
+ tilt (1.3.3)
203
+ treetop (1.4.10)
204
+ polyglot
205
+ polyglot (>= 0.3.1)
206
+ tzinfo (0.3.33)
207
+ warden (1.2.1)
208
+ rack (>= 1.0)
209
+ xml-simple (1.1.1)
210
+
211
+ PLATFORMS
212
+ ruby
213
+
214
+ DEPENDENCIES
215
+ activeadmin-blog!
data/README.md ADDED
@@ -0,0 +1,162 @@
1
+ ## activeadmin-blog
2
+
3
+ Blog app on the top of activeadmin and mongoid.
4
+
5
+
6
+ ## Quick install
7
+
8
+ **IMPORTANT**: Make sure local mongodb instance is running.
9
+
10
+ Replace `new_blog` name with the real one and run:
11
+
12
+ export project_name=new_blog ; curl https://raw.github.com/alexkravets/activeadmin-blog/master/install.sh | sh
13
+
14
+ This command creates new rails project fully configured and ready for Heroku deploy.
15
+
16
+
17
+ ## Manual Installation
18
+
19
+ ### Start a new rails project
20
+
21
+ $ rails new appname -T -O
22
+
23
+ ### Setup and configure ActiveAdmin
24
+
25
+ Add these gems to Gemfile and run `bundle` command:
26
+
27
+ # Activeadmin
28
+ gem "bson_ext"
29
+ gem "mongoid"
30
+ gem "devise"
31
+ gem "activeadmin-mongoid"
32
+
33
+ # Activeadmin Mongoid Blog
34
+ gem "activeadmin-settings"
35
+ gem "activeadmin-blog"
36
+
37
+ # Bootstrap styles
38
+ gem "therubyracer"
39
+ gem "twitter-bootstrap-rails"
40
+
41
+ # Assets
42
+ gem "asset_sync"
43
+
44
+ Run following generators:
45
+
46
+ $ rails g mongoid:config
47
+ $ rails g devise:install
48
+ $ rails g active_admin:install
49
+ $ rails g redactor:install
50
+ $ rails g activeadmin_settings:install
51
+ $ rails g activeadmin_blog:install blog
52
+
53
+ Create default admin user for activeadmin:
54
+
55
+ rake activeadmin:settings:create_admin
56
+
57
+ Run `rails s` blog should be accesible at `http://localhost:3000/blog`
58
+
59
+ ### Customizing blog views
60
+
61
+ Install default views templates to `/app/views/blog`:
62
+
63
+ $ rails g activeadmin_blog:views blog
64
+
65
+ ### Default style
66
+
67
+ By default blog is comming with a Twitter Bootstrap typography, to enable it add to `Gemfile`:
68
+
69
+ gem "twitter-bootstrap-rails", :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git"
70
+
71
+ Install required bootstrap assets:
72
+
73
+ rails g bootstrap:install
74
+
75
+ Remove `reuire_self` line from `application.js` and `application.css` these are added by bootstrap intall and will break the layout with activeadmin styles.
76
+
77
+ In `application.js` include:
78
+
79
+ //= require bootstrap
80
+
81
+ In `application.css` include:
82
+
83
+ /*
84
+ *= require bootstrap_and_overrides
85
+ *= require_self
86
+ */
87
+
88
+ // Tuning styles for kaminari pagination
89
+ .pagination .page.current {
90
+ float:left;
91
+ padding:0 14px;
92
+ line-height:34px;
93
+ text-decoration:none;
94
+ border:1px solid #DDD;
95
+ border-left-width:0;
96
+ color:#999;
97
+ cursor:default;
98
+ background-color:whiteSmoke;
99
+ }
100
+ .pagination span:first-child, .pagination .first a { border-left-width:1px; }
101
+
102
+
103
+ ## Heroku
104
+
105
+ #### Mongoid
106
+
107
+ Configure local and production `config/mongoid.yml` settings to look like this:
108
+
109
+ development:
110
+ host: localhost
111
+ database: supercaliblog
112
+
113
+ test:
114
+ host: localhost
115
+ database: supercaliblog_test
116
+
117
+ production:
118
+ uri: <%= ENV["MONGO_URL"] %>
119
+
120
+ #### Carrierwave
121
+
122
+ Create an S3 bucket for redactor image uploading feature and configure `config/initializers/carrierwave.rb`:
123
+
124
+ CarrierWave.configure do |config|
125
+ config.cache_dir = File.join(Rails.root, "tmp", "uploads")
126
+ config.storage = :fog
127
+
128
+ config.fog_credentials = {
129
+ :provider => "AWS",
130
+ :aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
131
+ :aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
132
+ }
133
+
134
+ case Rails.env.to_sym
135
+ when :development
136
+ config.storage = :file
137
+ when :production
138
+ config.fog_directory = ENV["FOG_MEDIA_DIRECTORY"]
139
+ config.fog_host = "//#{ ENV["FOG_MEDIA_DIRECTORY"] }.s3.amazonaws.com"
140
+ config.fog_attributes = {"Cache-Control"=>"max-age=315576000"} # optional, defaults to {}
141
+ end
142
+ end
143
+
144
+ Make sure you've set Heroku environtment variables:
145
+
146
+ FOG_MEDIA_DIRECTORY
147
+ AWS_ACCESS_KEY_ID
148
+ AWS_SECRET_ACCESS_KEY
149
+ MONGO_URL
150
+
151
+ #### Production assets
152
+
153
+ Add the following line to `config/environments/production.rb`:
154
+
155
+ config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor/css/style.css"]
156
+
157
+
158
+ ## TODO
159
+
160
+ - Admin blog post search;
161
+
162
+ ### The End
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems/package_task'
2
+
3
+ spec = Gem::Specification.load(Dir['*.gemspec'].first)
4
+ gem = Gem::PackageTask.new(spec)
5
+ gem.define()
6
+
7
+ #gem push pkg/activeadmin-blog-version.gem
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/activeadmin-blog/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'activeadmin-blog'
6
+ gem.summary = 'Blog app on the top of activeadmin and mongoid.'
7
+ gem.description = ''
8
+ gem.license = 'MIT'
9
+
10
+ gem.authors = ['Alex Kravets']
11
+ gem.email = 'santyor@gmail.com'
12
+ gem.homepage = 'https://github.com/alexkravets/activeadmin-blog'
13
+
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ['lib']
18
+ gem.version = ActiveadminBlog::VERSION
19
+
20
+ # Supress the warning about no rubyforge project
21
+ gem.rubyforge_project = 'nowarning'
22
+
23
+ # Dependencies
24
+ gem.add_runtime_dependency "nokogiri"
25
+ gem.add_runtime_dependency "mongoid_slug"
26
+ gem.add_runtime_dependency "mongoid_search", "~> 0.2.8" # "mongoid_search" this uses mongoid 3.x
27
+ gem.add_runtime_dependency "activeadmin-mongoid-reorder"
28
+ gem.add_runtime_dependency "activeadmin-mongoid"
29
+ gem.add_runtime_dependency "activeadmin-settings"
30
+ end
@@ -0,0 +1,50 @@
1
+ class ActiveadminBlog::PostsController < ApplicationController
2
+ before_filter :load_categories
3
+
4
+ def load_categories
5
+ @categories = ActiveadminBlog::BlogCategory.all
6
+ end
7
+
8
+ def index
9
+ @posts = ActiveadminBlog::BlogPost.published
10
+ @posts = @posts.page params[:page]
11
+ end
12
+
13
+ def search
14
+ search_query = params[:q]
15
+ @posts = ActiveadminBlog::BlogPost.blog_search(search_query)
16
+ @posts = @posts.page params[:page]
17
+ end
18
+
19
+ def category
20
+ category_slug = params[:slug]
21
+ @posts = ActiveadminBlog::BlogPost.published_in_category(category_slug)
22
+ @posts = @posts.page params[:page]
23
+ end
24
+
25
+ def archive
26
+ month = params[:m].to_i
27
+ year = params[:y].to_i
28
+ @posts = ActiveadminBlog::BlogPost.published_in_month(month, year)
29
+ @posts = @posts.page params[:page]
30
+ end
31
+
32
+ def tag
33
+ tag = params[:tag]
34
+ @posts = ActiveadminBlog::BlogPost.tagged_with(tag)
35
+ @posts = @posts.page params[:page]
36
+ end
37
+
38
+ def show
39
+ @post = ActiveadminBlog::BlogPost.find_by_permalink!(params[:slug])
40
+ end
41
+
42
+ def feed
43
+ @posts = ActiveadminBlog::BlogPost.published
44
+
45
+ respond_to do |format|
46
+ format.rss { render :layout => false } #index.rss.builder
47
+ format.all { head :not_found }
48
+ end
49
+ end
50
+ end