Permalink
Browse files

Cleaning up README

  • Loading branch information...
1 parent c8e6417 commit 86300185f11c621c578b281a7267a81aa56d8ea5 Kali Donovan committed Dec 21, 2013
Showing with 16 additions and 16 deletions.
  1. +14 −14 README.md
  2. +2 −2 lib/rack-referrals.rb
View
28 README.md
@@ -20,12 +20,12 @@ Quick and easy:
gem install rack-referrals
-Example Usage (Rails 3 App)
+Example Usage
-------------------------
Just add it to your middleware stack:
- # Rails 3 App - in config/application.rb
+ # Rails 3+ App - in config/application.rb
class Application < Rails::Application
...
config.middleware.use Rack::Referrals
@@ -41,20 +41,20 @@ Just add it to your middleware stack:
Now you can check any request to see what search engine referred it, and if any did, then what search terms were used.
- class ExampleController < ApplicationController
-
- def index
- str = if request.env['referring.search_engine']
- "You're from #{request.env['referring.search_engine']}, " \
- "where you searched: #{request.env['referring.search_terms']}"
- else
- "You're from somewhere boring."
- end
+ class ExampleController < ApplicationController
+
+ def index
+ str = if request.env['referring.search_engine']
+ "You're from #{request.env['referring.search_engine']}, " \
+ "where you searched: #{request.env['referring.search_terms']}"
+ else
+ "You're from somewhere boring."
+ end
- render :text => str
- end
+ render :text => str
+ end
- end
+ end
Gettin' Fancy
-------------
View
4 lib/rack-referrals.rb
@@ -28,7 +28,7 @@ class Referrals
:alltheweb => [/^https?:\/\/(www\.)?alltheweb.*/, 'q']
# Want to add support for more? A good place to start would be this list (note that they
- # give example domains, though, not anything we can use to construct a reliable reg exp):
+ # give example domains, though, not anything we can use to construct a reliable regex):
# http://code.google.com/apis/analytics/docs/tracking/gaTrackingTraffic.html#searchEngine
}
@@ -41,7 +41,7 @@ def initialize(app, opts = {})
def call(env)
request = Rack::Request.new(env)
- from = request.env["HTTP_REFERER"]
+ from = request.env["HTTP_REFERER"]
if from.to_s.length > 0
if engine = @engines.detect {|name, data| from =~ data[0] }

0 comments on commit 8630018

Please sign in to comment.