Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. function echo(string) { console.log(string); }
  2.  
  3. process.on('uncaughtException', function (err) {
  4. echo(err.stack);
  5. echo('uncaught Exception: ' + err);
  6. });
  7.  
  8. var KEYS = require('keychain'),
  9. $ = require('node-jquery'),
  10. S3 = require('amazon-s3').S3;
  11.  
  12. var storage = function() {
  13. return new S3(KEYS.AWS_KEY, KEYS.AWS_PASS);
  14. };
  15.  
  16. function BuzzPage(in_list) {
  17. this.list = in_list;
  18.  
  19. this.steps = [
  20. this.htmlHeaders,
  21. this.checkListExists,
  22. this.htmlFooters
  23. ]
  24.  
  25. this.step();
  26. }
  27.  
  28. BuzzPage.prototype.step = function() {
  29. $.proxy(this.steps.shift(), this)();
  30. };
  31.  
  32. BuzzPage.prototype.htmlHeaders = function() {
  33. echo('<h1>' + this.list + '</h1>');
  34.  
  35. return this.step();
  36. };
  37.  
  38. BuzzPage.prototype.htmlFooters = function() {
  39. echo('<footer>Thank you, come again</footer>');
  40. };
  41.  
  42. BuzzPage.prototype.checkListExists = function() {
  43. var self = this;
  44.  
  45. storage().info(this.list + '/recent.json').
  46. on('failure', function() {
  47. echo ('this list does not exist');
  48.  
  49. return self.htmlFooters();
  50. }).
  51. on('success', function(info) {
  52. return self.step();
  53. });
  54. }
  55.  
  56. new BuzzPage(process.argv[2]);
Add Comment
Please, Sign In to add comment