diff --git a/.gitignore b/.gitignore index 17451ae..5d8316f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.DS_Store examples/php/config.php +examples/ruby-sinatra/config.rb diff --git a/README.md b/README.md index 86e35a3..b12fa9b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The purpose of the PushNotifier.js library is to make is super easy to add simple Push notifications to any web application. It uses the [jQuery Gritter Growl plugin](http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/) for the UI and [Pusher](http://pusher.com) for realtime push notifications. -The first version of this sample shows how to perform Realtime Push Notifications from PHP. Later versions will demonstrate how to achieve this using other backend technologies. +The first version of this sample shows examples of server functionality in PHP and Ruby with Sinatra. If you'd like to see the example in other languages please [get in touch](http://pusher.com/support). ## How easy is it? @@ -28,6 +28,8 @@ It's as easy as: 3. Trigger events on your server and see them instantly appear in your web app: + **PHP** + $app_key = 'YOUR_APP_KEY'; $app_secret = 'YOUR_APP_SECRET'; $app_id = 'YOUR_APP_ID'; @@ -35,6 +37,16 @@ It's as easy as: $pusher = new Pusher($app_key, $app_secret, $app_id); $data = array('message' => 'This is an HTML5 Realtime Push Notification!'); $pusher->trigger('my_notifications', 'notification', $data); + + **Ruby** + require 'pusher' + + Pusher.app_id = 'YOUR_APP_ID' + Pusher.key = 'YOUR_APP_KEY' + Pusher.secret = 'YOUR_APP_SECRET' + + data = {'message' => 'This is an HTML5 Realtime Push Notification!'} + Pusher['my_notifications'].trigger('notification', data) ## Tutorial @@ -50,4 +62,12 @@ http://html5-realtime-push-notifications.phpfogapp.com/ ### PHP 1. Rename `examples/php/config.example.php` to `config.php` and add your Pusher app credentials. -2. Running on a web server navigate to `examples/index.html` to see a side-by-side page example and click the 'Notify' button to trigger a notification. \ No newline at end of file +2. Running on a web server navigate to `examples/index.html` to see a side-by-side page example and click the 'Notify' button to trigger a notification. + +### Ruby - sinatra + +1. Rename `examples/ruby-sinatra/config_example.rb` to `config.rb` and add your Pusher app credentials +2. Update `examples/notify.html` so that the `NOTIFY_ENDPOINT` has the value `/notify` +3. In `examples/ruby-sinatra` run `bundle install` to install the dependencies defined in `examples/ruby-sinatra/Gemfile` +4. Start the Sinatra server by running `bundle exec ruby -rubygems notify.rb` +5. Navigate to http://localhost:4567 (default for sinatra) to see a side-by-side page example and click the 'Notify' button to trigger a notification. \ No newline at end of file diff --git a/examples/index.html b/examples/index.html index 6ca46f3..aa65c95 100644 --- a/examples/index.html +++ b/examples/index.html @@ -2,7 +2,7 @@ - PHP HTML5 Push Notifications using Pusher - Frameset + HTML5 Push Notifications using Pusher - Frameset diff --git a/examples/notify.html b/examples/notify.html index b02ffcb..e203299 100644 --- a/examples/notify.html +++ b/examples/notify.html @@ -2,7 +2,7 @@ - PHP HTML5 Push Notifications using Pusher + HTML5 Push Notifications using Pusher @@ -19,10 +19,13 @@