Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function echo(string) { console.log(string); }
- process.on('uncaughtException', function (err) {
- echo(err.stack);
- echo('uncaught Exception: ' + err);
- });
- var KEYS = require('keychain'),
- $ = require('node-jquery'),
- S3 = require('amazon-s3').S3;
- var storage = function() {
- return new S3(KEYS.AWS_KEY, KEYS.AWS_PASS);
- };
- function BuzzPage(in_list) {
- this.list = in_list;
- this.steps = [
- this.htmlHeaders,
- this.checkListExists,
- this.htmlFooters
- ]
- this.step();
- }
- BuzzPage.prototype.step = function() {
- $.proxy(this.steps.shift(), this)();
- };
- BuzzPage.prototype.htmlHeaders = function() {
- echo('<h1>' + this.list + '</h1>');
- return this.step();
- };
- BuzzPage.prototype.htmlFooters = function() {
- echo('<footer>Thank you, come again</footer>');
- };
- BuzzPage.prototype.checkListExists = function() {
- var self = this;
- storage().info(this.list + '/recent.json').
- on('failure', function() {
- echo ('this list does not exist');
- return self.htmlFooters();
- }).
- on('success', function(info) {
- return self.step();
- });
- }
- new BuzzPage(process.argv[2]);
Add Comment
Please, Sign In to add comment