Sha256: e1edc1bbbe0d5995965e606971572ab4d6cca631a8281b66ae21625952877c98

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

# Rack::Olark

Middleware which inserts Olark JavaScript embed code before </body> 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](https://github.com/kangguru/rack-google-analytics). Never would've gotten started without them!

## Copyright

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-olark-0.2.1 README.md
rack-olark-0.2.0 README.md