cambium 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29da11f3322f226331391271921de5a185c1e038
4
- data.tar.gz: bc1726947ccc6aac36768db892bb9916413f4d1c
3
+ metadata.gz: 367bb1dafa5ce1f34612a0e5092e05a74a1d8121
4
+ data.tar.gz: d9ec577e4616fadb2fb3ff1b19d861d254731a62
5
5
  SHA512:
6
- metadata.gz: ebca18b41a35ec1eb921edc0dd0c766417bde5fc0f60b7b63d2ed688c066ce6c20d1ec8137e47abdef88e61f78b1047485ab135da55fbc7a81a0d7f4177cf94b
7
- data.tar.gz: 4868fff7264adcb70ab546c3f54f9499a372684a492eba871cd9077302a83a790478eee1d0981c5a50d90d329b9cf8d30c8dba71c1d560c370ccf937787e0d25
6
+ metadata.gz: 02c0947e578e85183f2768d4c8f697881d979dcdaa4000d831b0dc214558b1b2433ea0c791a9c9b8aa8f84ce86d12b5be4f9134d42e564b9f42ec16837009220
7
+ data.tar.gz: 9be5055314f591116cc9041efb5b42015549c6139f73a4ced6657b0b7d0c4a3dc5ade4e8ce879640f0f99fc8e2d90fb49086688c1a1ef57f64c37bdf0e136f92
@@ -4,6 +4,7 @@ class App.Views.Editor extends Backbone.View
4
4
  for textarea in $('textarea.editor')
5
5
  $(textarea).trumbowyg
6
6
  fullscreenable: false
7
+ svgPath: TRUMBOWYG_SVG
7
8
  btns: ['viewHTML',
8
9
  '|', 'formatting',
9
10
  '|', 'strong', 'em',
@@ -2,7 +2,7 @@ aside#activity {
2
2
  background: $color-light-dark;
3
3
  border-left: 1px solid $color-light-darker;
4
4
  padding: 25px 10px;
5
- @include box-sizing(border-box);
5
+ box-sizing: border-box;;
6
6
  article {
7
7
  margin: 0 0 30px 0;
8
8
  &:last-child {
@@ -5,7 +5,7 @@ div.status{
5
5
  width: 100%;
6
6
  z-index: 99999;
7
7
  text-align: center;
8
- @include box-sizing(border-box);
8
+ box-sizing: border-box;;
9
9
  p.notice, p.alert {
10
10
  margin: 0;
11
11
  padding: 25px 0;
@@ -37,14 +37,13 @@ section.form {
37
37
  & + .image-actions, & + img + .image-actions, .image-actions {
38
38
  display: block;
39
39
  clear: both;
40
- width: 100%;
41
- margin: 5px 0 20px;
40
+ width: 75%;
41
+ margin: 5px 0 20px 25%;
42
42
  font-size: 14px;
43
43
  line-height: 14px;
44
- text-align: right;
45
44
  a {
46
45
  display: inline-block;
47
- margin-left: 10px;
46
+ margin-right: 10px;
48
47
  }
49
48
  }
50
49
  & + div.input {
@@ -103,7 +102,7 @@ section.form {
103
102
  vertical-align: bottom;
104
103
  font-size: 16px;
105
104
  border: none;
106
- @include box-sizing(border-box);
105
+ box-sizing: border-box;;
107
106
  &[readonly=readonly] {
108
107
  background-color: $color-light-dark;
109
108
  border-bottom-color: $color-light-dark;
@@ -167,15 +166,23 @@ section.form {
167
166
  .trumbowyg-box {
168
167
  display: inline-block;
169
168
  width: 75%;
169
+ min-height: 375px;
170
170
  margin: 5px 0;
171
171
  &.trumbowyg-fullscreen {
172
172
  width: 100%;
173
173
  }
174
+ .trumbowyg-button-pane button {
175
+ margin: 0 0 1px;
176
+ }
177
+ textarea {
178
+ border: none;
179
+ width: 100%;
180
+ }
174
181
  }
175
182
  .trumbowyg-modal {
176
183
  // position: fixed;
177
184
  .trumbowyg-modal-box {
178
- height: 295px;
185
+ height: 315px;
179
186
  form {
180
187
  input {
181
188
  height: auto;
@@ -198,6 +205,7 @@ section.form {
198
205
  width: auto;
199
206
  .trumbowyg-input-infos {
200
207
  float: left;
208
+ margin-top: -24px;
201
209
  span {
202
210
  font-size: 14px;
203
211
  border: none;
@@ -217,7 +225,7 @@ section.form {
217
225
  display: block;
218
226
  width: 100%;
219
227
  margin: 15px 0 0 0;
220
- @include box-sizing(border-box);
228
+ box-sizing: border-box;;
221
229
  @include transition(all 0.35s linear);
222
230
  font-size: 16px;
223
231
  font-weight: 600;
@@ -50,7 +50,7 @@ header {
50
50
  float: right;
51
51
  height: 60px;
52
52
  padding: 0;
53
- @include box-sizing(border-box);
53
+ box-sizing: border-box;;
54
54
  // border-left: 1px solid $color-5-dark;
55
55
  @include transition-all;
56
56
  &:hover {
@@ -1,6 +1,8 @@
1
1
  class Cambium::AdminController < Cambium::BaseController
2
2
 
3
3
  before_filter :authenticate_admin!
4
+
5
+ before_filter :set_paper_trail_whodunnit
4
6
  before_filter :set_activities
5
7
 
6
8
  layout "admin"
@@ -1,12 +1,18 @@
1
1
  class Cambium::PagesController < ApplicationController
2
2
 
3
+ before_filter :set_page, :only => [:show]
4
+ before_filter :set_home_page, :only => [:home]
5
+
6
+ if Cambium.configuration.cache_pages
7
+ caches_action :show, :cache_path => :page_cache_path.to_proc
8
+ caches_action :home, :cache_path => :page_cache_path.to_proc
9
+ end
10
+
3
11
  def show
4
- @page = Cambium::Page.find_by_page_path(request.path)
5
12
  render :inline => @page.template.content, :layout => 'application'
6
13
  end
7
14
 
8
15
  def home
9
- @page = Cambium::Page.home
10
16
  if @page.nil?
11
17
  render 'home_missing'
12
18
  else
@@ -14,4 +20,22 @@ class Cambium::PagesController < ApplicationController
14
20
  end
15
21
  end
16
22
 
23
+ protected
24
+
25
+ def set_page
26
+ @page = Cambium::Page.find_by_page_path(request.path)
27
+ end
28
+
29
+ def set_home_page
30
+ @page = Cambium::Page.home
31
+ end
32
+
33
+ def q_to_s
34
+ request.query_parameters.to_a.collect { |q| "_#{q[0]}_#{q[1]}" }.join('')
35
+ end
36
+
37
+ def page_cache_path
38
+ "_p#{@page.id}#{q_to_s}"
39
+ end
40
+
17
41
  end
@@ -162,7 +162,7 @@ module Cambium
162
162
 
163
163
  def cambium_field(f, obj, field)
164
164
  attr = field.first.to_s
165
- options = field.last
165
+ options = field.is_a?(OpenStruct) ? field : field.last
166
166
  options = options.to_ostruct unless options.class == OpenStruct
167
167
  readonly = options.readonly || false
168
168
  label = options.label || attr.titleize
@@ -213,7 +213,7 @@ module Cambium
213
213
  end
214
214
  elsif options.type == 'wysiwyg'
215
215
  f.input(attr.to_sym, :as => :text, :label => label,
216
- :input_html => { :class => 'editor' })
216
+ :input_html => { :class => 'editor' }, :required => required)
217
217
  elsif options.type == 'media'
218
218
  content_tag(:div, :class => 'input media-picker file') do
219
219
  o2 = content_tag(:label, label)
@@ -235,30 +235,52 @@ module Cambium
235
235
  o = f.input(attr.to_sym, :as => options.type, :label => label,
236
236
  :readonly => readonly, :required => required)
237
237
  unless obj.send(attr).blank?
238
- if ['jpg','jpeg','gif','png'].include?(obj.send(attr).ext.downcase)
239
- o += image_tag obj.send(attr)
240
- .thumb("200x200##{obj.send("#{attr}_gravity")}")
241
- .url
242
- o += content_tag(:div, :class => 'image-actions') do
243
- o2 = ''.html_safe
244
- o2 += link_to('Crop Image', '#', :class => 'crop',
245
- :target => :blank, :data => {
246
- :url => obj.send(attr).url,
247
- :width => obj.send(attr).width,
248
- :height => obj.send(attr).height }) if options.crop
249
- o2 += link_to(obj.send(attr).name, obj.send(attr).url,
250
- :class => 'file', :target => :blank)
251
- o2 += f.input :"#{attr}_gravity", :as => :hidden
238
+ # Dragonfly ...
239
+ if obj.send(attr).respond_to?(:ext)
240
+ if %w(jpg jpeg gif png).include?(obj.send(attr).ext.downcase)
241
+ o += image_tag obj.send(attr)
242
+ .thumb("200x200##{obj.send("#{attr}_gravity")}")
243
+ .url
244
+ o += content_tag(:div, :class => 'image-actions') do
245
+ o2 = ''.html_safe
246
+ o2 += link_to('Crop Image', '#', :class => 'crop',
247
+ :target => :blank, :data => {
248
+ :url => obj.send(attr).url,
249
+ :width => obj.send(attr).width,
250
+ :height => obj.send(attr).height }) if options.crop
251
+ o2 += link_to(obj.send(attr).name, obj.send(attr).url,
252
+ :class => 'file', :target => :blank)
253
+ o2 += f.input :"#{attr}_gravity", :as => :hidden
254
+ end
255
+ else
256
+ o += link_to(obj.send(attr).name, obj.send(attr).url,
257
+ :class => 'file', :target => :blank)
252
258
  end
259
+ # CarrierWave (assumed, for now)
253
260
  else
254
- o += link_to(obj.send(attr).name, obj.send(attr).url,
261
+ if %w(jpg jpeg gif png).include?(obj.send(attr).file.extension.downcase)
262
+ o += image_tag obj.send(attr).thumb.url
263
+ o += content_tag(:div, :class => 'image-actions') do
264
+ o2 = ''.html_safe
265
+ # o2 += link_to('Crop Image', '#', :class => 'crop',
266
+ # :target => :blank, :data => {
267
+ # :url => obj.send(attr).url,
268
+ # :width => obj.send(attr).width,
269
+ # :height => obj.send(attr).height }) if options.crop
270
+ o2 += link_to(obj.send(attr).file.filename, obj.send(attr).url,
255
271
  :class => 'file', :target => :blank)
272
+ # o2 += f.input :"#{attr}_gravity", :as => :hidden
273
+ end
274
+ else
275
+ o += link_to(obj.send(attr).name, obj.send(attr).url,
276
+ :class => 'file', :target => :blank)
277
+ end
256
278
  end
257
279
  end
258
280
  o
259
281
  else
260
282
  f.input(attr.to_sym, :as => options.type, :label => label,
261
- :readonly => readonly)
283
+ :readonly => readonly, :required => required)
262
284
  end
263
285
  end
264
286
 
@@ -1,6 +1,8 @@
1
1
  module Cambium
2
2
  class Document < ActiveRecord::Base
3
3
 
4
+ extend Dragonfly::Model
5
+
4
6
  # ------------------------------------------ Plugins
5
7
 
6
8
  include PgSearch
@@ -22,6 +22,7 @@ module Cambium
22
22
 
23
23
  after_save :cache_page_path
24
24
  after_save :reload_routes!
25
+ after_save :expire_caches
25
26
 
26
27
  # ------------------------------------------ Class Methods
27
28
 
@@ -53,7 +54,9 @@ module Cambium
53
54
 
54
55
  def method_missing(method, *arguments, &block)
55
56
  if respond_to?(method.to_s)
56
- if template.fields[method.to_s]['type'] == 'media'
57
+ if template.fields[method.to_s.gsub(/\?$/, '')]['type'] == 'boolean'
58
+ template_data[method.to_s.gsub(/\?$/, '')].to_i == 1
59
+ elsif template.fields[method.to_s]['type'] == 'media'
57
60
  Cambium::Document.find_by_id(template_data[method.to_s].to_i)
58
61
  else
59
62
  template_data[method.to_s]
@@ -67,6 +70,9 @@ module Cambium
67
70
  return true if super
68
71
  return false if template.blank?
69
72
  return true if template.fields.keys.include?(method.to_s)
73
+ template.fields.each do |name, attrs|
74
+ return true if attrs["type"] == 'boolean' && method.to_s == "#{name}?"
75
+ end
70
76
  false
71
77
  end
72
78
 
@@ -80,5 +86,9 @@ module Cambium
80
86
  update_columns(:page_path => "/#{path.collect(&:slug).join('/')}")
81
87
  end
82
88
 
89
+ def expire_caches
90
+ Rails.cache.delete_matched(/\_p#{id}(.*)/)
91
+ end
92
+
83
93
  end
84
94
  end
@@ -14,20 +14,14 @@
14
14
  <% end %>
15
15
  <div class="dropdown-menu">
16
16
  <ul>
17
- <%= content_tag(
18
- :li,
19
- link_to(
20
- 'Edit Profile',
21
- cambium.edit_admin_user_path(current_user)
22
- )
23
- ) %>
24
- <%= content_tag(
25
- :li,
26
- link_to(
27
- 'Sign Out',
28
- main_app.destroy_user_session_path,
29
- )
30
- ) %>
17
+ <li>
18
+ <%= link_to 'Edit Profile',
19
+ cambium.edit_admin_user_path(current_user) %>
20
+ </li>
21
+ <li>
22
+ <%= link_to 'Sign Out', main_app.destroy_user_session_path,
23
+ :method => :delete %>
24
+ </li>
31
25
  </ul>
32
26
  </div>
33
27
  </div>
@@ -1,7 +1,6 @@
1
1
  <%= cambium_page_title(admin_form.title) %>
2
2
 
3
- <%= content_tag(
4
- :div,
5
- cambium_form(@object, admin_form.fields),
6
- :id => 'page-content'
7
- ) %>
3
+ <div id="page-content"
4
+ data-library="<%= cambium.admin_documents_path(:no_layout => true) %>">
5
+ <%= cambium_form(@object, admin_form.fields) %>
6
+ </div>
@@ -1,7 +1,6 @@
1
1
  <%= cambium_page_title(admin_form.title) %>
2
2
 
3
- <%= content_tag(
4
- :div,
5
- cambium_form(@object, admin_form.fields),
6
- :id => 'page-content'
7
- ) %>
3
+ <div id="page-content"
4
+ data-library="<%= cambium.admin_documents_path(:no_layout => true) %>">
5
+ <%= cambium_form(@object, admin_form.fields) %>
6
+ </div>
@@ -4,10 +4,8 @@
4
4
  <section class="form settings">
5
5
  <% @collection.each do |obj| %>
6
6
  <%= simple_form_for [:admin, obj] do |f| %>
7
- <%= f.input :value,
8
- :as => admin_view.form.edit.fields.send(obj.key).type,
9
- :label => admin_view.form.edit.fields.send(obj.key).label,
10
- :input_html => { :id => obj.key } %>
7
+ <% field = [:value, admin_view.form.edit.fields.send(obj.key)] %>
8
+ <%= cambium_field(f, obj, field) %>
11
9
  <%= f.submit "Save #{admin_view.form.edit.fields.send(obj.key).label}" %>
12
10
  <% end %>
13
11
  <% end %>
@@ -8,6 +8,9 @@
8
8
  <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
9
9
  <meta name="apple-mobile-web-app-capable" content="yes">
10
10
  <meta name="format-detection" content="telephone=no">
11
+ <script>
12
+ TRUMBOWYG_SVG = '<%= image_path('trumbowyg/images/icons.svg') %>';
13
+ </script>
11
14
  <%= stylesheet_link_tag 'cambium/admin/application', :media => 'all' %>
12
15
  <%= javascript_include_tag "modernizr" %>
13
16
  <%= csrf_meta_tags %>
data/config/routes.rb CHANGED
@@ -12,8 +12,14 @@ Cambium::Engine.routes.draw do
12
12
 
13
13
  if ActiveRecord::Base.connection.table_exists?('cambium_pages')
14
14
  Cambium::Page.published.each do |page|
15
+ template = page.template
16
+ next if template.nil? || page.page_path.blank?
15
17
  begin
16
- get page.page_path => 'pages#show' unless page.page_path.blank?
18
+ if template.respond_to?(:controller) && template.respond_to?(:action)
19
+ get page.page_path => "/#{template.controller}##{template.action}"
20
+ else
21
+ get page.page_path => 'pages#show'
22
+ end
17
23
  rescue
18
24
  end
19
25
  end
@@ -2,13 +2,15 @@ module Cambium
2
2
  class Configuration
3
3
 
4
4
  attr_accessor :app_title,
5
+ :cache_pages,
5
6
  :development_url,
6
7
  :production_url
7
8
 
8
9
  def initialize
10
+ @app_title = 'Cambium'
11
+ @cache_pages = false
9
12
  @development_url = 'localhost:3000'
10
13
  @production_url = 'example.com'
11
- @app_title = 'Cambium'
12
14
  end
13
15
 
14
16
  end
@@ -1,3 +1,3 @@
1
1
  module Cambium
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -32,10 +32,10 @@ module Cambium
32
32
  # end
33
33
 
34
34
  def confirm_model
35
- @model = model.constantize
36
- rescue
37
- puts "Can't find the model: #{model}"
38
- exit
35
+ @model = model.classify.singularize.constantize
36
+ # rescue
37
+ # puts "Can't find the model: #{model}"
38
+ # exit
39
39
  end
40
40
 
41
41
  def set_model_attrs
@@ -1,3 +1,3 @@
1
1
  Rails.application.config.assets.precompile += %w(
2
2
  modernizr.js trumbowyg/images/icons.png trumbowyg/images/icons-2x.png
3
- )
3
+ trumbowyg/images/icons.svg)
@@ -13,4 +13,13 @@ Cambium.configure do |config|
13
13
  #
14
14
  config.app_title = 'Cambium'
15
15
 
16
+ # -------------------------------------------------- Caching
17
+
18
+ # Cambium's Pages come with action caching support. It is disabled by default.
19
+ # Uncomment the setting below to enable action caching.
20
+ #
21
+ # NOTE: You must install the 'actionpack-action_caching' gem for this to work.
22
+ #
23
+ # config.cache_pages = true
24
+
16
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cambium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean C Davis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-14 00:00:00.000000000 Z
12
+ date: 2016-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -254,7 +254,6 @@ files:
254
254
  - app/assets/javascripts/cambium/admin/templates/.keep
255
255
  - app/assets/javascripts/cambium/admin/templates/image_cropper.jst.ejs
256
256
  - app/assets/javascripts/cambium/admin/templates/modal.jst.ejs
257
- - app/assets/javascripts/cambium/admin/users.js
258
257
  - app/assets/javascripts/cambium/admin/views/default_helpers.js.coffee
259
258
  - app/assets/javascripts/cambium/admin/views/dropdown_menu.js.coffee
260
259
  - app/assets/javascripts/cambium/admin/views/editor.js.coffee
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.