cardboard_cms 0.1.6 → 0.1.8

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: 79f74648f48e899a4cc6e823888f15ed437fe408
4
- data.tar.gz: c42474efb3ca96d02db0e23896e26530d9b2b287
3
+ metadata.gz: fe8f9938ba535b8fed9271fb66606e70e78e4a5b
4
+ data.tar.gz: 4eef9fe937568db71e1cd7af25b5f62f89add959
5
5
  SHA512:
6
- metadata.gz: 321b542f56a6083e0ab9961b45d776c3d564b306ca33cd87086248a54cd832316b9f1f13b1bb63b7262d26e3e069f36982c3d3da9f95cd91672479ed49083966
7
- data.tar.gz: 8d74c9ae9ded58328e7536f53d81ae69fe39dfb24a88bf5cb4d54181be48eaa0620d115ae25b594e8cbbeb7a37cc9d02b3bf862aecd07de8ef60f3ef88a5becb
6
+ metadata.gz: 680fb7e71e94677f7930ab992999e43484db299760dbc490a754a60290cb095c0b5f5fc206ecb8c3daf65f5bf7507458d52b02b51016a3a82da3ac2ca7db942e
7
+ data.tar.gz: 15a04806e88a768d83a769af68f8bacdfc8b13757517538013452c333b6b091eb7197ece71e97d97c83659e673825715819eaf7c93789e6c829947992fbc6b5d
data/Gemfile CHANGED
@@ -16,14 +16,8 @@ gemspec
16
16
  # Gems used by the dummy application
17
17
  gem "sqlite3"
18
18
  gem "jquery-rails"
19
-
20
-
21
- # should be dependencies
22
-
23
19
  gem 'devise', '>= 3.0.0'
24
20
 
25
-
26
-
27
21
  gem "thin"
28
22
  # gem 'rack-mini-profiler'
29
23
  gem 'letter_opener'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cardboard_cms (0.1.6)
4
+ cardboard_cms (0.1.8)
5
5
  bootstrap-datepicker-rails
6
6
  bootstrap-sass (~> 2.2)
7
7
  bootstrap-wysihtml5-rails
@@ -65,7 +65,7 @@ GEM
65
65
  erubis (>= 2.6.6)
66
66
  binding_of_caller (0.7.2)
67
67
  debug_inspector (>= 0.0.1)
68
- bootstrap-datepicker-rails (1.1.1.9)
68
+ bootstrap-datepicker-rails (1.3.0.1)
69
69
  railties (>= 3.0)
70
70
  bootstrap-sass (2.3.2.2)
71
71
  sass (~> 3.2)
@@ -79,7 +79,7 @@ GEM
79
79
  rack-test (>= 0.5.4)
80
80
  xpath (~> 2.0)
81
81
  chronic (0.10.2)
82
- cocoon (1.2.3)
82
+ cocoon (1.2.5)
83
83
  coderay (1.0.9)
84
84
  coffee-rails (4.0.1)
85
85
  coffee-script (>= 2.2.0)
@@ -87,7 +87,7 @@ GEM
87
87
  coffee-script (2.2.0)
88
88
  coffee-script-source
89
89
  execjs
90
- coffee-script-source (1.6.3)
90
+ coffee-script-source (1.7.0)
91
91
  columnize (0.3.6)
92
92
  daemons (1.1.9)
93
93
  database_cleaner (1.0.1)
@@ -105,7 +105,7 @@ GEM
105
105
  orm_adapter (~> 0.1)
106
106
  railties (>= 3.2.6, < 5)
107
107
  warden (~> 1.2.3)
108
- dragonfly (1.0)
108
+ dragonfly (1.0.3)
109
109
  multi_json (~> 1.0)
110
110
  rack
111
111
  erubis (2.7.0)
@@ -124,7 +124,7 @@ GEM
124
124
  railties (>= 3.1.1)
125
125
  sass-rails (>= 3.1.1)
126
126
  formatador (0.2.4)
127
- gon (4.1.1)
127
+ gon (5.0.1)
128
128
  actionpack (>= 2.3.0)
129
129
  json
130
130
  guard (1.8.2)
@@ -147,10 +147,10 @@ GEM
147
147
  jquery-rails (3.0.4)
148
148
  railties (>= 3.0, < 5.0)
149
149
  thor (>= 0.14, < 2.0)
150
- jquery-ui-rails (4.1.0)
150
+ jquery-ui-rails (4.1.1)
151
151
  railties (>= 3.1.0)
152
152
  json (1.8.0)
153
- kaminari (0.14.1)
153
+ kaminari (0.15.1)
154
154
  actionpack (>= 3.0.0)
155
155
  activesupport (>= 3.0.0)
156
156
  kaminari-bootstrap (0.1.3)
@@ -241,7 +241,7 @@ GEM
241
241
  json (~> 1.4)
242
242
  responders (1.0.0)
243
243
  railties (>= 3.2, < 5)
244
- sass (3.2.12)
244
+ sass (3.2.14)
245
245
  sass-rails (4.0.1)
246
246
  railties (>= 4.0.0, < 5.0)
247
247
  sass (>= 3.1.10)
@@ -251,7 +251,7 @@ GEM
251
251
  rdoc (~> 3.10)
252
252
  select2-rails (3.5.2)
253
253
  thor (~> 0.14)
254
- simple_form (3.0.0)
254
+ simple_form (3.0.1)
255
255
  actionpack (>= 4.0.0, < 4.1)
256
256
  activemodel (>= 4.0.0, < 4.1)
257
257
  simplecov (0.7.1)
@@ -272,7 +272,7 @@ GEM
272
272
  activesupport (>= 3.0)
273
273
  sprockets (~> 2.8)
274
274
  sqlite3 (1.3.7)
275
- stringex (2.1.2)
275
+ stringex (2.2.0)
276
276
  temple (0.6.7)
277
277
  thin (1.5.1)
278
278
  daemons (>= 1.0.9)
@@ -36,11 +36,11 @@ $(document).on('click', '.nav-tabs a', function(e){
36
36
  $(this).tab('show');
37
37
  });
38
38
 
39
- $(document).on("pjax:end ready cocoon:after-insert", function(e){
39
+ $(document).on("pjax:success ready cocoon:after-insert", function(e){
40
+
40
41
  $('select:not([data-search-select])').selectpicker();
41
42
  $('select[data-search-select]').select2({allowClear: true, width: "resolve"});
42
43
 
43
-
44
44
  $('.nav-tabs a:first').tab('show');
45
45
  });
46
46
 
@@ -2,6 +2,12 @@ $(function(){
2
2
  $("a#nav_dashboard_link").click(function(e){
3
3
  e.preventDefault();
4
4
  $("#content_sidebar").toggleClass('toggle');
5
+
6
+ // Expand #main_content down to fit the exposed sidebar
7
+ $("#main_content").css('height',
8
+ $('#content_sidebar').height() + $('#main_topbar').height()
9
+ );
10
+
5
11
  $('#content').toggleClass('toggle');
6
12
  // $(this).toggleClass('active');
7
13
  });
@@ -29,4 +35,4 @@ $(function(){
29
35
  results.show();
30
36
  });
31
37
  });
32
- });
38
+ });
@@ -15,7 +15,9 @@
15
15
  display: none;
16
16
 
17
17
  &.toggle {
18
- display: block;
18
+ position: absolute;
19
+ left: $main_sidebar_width;
20
+ display: inline;
19
21
  // left: $main_sidebar_width;
20
22
  // -webkit-transition: left $page_nav_slide_speed ease;
21
23
  // -moz-transition: left $page_nav_slide_speed ease;
@@ -93,4 +95,4 @@
93
95
  }
94
96
  }
95
97
 
96
- }
98
+ }
@@ -24,15 +24,17 @@ body{
24
24
  overflow-x: hidden;
25
25
  }
26
26
 
27
- #main_content{
28
- min-height:100%;
29
- overflow: hidden;
27
+ #main_content {
30
28
  width: 100%;
29
+ position: relative;
30
+ min-height: 100%;
31
31
  }
32
+
32
33
  #main_sidebar, #content_sidebar{
33
- margin-bottom: -9999px;
34
- padding-bottom: 9999px;
35
- float:left;
34
+ top: 0;
35
+ left: 0;
36
+ min-height: 100%;
37
+ position: absolute;
36
38
  }
37
39
 
38
40
  .center{
@@ -1,5 +1,6 @@
1
1
  require_dependency "cardboard/application_controller"
2
2
 
3
+ #yoda
3
4
  module Cardboard
4
5
  class SuperUserController < ApplicationController
5
6
  def index
@@ -1,6 +1,23 @@
1
1
  module Cardboard
2
2
  module PublicHelper
3
3
 
4
+ def dragonfly_image_tag(image, options = {})
5
+ return nil unless image
6
+ size = options.delete(:size) || '125x125'
7
+ image_tag image.thumb(size).url, options
8
+ end
9
+
10
+ def link_to_file(text, file, options = {})
11
+ return link_to(text, nil, options) unless file && file.url
12
+
13
+ html = ""
14
+ if [:doc, :docx, :xls, :xlsx, :pdf, :zip, :txt].include?(file.format)
15
+ html += image_tag("cardboard/icons/#{file.format}.png")
16
+ end
17
+ html += link_to(text, file.url, options)
18
+ html.html_safe
19
+ end
20
+
4
21
  # Example:
5
22
  # link_to_page 123, class: "btn" do |page|
6
23
  # "hello #{page.title}"
@@ -41,7 +58,7 @@ module Cardboard
41
58
  inner_nested_pages(Cardboard::Page.arrange(page), &block).try(:html_safe)
42
59
  end
43
60
 
44
- private
61
+ private
45
62
 
46
63
  def inner_nested_pages(pages, &block)
47
64
  return unless pages
@@ -1,9 +1,14 @@
1
1
  module Cardboard
2
2
  class Field::Boolean < Field
3
- before_validation :convert_to_boolean
4
-
5
3
  validate :is_boolean
6
-
4
+
5
+ def value
6
+ to_boolean(value_uid)
7
+ end
8
+
9
+ def value=(val)
10
+ self.value_uid = to_boolean(val) #saved as a consistent string 't'
11
+ end
7
12
 
8
13
  def default
9
14
  [true, false].sample
@@ -12,12 +17,7 @@ module Cardboard
12
17
  private
13
18
 
14
19
  def is_boolean
15
- errors.add(:value, "is not a valid boolean") if self.value.nil?
16
- end
17
-
18
- def convert_to_boolean
19
- self.value = to_boolean(self.value_uid)
20
- true # don't return a validation error on false
20
+ errors.add(:value, "is not a valid boolean") if self.value_uid.nil?
21
21
  end
22
22
 
23
23
  def to_boolean(val)
@@ -1,5 +1,5 @@
1
1
  #menu
2
- - if cardboard_user_can_manage?(:pages)
2
+ - if Cardboard.used_as_cms? && cardboard_user_can_manage?(:pages)
3
3
  = main_sidebar_nav_link "Pages", pages_path, id: "nav_dashboard_link", "data-skip-pjax" => true
4
4
 
5
5
 
data/cardboard.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.license = "GPLv3"
8
8
  s.version = Cardboard::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
- s.authors = ["Michael Elfassy", "Smashing Boxes"]
10
+ s.authors = ["Michael Elfassy", "SmashingBoxes"]
11
11
  s.email = ["michael@smashingboxes.com"]
12
12
  s.homepage = "http://smashingboxes.com"
13
13
  s.summary = "Rails CMS made simple"
@@ -29,7 +29,7 @@ module Cardboard
29
29
  page_parts.each do |id, part|
30
30
  db_part = db_page.parts.where(identifier: id.to_s).first_or_initialize
31
31
  db_part.part_position_position = part[:position] || :last
32
- db_part.update_attributes!(part.slice(:repeatable))
32
+ db_part.update_attributes!(:repeatable => part[:repeatable])
33
33
 
34
34
  db_part.subparts.first_or_create!
35
35
 
@@ -1,3 +1,3 @@
1
1
  module Cardboard
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/cardboard_cms.rb CHANGED
@@ -16,6 +16,11 @@ module Cardboard
16
16
  @user_class ||= application.user_class.to_s.camelize.constantize
17
17
  end
18
18
 
19
+ def used_as_cms?
20
+ @used_as_cms = Cardboard::Page.count > 0 if @used_as_cms.nil? #handle false
21
+ @used_as_cms
22
+ end
23
+
19
24
  def set_resource_controllers
20
25
  Dir[Rails.root.join('app/controllers/cardboard/*_controller.rb')].map.each do |controller|
21
26
  require_dependency controller
@@ -1,6 +1,7 @@
1
1
  // jquery.pjax.js
2
2
  // copyright chris wanstrath
3
3
  // https://github.com/defunkt/jquery-pjax
4
+ // version: 1.8.0
4
5
 
5
6
  (function($){
6
7
 
@@ -85,8 +86,7 @@ function handleClick(event, container, options) {
85
86
  var defaults = {
86
87
  url: link.href,
87
88
  container: $(link).attr('data-pjax'),
88
- target: link,
89
- fragment: null
89
+ target: link
90
90
  }
91
91
 
92
92
  var opts = $.extend({}, defaults, options)
@@ -96,6 +96,7 @@ function handleClick(event, container, options) {
96
96
  if (!clickEvent.isDefaultPrevented()) {
97
97
  pjax(opts)
98
98
  event.preventDefault()
99
+ $(link).trigger('pjax:clicked', [opts])
99
100
  }
100
101
  }
101
102
 
@@ -127,8 +128,7 @@ function handleSubmit(event, container, options) {
127
128
  url: form.action,
128
129
  data: $(form).serializeArray(),
129
130
  container: $(form).attr('data-pjax'),
130
- target: form,
131
- fragment: null
131
+ target: form
132
132
  }
133
133
 
134
134
  pjax($.extend({}, defaults, options))
@@ -263,8 +263,22 @@ function pjax(options) {
263
263
  window.history.replaceState(pjax.state, container.title, container.url)
264
264
  }
265
265
 
266
+ // Clear out any focused controls before inserting new page contents.
267
+ document.activeElement.blur()
268
+
266
269
  if (container.title) document.title = container.title
267
270
  context.html(container.contents)
271
+
272
+ // FF bug: Won't autofocus fields that are inserted via JS.
273
+ // This behavior is incorrect. So if theres no current focus, autofocus
274
+ // the last field.
275
+ //
276
+ // http://www.w3.org/html/wg/drafts/html/master/forms.html
277
+ var autofocusEl = context.find('input[autofocus], textarea[autofocus]').last()[0]
278
+ if (autofocusEl && document.activeElement !== autofocusEl) {
279
+ autofocusEl.focus();
280
+ }
281
+
268
282
  executeScriptTags(container.scripts)
269
283
 
270
284
  // Scroll to top by default
@@ -384,11 +398,15 @@ function onPjaxPopstate(event) {
384
398
  var state = event.state
385
399
 
386
400
  if (state && state.container) {
387
- // When coming forward from a seperate history session, will get an
401
+ // When coming forward from a separate history session, will get an
388
402
  // initial pop with a state we are already at. Skip reloading the current
389
403
  // page.
390
404
  if (initialPop && initialURL == state.url) return
391
405
 
406
+ // If popping back to the same state, just skip.
407
+ // Could be clicking back from hashchange rather than a pushState.
408
+ if (pjax.state.id === state.id) return
409
+
392
410
  var container = $(state.container)
393
411
  if (container.length) {
394
412
  var direction, contents = cacheMapping[state.id]
@@ -648,7 +666,7 @@ function extractContainer(data, xhr, options) {
648
666
  // Remove any parent title elements
649
667
  obj.contents = obj.contents.not(function() { return $(this).is('title') })
650
668
 
651
- // Then scrub any titles from their descendents
669
+ // Then scrub any titles from their descendants
652
670
  obj.contents.find('title').remove()
653
671
 
654
672
  // Gather all script[src] elements
@@ -811,7 +829,7 @@ function disable() {
811
829
  if ( $.inArray('state', $.event.props) < 0 )
812
830
  $.event.props.push('state')
813
831
 
814
- // Is pjax supported by this browser?
832
+ // Is pjax supported by this browser?
815
833
  $.support.pjax =
816
834
  window.history && window.history.pushState && window.history.replaceState &&
817
835
  // pushState isn't reliable on iOS until 5.
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardboard_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Elfassy
8
- - Smashing Boxes
8
+ - SmashingBoxes
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-13 00:00:00.000000000 Z
12
+ date: 2014-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -491,6 +491,13 @@ files:
491
491
  - app/assets/images/cardboard/.gitkeep
492
492
  - app/assets/images/cardboard/bg.png
493
493
  - app/assets/images/cardboard/calendar.png
494
+ - app/assets/images/cardboard/icons/doc.png
495
+ - app/assets/images/cardboard/icons/docx.png
496
+ - app/assets/images/cardboard/icons/pdf.png
497
+ - app/assets/images/cardboard/icons/txt.png
498
+ - app/assets/images/cardboard/icons/xls.png
499
+ - app/assets/images/cardboard/icons/xlsx.png
500
+ - app/assets/images/cardboard/icons/zip.png
494
501
  - app/assets/images/cardboard/lorem-ipsum-coffe-mug.jpg
495
502
  - app/assets/javascripts/cardboard.js
496
503
  - app/assets/javascripts/cardboard/admin.js