pagelet_rails 0.1.7 → 0.1.8

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: 1a94ff187b504886484c7a6ea7f3e7606ee8a1b4
4
- data.tar.gz: da24f459abc2b52b87bc687332467e5d37383bb3
3
+ metadata.gz: 97462c6b25fab3b82e8fe2bba67bb3016e55d24e
4
+ data.tar.gz: 5ebaa4854e612096b42136b486fc4f7f1cdad17e
5
5
  SHA512:
6
- metadata.gz: 944a95a469bf4d377f17ba270bdd2dcf53034e6218b39415ae5529b60e649b51d8f0d427ef0d52e5e94ad1acd5083d20fc02ab42d14b065415b8d52456955507
7
- data.tar.gz: bfec15b0d980d68efac76521ef017ef82ecd0713babce334f1e8ed5708e5a1e87eda3ff83c57dd72ac73c6579517d6512f701ac5e0623320525825a8d5371cf8
6
+ metadata.gz: a6ac654ef6e579b77207b9d492c030675f35f6f5d2ca2b1767d520b95702a337ae455d07202a14f41749b0ed4451f042edc2572657780accbce91e4778c33f0e
7
+ data.tar.gz: 5cb1c8361d0f6223dde0b989b2dc43923144ac4c2bbd8abe7b1643631d3e144b79f5528b4b9dfae1f30d88242e7208518be42f959f3c0a70e4a0795b780f0055
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.8
2
+
3
+ - Fix executable "rails" conflicts with railties (#11)
4
+ - Added trial feature to trigger updates
5
+
1
6
  ### 0.1.7
2
7
 
3
8
  - fixed Rails 5.1
data/README.md CHANGED
@@ -171,12 +171,17 @@ You can specify html attributes to pagelet with `html` option
171
171
 
172
172
  ### placeholder
173
173
 
174
+ Configuration for placeholder before pagelet is loaded.
175
+
174
176
  ```erb
175
177
  <%= pagelet :pagelets_current_time, placeholder: { text: 'Loading...', height: 300 } %>
176
178
  ```
177
179
 
178
- Configuration for placeholder before pagelet is loaded.
180
+ or use your own placeholder template
179
181
 
182
+ ```erb
183
+ <%= pagelet :pagelets_current_time, placeholder: { view: 'path_to_template' } %>
184
+ ```
180
185
 
181
186
  ### other
182
187
 
@@ -75,7 +75,7 @@
75
75
  };
76
76
 
77
77
  root.loadPagelets = function(selector) {
78
- selector = selector || '[data-widget-url]';
78
+ selector = selector || '[data-pagelet-load]';
79
79
  var groups = {};
80
80
 
81
81
  $(selector).each(function(index, elem) {
@@ -112,14 +112,26 @@
112
112
  }
113
113
  };
114
114
 
115
- root.pageletArrived = function(id, content) {
115
+ root.pageletArrived = function(id, content, tags) {
116
116
  root.placeToContainer(id, content);
117
117
  root.processDataRemoteTags();
118
+ root.tagsChanged(id, tags);
118
119
  $(document).trigger('pagelet-loaded');
119
120
  };
120
121
 
121
122
  root.placeToContainer = function(id, content) {
122
- $('#' + id).html(content);
123
+ $('#' + id).replaceWith(content);
124
+ };
125
+
126
+ root.tagsChanged = function(id, tags) {
127
+ if (tags && tags.length > 0) {
128
+ var selector = $();
129
+ tags.forEach(function(tag) {
130
+ selector = selector.add('[data-pagelet-tags~="' + tag + '"]:not(#' + id + ')');
131
+ });
132
+
133
+ root.loadPagelets(selector);
134
+ }
123
135
  };
124
136
 
125
137
  root.processDataRemoteTags = function() {
@@ -10,7 +10,7 @@ class PageletProxyController < ::ApplicationController
10
10
  response.stream.write "\n"
11
11
 
12
12
  @urls.each do |url|
13
- response.stream.write pagelet(url)
13
+ response.stream.write pagelet(url, skip_parent_params: true)
14
14
  response.stream.write "\n\n//\n\n"
15
15
  end
16
16
  ensure
@@ -10,7 +10,16 @@ module PageletsHelper
10
10
  html_opts[:class] = classes.join(' ')
11
11
 
12
12
  html_opts['data-pagelet-container'] = true
13
- html_opts['data-pagelet-options'] = pagelet_encoded_original_options
13
+ html_opts['data-pagelet-options'] = pagelet_encoded_original_options(
14
+ html: {id: html_opts[:id]}
15
+ )
16
+
17
+ if Rails.env.development?
18
+ html_opts['data-debug'] = PageletRails::Encryptor.decode(html_opts['data-pagelet-options'])
19
+ end
20
+
21
+ html_opts['data-pagelet-tags'] = identified_by.join(' ')
22
+ html_opts['data-widget-url'] = url_for(params.to_unsafe_h)
14
23
 
15
24
  if pagelet_options.ajax_group
16
25
  html_opts['data-pagelet-group'] = pagelet_options.ajax_group
@@ -66,18 +75,20 @@ module PageletsHelper
66
75
  p_options.deep_merge! html: { id: html_id }
67
76
 
68
77
  add_pagelet_stream html_id, &Proc.new {
69
- pagelet path, p_options.merge(remote: false, skip_container: true)
78
+ pagelet path, p_options.merge(remote: false)
70
79
  }
71
80
  end
72
81
 
73
- parent_params =
74
- if params.respond_to?(:to_unsafe_h)
75
- params.to_unsafe_h
76
- else
77
- params.to_h
78
- end
82
+ unless p_options.delete(:skip_parent_params)
83
+ parent_params =
84
+ if params.respond_to?(:to_unsafe_h)
85
+ params.to_unsafe_h
86
+ else
87
+ params.to_h
88
+ end
79
89
 
80
- p_options.deep_merge! parent_params: parent_params
90
+ p_options.deep_merge!(parent_params: parent_params)
91
+ end
81
92
 
82
93
  c = controller_class.new
83
94
  c.pagelet_options p_options
@@ -1,8 +1,3 @@
1
- <% if pagelet_request? || pagelet_options.skip_container %>
1
+ <%= content_tag :div, html_container_attributes do %>
2
2
  <%= content_for?(:content) ? yield(:content) : yield %>
3
-
4
- <% else %>
5
- <%= content_tag :div, html_container_attributes do %>
6
- <%= content_for?(:content) ? yield(:content) : yield %>
7
- <% end %>
8
3
  <% end %>
@@ -8,6 +8,9 @@ module PageletRails::Concerns::Controller
8
8
  include PageletRails::Concerns::Options
9
9
  include PageletRails::Concerns::Cache
10
10
  include PageletRails::Concerns::Placeholder
11
+ include PageletRails::Concerns::Tags
12
+
13
+ include PageletsHelper
11
14
 
12
15
  prepend_before_action :merge_original_pagelet_options
13
16
  prepend_before_action :append_pagelet_view_paths
@@ -52,11 +55,12 @@ module PageletRails::Concerns::Controller
52
55
  if params[:original_pagelet_options]
53
56
  opts = PageletRails::Encryptor.decode(params[:original_pagelet_options])
54
57
  pagelet_options(opts)
58
+ pagelet_options(original_options: opts)
55
59
  end
56
60
  end
57
61
 
58
- def pagelet_encoded_original_options
59
- encode_data = pagelet_options.original_options.to_h.except('remote')
62
+ def pagelet_encoded_original_options new_opts = {}
63
+ encode_data = pagelet_options.original_options.to_h.except('remote').merge(new_opts)
60
64
  PageletRails::Encryptor.encode(encode_data)
61
65
  end
62
66
 
@@ -79,4 +83,10 @@ module PageletRails::Concerns::Controller
79
83
  render_remotely
80
84
  end
81
85
 
86
+ def redirect_to *args
87
+ options = args.extract_options!
88
+ new_params = options.merge(original_pagelet_options: pagelet_encoded_original_options)
89
+
90
+ render plain: pagelet(url_for(*args, new_params))
91
+ end
82
92
  end
@@ -31,7 +31,7 @@ module PageletRails::Concerns::Placeholder
31
31
  render body: "<!--#include virtual=\"#{path}\" -->"
32
32
  else
33
33
  if pagelet_options.remote != :stream
34
- pagelet_options html: { 'data-widget-url' => url_for(data) }
34
+ pagelet_options html: { 'data-pagelet-load' => 'true' }
35
35
  end
36
36
 
37
37
  default_view = '/layouts/pagelet_rails/loading_placeholder'
@@ -21,7 +21,7 @@ module PageletRails::Concerns::ResponseWrapper
21
21
  js = ActionController::Base.helpers.escape_javascript html
22
22
 
23
23
  html = ActionController::Base.helpers.raw(
24
- "PageletRails.pageletArrived('#{id}', '#{js}');"
24
+ "PageletRails.pageletArrived('#{id}', '#{js}', #{trigger_change.to_json.html_safe});"
25
25
  )
26
26
 
27
27
  self.response_body = [html]
@@ -0,0 +1,24 @@
1
+ module PageletRails::Concerns::Tags
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ helper_method :identified_by
6
+ helper_method :trigger_change
7
+ end
8
+
9
+ def trigger_change tag = nil
10
+ @trigger_change ||= []
11
+ if tag.present?
12
+ @trigger_change << tag
13
+ end
14
+ @trigger_change
15
+ end
16
+
17
+ def identified_by tag = nil
18
+ @identified_by ||= []
19
+ if tag.present?
20
+ @identified_by << tag
21
+ end
22
+ @identified_by
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module PageletRails
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
data/lib/pagelet_rails.rb CHANGED
@@ -22,6 +22,7 @@ module PageletRails
22
22
  autoload :Placeholder
23
23
  autoload :ResponseWrapper
24
24
  autoload :Routes
25
+ autoload :Tags
25
26
  end
26
27
  end
27
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagelet_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Katunin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -140,8 +140,7 @@ description: Improve perceived performance of your rails application with minimu
140
140
  effort
141
141
  email:
142
142
  - antulik@gmail.com
143
- executables:
144
- - rails
143
+ executables: []
145
144
  extensions: []
146
145
  extra_rdoc_files: []
147
146
  files:
@@ -166,7 +165,6 @@ files:
166
165
  - app/views/layouts/pagelet_rails/container.erb
167
166
  - app/views/layouts/pagelet_rails/inner.erb
168
167
  - app/views/layouts/pagelet_rails/loading_placeholder.erb
169
- - bin/rails
170
168
  - config/routes.rb
171
169
  - gemfiles/rails_4.2.8.gemfile
172
170
  - gemfiles/rails_5.0.2.gemfile
@@ -180,6 +178,7 @@ files:
180
178
  - lib/pagelet_rails/concerns/placeholder.rb
181
179
  - lib/pagelet_rails/concerns/response_wrapper.rb
182
180
  - lib/pagelet_rails/concerns/routes.rb
181
+ - lib/pagelet_rails/concerns/tags.rb
183
182
  - lib/pagelet_rails/encryptor.rb
184
183
  - lib/pagelet_rails/engine.rb
185
184
  - lib/pagelet_rails/router.rb
data/bin/rails DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
- ENGINE_PATH = File.expand_path('../../lib/pagelet_rails/engine', __FILE__)
7
-
8
- # Set up gems listed in the Gemfile.
9
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
10
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
-
12
- require 'rails/all'
13
- require 'rails/engine/commands'