rocket_cms 0.13.6 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb5c88210653666ea04fdfcfb2d10c8dd8f2bfcf
4
- data.tar.gz: 05e9b96ef57111228391810d2764fecdfad75faf
3
+ metadata.gz: 9f65442d32f6e3b45a3d95d120d36ca2622864d1
4
+ data.tar.gz: e2a3b86bbf097a5930c38c800b50454a2f6e8815
5
5
  SHA512:
6
- metadata.gz: 03c6e719619ce146918bafcb3c140d357f42c2e21f0982d12182243331729cb3432813d2aa63b867a3a4149d5cb9ccb1f3bcd3e829a24d394a5c5f360d196335
7
- data.tar.gz: 6f93d5c304b20f95e1069a630f71f4b19759d1bafe04c278c94c7cfec18d34bdd52f6eccaf77327d645f90686ac279c60ad0f26e09ef516f7a5c8489a7318eab
6
+ metadata.gz: 1af6c77eb6f1b4c55bf932ecdf5d3e46c06cd0d7929b03eb1588fde6cc78c3294920fa52c59c6280df28775e5516f376dc2ea4e4c9615bfba356cafd3ad299a3
7
+ data.tar.gz: c66f5819a3b36d2025696ef27b2ac42094fd568cb662a252cb5a8345aaf099a9197003a4778ede51612137fa535b4b8b9ccffca021d48707a24fe18b4edf3cc8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rocket_cms (0.13.6)
4
+ rocket_cms (0.14.0)
5
5
  addressable
6
6
  coffee-rails
7
7
  jquery-rails
@@ -16,45 +16,45 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- actioncable (5.0.0)
20
- actionpack (= 5.0.0)
19
+ actioncable (5.0.0.1)
20
+ actionpack (= 5.0.0.1)
21
21
  nio4r (~> 1.2)
22
22
  websocket-driver (~> 0.6.1)
23
- actionmailer (5.0.0)
24
- actionpack (= 5.0.0)
25
- actionview (= 5.0.0)
26
- activejob (= 5.0.0)
23
+ actionmailer (5.0.0.1)
24
+ actionpack (= 5.0.0.1)
25
+ actionview (= 5.0.0.1)
26
+ activejob (= 5.0.0.1)
27
27
  mail (~> 2.5, >= 2.5.4)
28
28
  rails-dom-testing (~> 2.0)
29
- actionpack (5.0.0)
30
- actionview (= 5.0.0)
31
- activesupport (= 5.0.0)
29
+ actionpack (5.0.0.1)
30
+ actionview (= 5.0.0.1)
31
+ activesupport (= 5.0.0.1)
32
32
  rack (~> 2.0)
33
33
  rack-test (~> 0.6.3)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
36
- actionview (5.0.0)
37
- activesupport (= 5.0.0)
36
+ actionview (5.0.0.1)
37
+ activesupport (= 5.0.0.1)
38
38
  builder (~> 3.1)
39
39
  erubis (~> 2.7.0)
40
40
  rails-dom-testing (~> 2.0)
41
41
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
42
- activejob (5.0.0)
43
- activesupport (= 5.0.0)
42
+ activejob (5.0.0.1)
43
+ activesupport (= 5.0.0.1)
44
44
  globalid (>= 0.3.6)
45
- activemodel (5.0.0)
46
- activesupport (= 5.0.0)
47
- activerecord (5.0.0)
48
- activemodel (= 5.0.0)
49
- activesupport (= 5.0.0)
45
+ activemodel (5.0.0.1)
46
+ activesupport (= 5.0.0.1)
47
+ activerecord (5.0.0.1)
48
+ activemodel (= 5.0.0.1)
49
+ activesupport (= 5.0.0.1)
50
50
  arel (~> 7.0)
51
- activesupport (5.0.0)
51
+ activesupport (5.0.0.1)
52
52
  concurrent-ruby (~> 1.0, >= 1.0.2)
53
53
  i18n (~> 0.7)
54
54
  minitest (~> 5.1)
55
55
  tzinfo (~> 1.1)
56
56
  addressable (2.4.0)
57
- arel (7.0.0)
57
+ arel (7.1.1)
58
58
  builder (3.2.2)
59
59
  coffee-rails (4.2.1)
60
60
  coffee-script (>= 2.2.0)
@@ -66,7 +66,7 @@ GEM
66
66
  concurrent-ruby (1.0.2)
67
67
  erubis (2.7.0)
68
68
  execjs (2.7.0)
69
- globalid (0.3.6)
69
+ globalid (0.3.7)
70
70
  activesupport (>= 4.1.0)
71
71
  htmlentities (4.3.4)
72
72
  i18n (0.7.0)
@@ -95,26 +95,26 @@ GEM
95
95
  rack (2.0.1)
96
96
  rack-test (0.6.3)
97
97
  rack (>= 1.0)
98
- rails (5.0.0)
99
- actioncable (= 5.0.0)
100
- actionmailer (= 5.0.0)
101
- actionpack (= 5.0.0)
102
- actionview (= 5.0.0)
103
- activejob (= 5.0.0)
104
- activemodel (= 5.0.0)
105
- activerecord (= 5.0.0)
106
- activesupport (= 5.0.0)
98
+ rails (5.0.0.1)
99
+ actioncable (= 5.0.0.1)
100
+ actionmailer (= 5.0.0.1)
101
+ actionpack (= 5.0.0.1)
102
+ actionview (= 5.0.0.1)
103
+ activejob (= 5.0.0.1)
104
+ activemodel (= 5.0.0.1)
105
+ activerecord (= 5.0.0.1)
106
+ activesupport (= 5.0.0.1)
107
107
  bundler (>= 1.3.0, < 2.0)
108
- railties (= 5.0.0)
108
+ railties (= 5.0.0.1)
109
109
  sprockets-rails (>= 2.0.0)
110
110
  rails-dom-testing (2.0.1)
111
111
  activesupport (>= 4.2.0, < 6.0)
112
112
  nokogiri (~> 1.6.0)
113
113
  rails-html-sanitizer (1.0.3)
114
114
  loofah (~> 2.0)
115
- railties (5.0.0)
116
- actionpack (= 5.0.0)
117
- activesupport (= 5.0.0)
115
+ railties (5.0.0.1)
116
+ actionpack (= 5.0.0.1)
117
+ activesupport (= 5.0.0.1)
118
118
  method_source
119
119
  rake (>= 0.8.7)
120
120
  thor (>= 0.18.1, < 2.0)
@@ -122,17 +122,17 @@ GEM
122
122
  smart_excerpt (0.1.5)
123
123
  activesupport
124
124
  htmlentities
125
- sprockets (3.6.3)
125
+ sprockets (3.7.0)
126
126
  concurrent-ruby (~> 1.0)
127
127
  rack (> 1, < 3)
128
128
  sprockets-rails (3.1.1)
129
129
  actionpack (>= 4.0)
130
130
  activesupport (>= 4.0)
131
131
  sprockets (>= 3.0.0)
132
- stringex (2.6.0)
132
+ stringex (2.6.1)
133
133
  thor (0.19.1)
134
134
  thread_safe (0.3.5)
135
- turbolinks (5.0.0)
135
+ turbolinks (5.0.1)
136
136
  turbolinks-source (~> 5)
137
137
  turbolinks-source (5.0.0)
138
138
  tzinfo (1.2.2)
data/lib/rocket_cms.rb CHANGED
@@ -63,6 +63,7 @@ module RocketCMS
63
63
  end
64
64
  end
65
65
 
66
+ autoload :Menu, 'rocket_cms/menu'
66
67
  autoload :Migration, 'rocket_cms/migration'
67
68
  autoload :UrlHelper, 'rocket_cms/url_helper'
68
69
 
@@ -98,4 +99,17 @@ module RocketCMS
98
99
  end
99
100
  end
100
101
 
102
+ require 'rails_admin_nested_set/helper'
103
+
104
+ module RailsAdminNestedSet::Helper
105
+ def extra_fields(node)
106
+ if node.class.name == 'Page'
107
+ ret = RocketCMS::Menu.build_toggles(self, node.class, node, 'xs', '')
108
+ ('<div style="white-space: normal; display: inline-block; margin-left: 10px;">' + ret.join(' ') + '</div>').html_safe
109
+ else
110
+ "".html_safe
111
+ end
112
+ end
113
+ end
114
+
101
115
  require 'manual_slug'
@@ -0,0 +1,56 @@
1
+ module RocketCMS
2
+ module Menu
3
+ class << self
4
+ def get_menus
5
+ Rails.cache.fetch 'menus', expires_in: 10.minutes do
6
+ if RocketCMS.mongoid?
7
+ ::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
8
+ else
9
+ ::Menu.all.map { |m| {id: m.id, name: m.name } }
10
+ end
11
+ end
12
+ end
13
+
14
+ def btn_js
15
+ <<-END.strip_heredoc.gsub("\n", ' ').gsub(/ +/, ' ')
16
+ var $t = $(this);
17
+ $.ajax({
18
+ type: "POST",
19
+ url: $t.attr("href"),
20
+ data: {ajax: true},
21
+ success: function(r) {
22
+ $t.attr("href", r.href);
23
+ $t.removeClass("btn-success btn-danger");
24
+ $t.addClass(r.class);
25
+ },
26
+ error: function(e) {
27
+ alert(e.responseText);
28
+ }
29
+ });
30
+ return false;
31
+ END
32
+ end
33
+
34
+ def build_toggles(view, model, obj, btn_size, btn_style = '')
35
+ ret = []
36
+ get_menus.each do |m|
37
+ if RocketCMS.mongoid?
38
+ on = obj.menu_ids.include?(BSON::ObjectId.from_string(m[:id]))
39
+ else
40
+ on = obj.menu_ids.include?(m[:id].to_i)
41
+ end
42
+ ret << view.link_to(
43
+ m[:name],
44
+ view.toggle_menu_path(model_name: model, id: obj.id, menu: m[:id], on: !on),
45
+ #method: :post,
46
+ title: m[:name],
47
+ class: "btn btn-#{btn_size} #{on ? "btn-success" : "btn-danger"}",
48
+ style: btn_style,
49
+ onclick: btn_js
50
+ )
51
+ end
52
+ ret
53
+ end
54
+ end
55
+ end
56
+ end
@@ -9,30 +9,7 @@ module RailsAdmin
9
9
 
10
10
  register_instance_option :pretty_value do
11
11
  obj = bindings[:object]
12
- ret = []
13
- menus = Rails.cache.fetch 'menus', expires_in: 10.minutes do
14
- if RocketCMS.mongoid?
15
- ::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
16
- else
17
- ::Menu.all.map { |m| {id: m.id, name: m.name } }
18
- end
19
- end
20
- menus.each do |m|
21
- if RocketCMS.mongoid?
22
- on = obj.menu_ids.include?(BSON::ObjectId.from_string(m[:id]))
23
- else
24
- on = obj.menu_ids.include?(m[:id].to_i)
25
- end
26
- ret << bindings[:view].link_to(
27
- m[:name],
28
- bindings[:view].toggle_menu_path(model_name: @abstract_model, id: obj.id, menu: m[:id], on: !on),
29
- #method: :post,
30
- title: m[:name],
31
- class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
32
- style: 'margin-bottom: 5px;',
33
- onclick: 'var $t = $(this); $.ajax({type: "POST", url: $t.attr("href"), data: {ajax:true}, success: function(r) { $t.attr("href", r.href); $t.attr("class", r.class); }, error: function(e) { alert(e.responseText); }}); return false;'
34
- )
35
- end
12
+ ret = RocketCMS::Menu.build_toggles(bindings[:view], @abstract_model, obj, 'sm', 'margin-bottom: 5px;')
36
13
  ('<div style="white-space: normal;">' + ret.join(' ') + '</div>').html_safe
37
14
  end
38
15
 
@@ -78,7 +55,7 @@ module RailsAdmin
78
55
  ajax_link = Proc.new do |am, obj, menu, on|
79
56
  render json: {
80
57
  href: toggle_menu_path(model_name: am, id: obj.id, menu: menu.id, on: !on),
81
- class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
58
+ class: on ? "btn-success" : "btn-danger",
82
59
  }
83
60
  end
84
61
  if params['id'].present?
@@ -1,3 +1,3 @@
1
1
  module RocketCMS
2
- VERSION = "0.13.6"
2
+ VERSION = "0.14.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.6
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -299,6 +299,7 @@ files:
299
299
  - lib/rocket_cms/controllers/pages.rb
300
300
  - lib/rocket_cms/controllers/search.rb
301
301
  - lib/rocket_cms/engine.rb
302
+ - lib/rocket_cms/menu.rb
302
303
  - lib/rocket_cms/migration.rb
303
304
  - lib/rocket_cms/model.rb
304
305
  - lib/rocket_cms/models/active_record/contact_message.rb