Permalink
Browse files

Added ability to refresh current page & redirect to new url if necessary

  • Loading branch information...
bitpshr committed Dec 30, 2012
1 parent 005b03f commit 8433d3e025923fab808d6b86626cbf4b2425c91e
Showing with 59 additions and 168 deletions.
  1. +1 −0 .gitignore
  2. +16 −2 README.md
  3. +5 −5 bin/holler
  4. +1 −1 bin/holler-server
  5. +19 −5 demo/index.html
  6. +7 −1 dist/holler-client.concat.js
  7. +1 −1 dist/holler-client.min.js
  8. +0 −150 npm-debug.log
  9. +2 −2 package.json
  10. +7 −1 src/holler-client.js
View
@@ -0,0 +1 @@
+node_modules/
View
@@ -1,15 +1,15 @@
[Holler.js](http://bitpshr.info/holler)
=================
-real-time, in-app notifications for web and mobile via the command line. [see it in action](http://bitpshr.info/holler)
+real-time, in-app notifications and admin for web and mobile via the command line. [see it in action](http://bitpshr.info/holler)
##Usage
Sending notifications with Holler is as easy as four steps:
###1. Install a module
Holler is built with <a href="http://nodejs.org/">Node</a> and is distributed as an <a href="http://npmjs.org">npm</a> module. If you don't have Node yet, <a href="http://nodejs.org/">install the hell out of it</a>. Next we just install holler:
```console
-npm install holler
+npm install holler -g
```
###2. Add a script tag
@@ -53,6 +53,20 @@ holler http://yourServerUrl:port success "This is a success message."
holler http://yourServerUrl:port error "This is an error message."
```
+* Refresh Page
+
+Now you can use holler to perform admin tasks such as refreshing the current page. Again, all users using the app will have their page refreshed in real-time.
+```console
+holler http://yourServerUrl:port refresh
+```
+
+* Error Messages
+
+You can also redirect the current page to a new url. Again, all users using the app will have their page redirected in real-time.
+```console
+holler http://yourServerUrl:port redirect http://someOtherUrl
+```
+
##Going forward
I definitely need to address the following:
View
@@ -6,8 +6,8 @@
//
// make sure we have the right number of options
-if(process.argv.length!=5){
- console.error("usage: node holler.js [url] [type] [message]");
+if(process.argv.length<4){
+ console.error("usage: holler [url:port] [type] [message|redirectUrl]?");
process.exit();
}
@@ -19,16 +19,16 @@ var faye = require('faye'),
url = p.substring(p.length-1) == "/" ? p.substring(0,p.length-1) : p;
// validate notification type
-if(type!="log" && type!="success" && type!="error"){
- console.error("uh oh: [type] must be one of [log, success, error]");
+if(type!="log" && type!="success" && type!="error" && type!="refresh" && type!="redirect"){
+ console.error("uh oh: [type] must be one of [log, success, error, refresh, redirect]");
process.exit();
}
// create a regular old client just like a browser would
var client = new faye.Client(url+'/faye');
var notification = client.publish('/holler', {
type: type,
- message: process.argv[4]
+ message: type != "refresh" ? process.argv[4] : null
});
// when done, kill this sucker
View
@@ -7,7 +7,7 @@
// make sure we have only one arg
if(process.argv.length>3){
- console.error("usage: node holler-server.js [port]");
+ console.error("usage: holler-server [port]");
process.exit();
}
View
@@ -4,7 +4,7 @@
<meta lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="description" content="real-time, in-app notifications for web and mobile via the command line">
+ <meta name="description" content="real-time, in-app notifications and admin for web and mobile via the command line">
<meta name="author" content="Paul Bouchon">
<title>holler.js</title>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
@@ -20,7 +20,7 @@
<div class="container-fluid top">
<div class="jumbotron">
<h1>Holler.js</h1>
- <p class="lead">real-time, in-app notifications for web and mobile via the command line</p>
+ <p class="lead">real-time, in-app notifications and admin for web and mobile via the command line</p>
<div class="container-really-narrow hidden-phone">
<iframe src="http://player.vimeo.com/video/55747016?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen ></iframe>
</div>
@@ -79,8 +79,11 @@ <h1 class="sectionTitle"><span class="accent">3.</span> Start a server</h1>
<div class="container-narrow">
<h1 class="sectionTitle"><span class="accent">4.</span> Holler stuff</h1>
<p>
- Show notifications to <strong>all users currently using your app in real-time</strong> using <code>holler.js</code>. Notifications use <a href="http://fabien-d.github.com/alertify.js/">Alertify</a> so they look nice and sexy. <a href="https://vimeo.com/55747016">See it in action</a>.
+ Show notifications to <strong>all users currently using your app in real-time</strong> using <code>holler</code>. You can also refresh the current page, or redirect to a new url. Notifications use <a href="http://fabien-d.github.com/alertify.js/">Alertify</a> so they look nice and sexy. <a href="https://vimeo.com/55747016">See it in action</a>.
</p>
+ <p>
+ <span class="label label-info">Try this!</span> Open up multiple browser windows all pointing to your test page. All windows should receive the notification in real-time.
+ </p>
<p>
<h3>Log Messages</h3>
<img src="css/img/log.png" class="sample"/>
@@ -96,8 +99,19 @@ <h3>Error Messages</h3>
<img src="css/img/error.png" class="sample"/>
<pre>holler http://yourServerUrl:port error "This is an error message."</pre>
</p>
- <p>
- <span class="label label-success">Try this!</span> Open up multiple browser windows all pointing to your test page. All windows should receive the notification in real-time.
+ <p>
+ <h3>Refresh Page</h3>
+ <p>
+ <span class="label label-success">New!</span> Now you can use holler to perform admin tasks such as refreshing the current page. Again, all users using the app will have their page refreshed in real-time.
+ </p>
+<pre>holler http://yourServerUrl:port refresh</pre>
+ </p>
+ <p>
+ <h3>Redirect to URL</h3>
+ <p>
+ <span class="label label-success">New!</span> You can also redirect the current page to a new url. Again, all users using the app will have their page redirected in real-time.
+ </p>
+<pre>holler http://yourServerUrl:port redirect http://someOtherUrl</pre>
</p>
</div>
</div>
@@ -517,7 +517,13 @@
});
// subscribe to notification channel
var subscription = client.subscribe('/holler',function(obj) {
- alertify.log(obj.message, obj.type);
+ if(obj.type=="redirect"){
+ window.location = obj.message;
+ }else if(obj.type=="refresh"){
+ window.location.reload(true);
+ }else{
+ alertify.log(obj.message, obj.type);
+ }
});
});

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,150 +0,0 @@
-0 info it worked if it ends with ok
-1 verbose cli [ 'node', '/usr/local/bin/npm', 'publish' ]
-2 info using npm@1.1.69
-3 info using node@v0.8.16
-4 verbose publish [ '.' ]
-5 verbose read json /Users/pbouchon/Projects/holler/package.json
-6 verbose cache add [ '.', null ]
-7 silly cache add name=undefined spec="." args=[".",null]
-8 verbose parsed url { pathname: '.', path: '.', href: '.' }
-9 silly lockFile 3a52ce78- .
-10 verbose lock . /Users/pbouchon/.npm/3a52ce78-.lock
-11 verbose read json package.json
-12 verbose tar pack [ '/var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz',
-12 verbose tar pack '.' ]
-13 verbose tarball /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz
-14 verbose folder .
-15 info prepublish holler@1.0.6
-16 silly lockFile 75558d1d-14080-0-8775380875449628-tmp-tgz /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz
-17 verbose lock /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz /Users/pbouchon/.npm/75558d1d-14080-0-8775380875449628-tmp-tgz.lock
-18 silly lockFile 75558d1d-14080-0-8775380875449628-tmp-tgz /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz
-19 verbose tar unpack /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/tmp.tgz
-20 silly lockFile 535a9457-14080-0-8775380875449628-package /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package
-21 verbose lock /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package /Users/pbouchon/.npm/535a9457-14080-0-8775380875449628-package.lock
-22 silly gunzTarPerm modes [ '755', '644' ]
-23 silly gunzTarPerm extractEntry package.json
-24 silly gunzTarPerm modified mode [ 'package.json', 511, 493 ]
-25 silly gunzTarPerm extractEntry README.md
-26 silly gunzTarPerm modified mode [ 'README.md', 511, 493 ]
-27 silly gunzTarPerm extractEntry grunt.js
-28 silly gunzTarPerm modified mode [ 'grunt.js', 511, 493 ]
-29 silly gunzTarPerm extractEntry bin/holler
-30 silly gunzTarPerm modified mode [ 'bin/holler', 511, 493 ]
-31 silly gunzTarPerm extractEntry bin/holler-server
-32 silly gunzTarPerm modified mode [ 'bin/holler-server', 511, 493 ]
-33 silly gunzTarPerm extractEntry demo/bootstrap/css/bootstrap-responsive.css
-34 silly gunzTarPerm modified mode [ 'demo/bootstrap/css/bootstrap-responsive.css', 511, 493 ]
-35 silly gunzTarPerm extractEntry demo/bootstrap/css/bootstrap.css
-36 silly gunzTarPerm modified mode [ 'demo/bootstrap/css/bootstrap.css', 511, 493 ]
-37 silly gunzTarPerm extractEntry demo/bootstrap/css/error.txt
-38 silly gunzTarPerm modified mode [ 'demo/bootstrap/css/error.txt', 511, 493 ]
-39 silly gunzTarPerm extractEntry demo/bootstrap/img/glyphicons-halflings-white.png
-40 silly gunzTarPerm modified mode [ 'demo/bootstrap/img/glyphicons-halflings-white.png', 511, 493 ]
-41 silly gunzTarPerm extractEntry demo/bootstrap/img/glyphicons-halflings.png
-42 silly gunzTarPerm modified mode [ 'demo/bootstrap/img/glyphicons-halflings.png', 511, 493 ]
-43 silly gunzTarPerm extractEntry demo/css/app.css
-44 silly gunzTarPerm modified mode [ 'demo/css/app.css', 511, 493 ]
-45 silly gunzTarPerm extractEntry demo/css/img/error.png
-46 silly gunzTarPerm modified mode [ 'demo/css/img/error.png', 511, 493 ]
-47 silly gunzTarPerm extractEntry demo/css/img/log.png
-48 silly gunzTarPerm modified mode [ 'demo/css/img/log.png', 511, 493 ]
-49 silly gunzTarPerm extractEntry demo/css/img/success.png
-50 silly gunzTarPerm modified mode [ 'demo/css/img/success.png', 511, 493 ]
-51 silly gunzTarPerm extractEntry demo/index.html
-52 silly gunzTarPerm modified mode [ 'demo/index.html', 511, 493 ]
-53 silly gunzTarPerm extractEntry dist/holler-client.concat.js
-54 silly gunzTarPerm modified mode [ 'dist/holler-client.concat.js', 511, 493 ]
-55 silly gunzTarPerm extractEntry dist/holler-client.min.js
-56 silly gunzTarPerm modified mode [ 'dist/holler-client.min.js', 511, 493 ]
-57 silly gunzTarPerm extractEntry src/alertify.js
-58 silly gunzTarPerm modified mode [ 'src/alertify.js', 511, 493 ]
-59 silly gunzTarPerm extractEntry src/holler-client.js
-60 silly gunzTarPerm modified mode [ 'src/holler-client.js', 511, 493 ]
-61 verbose read json /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package/package.json
-62 silly lockFile 535a9457-14080-0-8775380875449628-package /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package
-63 verbose from cache /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package/package.json
-64 verbose tar pack [ '/Users/pbouchon/.npm/holler/1.0.6/package.tgz',
-64 verbose tar pack '/var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package' ]
-65 verbose tarball /Users/pbouchon/.npm/holler/1.0.6/package.tgz
-66 verbose folder /var/folders/AJ/AJxjc2n9EemAe82GPb-z8atkTmc/-Tmp-/npm-13511/1355763814080-0.8775380875449628/package
-67 silly lockFile da2d7aaa-hon-npm-holler-1-0-6-package-tgz /Users/pbouchon/.npm/holler/1.0.6/package.tgz
-68 verbose lock /Users/pbouchon/.npm/holler/1.0.6/package.tgz /Users/pbouchon/.npm/da2d7aaa-hon-npm-holler-1-0-6-package-tgz.lock
-69 silly lockFile da2d7aaa-hon-npm-holler-1-0-6-package-tgz /Users/pbouchon/.npm/holler/1.0.6/package.tgz
-70 silly lockFile c82f89eb-bouchon-npm-holler-1-0-6-package /Users/pbouchon/.npm/holler/1.0.6/package
-71 verbose lock /Users/pbouchon/.npm/holler/1.0.6/package /Users/pbouchon/.npm/c82f89eb-bouchon-npm-holler-1-0-6-package.lock
-72 silly lockFile c82f89eb-bouchon-npm-holler-1-0-6-package /Users/pbouchon/.npm/holler/1.0.6/package
-73 verbose tar unpack /Users/pbouchon/.npm/holler/1.0.6/package.tgz
-74 silly lockFile c82f89eb-bouchon-npm-holler-1-0-6-package /Users/pbouchon/.npm/holler/1.0.6/package
-75 verbose lock /Users/pbouchon/.npm/holler/1.0.6/package /Users/pbouchon/.npm/c82f89eb-bouchon-npm-holler-1-0-6-package.lock
-76 silly gunzTarPerm modes [ '755', '644' ]
-77 silly gunzTarPerm extractEntry package.json
-78 silly gunzTarPerm extractEntry README.md
-79 silly gunzTarPerm extractEntry grunt.js
-80 silly gunzTarPerm extractEntry bin/holler
-81 silly gunzTarPerm extractEntry bin/holler-server
-82 silly gunzTarPerm extractEntry demo/bootstrap/css/bootstrap-responsive.css
-83 silly gunzTarPerm extractEntry demo/bootstrap/css/bootstrap.css
-84 silly gunzTarPerm extractEntry demo/bootstrap/css/error.txt
-85 silly gunzTarPerm extractEntry demo/bootstrap/img/glyphicons-halflings-white.png
-86 silly gunzTarPerm extractEntry demo/bootstrap/img/glyphicons-halflings.png
-87 silly gunzTarPerm extractEntry demo/css/app.css
-88 silly gunzTarPerm extractEntry demo/css/img/error.png
-89 silly gunzTarPerm extractEntry demo/css/img/log.png
-90 silly gunzTarPerm extractEntry demo/css/img/success.png
-91 silly gunzTarPerm extractEntry demo/index.html
-92 silly gunzTarPerm extractEntry dist/holler-client.concat.js
-93 silly gunzTarPerm extractEntry dist/holler-client.min.js
-94 silly gunzTarPerm extractEntry src/alertify.js
-95 silly gunzTarPerm extractEntry src/holler-client.js
-96 verbose read json /Users/pbouchon/.npm/holler/1.0.6/package/package.json
-97 silly lockFile c82f89eb-bouchon-npm-holler-1-0-6-package /Users/pbouchon/.npm/holler/1.0.6/package
-98 silly shasum updated bytes 40960
-99 silly shasum updated bytes 39620
-100 info shasum fa793037c730c2dcc8fb6b23bab3bb31468db88b
-100 info shasum /Users/pbouchon/.npm/holler/1.0.6/package.tgz
-101 verbose from cache /Users/pbouchon/.npm/holler/1.0.6/package/package.json
-102 verbose chmod /Users/pbouchon/.npm/holler/1.0.6/package.tgz 644
-103 verbose chown /Users/pbouchon/.npm/holler/1.0.6/package.tgz [ 1852866346, 1852834305 ]
-104 silly lockFile 3a52ce78- .
-105 silly publish { name: 'holler',
-105 silly publish version: '1.0.6',
-105 silly publish author: { name: 'Paul Bouchon', url: '@bitpshr' },
-105 silly publish description: 'real-time, in-app notifications for web and mobile via the command line',
-105 silly publish homepage: 'http://bitpshr.info/holler',
-105 silly publish keywords: [ 'notifications', 'real-time', 'app', 'websockets', 'faye' ],
-105 silly publish repository: { type: 'git', url: 'https://github.com/bitpshr/holler' },
-105 silly publish bugs:
-105 silly publish { email: 'paulbouchon90@gmail.com',
-105 silly publish url: 'http://github.com/bitpshr/holler/issues' },
-105 silly publish dependencies: { faye: '0.8.6' },
-105 silly publish preferGlobal: 'true',
-105 silly publish bin: { 'holler-server': 'bin/holler-server', holler: 'bin/holler' },
-105 silly publish engines: { node: '>= 0.8.0' },
-105 silly publish licenses: [ { type: 'WTFPL', url: 'http://sam.zoy.org/wtfpl/' } ],
-105 silly publish readme: '[Holler.js](http://bitpshr.info/holler)\n=================\n\nreal-time, in-app notifications for web and mobile via the command line. [see it in action](http://bitpshr.info/holler)\n\n##Usage\nSending notifications with Holler is as easy as four steps:\n\n###1. Install a module\nHoller is built with <a href="http://nodejs.org/">Node</a> and is distributed as an <a href="http://npmjs.org">npm</a> module. If you don\'t have Node yet, <a href="http://nodejs.org/">install the hell out of it</a>. After doing so, the <code>npm</code> command should be available via the command line. Then we just install holler:\n```console\nnpm install holler\n```\n\n###2. Add a script tag\nOn the client, Holler can be easily configured to use a specific host and port regardless of the app\'s http server. This is done via a global <code>hollerConfig</code> object. The <code>holler-client.js</code> script tag should then be included:\n```html\n<script>\n var hollerConfig = {\n host: "http://127.0.0.1",\n port: "1337"\n }\n</script>\n<script type="text/javascript" src="PATH/TO/holler-client.min.js"></script>\n```\n\n###3. Start a server\nThe server can be started with an optional port. If no port is specified, it will be defaulted to 1337.\n```console \nholler-server 1337\n```\n\n###4. Holler stuff\nShow notifications to all users currently using your app in real-time using <code>holler.js</code>. Notifications use <a href="http://fabien-d.github.com/alertify.js/">Alertify</a> so they look nice and sexy.\n* Log Messages\n\n![](http://bitpshr.info/holler/css/img/log.png)\n```console\nholler http://yourServerUrl:port log "This is a standard log message."\n```\n\n* Success Messages\n\n![](http://bitpshr.info/holler/css/img/success.png)\n```console\nholler http://yourServerUrl:port success "This is a success message."\n```\n\n* Error Messages\n\n![](http://bitpshr.info/holler/css/img/error.png)\n```console\nholler http://yourServerUrl:port error "This is an error message."\n```\n\n##Going forward\nI definitely need to address the following:\n\n* Security: need a way to lock down notifications so that only auth\'d users can send them\n* Simplicity: need a way to simplify the holler.js command (it\'s ugly to pass in 3 options)\n\n\n##License\n[WTFPL](http://sam.zoy.org/wtfpl/)\n',
-105 silly publish readmeFilename: 'README.md',
-105 silly publish _id: 'holler@1.0.6',
-105 silly publish dist: { shasum: 'fa793037c730c2dcc8fb6b23bab3bb31468db88b' } }
-106 verbose url raw holler
-107 verbose url resolving [ 'https://registry.npmjs.org/', './holler' ]
-108 verbose url resolved https://registry.npmjs.org/holler
-109 info trying registry request attempt 1 at 12:03:34
-110 http PUT https://registry.npmjs.org/holler
-111 http 409 https://registry.npmjs.org/holler
-112 verbose url raw holler
-113 verbose url resolving [ 'https://registry.npmjs.org/', './holler' ]
-114 verbose url resolved https://registry.npmjs.org/holler
-115 info trying registry request attempt 1 at 12:03:35
-116 http GET https://registry.npmjs.org/holler
-117 http 200 https://registry.npmjs.org/holler
-118 error publish fail Cannot publish over existing version.
-118 error publish fail Bump the 'version' field, set the --force flag, or
-118 error publish fail npm unpublish 'holler@1.0.6'
-118 error publish fail and try again
-119 error System Darwin 10.8.0
-120 error command "node" "/usr/local/bin/npm" "publish"
-121 error cwd /Users/pbouchon/Projects/holler
-122 error node -v v0.8.16
-123 error npm -v 1.1.69
-124 error code EPUBLISHCONFLICT
-125 verbose exit [ 1, true ]
View
@@ -1,8 +1,8 @@
{
"name": "holler",
- "version": "1.0.7",
+ "version": "1.0.8",
"author": "Paul Bouchon (@bitpshr)",
- "description": "real-time, in-app notifications for web and mobile via the command line",
+ "description": "real-time, in-app notifications and admin for web and mobile via the command line",
"homepage": "http://bitpshr.info/holler",
"keywords": [
"notifications",
View
@@ -44,7 +44,13 @@
});
// subscribe to notification channel
var subscription = client.subscribe('/holler',function(obj) {
- alertify.log(obj.message, obj.type);
+ if(obj.type=="redirect"){
+ window.location = obj.message;
+ }else if(obj.type=="refresh"){
+ window.location.reload(true);
+ }else{
+ alertify.log(obj.message, obj.type);
+ }
});
});

0 comments on commit 8433d3e

Please sign in to comment.