progressive_render 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b67772885c5165b7865be20cd468a5bedeafab7
4
+ data.tar.gz: 4384f6793c5575487e3a5f3ae4df14a22671bdb3
5
+ SHA512:
6
+ metadata.gz: 29360ee21b141fbba94f6b34cb1812e976591c7b21c11a073de6cb1d5560685b21b59e1bfaa19accf7a09fdd64eaf785ea69fd613c2b2a1a41e3c31ce00ba6c2
7
+ data.tar.gz: a70b560a4042972046118f92d68b275979ebda77073a295313a4b7c1a5cb205c0d6adfd22739158452540a830801ed931d12c1a3bf79261b790bcaa332bb303e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.2.3
5
+ - ruby-head
6
+
7
+ before_install: gem install bundler -v 1.10.3
8
+
9
+ gemfile:
10
+ - gemfiles/rails_4_2.gemfile
11
+ - gemfiles/rails_4_1.gemfile
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
data/Appraisals ADDED
@@ -0,0 +1,9 @@
1
+ appraise "rails-4-2" do
2
+ gem "rails", "4.2.4"
3
+ gem "nokogiri"
4
+ end
5
+
6
+ appraise "rails-4-1" do
7
+ gem "rails", "4.1.13"
8
+ gem "nokogiri"
9
+ end
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/DESIGN.md ADDED
@@ -0,0 +1,109 @@
1
+ # PathResolver (Rails Specific) #
2
+ Status: Implemented
3
+
4
+ Resolves the full path for views/partials. Might want to give it a RequestHandler.
5
+
6
+ ## Basic Syntax ##
7
+ ```ruby
8
+ dtp = PathResolver.new(template_context)
9
+ dtp.path_for('')
10
+ ```
11
+
12
+ ## TemplateContext ##
13
+ controller:string
14
+ action:string
15
+ type: :view, :controller
16
+
17
+ ## Examples ##
18
+ For the Foo controller inside of the view
19
+ ```ruby
20
+ dtp = PathResolver.new(controller: Foo, action: :index, type: :view)
21
+ dtp.path_for('table') == foo/_table
22
+ dtp.path_for('shared/dialogs/bar') == shared/dialogs/bar (Or should it also search foo/shared/..?)
23
+ dtp.path_for('') == InvalidPath_forException
24
+ ```
25
+
26
+ For the Foo controler inside of the controller
27
+ ```ruby
28
+ dtp = PathResolver.new(controller: Foo, action: :index, type: :controller)
29
+ dtp.path_for('') == foo/index
30
+ dtp.path_for('bar') == foo/bar
31
+ ```
32
+
33
+ # ViewRenderer (Rails Specific) #
34
+ Status: TODO
35
+
36
+ Renders a partial to a string? Maybe. Controller vs. View may need seperate view renderers because controller needs to output the stream. Is there a difference between ActionController.render and ActionView.render?
37
+
38
+ ## Basic Syntax ##
39
+ ```ruby
40
+ rt = ViewRenderer.new
41
+ rt.render(full_path) # normal render
42
+ rt.render_text(content) # render plain text (or safe HTML)
43
+ rt.render_inline(content) # is this needed?
44
+ ```
45
+
46
+ # RequestHandler (Rack Specific) #
47
+ Status: Implemented
48
+
49
+ Parses the request object to determine if this is the main load of the app and if not, what partial view is being requested
50
+
51
+ ## Basic Syntax ##
52
+ ```ruby
53
+ rh = RequestHandler.new(request)
54
+ rh.is_main_load?
55
+ rh.fragment_name
56
+ rh.load_path(fragment_name)
57
+ rh.should_render_partial?(fragment_name)
58
+ ```
59
+
60
+ # RailsBuilder #
61
+ Status: TODO
62
+
63
+ Takes all necessary context and gives access to the ProgressiveRenderer
64
+
65
+ ## Basic Syntax ##
66
+ ```ruby
67
+ rb = RailsBuilder.new(request)
68
+ rb.view_renderer => ProgressiveRenderer
69
+ rb.controller_renderer => ProgressiveRenderer
70
+ ```
71
+
72
+ # ProgresiveRenderer #
73
+ Status: TODO. Currently handled by ProgressiveRender::Controller/View/Helpers
74
+
75
+ Applies all policies to provide a simple render interface.
76
+
77
+ Can we get around the partial_renderer field? It determines if it should render placeholders in place of the view passed into it.
78
+
79
+ ## Basic Syntax ##
80
+ ```ruby
81
+ pr = ProgressiveRenderer.new(request_handler, view_renderer, path_resolver, partial_renderer:bool)
82
+ pr.render(partial_name, &block=nil)
83
+ ```
84
+
85
+ # RailsInstaller #
86
+ Status: TODO. Currently handled by ProgressiveRender
87
+
88
+ Installs the view/controller renderer into ActionView/ActionController
89
+
90
+ ## Basic Syntax ##
91
+ ```ruby
92
+ RailsInstaller.mount_initializer
93
+ # Or?
94
+ RailsInstaller.mount_initializer(app)
95
+ ```
96
+
97
+
98
+ # Structure #
99
+ lib/
100
+ progressive_render.rb (version)
101
+ rails/
102
+ rails.rb
103
+ installer.rb
104
+ builder.rb
105
+ view_renderer.rb
106
+ path_resolver.rb
107
+ rack/
108
+ request_handler.rb
109
+ progressive_renderer.rb
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in progressive_render.gemspec
4
+ gem 'appraisal'
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jeff Johnson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # ProgressiveRender
2
+
3
+ ![ProgressiveRender Demo](http://g.recordit.co/s4EYYte2sC.gif)
4
+
5
+ Slow content got you down? Load it later! Use this gem to defer loading of specific page sections till after page load. They will be fetched via AJAX and placed on the page when ready.
6
+
7
+ ## State of Project
8
+ [![Build Status](https://travis-ci.org/johnsonj/progressive_load.svg?branch=master)](https://travis-ci.org/johnsonj/progressive_load) [![Code Climate](https://codeclimate.com/github/johnsonj/progressive_load/badges/gpa.svg)](https://codeclimate.com/github/johnsonj/progressive_load) [![Test Coverage](https://codeclimate.com/github/johnsonj/progressive_load/badges/coverage.svg)](https://codeclimate.com/github/johnsonj/progressive_load/coverage)
9
+
10
+ This gem is tracking a 1.0.0 release but should not be considered stable until then. [See open issues](https://github.com/johnsonj/progressive_render/milestones/1.0.0).
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile and run bundle
15
+
16
+ ```ruby
17
+ gem 'progressive_render', github: 'johnsonj/progressive_render'
18
+ ```
19
+
20
+ Then add the following to your application.js:
21
+
22
+ ```javascript
23
+ //=progressive_render
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Wrap slow content in your view with a call to `progressive_render 'friendly_name'` where `friendly_name` is an identifier unique to that view:
29
+
30
+ ```erb
31
+ <%=progressive_render 'my_slow_block' do %>
32
+ <h1>Content!</h1>
33
+ <% sleep 5 >
34
+ <% end %>
35
+ ```
36
+
37
+ In the controller action, end it with:
38
+
39
+ ```ruby
40
+ def action
41
+ # your code here
42
+ progressive_render
43
+ end
44
+ ```
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. There is a dummy application located in spec/dummy/ that demonstrates a sample integration and can be used for interactive testing.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/johnsonj/progressive_render. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ <div style="display:table-cell;vertical-align:middle;">
2
+ <div style="margin-left:auto;margin-right:auto; text-align:center">
3
+ <div id="progressive-render-placeholder">
4
+ <%= image_tag "progressive_render.gif" %>
5
+ </div>
6
+ </div>
7
+ </div>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "progressive_render"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "4.1.13"
7
+ gem "nokogiri"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ progressive_render (0.1.1)
5
+ coffee-rails
6
+ jquery-rails
7
+ nokogiri
8
+ rails (>= 4.1)
9
+ railties
10
+ sass-rails
11
+ uglifier
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ actionmailer (4.1.13)
17
+ actionpack (= 4.1.13)
18
+ actionview (= 4.1.13)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ actionpack (4.1.13)
21
+ actionview (= 4.1.13)
22
+ activesupport (= 4.1.13)
23
+ rack (~> 1.5.2)
24
+ rack-test (~> 0.6.2)
25
+ actionview (4.1.13)
26
+ activesupport (= 4.1.13)
27
+ builder (~> 3.1)
28
+ erubis (~> 2.7.0)
29
+ activemodel (4.1.13)
30
+ activesupport (= 4.1.13)
31
+ builder (~> 3.1)
32
+ activerecord (4.1.13)
33
+ activemodel (= 4.1.13)
34
+ activesupport (= 4.1.13)
35
+ arel (~> 5.0.0)
36
+ activesupport (4.1.13)
37
+ i18n (~> 0.6, >= 0.6.9)
38
+ json (~> 1.7, >= 1.7.7)
39
+ minitest (~> 5.1)
40
+ thread_safe (~> 0.1)
41
+ tzinfo (~> 1.1)
42
+ appraisal (2.1.0)
43
+ bundler
44
+ rake
45
+ thor (>= 0.14.0)
46
+ arel (5.0.1.20140414130214)
47
+ builder (3.2.2)
48
+ byebug (5.0.0)
49
+ columnize (= 0.9.0)
50
+ codeclimate-test-reporter (0.4.8)
51
+ simplecov (>= 0.7.1, < 1.0.0)
52
+ coderay (1.1.0)
53
+ coffee-rails (4.1.0)
54
+ coffee-script (>= 2.2.0)
55
+ railties (>= 4.0.0, < 5.0)
56
+ coffee-script (2.4.1)
57
+ coffee-script-source
58
+ execjs
59
+ coffee-script-source (1.9.1.1)
60
+ columnize (0.9.0)
61
+ diff-lcs (1.2.5)
62
+ docile (1.1.5)
63
+ erubis (2.7.0)
64
+ execjs (2.6.0)
65
+ i18n (0.7.0)
66
+ jquery-rails (3.1.4)
67
+ railties (>= 3.0, < 5.0)
68
+ thor (>= 0.14, < 2.0)
69
+ json (1.8.3)
70
+ mail (2.6.3)
71
+ mime-types (>= 1.16, < 3)
72
+ method_source (0.8.2)
73
+ mime-types (2.6.1)
74
+ mini_portile (0.6.2)
75
+ minitest (5.8.0)
76
+ nokogiri (1.6.6.2)
77
+ mini_portile (~> 0.6.0)
78
+ pry (0.10.1)
79
+ coderay (~> 1.1.0)
80
+ method_source (~> 0.8.1)
81
+ slop (~> 3.4)
82
+ pry-byebug (3.2.0)
83
+ byebug (~> 5.0)
84
+ pry (~> 0.10)
85
+ rack (1.5.5)
86
+ rack-test (0.6.3)
87
+ rack (>= 1.0)
88
+ rails (4.1.13)
89
+ actionmailer (= 4.1.13)
90
+ actionpack (= 4.1.13)
91
+ actionview (= 4.1.13)
92
+ activemodel (= 4.1.13)
93
+ activerecord (= 4.1.13)
94
+ activesupport (= 4.1.13)
95
+ bundler (>= 1.3.0, < 2.0)
96
+ railties (= 4.1.13)
97
+ sprockets-rails (~> 2.0)
98
+ railties (4.1.13)
99
+ actionpack (= 4.1.13)
100
+ activesupport (= 4.1.13)
101
+ rake (>= 0.8.7)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rake (10.4.2)
104
+ rspec (3.3.0)
105
+ rspec-core (~> 3.3.0)
106
+ rspec-expectations (~> 3.3.0)
107
+ rspec-mocks (~> 3.3.0)
108
+ rspec-core (3.3.2)
109
+ rspec-support (~> 3.3.0)
110
+ rspec-expectations (3.3.1)
111
+ diff-lcs (>= 1.2.0, < 2.0)
112
+ rspec-support (~> 3.3.0)
113
+ rspec-mocks (3.3.2)
114
+ diff-lcs (>= 1.2.0, < 2.0)
115
+ rspec-support (~> 3.3.0)
116
+ rspec-rails (3.3.3)
117
+ actionpack (>= 3.0, < 4.3)
118
+ activesupport (>= 3.0, < 4.3)
119
+ railties (>= 3.0, < 4.3)
120
+ rspec-core (~> 3.3.0)
121
+ rspec-expectations (~> 3.3.0)
122
+ rspec-mocks (~> 3.3.0)
123
+ rspec-support (~> 3.3.0)
124
+ rspec-support (3.3.0)
125
+ sass (3.4.18)
126
+ sass-rails (5.0.3)
127
+ railties (>= 4.0.0, < 5.0)
128
+ sass (~> 3.1)
129
+ sprockets (>= 2.8, < 4.0)
130
+ sprockets-rails (>= 2.0, < 4.0)
131
+ tilt (~> 1.1)
132
+ simplecov (0.10.0)
133
+ docile (~> 1.1.0)
134
+ json (~> 1.8)
135
+ simplecov-html (~> 0.10.0)
136
+ simplecov-html (0.10.0)
137
+ slop (3.6.0)
138
+ sprockets (3.3.4)
139
+ rack (~> 1.0)
140
+ sprockets-rails (2.3.2)
141
+ actionpack (>= 3.0)
142
+ activesupport (>= 3.0)
143
+ sprockets (>= 2.8, < 4.0)
144
+ sqlite3 (1.3.10)
145
+ thor (0.19.1)
146
+ thread_safe (0.3.5)
147
+ tilt (1.4.1)
148
+ tzinfo (1.2.2)
149
+ thread_safe (~> 0.1)
150
+ uglifier (2.7.2)
151
+ execjs (>= 0.3.0)
152
+ json (>= 1.8.0)
153
+
154
+ PLATFORMS
155
+ ruby
156
+
157
+ DEPENDENCIES
158
+ appraisal
159
+ bundler (~> 1.10)
160
+ codeclimate-test-reporter
161
+ nokogiri
162
+ progressive_render!
163
+ pry-byebug
164
+ rails (= 4.1.13)
165
+ rake (~> 10.0)
166
+ rspec
167
+ rspec-rails
168
+ sqlite3
169
+
170
+ BUNDLED WITH
171
+ 1.10.3
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "4.2.4"
7
+ gem "nokogiri"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,194 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ progressive_render (0.1.1)
5
+ coffee-rails
6
+ jquery-rails
7
+ nokogiri
8
+ rails (>= 4.1)
9
+ railties
10
+ sass-rails
11
+ uglifier
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ actionmailer (4.2.4)
17
+ actionpack (= 4.2.4)
18
+ actionview (= 4.2.4)
19
+ activejob (= 4.2.4)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ actionpack (4.2.4)
23
+ actionview (= 4.2.4)
24
+ activesupport (= 4.2.4)
25
+ rack (~> 1.6)
26
+ rack-test (~> 0.6.2)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (4.2.4)
30
+ activesupport (= 4.2.4)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
35
+ activejob (4.2.4)
36
+ activesupport (= 4.2.4)
37
+ globalid (>= 0.3.0)
38
+ activemodel (4.2.4)
39
+ activesupport (= 4.2.4)
40
+ builder (~> 3.1)
41
+ activerecord (4.2.4)
42
+ activemodel (= 4.2.4)
43
+ activesupport (= 4.2.4)
44
+ arel (~> 6.0)
45
+ activesupport (4.2.4)
46
+ i18n (~> 0.7)
47
+ json (~> 1.7, >= 1.7.7)
48
+ minitest (~> 5.1)
49
+ thread_safe (~> 0.3, >= 0.3.4)
50
+ tzinfo (~> 1.1)
51
+ appraisal (2.1.0)
52
+ bundler
53
+ rake
54
+ thor (>= 0.14.0)
55
+ arel (6.0.3)
56
+ builder (3.2.2)
57
+ byebug (5.0.0)
58
+ columnize (= 0.9.0)
59
+ codeclimate-test-reporter (0.4.8)
60
+ simplecov (>= 0.7.1, < 1.0.0)
61
+ coderay (1.1.0)
62
+ coffee-rails (4.1.0)
63
+ coffee-script (>= 2.2.0)
64
+ railties (>= 4.0.0, < 5.0)
65
+ coffee-script (2.4.1)
66
+ coffee-script-source
67
+ execjs
68
+ coffee-script-source (1.9.1.1)
69
+ columnize (0.9.0)
70
+ diff-lcs (1.2.5)
71
+ docile (1.1.5)
72
+ erubis (2.7.0)
73
+ execjs (2.6.0)
74
+ globalid (0.3.6)
75
+ activesupport (>= 4.1.0)
76
+ i18n (0.7.0)
77
+ jquery-rails (4.0.5)
78
+ rails-dom-testing (~> 1.0)
79
+ railties (>= 4.2.0)
80
+ thor (>= 0.14, < 2.0)
81
+ json (1.8.3)
82
+ loofah (2.0.3)
83
+ nokogiri (>= 1.5.9)
84
+ mail (2.6.3)
85
+ mime-types (>= 1.16, < 3)
86
+ method_source (0.8.2)
87
+ mime-types (2.6.1)
88
+ mini_portile (0.6.2)
89
+ minitest (5.8.0)
90
+ nokogiri (1.6.6.2)
91
+ mini_portile (~> 0.6.0)
92
+ pry (0.10.1)
93
+ coderay (~> 1.1.0)
94
+ method_source (~> 0.8.1)
95
+ slop (~> 3.4)
96
+ pry-byebug (3.2.0)
97
+ byebug (~> 5.0)
98
+ pry (~> 0.10)
99
+ rack (1.6.4)
100
+ rack-test (0.6.3)
101
+ rack (>= 1.0)
102
+ rails (4.2.4)
103
+ actionmailer (= 4.2.4)
104
+ actionpack (= 4.2.4)
105
+ actionview (= 4.2.4)
106
+ activejob (= 4.2.4)
107
+ activemodel (= 4.2.4)
108
+ activerecord (= 4.2.4)
109
+ activesupport (= 4.2.4)
110
+ bundler (>= 1.3.0, < 2.0)
111
+ railties (= 4.2.4)
112
+ sprockets-rails
113
+ rails-deprecated_sanitizer (1.0.3)
114
+ activesupport (>= 4.2.0.alpha)
115
+ rails-dom-testing (1.0.7)
116
+ activesupport (>= 4.2.0.beta, < 5.0)
117
+ nokogiri (~> 1.6.0)
118
+ rails-deprecated_sanitizer (>= 1.0.1)
119
+ rails-html-sanitizer (1.0.2)
120
+ loofah (~> 2.0)
121
+ railties (4.2.4)
122
+ actionpack (= 4.2.4)
123
+ activesupport (= 4.2.4)
124
+ rake (>= 0.8.7)
125
+ thor (>= 0.18.1, < 2.0)
126
+ rake (10.4.2)
127
+ rspec (3.3.0)
128
+ rspec-core (~> 3.3.0)
129
+ rspec-expectations (~> 3.3.0)
130
+ rspec-mocks (~> 3.3.0)
131
+ rspec-core (3.3.2)
132
+ rspec-support (~> 3.3.0)
133
+ rspec-expectations (3.3.1)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.3.0)
136
+ rspec-mocks (3.3.2)
137
+ diff-lcs (>= 1.2.0, < 2.0)
138
+ rspec-support (~> 3.3.0)
139
+ rspec-rails (3.3.3)
140
+ actionpack (>= 3.0, < 4.3)
141
+ activesupport (>= 3.0, < 4.3)
142
+ railties (>= 3.0, < 4.3)
143
+ rspec-core (~> 3.3.0)
144
+ rspec-expectations (~> 3.3.0)
145
+ rspec-mocks (~> 3.3.0)
146
+ rspec-support (~> 3.3.0)
147
+ rspec-support (3.3.0)
148
+ sass (3.4.18)
149
+ sass-rails (5.0.3)
150
+ railties (>= 4.0.0, < 5.0)
151
+ sass (~> 3.1)
152
+ sprockets (>= 2.8, < 4.0)
153
+ sprockets-rails (>= 2.0, < 4.0)
154
+ tilt (~> 1.1)
155
+ simplecov (0.10.0)
156
+ docile (~> 1.1.0)
157
+ json (~> 1.8)
158
+ simplecov-html (~> 0.10.0)
159
+ simplecov-html (0.10.0)
160
+ slop (3.6.0)
161
+ sprockets (3.3.4)
162
+ rack (~> 1.0)
163
+ sprockets-rails (2.3.2)
164
+ actionpack (>= 3.0)
165
+ activesupport (>= 3.0)
166
+ sprockets (>= 2.8, < 4.0)
167
+ sqlite3 (1.3.10)
168
+ thor (0.19.1)
169
+ thread_safe (0.3.5)
170
+ tilt (1.4.1)
171
+ tzinfo (1.2.2)
172
+ thread_safe (~> 0.1)
173
+ uglifier (2.7.2)
174
+ execjs (>= 0.3.0)
175
+ json (>= 1.8.0)
176
+
177
+ PLATFORMS
178
+ ruby
179
+
180
+ DEPENDENCIES
181
+ appraisal
182
+ bundler (~> 1.10)
183
+ codeclimate-test-reporter
184
+ nokogiri
185
+ progressive_render!
186
+ pry-byebug
187
+ rails (= 4.2.4)
188
+ rake (~> 10.0)
189
+ rspec
190
+ rspec-rails
191
+ sqlite3
192
+
193
+ BUNDLED WITH
194
+ 1.10.3
@@ -0,0 +1,26 @@
1
+ require 'progressive_render/helpers'
2
+
3
+ module ProgressiveRender
4
+ module Controller
5
+ include Helpers
6
+
7
+ def progressive_render(template=nil)
8
+ rh = ProgressiveRender::Rack::RequestHandler.new(request)
9
+
10
+ tc = ProgressiveRender::Rails::PathResolver::TemplateContext.new
11
+
12
+ tc.type = :controller
13
+ tc.controller = request.params["controller"]
14
+ tc.action = request.params["action"]
15
+ pr = ProgressiveRender::Rails::PathResolver.new(tc)
16
+
17
+ if rh.is_main_load?
18
+ render pr.path_for(template)
19
+ else
20
+ content = render_to_string template: pr.path_for(template), layout: false
21
+ stripped = Nokogiri::HTML(content).at_css("div##{rh.fragment_name}_progressive_render")
22
+ render text: stripped
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ module ProgressiveRender
2
+ module Helpers
3
+ def progressive_render_content(name, placeholder=true)
4
+ content_tag(:div, id: "#{name}_progressive_render", data: {progressive_render_placeholder: placeholder, progressive_render_path: progressive_render_path(request, name)}) do
5
+ yield
6
+ end
7
+ end
8
+
9
+ def progressive_render_path(req, fragment_name)
10
+ rh = ProgressiveRender::Rack::RequestHandler.new(req)
11
+ rh.load_path(fragment_name)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ require 'uri'
2
+
3
+ module ProgressiveRender
4
+ module Rack
5
+ class RequestHandler
6
+ FRAGMENT_KEY = "load_partial"
7
+
8
+ def initialize(_request)
9
+ @request = _request
10
+ end
11
+
12
+ def is_main_load?
13
+ fragment_name == nil || fragment_name == ""
14
+ end
15
+
16
+ def fragment_name
17
+ @request.GET[FRAGMENT_KEY]
18
+ end
19
+
20
+ def should_render_fragment?(_fragment_name)
21
+ !is_main_load? && fragment_name == _fragment_name
22
+ end
23
+
24
+ def load_path(fragment_name)
25
+ return nil if !is_main_load?
26
+
27
+ # Ensure we get a fresh copy of the request and aren't modifying it
28
+ query = @request.GET.clone
29
+ query[FRAGMENT_KEY] = fragment_name
30
+
31
+ URI::HTTP.build(path: @request.path, query: URI.encode_www_form(query)).request_uri
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,6 @@
1
+ require 'progressive_render/rack/request_handler'
2
+
3
+ module ProgressiveRender
4
+ module Rack
5
+ end
6
+ end
@@ -0,0 +1,44 @@
1
+ module ProgressiveRender
2
+ module Rails
3
+ class PathResolver
4
+ class TemplateContext
5
+ attr_accessor :controller, :action, :type
6
+
7
+ def valid?
8
+ return false if type != :view && type != :controller
9
+ return false if controller.nil? or controller.empty?
10
+ return false if action.nil? or action.empty?
11
+ true
12
+ end
13
+ end
14
+
15
+ class InvalidTemplateContextException < Exception
16
+ end
17
+
18
+ class InvalidPathException < Exception
19
+ end
20
+
21
+ def initialize(_template_context)
22
+ @context = _template_context
23
+ end
24
+
25
+ def path_for(view_name=nil)
26
+ raise InvalidTemplateContextException.new unless @context && @context.valid?
27
+ raise InvalidPathException.new if (view_name.nil? or view_name.empty?) and view_action?
28
+
29
+ path = "#{@context.controller.downcase}/"
30
+
31
+ if view_name == nil || view_name.empty?
32
+ path += "#{@context.action}"
33
+ else
34
+ path += "#{view_name}"
35
+ end
36
+ end
37
+
38
+ private
39
+ def view_action?
40
+ @context.type == :view
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,6 @@
1
+ require 'progressive_render/rails/path_resolver'
2
+
3
+ module ProgressiveRender
4
+ module Rails
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module ProgressiveRender
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,22 @@
1
+ require 'progressive_render'
2
+
3
+ module ProgressiveRender
4
+ module View
5
+ include Helpers
6
+
7
+ def progressive_render(fragment_name, &content)
8
+ rh = ProgressiveRender::Rack::RequestHandler.new(request)
9
+
10
+ progressive_render_content(fragment_name, rh.is_main_load?) do
11
+ if rh.is_main_load?
12
+ render partial: 'progressive_render/placeholder'
13
+ elsif rh.should_render_fragment?(fragment_name)
14
+ content.call
15
+ else
16
+ # Another progressive partial on this page but not the one we've been asked to render
17
+ render text: ""
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ require 'progressive_render/version'
2
+ require 'progressive_render/controller'
3
+ require 'progressive_render/view'
4
+
5
+ require 'progressive_render/rack'
6
+ require 'progressive_render/rails'
7
+
8
+ module ProgressiveRender
9
+ if defined?(::Rails) and Gem::Requirement.new('>= 3.1').satisfied_by?(Gem::Version.new ::Rails.version)
10
+ module Rails
11
+ class Engine < ::Rails::Engine
12
+ initializer "progressive_render.assets.precompile" do |app|
13
+ app.config.assets.precompile += %w( progressive_render.gif progressive_render.js.coffee progressive_render.css.scss )
14
+ end
15
+
16
+ initializer "progressive_render.install" do
17
+ ActionController::Base.class_eval do
18
+ include ProgressiveRender::Controller
19
+ end
20
+
21
+ ActionView::Base.class_eval do
22
+ include ProgressiveRender::View
23
+ end
24
+ end
25
+ end
26
+ end
27
+ else
28
+ puts "WARNING: ProgressiveRender has not been installed due to missing dependencies"
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'progressive_render/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "progressive_render"
8
+ spec.version = ProgressiveRender::VERSION
9
+ spec.authors = ["Jeff Johnson"]
10
+ spec.email = ["johnsonjeff@gmail.com"]
11
+
12
+ spec.summary = %q{Progressively load static or dynamic content on page load}
13
+ spec.description = %q{For large or expensive pages, use this gem to load less critical portions of the page. Especially useful for large queries or content that's hidden from the user on load. The best solution may be to optimize your content, but there's not always time for that.}
14
+ spec.homepage = "https://github.com/johnsonj/progressive_render"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "codeclimate-test-reporter"
26
+ spec.add_development_dependency "rspec-rails"
27
+ spec.add_development_dependency "sqlite3"
28
+ spec.add_development_dependency "pry-byebug"
29
+
30
+ spec.add_dependency "sass-rails"
31
+ spec.add_dependency "uglifier"
32
+ spec.add_dependency "coffee-rails"
33
+ spec.add_dependency "railties"
34
+ spec.add_dependency "jquery-rails"
35
+ spec.add_dependency "rails", ">= 4.1"
36
+ spec.add_dependency "nokogiri"
37
+ end
@@ -0,0 +1,20 @@
1
+ # TODO: API for load missing content or binding to page events
2
+ $ ->
3
+ setup_listener()
4
+ load_missing_content()
5
+
6
+ setup_listener = ->
7
+ $(document).on 'progressive_render:end', load_missing_content
8
+ $(document).on 'ajax:end', load_missing_content
9
+
10
+ load_missing_content = ->
11
+ $('[data-progressive-render-placeholder=true]').each ->
12
+ $this = $(this)
13
+ # Don't re-process div's we've already seen
14
+ return if $this.data('progressive-render-setup')
15
+ $this.data('progressive-render-setup', true)
16
+
17
+ # Start the load
18
+ $.ajax url: $this.data('progressive-render-path'), cache: false, success: (response) ->
19
+ $this.html(response);
20
+ $(document).trigger('progressive_render:end')
@@ -0,0 +1,5 @@
1
+ #progressive-render-placeholder {
2
+ height: 40px;
3
+ width: 40px;
4
+ background-image: asset-data-url('progressive_render.gif');
5
+ }
metadata ADDED
@@ -0,0 +1,273 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: progressive_render
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Johnson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sass-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: uglifier
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: coffee-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: railties
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: jquery-rails
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rails
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '4.1'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '4.1'
195
+ - !ruby/object:Gem::Dependency
196
+ name: nokogiri
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: For large or expensive pages, use this gem to load less critical portions
210
+ of the page. Especially useful for large queries or content that's hidden from the
211
+ user on load. The best solution may be to optimize your content, but there's not
212
+ always time for that.
213
+ email:
214
+ - johnsonjeff@gmail.com
215
+ executables: []
216
+ extensions: []
217
+ extra_rdoc_files: []
218
+ files:
219
+ - ".gitignore"
220
+ - ".rspec"
221
+ - ".travis.yml"
222
+ - Appraisals
223
+ - CODE_OF_CONDUCT.md
224
+ - DESIGN.md
225
+ - Gemfile
226
+ - LICENSE.txt
227
+ - README.md
228
+ - Rakefile
229
+ - app/views/progressive_render/_placeholder.html.erb
230
+ - bin/console
231
+ - bin/setup
232
+ - gemfiles/rails_4_1.gemfile
233
+ - gemfiles/rails_4_1.gemfile.lock
234
+ - gemfiles/rails_4_2.gemfile
235
+ - gemfiles/rails_4_2.gemfile.lock
236
+ - lib/progressive_render.rb
237
+ - lib/progressive_render/controller.rb
238
+ - lib/progressive_render/helpers.rb
239
+ - lib/progressive_render/rack.rb
240
+ - lib/progressive_render/rack/request_handler.rb
241
+ - lib/progressive_render/rails.rb
242
+ - lib/progressive_render/rails/path_resolver.rb
243
+ - lib/progressive_render/version.rb
244
+ - lib/progressive_render/view.rb
245
+ - progressive_load.gemspec
246
+ - vendor/assets/images/progressive_render.gif
247
+ - vendor/assets/javascripts/progressive_render.js.coffee
248
+ - vendor/assets/stylesheets/progressive_render.css.scss
249
+ homepage: https://github.com/johnsonj/progressive_render
250
+ licenses:
251
+ - MIT
252
+ metadata: {}
253
+ post_install_message:
254
+ rdoc_options: []
255
+ require_paths:
256
+ - lib
257
+ required_ruby_version: !ruby/object:Gem::Requirement
258
+ requirements:
259
+ - - ">="
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: '0'
267
+ requirements: []
268
+ rubyforge_project:
269
+ rubygems_version: 2.4.6
270
+ signing_key:
271
+ specification_version: 4
272
+ summary: Progressively load static or dynamic content on page load
273
+ test_files: []