Giter Site home page Giter Site logo

rack-olark's Introduction

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.

rack-olark's People

Contributors

dpoggi avatar

Stargazers

Nathan Baschez avatar  avatar Patrick Schmitz avatar Jacob Reiff avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.