cambium 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -3
  3. data/.ruby-version +1 -0
  4. data/README.md +301 -0
  5. data/Rakefile +20 -1
  6. data/app/assets/javascripts/cambium/admin/application.js.coffee +1 -0
  7. data/app/assets/javascripts/cambium/admin/routers/router.js.coffee +8 -17
  8. data/app/assets/javascripts/cambium/admin/templates/image_cropper.jst.ejs +20 -0
  9. data/app/assets/javascripts/cambium/admin/templates/modal.jst.ejs +3 -0
  10. data/app/assets/javascripts/cambium/admin/views/editor.js.coffee +14 -0
  11. data/app/assets/javascripts/cambium/admin/views/image_cropper.js.coffee +27 -0
  12. data/app/assets/javascripts/cambium/admin/views/keyboard_shortcuts.js.coffee +17 -0
  13. data/app/assets/javascripts/cambium/admin/views/media_picker.js.coffee +38 -0
  14. data/app/assets/stylesheets/cambium/admin/application.scss +4 -0
  15. data/app/assets/stylesheets/cambium/admin/partials/_globals.scss +14 -0
  16. data/app/assets/stylesheets/cambium/admin/partials/components.scss +5 -4
  17. data/app/assets/stylesheets/cambium/admin/partials/forms.scss +95 -2
  18. data/app/assets/stylesheets/cambium/admin/partials/modal.scss +40 -0
  19. data/app/assets/stylesheets/cambium/admin/partials/pagination.scss +28 -0
  20. data/app/assets/stylesheets/cambium/admin/partials/tables.scss +18 -27
  21. data/app/assets/stylesheets/cambium/admin/partials/tiles.scss +57 -0
  22. data/app/controllers/cambium/admin/documents_controller.rb +11 -0
  23. data/app/controllers/cambium/admin/pages_controller.rb +15 -0
  24. data/app/controllers/cambium/admin/settings_controller.rb +32 -0
  25. data/app/controllers/cambium/admin_controller.rb +21 -9
  26. data/app/controllers/cambium/pages_controller.rb +17 -0
  27. data/app/helpers/cambium/cambium_helper.rb +148 -116
  28. data/app/models/cambium/document.rb +59 -0
  29. data/app/models/cambium/page.rb +84 -0
  30. data/app/models/cambium/page_template.rb +85 -0
  31. data/app/models/cambium/setting.rb +40 -0
  32. data/app/models/concerns/publishable.rb +0 -21
  33. data/app/views/cambium/admin/documents/index.html.erb +21 -0
  34. data/app/views/cambium/admin/pages/edit.html.erb +16 -0
  35. data/app/views/cambium/admin/paper_trail/versions/_version.html.erb +1 -1
  36. data/app/views/cambium/admin/search/index.html.erb +2 -1
  37. data/app/views/cambium/admin/settings/index.html.erb +15 -0
  38. data/app/views/cambium/pages/home_missing.html.erb +2 -0
  39. data/app/views/layouts/admin.html.erb +1 -1
  40. data/app/views/pages/default.html.erb +13 -0
  41. data/bin/rails +12 -0
  42. data/cambium.gemspec +9 -3
  43. data/config/routes.rb +12 -0
  44. data/db/migrate/20160107161039_create_cambium_pages.rb +19 -0
  45. data/db/migrate/20160108160638_create_cambium_documents.rb +11 -0
  46. data/db/migrate/20160108185904_create_cambium_settings.rb +10 -0
  47. data/db/migrate/20160111154240_add_is_home_to_pages.rb +5 -0
  48. data/db/migrate/20160125174822_add_page_path_to_pages.rb +5 -0
  49. data/db/migrate/20160205190935_add_upload_gravity_to_documents.rb +5 -0
  50. data/lib/cambium.rb +3 -0
  51. data/lib/cambium/engine.rb +21 -0
  52. data/lib/cambium/version.rb +1 -1
  53. data/lib/generators/cambium/admin_generator.rb +1 -1
  54. data/lib/generators/templates/config/admin/documents.yml +23 -0
  55. data/lib/generators/templates/config/admin/pages.yml +56 -0
  56. data/lib/generators/templates/config/admin/settings.yml +19 -0
  57. data/lib/generators/templates/config/admin/sidebar.yml +15 -0
  58. data/lib/generators/templates/config/initializers/assets.rb +3 -1
  59. data/spec/controllers/cambium/admin/documents_controller_spec.rb +7 -0
  60. data/spec/controllers/cambium/admin/pages_controller_spec.rb +7 -0
  61. data/spec/controllers/cambium/admin/settings_controller_spec.rb +7 -0
  62. data/spec/controllers/cambium/pages_controller_spec.rb +7 -0
  63. data/spec/dummy/README.rdoc +28 -0
  64. data/spec/dummy/Rakefile +6 -0
  65. data/spec/dummy/app/assets/images/.keep +0 -0
  66. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  67. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  68. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  69. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  70. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  71. data/spec/dummy/app/mailers/.keep +0 -0
  72. data/spec/dummy/app/models/.keep +0 -0
  73. data/spec/dummy/app/models/concerns/.keep +0 -0
  74. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  75. data/spec/dummy/bin/bundle +3 -0
  76. data/spec/dummy/bin/rails +4 -0
  77. data/spec/dummy/bin/rake +4 -0
  78. data/spec/dummy/bin/setup +29 -0
  79. data/spec/dummy/config.ru +4 -0
  80. data/spec/dummy/config/application.rb +32 -0
  81. data/spec/dummy/config/boot.rb +5 -0
  82. data/spec/dummy/config/database.yml +25 -0
  83. data/spec/dummy/config/environment.rb +5 -0
  84. data/spec/dummy/config/environments/development.rb +41 -0
  85. data/spec/dummy/config/environments/production.rb +79 -0
  86. data/spec/dummy/config/environments/test.rb +42 -0
  87. data/spec/dummy/config/initializers/assets.rb +11 -0
  88. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  89. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  90. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/spec/dummy/config/initializers/inflections.rb +16 -0
  92. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  93. data/spec/dummy/config/initializers/session_store.rb +3 -0
  94. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/spec/dummy/config/locales/en.yml +23 -0
  96. data/spec/dummy/config/routes.rb +4 -0
  97. data/spec/dummy/config/secrets.yml +22 -0
  98. data/spec/dummy/lib/assets/.keep +0 -0
  99. data/spec/dummy/log/.keep +0 -0
  100. data/spec/dummy/public/404.html +67 -0
  101. data/spec/dummy/public/422.html +67 -0
  102. data/spec/dummy/public/500.html +66 -0
  103. data/spec/dummy/public/favicon.ico +0 -0
  104. data/spec/factories/cambium_documents.rb +7 -0
  105. data/spec/factories/cambium_pages.rb +6 -0
  106. data/spec/factories/cambium_settings.rb +7 -0
  107. data/spec/models/cambium/document_spec.rb +7 -0
  108. data/spec/models/cambium/page_spec.rb +7 -0
  109. data/spec/models/cambium/setting_spec.rb +7 -0
  110. data/spec/spec_helper.rb +18 -0
  111. metadata +219 -11
  112. data/test/controllers/cambium/admin/dashboard_controller_test.rb +0 -9
  113. data/test/controllers/cambium/admin/users_controller_test.rb +0 -9
  114. data/test/controllers/cambium/admin_controller_test.rb +0 -9
@@ -0,0 +1,3 @@
1
+ <div id="modal-container">
2
+ <%= yield %>
3
+ </div>
@@ -0,0 +1,14 @@
1
+ class App.Views.Editor extends Backbone.View
2
+
3
+ initialize: ->
4
+ for textarea in $('textarea.editor')
5
+ $(textarea).trumbowyg
6
+ fullscreenable: false
7
+ btns: ['viewHTML',
8
+ '|', 'formatting',
9
+ '|', 'strong', 'em',
10
+ '|', 'link',
11
+ '|', 'insertImage',
12
+ '|', 'justifyLeft', 'justifyCenter',
13
+ '|', 'btnGrp-lists',
14
+ '|', 'horizontalRule']
@@ -0,0 +1,27 @@
1
+ class App.Views.ImageCropper extends Backbone.View
2
+
3
+ el: 'body'
4
+
5
+ template: JST['cambium/admin/templates/image_cropper']
6
+
7
+ events:
8
+ 'click .image-actions a.crop': 'openModal'
9
+
10
+ openModal: (e) ->
11
+ e.preventDefault()
12
+ data =
13
+ url: $(e.target).data('url')
14
+ width: $(e.target).data('width') / 3
15
+ height: $(e.target).data('height') / 3
16
+ $('#modal-container').remove()
17
+ $('body').prepend(@template(image: data))
18
+ $('#modal-container img').on 'load', () ->
19
+ $('#modal-container .gravity div')
20
+ .height($('#modal-container img').height() / 3)
21
+ $('#modal-container .gravity div').click (event) =>
22
+ e.preventDefault()
23
+ $(e.target).parents('.image-actions').find('input')
24
+ .val($(event.target).attr('data-gravity'))
25
+ $('#modal-container').remove()
26
+ $(document).keyup (e) ->
27
+ $('#modal-container').remove() if e.keyCode == 27
@@ -0,0 +1,17 @@
1
+ class App.Views.KeyboardShortcuts extends Backbone.View
2
+
3
+ el: 'body'
4
+
5
+ events:
6
+ 'keyup': 'shortcut'
7
+
8
+ shortcut: (e) ->
9
+ return if $('input, select, textarea').is(':focus')
10
+ switch e.keyCode
11
+ when 27 # Esc
12
+ $('.search-box input').blur()
13
+ when 78 # n
14
+ if $('#title-bar .button.new').length > 0
15
+ window.location = $('#title-bar .button.new').first().attr('href')
16
+ when 111, 191 # /
17
+ $('.search-box input').focus()
@@ -0,0 +1,38 @@
1
+ class App.Views.MediaPicker extends Backbone.View
2
+
3
+ el: 'body'
4
+
5
+ template: JST['cambium/admin/templates/modal']
6
+
7
+ events:
8
+ 'click .media-picker .add': 'addMedia'
9
+ 'click .media-picker .remove': 'removeMedia'
10
+
11
+ addMedia: (e) ->
12
+ e.preventDefault()
13
+ $.get $('#page-content').data('library'), (data) =>
14
+ $('#modal-container').remove()
15
+ $('body').prepend(@template(yield: data))
16
+ $('article.tile').click (e2) =>
17
+ e2.preventDefault()
18
+ id = $(e2.target).parents('.tile').first().attr('data-id')
19
+ filename = $(e2.target).parents('.tile').first().attr('data-filename')
20
+ url = $(e2.target).parents('.tile').first().attr('data-url')
21
+ thumb = $(e2.target).parents('.tile').first().attr('data-thumb')
22
+ image = $(e2.target).parents('.tile').first().attr('data-image')
23
+ $(e.target).siblings('input').first().val(id)
24
+ $(e.target).siblings('a.file, img').remove()
25
+ if image == 'true'
26
+ $(e.target).parents('.media-picker').append("<img src=\"#{thumb}\">")
27
+ $(e.target).parents('.media-picker').append """
28
+ <a href="#{url}" class="file" target="_blank">#{filename}</a>
29
+ """
30
+ $(e.target).parents('.media-picker').find('a.remove').addClass('active')
31
+ $('#modal-container').remove()
32
+
33
+ removeMedia: (e) ->
34
+ e.preventDefault()
35
+ $(e.target).siblings('input').first().val('')
36
+ $(e.target).siblings('img, a.file').remove()
37
+ $(e.target).parents('.media-picker').find('a.remove').removeClass('active')
38
+ $(e.target).siblings('input').first().val('')
@@ -3,6 +3,7 @@
3
3
 
4
4
  @import 'bourbon';
5
5
  @import 'cambium/admin/bones/bones';
6
+ @import 'trumbowyg/trumbowyg';
6
7
  @import 'pickadate/classic';
7
8
  @import 'pickadate/classic.date';
8
9
  @import 'pickadate/classic.time';
@@ -20,7 +21,10 @@
20
21
  @import 'cambium/admin/partials/activity';
21
22
  @import 'cambium/admin/partials/forms';
22
23
  @import 'cambium/admin/partials/tables';
24
+ @import 'cambium/admin/partials/tiles';
23
25
  @import 'cambium/admin/partials/dashboard';
26
+ @import 'cambium/admin/partials/modal';
27
+ @import 'cambium/admin/partials/pagination';
24
28
 
25
29
  // ------------------------------------------ Optional Override
26
30
 
@@ -19,3 +19,17 @@
19
19
  }
20
20
  }
21
21
  }
22
+
23
+ @mixin icon {
24
+ font-family: 'icomoon';
25
+ speak: none;
26
+ font-style: normal;
27
+ font-weight: normal;
28
+ font-variant: normal;
29
+ text-transform: none;
30
+ line-height: 1;
31
+
32
+ /* Better Font Rendering =========== */
33
+ -webkit-font-smoothing: antialiased;
34
+ -moz-osx-font-smoothing: grayscale;
35
+ }
@@ -38,7 +38,7 @@ div.status{
38
38
  }
39
39
 
40
40
  a {
41
- &.new, &.export, &.file, &.delete {
41
+ &.add, &.new, &.export, &.file, &.delete, &.crop, &.remove {
42
42
  &:before {
43
43
  font-family: 'icomoon';
44
44
  font-size: inherit;
@@ -46,10 +46,11 @@ a {
46
46
  margin: 0 5px 0 0;
47
47
  }
48
48
  }
49
- &.new:before { content: "\e702"; }
49
+ &.new:before, &.add:before { content: "\e702"; }
50
50
  &.export:before { content: "\e65e"; }
51
- &.delete:before { content: "\e6a7"; }
52
- &.file:before { content: "\e622"; }
51
+ &.delete:before, &.remove:before { content: "\e6a7"; }
52
+ &.file:before { content: "\e65e"; }
53
+ &.crop:before { content: "\e73d"; }
53
54
  }
54
55
 
55
56
  .avatar-container {
@@ -1,4 +1,10 @@
1
1
  section.form {
2
+ &.settings {
3
+ form input[type=submit] {
4
+ width: 75%;
5
+ margin: 0 0 25px 25%;
6
+ }
7
+ }
2
8
  form {
3
9
 
4
10
  h2 {
@@ -14,18 +20,58 @@ section.form {
14
20
  padding: 20px 0;
15
21
  &.file {
16
22
  padding: 20px 0 0 0;
17
- & + a.file {
23
+ & + img, img {
24
+ display: block;
25
+ width: 75%;
26
+ max-width: 200px;
27
+ margin: 20px 0 10px 25%;
28
+ }
29
+ & + a.file, & + img + a.file, a.file {
18
30
  display: block;
31
+ clear: both;
19
32
  width: 100%;
20
- padding: 5px 0 20px 0;
33
+ margin: 5px 0 0 25%;
34
+ font-size: 14px;
35
+ line-height: 14px;
36
+ }
37
+ & + .image-actions, & + img + .image-actions, .image-actions {
38
+ display: block;
39
+ clear: both;
40
+ width: 100%;
41
+ margin: 5px 0 20px;
21
42
  font-size: 14px;
22
43
  line-height: 14px;
23
44
  text-align: right;
45
+ a {
46
+ display: inline-block;
47
+ margin-left: 10px;
48
+ }
24
49
  }
25
50
  & + div.input {
26
51
  padding-top: 40px;
27
52
  }
28
53
  }
54
+ &.media-picker .add, &.media-picker .remove {
55
+ display: inline-block;
56
+ background: $color-2;
57
+ padding: 6px 10px;
58
+ font-size: 15px;
59
+ font-weight: 400;
60
+ color: $color-dark;
61
+ vertical-align: top;
62
+ &:before {
63
+ font-size: 10px;
64
+ }
65
+ }
66
+ &.media-picker .remove {
67
+ background: $color-danger;
68
+ margin-left: 10px;
69
+ color: $color-light;
70
+ display: none;
71
+ &.active {
72
+ display: inline-block;
73
+ }
74
+ }
29
75
  label {
30
76
  position: relative;
31
77
  display: inline-block;
@@ -118,6 +164,53 @@ section.form {
118
164
  color: $color-danger;
119
165
  text-transform: uppercase;
120
166
  }
167
+ .trumbowyg-box {
168
+ display: inline-block;
169
+ width: 75%;
170
+ margin: 5px 0;
171
+ &.trumbowyg-fullscreen {
172
+ width: 100%;
173
+ }
174
+ }
175
+ .trumbowyg-modal {
176
+ // position: fixed;
177
+ .trumbowyg-modal-box {
178
+ height: 295px;
179
+ form {
180
+ input {
181
+ height: auto;
182
+ margin: 0 !important;
183
+ padding: 5px 10px !important;
184
+ font-size: 14px !important;
185
+ color: $color-light-darkest !important;
186
+ line-height: 25px !important;
187
+ border: 1px solid $color-light-dark !important;
188
+ }
189
+ label {
190
+ display: block;
191
+ position: relative;
192
+ height: 42px;
193
+ margin-bottom: 5px;
194
+ // margin: 15px 12px;
195
+ // height: 27px;
196
+ line-height: 27px;
197
+ overflow: hidden;
198
+ width: auto;
199
+ .trumbowyg-input-infos {
200
+ float: left;
201
+ span {
202
+ font-size: 14px;
203
+ border: none;
204
+ }
205
+ }
206
+ }
207
+ .trumbowyg-modal-button {
208
+ height: auto;
209
+ line-height: 16px;
210
+ }
211
+ }
212
+ }
213
+ }
121
214
  }
122
215
 
123
216
  input[type=submit] {
@@ -0,0 +1,40 @@
1
+ body > #modal-container {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ height: 100%;
7
+ z-index: 9999999;
8
+ background: rgba($color-dark, 0.9);
9
+
10
+ #title-bar {
11
+ position: relative;
12
+ top: 0;
13
+ padding: 5px 25px;
14
+ }
15
+ .tiles {
16
+ margin: 50px;
17
+ }
18
+
19
+ .image-container {
20
+ position: relative;
21
+ max-width: 600px;
22
+ margin: 25px auto;
23
+ .gravity {
24
+ @include position(absolute, 0 null null 0);
25
+ @include size(100%);
26
+ font-size: 0;
27
+ div {
28
+ display: inline-block;
29
+ width: 33.3%;
30
+ &:hover {
31
+ cursor: pointer;
32
+ background: rgba($color-1, 0.75);
33
+ }
34
+ }
35
+ }
36
+ img {
37
+ width: 100%;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,28 @@
1
+ .pagination {
2
+ &:first-child {
3
+ margin: 0 0 15px 0;
4
+ }
5
+ &:last-child {
6
+ margin: 15px 0 0 0;
7
+ }
8
+ span {
9
+ display: inline-block;
10
+ margin: 0;
11
+ padding: 0;
12
+ font-weight: 400;
13
+ &.current {
14
+ padding: 3px;
15
+ font-weight: 600;
16
+ }
17
+ a {
18
+ margin: 0;
19
+ padding: 3px;
20
+ font-size: inherit;
21
+ font-weight: inherit;
22
+ }
23
+ }
24
+ }
25
+
26
+ table .pagination {
27
+ text-align: right;
28
+ }
@@ -12,6 +12,23 @@ section.data-table {
12
12
  font-weight: 400;
13
13
  text-transform: uppercase;
14
14
  color: $color-1;
15
+ a {
16
+ font-weight: inherit;
17
+ &.active.asc, &.active.desc {
18
+ &:before {
19
+ @include icon;
20
+ display: inline-block;
21
+ margin-right: 5px;
22
+ font-size: 0.75em;
23
+ }
24
+ }
25
+ &.active.asc:before {
26
+ content: "\e72c";
27
+ }
28
+ &.active.desc:before {
29
+ content: "\e728";
30
+ }
31
+ }
15
32
  }
16
33
  }
17
34
  }
@@ -51,30 +68,4 @@ section.data-table {
51
68
  }
52
69
  }
53
70
  }
54
-
55
- .pagination {
56
- text-align: right;
57
- &:first-child {
58
- margin: 0 0 15px 0;
59
- }
60
- &:last-child {
61
- margin: 15px 0 0 0;
62
- }
63
- span {
64
- display: inline-block;
65
- margin: 0;
66
- padding: 0;
67
- font-weight: 400;
68
- &.current {
69
- padding: 3px;
70
- font-weight: 600;
71
- }
72
- a {
73
- margin: 0;
74
- padding: 3px;
75
- font-size: inherit;
76
- font-weight: inherit;
77
- }
78
- }
79
- }
80
- }
71
+ }
@@ -0,0 +1,57 @@
1
+ #page-content.tiles {
2
+ margin-top: 75px;
3
+ article {
4
+ position: relative;
5
+ display: inline-block;
6
+ width: 180px;
7
+ height: 180px;
8
+ margin: 5px;
9
+ background: $color-light;
10
+ &:before {
11
+ display: block;
12
+ margin: 75px 0 0 0;
13
+ font-family: 'icomoon';
14
+ font-size: inherit;
15
+ line-height: inherit;
16
+ content: "\e622";
17
+ font-size: 72px;
18
+ color: $color-light-darkest;
19
+ text-align: center;
20
+ }
21
+ &.pdf:before { content: "\e7b2"; }
22
+ &.doc:before, &.docx:before { content: "\e7b4"; }
23
+ &.xls:before, &.xlsx:before { content: "\e7b5"; }
24
+ &.zip:before { content: "\e7b6"; }
25
+ &.ppt:before, &.pptx:before { content: "\e7b7"; }
26
+ &.xml:before { content: "\e7b8"; }
27
+ &.css:before { content: "\e7b9"; }
28
+ &.html:before { content: "\e7ba"; }
29
+ a {
30
+ position: absolute;
31
+ top: 0;
32
+ left: 0;
33
+ width: 100%;
34
+ height: 100%;
35
+ &:hover h3 {
36
+ background: $color-2;
37
+ }
38
+ }
39
+ img {
40
+ height: 100%;
41
+ width: 100%;
42
+ }
43
+ h3 {
44
+ position: absolute;
45
+ left: 0;
46
+ bottom: 0;
47
+ width: 100%;
48
+ margin: 0;
49
+ padding: 5px 10px;
50
+ box-sizing: border-box;
51
+ font-size: 1em;
52
+ background: $color-1;
53
+ color: $color-dark;
54
+ @include transition(all 0.35s linear);
55
+ }
56
+ }
57
+ }