Project

rack-olark

0.0
No commit activity in last 3 years
No release in over 3 years
Middleware which inserts Olark JavaScript embed code before </body> in HTML served by Rack.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 1.2.0
 Project Readme

Rack::Olark

Middleware which inserts Olark JavaScript embed code before in HTML served by Rack.

Usage

In config.ru, or wherever else you mount middleware:

use Rack::Olark, id: '1234-567-89-0123'

All non-special options given to Rack::Olark are passed through as JavaScript in the following manner:

olark.configure('key', value);

There are two special options: id and paths.

id is your Olark Site-ID, and the middleware won't allow your app to boot without it.

paths decides which of your routes will display the Olark chat box. It accepts an array of routes, with the leading slash (/) included. paths defaults to empty array ([]), causing Olark to be embedded for every route. As of version 0.0.4, routes in paths can also be described with a Regexp. Non-Regexp paths entries will be handled using:

/^#{Regexp.escape('/my/path')}$/

Example of usage with options:

use Rack::Olark, {
  :id                          => '1234-567-89-0123',
  :paths                       => ['/', '/aboutus'],
  'features.attention_grabber' => true,
}

Note that in order to use custom Olark JavaScript options, you may have to revert to hashrocket syntax, as they tend to contain characters Ruby doesn't like in symbols.

Acknowledgements

Originally based on code from rack-google-analytics. Never would've gotten started without them!

Copyright

Copyright (C) 2011 Dan Poggi. MIT License, see LICENSE for details.