atomic_cms 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +16 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +5 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +243 -0
  9. data/README.md +175 -0
  10. data/Rakefile +15 -0
  11. data/app/assets/images/icon_add_component.png +0 -0
  12. data/app/assets/images/icon_add_component@2x.png +0 -0
  13. data/app/assets/javascripts/atomic_cms.js +286 -0
  14. data/app/assets/stylesheets/atomic_cms.css.scss +135 -0
  15. data/app/components/array_component.rb +11 -0
  16. data/app/controllers/atomic_cms/components_controller.rb +7 -0
  17. data/app/controllers/atomic_cms/media_controller.rb +18 -0
  18. data/app/controllers/concerns/media_scrubber.rb +28 -0
  19. data/app/helpers/component_helper.rb +21 -0
  20. data/app/models/atomic_cms/image.rb +6 -0
  21. data/app/models/atomic_cms/media.rb +12 -0
  22. data/app/views/components/_children_field.html.slim +6 -0
  23. data/app/views/components/_edit.html.slim +2 -0
  24. data/app/views/components/_file_field.slim +5 -0
  25. data/app/views/components/_markdown_field.slim +5 -0
  26. data/app/views/components/_select_field.slim +5 -0
  27. data/app/views/components/_template_field.slim +1 -0
  28. data/app/views/components/_text_area_field.slim +4 -0
  29. data/app/views/components/_text_field.slim +3 -0
  30. data/atomic_cms.gemspec +30 -0
  31. data/bin/rails +12 -0
  32. data/config/routes.rb +4 -0
  33. data/db/migrate/20151013175254_create_media.rb +9 -0
  34. data/lib/generators/atomic_cms/assets/assets_generator.rb +33 -7
  35. data/lib/generators/atomic_cms/scaffold/scaffold_generator.rb +76 -0
  36. data/lib/generators/atomic_cms/templates/admin.erb +79 -0
  37. data/lib/generators/atomic_cms/templates/controller.erb +16 -0
  38. data/lib/generators/atomic_cms/templates/model.erb +4 -0
  39. data/lib/generators/atomic_cms/templates/show.html.slim +1 -0
  40. data/vendor/assets/javascripts/angular-markdown.js +19 -0
  41. data/vendor/assets/javascripts/showdown.min.js +2 -0
  42. metadata +40 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f86fcb1ed12c234e15e219684b25b77a5775bee
4
- data.tar.gz: 76fc3306cd7814413f8813963282a15816659c97
3
+ metadata.gz: 2ef68fd2934dc40720fe78c309ede067c8f48098
4
+ data.tar.gz: 13ba7932c24ace6e795b82cf880d3df696654009
5
5
  SHA512:
6
- metadata.gz: 68339f90980248a485daeb22ed8974c084ce8917923483dae652c96b0e42df8a7ff0406e2ae01edfc27d1707939eaae8cdc2e03086d275a34d9869fb711d3012
7
- data.tar.gz: 0ec70c6c1c2d0258cfe8d8db8f4321f8f322f82971bee5b59c8f1e472b0e91fd02a52cfe02fc1bfba1e5ce4462780739e71a640e47b9a31d1ce334a58a5e6cd6
6
+ metadata.gz: 22966be2c77229934a7849521b2a7334dd6e077320530e450d7c06fda88989fee98fa1007d98938f38bc154f5e5dc6435131abdbaa02b7d96f489a462020cd1e
7
+ data.tar.gz: 96e7f3e00c584006ccd308e3100e3b900c6b11f0672cf04eb708c334ec8fee4a6918040d6a2ec810d941472bb1c0969e1fd1ef36d293015b87626b68f0989e8d
data/.eslintrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ 'env': {
3
+ 'browser': true,
4
+ 'node': true
5
+ },
6
+ 'globals': {
7
+ 'window': true,
8
+ 'document': true,
9
+ 'jQuery': true,
10
+ '$': true,
11
+ 'angular': true
12
+ },
13
+ 'rules': {
14
+ 'quotes': [2, 'single', 'avoid-escape']
15
+ }
16
+ }
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ *.gem
5
+ *.DS_Store
6
+ *.keep
7
+ spec/dummy/db/*.sqlite3
8
+ spec/dummy/db/*.sqlite3-journal
9
+ spec/dummy/log/*.log
10
+ spec/dummy/tmp/
11
+ spec/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/StringLiterals:
5
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,243 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ atomic_cms (0.0.1)
5
+ activeadmin (= 1.0.0.pre2)
6
+ angularjs-rails (~> 1.3, < 1.4)
7
+ atomic_assets (~> 0.0.4)
8
+ jquery-rails (~> 4.0, >= 4.0.3)
9
+ paperclip (~> 4.3)
10
+ rails (~> 4.2)
11
+ redcarpet (~> 3.3)
12
+ slim-rails (~> 3.0)
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ actionmailer (4.2.4)
18
+ actionpack (= 4.2.4)
19
+ actionview (= 4.2.4)
20
+ activejob (= 4.2.4)
21
+ mail (~> 2.5, >= 2.5.4)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ actionpack (4.2.4)
24
+ actionview (= 4.2.4)
25
+ activesupport (= 4.2.4)
26
+ rack (~> 1.6)
27
+ rack-test (~> 0.6.2)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
+ actionview (4.2.4)
31
+ activesupport (= 4.2.4)
32
+ builder (~> 3.1)
33
+ erubis (~> 2.7.0)
34
+ rails-dom-testing (~> 1.0, >= 1.0.5)
35
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
36
+ activeadmin (1.0.0.pre2)
37
+ arbre (~> 1.0, >= 1.0.2)
38
+ bourbon
39
+ coffee-rails
40
+ formtastic (~> 3.1)
41
+ formtastic_i18n
42
+ inherited_resources (~> 1.6)
43
+ jquery-rails
44
+ jquery-ui-rails
45
+ kaminari (~> 0.15)
46
+ rails (>= 3.2, < 5.0)
47
+ ransack (~> 1.3)
48
+ sass-rails
49
+ activejob (4.2.4)
50
+ activesupport (= 4.2.4)
51
+ globalid (>= 0.3.0)
52
+ activemodel (4.2.4)
53
+ activesupport (= 4.2.4)
54
+ builder (~> 3.1)
55
+ activerecord (4.2.4)
56
+ activemodel (= 4.2.4)
57
+ activesupport (= 4.2.4)
58
+ arel (~> 6.0)
59
+ activesupport (4.2.4)
60
+ i18n (~> 0.7)
61
+ json (~> 1.7, >= 1.7.7)
62
+ minitest (~> 5.1)
63
+ thread_safe (~> 0.3, >= 0.3.4)
64
+ tzinfo (~> 1.1)
65
+ angularjs-rails (1.3.15)
66
+ arbre (1.0.3)
67
+ activesupport (>= 3.0.0)
68
+ arel (6.0.3)
69
+ atomic_assets (0.0.4)
70
+ draper (~> 2.1)
71
+ bourbon (4.2.5)
72
+ sass (~> 3.4)
73
+ thor (~> 0.19)
74
+ builder (3.2.2)
75
+ climate_control (0.0.3)
76
+ activesupport (>= 3.0)
77
+ cocaine (0.5.7)
78
+ climate_control (>= 0.0.3, < 1.0)
79
+ coffee-rails (4.1.0)
80
+ coffee-script (>= 2.2.0)
81
+ railties (>= 4.0.0, < 5.0)
82
+ coffee-script (2.4.1)
83
+ coffee-script-source
84
+ execjs
85
+ coffee-script-source (1.9.1.1)
86
+ diff-lcs (1.2.5)
87
+ draper (2.1.0)
88
+ actionpack (>= 3.0)
89
+ activemodel (>= 3.0)
90
+ activesupport (>= 3.0)
91
+ request_store (~> 1.0)
92
+ erubis (2.7.0)
93
+ execjs (2.6.0)
94
+ factory_girl (4.5.0)
95
+ activesupport (>= 3.0.0)
96
+ factory_girl_rails (4.5.0)
97
+ factory_girl (~> 4.5.0)
98
+ railties (>= 3.0.0)
99
+ formtastic (3.1.3)
100
+ actionpack (>= 3.2.13)
101
+ formtastic_i18n (0.4.1)
102
+ globalid (0.3.6)
103
+ activesupport (>= 4.1.0)
104
+ has_scope (0.6.0)
105
+ actionpack (>= 3.2, < 5)
106
+ activesupport (>= 3.2, < 5)
107
+ i18n (0.7.0)
108
+ inherited_resources (1.6.0)
109
+ actionpack (>= 3.2, < 5)
110
+ has_scope (~> 0.6.0.rc)
111
+ railties (>= 3.2, < 5)
112
+ responders
113
+ jquery-rails (4.0.5)
114
+ rails-dom-testing (~> 1.0)
115
+ railties (>= 4.2.0)
116
+ thor (>= 0.14, < 2.0)
117
+ jquery-ui-rails (5.0.5)
118
+ railties (>= 3.2.16)
119
+ json (1.8.3)
120
+ kaminari (0.16.3)
121
+ actionpack (>= 3.0.0)
122
+ activesupport (>= 3.0.0)
123
+ loofah (2.0.3)
124
+ nokogiri (>= 1.5.9)
125
+ mail (2.6.3)
126
+ mime-types (>= 1.16, < 3)
127
+ mime-types (2.6.2)
128
+ mimemagic (0.3.0)
129
+ mini_portile (0.6.2)
130
+ minitest (5.8.1)
131
+ nokogiri (1.6.6.2)
132
+ mini_portile (~> 0.6.0)
133
+ paperclip (4.3.1)
134
+ activemodel (>= 3.2.0)
135
+ activesupport (>= 3.2.0)
136
+ cocaine (~> 0.5.5)
137
+ mime-types
138
+ mimemagic (= 0.3.0)
139
+ polyamorous (1.2.0)
140
+ activerecord (>= 3.0)
141
+ rack (1.6.4)
142
+ rack-test (0.6.3)
143
+ rack (>= 1.0)
144
+ rails (4.2.4)
145
+ actionmailer (= 4.2.4)
146
+ actionpack (= 4.2.4)
147
+ actionview (= 4.2.4)
148
+ activejob (= 4.2.4)
149
+ activemodel (= 4.2.4)
150
+ activerecord (= 4.2.4)
151
+ activesupport (= 4.2.4)
152
+ bundler (>= 1.3.0, < 2.0)
153
+ railties (= 4.2.4)
154
+ sprockets-rails
155
+ rails-deprecated_sanitizer (1.0.3)
156
+ activesupport (>= 4.2.0.alpha)
157
+ rails-dom-testing (1.0.7)
158
+ activesupport (>= 4.2.0.beta, < 5.0)
159
+ nokogiri (~> 1.6.0)
160
+ rails-deprecated_sanitizer (>= 1.0.1)
161
+ rails-html-sanitizer (1.0.2)
162
+ loofah (~> 2.0)
163
+ railties (4.2.4)
164
+ actionpack (= 4.2.4)
165
+ activesupport (= 4.2.4)
166
+ rake (>= 0.8.7)
167
+ thor (>= 0.18.1, < 2.0)
168
+ rake (10.4.2)
169
+ ransack (1.7.0)
170
+ actionpack (>= 3.0)
171
+ activerecord (>= 3.0)
172
+ activesupport (>= 3.0)
173
+ i18n
174
+ polyamorous (~> 1.2)
175
+ redcarpet (3.3.3)
176
+ request_store (1.2.0)
177
+ responders (2.1.0)
178
+ railties (>= 4.2.0, < 5)
179
+ rspec-core (3.3.2)
180
+ rspec-support (~> 3.3.0)
181
+ rspec-expectations (3.3.1)
182
+ diff-lcs (>= 1.2.0, < 2.0)
183
+ rspec-support (~> 3.3.0)
184
+ rspec-mocks (3.3.2)
185
+ diff-lcs (>= 1.2.0, < 2.0)
186
+ rspec-support (~> 3.3.0)
187
+ rspec-rails (3.3.3)
188
+ actionpack (>= 3.0, < 4.3)
189
+ activesupport (>= 3.0, < 4.3)
190
+ railties (>= 3.0, < 4.3)
191
+ rspec-core (~> 3.3.0)
192
+ rspec-expectations (~> 3.3.0)
193
+ rspec-mocks (~> 3.3.0)
194
+ rspec-support (~> 3.3.0)
195
+ rspec-support (3.3.0)
196
+ sass (3.4.18)
197
+ sass-rails (5.0.4)
198
+ railties (>= 4.0.0, < 5.0)
199
+ sass (~> 3.1)
200
+ sprockets (>= 2.8, < 4.0)
201
+ sprockets-rails (>= 2.0, < 4.0)
202
+ tilt (>= 1.1, < 3)
203
+ shoulda-matchers (3.0.0)
204
+ activesupport (>= 4.0.0)
205
+ slim (3.0.6)
206
+ temple (~> 0.7.3)
207
+ tilt (>= 1.3.3, < 2.1)
208
+ slim-rails (3.0.1)
209
+ actionmailer (>= 3.1, < 5.0)
210
+ actionpack (>= 3.1, < 5.0)
211
+ activesupport (>= 3.1, < 5.0)
212
+ railties (>= 3.1, < 5.0)
213
+ slim (~> 3.0)
214
+ sprockets (3.4.0)
215
+ rack (> 1, < 3)
216
+ sprockets-rails (2.3.3)
217
+ actionpack (>= 3.0)
218
+ activesupport (>= 3.0)
219
+ sprockets (>= 2.8, < 4.0)
220
+ sqlite3 (1.3.11)
221
+ temple (0.7.6)
222
+ thor (0.19.1)
223
+ thread_safe (0.3.5)
224
+ tilt (2.0.1)
225
+ tzinfo (1.2.2)
226
+ thread_safe (~> 0.1)
227
+
228
+ PLATFORMS
229
+ ruby
230
+
231
+ DEPENDENCIES
232
+ atomic_cms!
233
+ factory_girl_rails
234
+ rspec-core (~> 3.3)
235
+ rspec-expectations (~> 3.3)
236
+ rspec-mocks (~> 3.3)
237
+ rspec-rails
238
+ rspec-support (~> 3.3)
239
+ shoulda-matchers
240
+ sqlite3
241
+
242
+ BUNDLED WITH
243
+ 1.10.6
data/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # Atomic CMS
2
+ The biggest problem with any content management system is the admin users are
3
+ given too much or too little power when editing their site. This gem provides a
4
+ means to manage usage of components created from the gem Atomic Assets. By
5
+ providing admin users with a way to manage their Atomic Assets, developers and
6
+ designers are able to ensure the components they create remained styled properly
7
+ while allowing admins to update their content as needed without developer
8
+ intervention. Below are instructions for getting started.
9
+
10
+ ## Gemfile
11
+ After initializing a new Rails application, or adding to an existing
12
+ application, add the following gems to your Gemfile.
13
+ ```ruby
14
+ gem 'atomic_cms', github: 'spartansystems/atomic_cms'
15
+ gem 'devise'
16
+ ```
17
+ _Note: devise is optional if you do not want admin users to login._
18
+
19
+ Then perform a `bundle install`.
20
+
21
+ ## Initialization
22
+ ### Active Admin
23
+ To initialize Active Admin:
24
+ ```ruby
25
+ rails generate atomic_cms:install
26
+ ```
27
+ Remove the comments migration Active Admin created along with disabling comments
28
+ on line 122 of the Active Admin initializer.
29
+
30
+ Now you shall run the migration and seeds with:
31
+ ```ruby
32
+ bundle exec rake db:create
33
+ bundle exec rake db:migrate
34
+ ```
35
+ To verify, start the server and visit `localhost:3000/admin`. If you can login
36
+ as `admin@example.com` with the password `password` you have successfully
37
+ completed this step.
38
+
39
+ ### Atomic CMS
40
+ #### Routes
41
+ Update your `config/routes.rb` to include the following:
42
+ ```ruby
43
+ mount AtomicCms::Engine => "/atomic_cms", as: :atomic_cms
44
+ # If you are going to use a catch all route add the following line
45
+ get "*path", to: "pages#show", controller: "pages", as: :page, format: false
46
+ root to: 'pages#show', controller: "pages"
47
+ ```
48
+ The last two lines need to be at the **END** of your `routes.rb` file.
49
+
50
+ ##### Devise Authentication
51
+ Change the mount point above to be the following:
52
+ ```ruby
53
+ authenticate :admin_user, -> (u) { u.admin? } do
54
+ mount AtomicCms::Engine => "/atomic_cms", as: :atomic_cms
55
+ end
56
+ ```
57
+ where `u` is the user and `admin?` the authentication method you have on that
58
+ user; it should return a boolean value.
59
+
60
+ #### Scaffold Generator
61
+ Execute the following to create a model for your static pages:
62
+ ```ruby
63
+ rails g atomic_cms:scaffold page
64
+ ```
65
+ *After this you should run your migrations.*
66
+
67
+ Here is a list of everything that is generated for you:
68
+
69
+ * Model
70
+ * Controller
71
+ * Active Admin Form
72
+ * Migration **Will need to be edited**
73
+ * Show View
74
+ * Route
75
+
76
+ ### Media Upload
77
+ To install the media tables so that you can upload files until your heart is
78
+ literally full run:
79
+ ```
80
+ rake atomic_cms:install:migrations
81
+ rake db:migrate
82
+ ```
83
+ Also, you should configure paperclip to use s3, since s3 is better than local
84
+ file storage.
85
+ ```ruby
86
+ class Application < Rails::Application
87
+ ...
88
+ config.paperclip_defaults = {
89
+ storage: :s3,
90
+ s3_protocol: "https",
91
+ s3_credentials: {
92
+ bucket: ENV.fetch("AWS_S3_BUCKET", ""),
93
+ access_key_id: ENV.fetch("AWS_ACCESS_KEY", ""),
94
+ secret_access_key: ENV.fetch("AWS_SECRET", ""),
95
+ s3_host_name: "s3-#{ENV.fetch('AWS_REGION', '')}.amazonaws.com"
96
+ }
97
+ }
98
+ ...
99
+ end
100
+ ```
101
+
102
+ #### Styles
103
+ In order for component previews to have the proper project styling,
104
+ `active_admin.scss` will need to be updated to import your `application.scss`.
105
+ *NOTE:* If you are using bourbon, bitters, and neat you will not be able to
106
+ straight import `application.scss` as certain styles within base must be
107
+ imported under the `#component_preview` selector. Below is an example of how
108
+ this is properly imported:
109
+
110
+ ```scss
111
+ @import "active_admin/mixins";
112
+ @import "active_admin/base";
113
+ @import "bourbon";
114
+ @import "neat";
115
+ @import "base/variables";
116
+ @import "base/grid-settings";
117
+ @import "atomic_cms";
118
+
119
+ #component_preview {
120
+ @import "reset";
121
+ @import "base/buttons";
122
+ @import "base/forms";
123
+ @import "base/lists";
124
+ @import "base/tables";
125
+ @import "base/typography";
126
+ @import "components/*";
127
+ @include font-feature-settings("kern", "liga", "pnum");
128
+ -webkit-font-smoothing: antialiased;
129
+ color: $base-font-color;
130
+ font-family: $base-font-family;
131
+ font-size: 16px;
132
+ line-height: $base-line-height;
133
+ // When editing a page through the CMS,
134
+ // images with broken links will not be displayed
135
+ img[src="image"] {
136
+ display: none !important;
137
+ }
138
+ }
139
+
140
+ // Overriding any non-variable SASS must be done after the fact.
141
+ // For example, to change the default status-tag color:
142
+ //
143
+ // .status_tag { background: #6090DB; }
144
+ ```
145
+ *NOTE:* At the minimum, here is what is needed in `active_admin.scss`:
146
+ ```scss
147
+ @import "active_admin/mixins";
148
+ @import "active_admin/base";
149
+ @import "atomic_cms";
150
+
151
+ #component_preview {
152
+ // Include application specific styling here
153
+ }
154
+ ```
155
+
156
+ #### Components
157
+ Generate components by executing the following:
158
+ ```
159
+ rails g atomic_assets:component text_block
160
+ ```
161
+ In order for components to be utilized when managing content, a partial needs to
162
+ be created similar to the following at `app/views/admin/_edit_buttons.html.slim`:
163
+ ```slim
164
+ ol.edit-buttons
165
+ li
166
+ = link_to 'Text Block', atomic_cms.edit_component_path('text_block'), class: 'button'
167
+ ```
168
+ #### Config
169
+ Update `config/application.rb` to include:
170
+ ```ruby
171
+ config.autoload_paths += %W(#{config.root}/lib, #{config.root}/app/components/**/)
172
+ ```
173
+ ### Gotcha's
174
+ When creating a path for a page, from the examples above, make sure to include a
175
+ leading '/', for example: '/home' -or- '/bears'
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
+ load 'rails/tasks/engine.rake'
9
+ Bundler::GemHelper.install_tasks
10
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
11
+ require 'rspec/core'
12
+ require 'rspec/core/rake_task'
13
+ desc "Run all specs in spec directory (excluding plugin specs)"
14
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
15
+ task :default => :spec