prerender_rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -3
- data/lib/prerender_rails.rb +3 -3
- data/lib/rack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9131d6f39c2dc688b5255b910007e5a434fe85a5
|
4
|
+
data.tar.gz: fd614761588694380e2abbb6ec3c6a32c64d42f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd0a338c2026fa5c6abd80bc97410619df877ff94b2dc44e283b6f7c6119959aebb9b8dd307deec5f42f9a88d019ca3977c74f748175071ae3a28c771b2a1d15
|
7
|
+
data.tar.gz: 4fd993cf3da044b7a2fa60da6e09be5d83cd51cdcceeb855c3f47edf58564d41d0e7b7e63a6ce58f08c3baa9daca80b84ea53ecf536901e68cbef6370d163d37
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
Prerender Rails
|
2
|
+
===========================
|
2
3
|
|
3
|
-
|
4
|
+
This gem installs middleware that prerenders a javascript-rendered page and sends the HTML to a search engine crawler for SEO. It checks the agent string on the requesting browser for a crawler, and continues on to your normal routes if the requester is not a crawler.
|
5
|
+
|
6
|
+
## How it works
|
7
|
+
* Check to make sure the request is from a crawler and we aren't requesting a resource (js, css, etc...)
|
8
|
+
* Make a `GET` request to the [prerender service](https://github.com/collectiveip/prerender) for the page's prerendered HTML
|
9
|
+
* Return that HTML to the crawler
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
@@ -18,7 +24,15 @@ Or install it yourself as:
|
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
In `config/environment/production.rb`, add this line:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config.middleware.use Rack::Prerender
|
31
|
+
```
|
32
|
+
|
33
|
+
If you've deployed the prerender service on your own, set the `PRERENDER_URL` environment variable so that this gem points there instead. Otherwise, it will default to the service already deployed at `http://prerender.herokuapp.com`
|
34
|
+
|
35
|
+
$ export PRERENDER_URL=<new url>
|
22
36
|
|
23
37
|
## Contributing
|
24
38
|
|
@@ -27,3 +41,27 @@ TODO: Write usage instructions here
|
|
27
41
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
42
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
43
|
5. Create new Pull Request
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The MIT License (MIT)
|
48
|
+
|
49
|
+
Copyright (c) 2013 Todd Hooper <todd@collectiveip.com>
|
50
|
+
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
52
|
+
of this software and associated documentation files (the "Software"), to deal
|
53
|
+
in the Software without restriction, including without limitation the rights
|
54
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
55
|
+
copies of the Software, and to permit persons to whom the Software is
|
56
|
+
furnished to do so, subject to the following conditions:
|
57
|
+
|
58
|
+
The above copyright notice and this permission notice shall be included in
|
59
|
+
all copies or substantial portions of the Software.
|
60
|
+
|
61
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
62
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
63
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
64
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
65
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
66
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
67
|
+
THE SOFTWARE.
|
data/lib/prerender_rails.rb
CHANGED
@@ -26,9 +26,9 @@ module Rack
|
|
26
26
|
request = Rack::Request.new(env)
|
27
27
|
user_agent = env['HTTP_USER_AGENT'].downcase
|
28
28
|
|
29
|
-
should_show_based_on_agent_string = user_agent == 'googlebot'
|
30
|
-
user_agent == 'yahoo'
|
31
|
-
user_agent == 'bingbot'
|
29
|
+
should_show_based_on_agent_string = user_agent == 'googlebot' ||
|
30
|
+
user_agent == 'yahoo' ||
|
31
|
+
user_agent == 'bingbot' ||
|
32
32
|
user_agent == 'baiduspider'
|
33
33
|
|
34
34
|
return false if !should_show_based_on_agent_string #short circuit
|
data/lib/rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prerender_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Hooper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|