pagelet_rails 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.travis.yml +14 -0
- data/Appraisals +14 -0
- data/CHANGELOG.md +35 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -40
- data/app/assets/javascripts/pagelet_rails.js +4 -8
- data/app/controllers/pagelet_controller.rb +0 -1
- data/app/helpers/pagelets_helper.rb +9 -2
- data/bin/rails +13 -0
- data/gemfiles/rails_4.2.8.gemfile +12 -0
- data/gemfiles/rails_5.0.2.gemfile +12 -0
- data/gemfiles/rails_5.1.0.gemfile +12 -0
- data/lib/pagelet_rails/concerns/cache.rb +13 -11
- data/lib/pagelet_rails/concerns/controller.rb +1 -1
- data/lib/pagelet_rails/encryptor.rb +1 -1
- data/lib/pagelet_rails/version.rb +1 -1
- data/pagelet_rails.gemspec +31 -0
- data/test/benchmarks/ssi_benchmark.rb +47 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/dyno_controller.rb +13 -0
- data/test/dummy/app/controllers/pagelet_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/pagelets/params_example/params_example_controller.rb +7 -0
- data/test/dummy/app/pagelets/params_example/views/show.html.erb +3 -0
- data/test/dummy/app/pagelets/render_inline/render_inline_controller.rb +8 -0
- data/test/dummy/app/pagelets/static_text/static_text_controller.rb +12 -0
- data/test/dummy/app/pagelets/static_text/views/show.html.erb +1 -0
- data/test/dummy/app/views/dyno/benchmark.html.erb +4 -0
- data/test/dummy/app/views/dyno/params_example.html.erb +1 -0
- data/test/dummy/app/views/dyno/ssi.html.erb +2 -0
- data/test/dummy/app/views/dyno/static_text.html.erb +1 -0
- data/test/dummy/app/views/dyno/static_text_ajax.html.erb +1 -0
- data/test/dummy/app/views/dyno/test.html.erb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +29 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/schema.rb +15 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/dyno_test.rb +20 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/lib/options_test.rb +62 -0
- data/test/pagelet_rails_test.rb +7 -0
- data/test/test_helper.rb +30 -0
- metadata +252 -5
- data/MIT-LICENSE +0 -20
data/bin/rails
ADDED
@@ -0,0 +1,13 @@
|
|
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'
|
@@ -26,17 +26,19 @@ module PageletRails::Concerns::Cache
|
|
26
26
|
|
27
27
|
cache_path = pagelet_options.cache_path || cache_defaults[:cache_path]
|
28
28
|
|
29
|
-
cache_path =
|
30
|
-
|
31
|
-
|
32
|
-
cache_path.call
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
cache_path =
|
30
|
+
if cache_path.is_a?(Proc)
|
31
|
+
self.instance_exec(self, &cache_path)
|
32
|
+
elsif cache_path.respond_to?(:call)
|
33
|
+
cache_path.call(self)
|
34
|
+
elsif cache_path.is_a?(String)
|
35
|
+
{
|
36
|
+
custom: cache_path
|
37
|
+
}
|
38
|
+
else
|
39
|
+
cache_path
|
40
|
+
end
|
41
|
+
|
40
42
|
cache_path ||= {}
|
41
43
|
cache_path[:controller] = params[:controller]
|
42
44
|
cache_path[:action] = params[:action]
|
@@ -39,7 +39,7 @@ module PageletRails::Concerns::Controller
|
|
39
39
|
# lookup_context.prefixes.clear
|
40
40
|
view = "#{controller_name}/views"
|
41
41
|
if lookup_context.prefixes.exclude?(view)
|
42
|
-
lookup_context.prefixes.unshift
|
42
|
+
lookup_context.prefixes.unshift view
|
43
43
|
end
|
44
44
|
|
45
45
|
# https://github.com/rails/actionpack-action_caching/issues/32
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'pagelet_rails/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'pagelet_rails'
|
7
|
+
s.version = PageletRails::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Anton Katunin']
|
10
|
+
s.email = ['antulik@gmail.com']
|
11
|
+
s.homepage = 'https://github.com/antulik/pagelet_rails'
|
12
|
+
s.summary = 'Improve perceived performance of your rails application with minimum effort'
|
13
|
+
s.description = 'Improve perceived performance of your rails application with minimum effort'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.add_dependency 'rails', '>= 4.0.0'
|
17
|
+
s.add_dependency 'ejs'
|
18
|
+
|
19
|
+
s.add_development_dependency 'sqlite3'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.add_development_dependency 'simplecov'
|
22
|
+
s.add_development_dependency 'appraisal'
|
23
|
+
s.add_development_dependency 'pry-rails'
|
24
|
+
s.add_development_dependency 'binding_of_caller'
|
25
|
+
s.add_development_dependency 'better_errors'
|
26
|
+
|
27
|
+
s.files = `git ls-files`.split("\n")
|
28
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
30
|
+
s.require_paths = ['lib']
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'active_support/all'
|
3
|
+
require 'csv'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
root_url = 'http://local.dev/dyno/benchmark.html'
|
7
|
+
|
8
|
+
delays = [0, 10, 20, 30, 50, 100, 200]
|
9
|
+
sizes = (1..10).to_a
|
10
|
+
modes = ['inline']
|
11
|
+
|
12
|
+
rows = []
|
13
|
+
sizes.map do |size|
|
14
|
+
|
15
|
+
delays.each do |delay|
|
16
|
+
r = []
|
17
|
+
r << size
|
18
|
+
r << delay
|
19
|
+
|
20
|
+
modes.each do |mode|
|
21
|
+
params = {
|
22
|
+
remote: mode,
|
23
|
+
sleep: delay,
|
24
|
+
size: size
|
25
|
+
}
|
26
|
+
url = "#{root_url}?#{params.to_query}"
|
27
|
+
|
28
|
+
args = %W(ab -n 50 -e output.csv -l #{url})
|
29
|
+
# puts args
|
30
|
+
system(*args)
|
31
|
+
|
32
|
+
sleep 1
|
33
|
+
arr_of_arrs = CSV.read("./output.csv")
|
34
|
+
last_row = arr_of_arrs.last(10).first
|
35
|
+
time = last_row.last
|
36
|
+
|
37
|
+
# File.delete('./output.csv')
|
38
|
+
# puts time
|
39
|
+
r << time
|
40
|
+
end
|
41
|
+
|
42
|
+
rows << r.join("\t")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
puts rows
|
data/test/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
// require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<div>Static text</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pagelet :pagelets_params_example, params: {color: 'red'} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pagelet :pagelets_static_text %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pagelet :pagelets_static_text, remote: true %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rake
ADDED