A tiny Rack app that lets you broadcast messages to your website's users.
Ruby JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
public
spec
.gitignore
Gemfile
Gemfile.lock
LICENSE
Rakefile
Readme.md
config.ru
user_radio.gemspec

Readme.md

What it does

The app provides a JavaScript snipped to be embedded on your website. This creates a widget that displays a broadcast message to the users. Each user can hide the message, which will disable the widget until you set a new message.

Security Considerations

This app uses no session and does not restrict access. Anyone can read your broadcasts and unless your user ids are random anyone can hide messages for any user.

Installation

  1. Install the gem

  2. Fire up Redis

  3. UserRadio::App is a Rack app you can either embed into other apps or run standalone. In Rails you would add it to your routes like this:

    scope '/broadcast' do match '(*path)' => UserRadio::App end

To embed the widget into a page add jQuery and some HTML/JavaScript:

<div id="radio"></div>

<script src="/path/to/user_radio/user_radio.js"></script>
<script>
  $('#radio').userRadio('<current-user-id>');
</script>

Note that the domains for both apps must be the same so that the widget can hide messages using ajax.

Creating/updating the broadcast message

Start an irb session and enter the following:

UserRadio::App.database.new_broadcast '<your message>'