From f98c8d05046f7ebbfce83c2f0892a3bdbf127359 Mon Sep 17 00:00:00 2001 From: Marak Date: Thu, 5 Mar 2015 02:17:49 +0530 Subject: [PATCH 001/963] [fix] Missing require statement in bodyParser. Closes #40 #6 --- lib/resources/hook/parseRequestBody.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/resources/hook/parseRequestBody.js b/lib/resources/hook/parseRequestBody.js index cbe8b1a3..676bc133 100644 --- a/lib/resources/hook/parseRequestBody.js +++ b/lib/resources/hook/parseRequestBody.js @@ -1,4 +1,6 @@ var mergeParams = require('../../../view/mergeParams'); +var bodyParser = require('body-parser'); +var jsonParser = bodyParser.json(); module['exports'] = function parseRequestBody (req, res, next) { var hook = require('./'); From 694c2d03470239b649bdb899edbb480d8e1083a7 Mon Sep 17 00:00:00 2001 From: Marak Date: Fri, 8 May 2015 19:06:33 +0200 Subject: [PATCH 002/963] [minor] Update modules HTML. Update billing UI. --- view/billing.html | 28 ++++++++++++++++++++++++---- view/billing.js | 2 +- view/modules.html | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/view/billing.html b/view/billing.html index 14e60808..63fe94fa 100644 --- a/view/billing.html +++ b/view/billing.html @@ -19,6 +19,9 @@ font-size: 36px; color: #6bc40c; } + .error { + color: red; + } #slider { cursor: pointer; @@ -48,10 +51,17 @@ - + + + +
+
+

Select the amount you want to pay each month

+
+
@@ -63,16 +73,18 @@ value="Pay $0.00 per month" data-image="/img/pipe.gif" data-key="pk_test_axAR0vF3Qam8zs09JE7t8ZIo" - data-amount="000" + data-amount="500" data-currency="usd" data-name="hook.io hosting" data-description="1 Month Basic Hosting" /> + +
- +
+
-

Select the amount you want to pay each month

We let our users choose how much to pay every month. The more you choose to pay, the better we can make the service in the future. We appreciate your business and respect your choice to pay whatever you want.

@@ -108,10 +120,18 @@

We let our users choose how much to pay every month. The more you choose to console.log(ui.value); $('#addPaymentMethod').val('Pay $' + ui.value + '.00 per month'); $('#amount').val(ui.value * 100); + $('#addPaymentMethod').attr('data-amount', Number(ui.value) * 100); + // TODO: issue with stripe checkout.js not adjusting input dollar value, + // after closing and opening with a new slider value + // $('.iconTick').html('Pay $' + ui.value + '.00'); // maybe? } $('#slider').on("slide", function(ev, ui){ handleSlide(ev, ui); + }).slider("pips", { + prefix: "$", + rest: 'label', + step: 2 }); // if user already has billing, show plan diff --git a/view/billing.js b/view/billing.js index 6d4bc05e..af3596d0 100644 --- a/view/billing.js +++ b/view/billing.js @@ -52,7 +52,7 @@ module['exports'] = function view (opts, callback) { }; results.forEach(function(item){ - item.destroy(); + // item.destroy(); billingForm(item, function (err, re){ $('.billingForm').append(re); count--; diff --git a/view/modules.html b/view/modules.html index 896282ab..64490038 100644 --- a/view/modules.html +++ b/view/modules.html @@ -35,7 +35,7 @@

Need a module not listed here?

Name Version - bluebird ^2.3.11 cheerio ^0.17.0 colors ^1.0.3 contentful ^0.1.2 contentful-management ^0.1.0 cron ^1.0.5 geocodio ^0.0.1 gengo ^0.1.8 github ^0.2.2 github-url-from-git ^1.4.0 gm ^1.16.0 hyperquest ^1.0.1 irc ^0.3.7 map-async ^0.1.1 map-sync ^0.1.1 moment ^2.8.3 mschema ^0.5.3 object-path ^0.6.0 once ^1.3.1 passport ^0.2.1 passport-github ^0.1.5 questor ^1.0.0 resource ^0.5.3 resource-user 0.5.x slack-notify ^0.1.2 stream-buffers ^1.1.0 stream-transcoder 0.0.5 stripe ^2.8.0 through2 ^0.6.3 twilio ^1.7.0 twit ^1.1.18 xtend ^4.0.0 + bluebird ^2.3.11 cheerio ^0.17.0 colors ^1.0.3 collect-stream ^1.0.0 contentful ^0.1.2 contentful-management ^0.1.0 cron ^1.0.5 geocodio ^0.0.1 gengo ^0.1.8 github ^0.2.2 github-url-from-git ^1.4.0 gm ^1.16.0 hyperquest ^1.0.1 irc ^0.3.7 map-async ^0.1.1 map-sync ^0.1.1 moment ^2.8.3 mschema ^0.5.3 object-path ^0.6.0 once ^1.3.1 passport ^0.2.1 passport-github ^0.1.5 questor ^1.0.0 resource ^0.5.3 resource-user 0.5.x slack-notify ^0.1.2 stream-buffers ^1.1.0 stream-transcoder 0.0.5 stripe ^2.8.0 through2 ^0.6.3 twilio ^1.7.0 twit ^1.1.18 xtend ^4.0.0 From 0f0a074ddf5901a7a3f061c28d95408f30a2051c Mon Sep 17 00:00:00 2001 From: Marak Date: Fri, 8 May 2015 20:08:32 +0200 Subject: [PATCH 003/963] [refactor] [minor] Move stripe keys into config --- config/index.js | 6 +++++- view/account.html | 1 - view/addPaymentOption.js | 4 +--- view/billing.html | 5 ++--- view/billing.js | 10 ++++++---- view/pricing.html | 1 - 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/config/index.js b/config/index.js index b8e4bbeb..29624356 100644 --- a/config/index.js +++ b/config/index.js @@ -1,7 +1,7 @@ module['exports'] = { site: { port: 9999, - https: false + https: true }, couch: { "database": "hook", @@ -21,4 +21,8 @@ module['exports'] = { }, defaultTheme : "http://localhost:9999/themes/debug/index.html", defaultPresenter : "http://localhost:9999/themes/debug/index.js", + stripe: { + secretKey: "sk_test_ZXdJj4I3Db2iB9ZRm0gqyzDV", + publicKey: "pk_test_axAR0vF3Qam8zs09JE7t8ZIo" + }, }; \ No newline at end of file diff --git a/view/account.html b/view/account.html index 739f4edd..f3834fe1 100644 --- a/view/account.html +++ b/view/account.html @@ -49,7 +49,6 @@ class="well" value="Add Payment Method" data-image="/img/pipe.gif" - data-key="pk_test_axAR0vF3Qam8zs09JE7t8ZIo" data-amount="500" data-currency="usd" data-name="hook.io hosting" diff --git a/view/addPaymentOption.js b/view/addPaymentOption.js index e179d7d9..84966335 100644 --- a/view/addPaymentOption.js +++ b/view/addPaymentOption.js @@ -6,7 +6,7 @@ module['exports'] = function addPaymentOption (opts, cb) { \ - -
-

Custom Web Domains

-

Here you can add / remove custom web domains that will route to your hooks.

-

This is a great way to use a custom domain like www.marak.com to point to a hook.

-
- Add new Domain -
-
- -
- - - - - - -
 Domain
-
- -
-
+
\ No newline at end of file diff --git a/view/domains.js b/view/domains.js index ab06e43c..e8375765 100644 --- a/view/domains.js +++ b/view/domains.js @@ -1,138 +1,67 @@ -// TODO: remove copy-pasta from env.js +var forms = require('resource-forms'), +domain = require('../lib/resources/domain'), +mschemaForms = require('mschema-forms'); -var user = require('../lib/resources/user'); +var mergeParams = require('./mergeParams'); var bodyParser = require('body-parser'); -module['exports'] = function view (opts, callback) { - var req = opts.request, res = opts.response; - var $ = this.$; - if (!req.isAuthenticated()) { - req.session.redirectTo = "/domains"; - return res.redirect('/login'); - } - - bodyParser()(req, res, function bodyParsed(){ - mergeParams(req, res, function(){}); - - var params = req.resource.params; - - user.find({ name: req.user.username }, function(err, results) { - if (err) { - return callback(null, err.message); - } - if (results.length === 0) { - return callback(null, 'No user found'); - } - var _user = results[0]; - console.log('we have ', _user.domains.items) - if (params.update) { - // update is destructive and complete - // entire User.env will now be replaced by the contents of the form submitted - // all old fields are deleted and replaced with new values - //_user.env = {}; - if (params.key) { - if (typeof params.key === "string") { - params.key = [params.key]; - } - if (typeof params.value === "string") { - params.value = [params.value]; - } - params.key.forEach(function(k, i){ - if (k.length) { - // console.log('about to save', typeof val, val) - _user.domains.items.push(k); - } - }) - } - _user.save(function(err){ - if (err) { - return res.end(err.message); - } - showEnv(); - }); - } else { - showEnv(); - } +module['exports'] = function view (opts, callback) { - function quoteattr(s, preserveCR) { - preserveCR = preserveCR ? ' ' : '\n'; - return ('' + s) /* Forces the conversion to string. */ - .replace(/&/g, '&') /* This MUST be the 1st replacement. */ - .replace(/'/g, ''') /* The 4 other predefined entities, required. */ - .replace(/"/g, '"') - .replace(//g, '>') - /* - You may add other replacements here for HTML only - (but it's not necessary). - Or for XML, only if the named entities are defined in its DTD. - */ - .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */ - .replace(/[\r\n]/g, preserveCR); - ; + var req = opts.request, + res = opts.response, + $ = this.$; + + // if not logged in, kick out + if (!req.isAuthenticated()) { + req.session.redirectTo = "/domains"; + return res.redirect('/login'); + } + + bodyParser()(req, res, function bodyParsed() { + mergeParams(req, res, function (){}); + + req.resource.params.owner = req.user.username; + + var middle = forms.generate({ + view: 'grid-with-form', + resource: domain, + action: '/domains', + params: req.resource.params, + useLayout: false, + form: { + create: { + legend: 'Add a new Domain', + submit: "Add Domain" + }, + grid: { + legend: 'Your Domains' } - function showEnv () { - var env = _user.domains.items || []; - function addRow (k, v) { - if (typeof v === "object") { - v = JSON.stringify(v); - } - var _delete = 'X'; - var _key = ''; - var _value = ''; - $('.env').append('' + _delete + '' + k + ''); - }; - - if (env.length === 0) { - addRow('', ''); - } - - env.forEach(function(key){ - console.log('ff', key) - addRow(key.id); - }); - - callback(null, $.html()); + }, + schema: { + name: { + type: 'string', + description: 'marak.com', + required: true, + minLength: 1, + maxLength: 50 + }, + forwardUrl: { + type: 'string', + description: '/Marak/echo', + required: true, + minLength: 1, + maxLength: 50 } - - }); - - }); - -}; - - - -// -// Middleware for merging all querystring / request.body and route parameters, -// into a common scope bound to req.resource.params -// -function mergeParams (req, res, next) { - - req.resource = req.resource || {}; - req.resource.params = {}; - req.body = req.body || {}; - - // - // Iterate through all the querystring and request.body values and - // merge them into a single "data" argument - // - if (typeof req.params === 'object') { - Object.keys(req.params).forEach(function (p) { - req.resource.params[p] = req.param(p); - }); - } - - if (typeof req.query === 'object') { - Object.keys(req.query).forEach(function (p) { - req.resource.params[p] = req.query[p]; + } + }, function (err, result){ + if (err) { + return res.end(err.message); + } + $('.domains').html(result); + callback(null, $.html()); + return; + }); }); - } - - Object.keys(req.body).forEach(function (p) { - req.resource.params[p] = req.body[p]; - }); - next(); -} \ No newline at end of file +}; \ No newline at end of file From b7aecabd8c60005f3a1849086c34cf5e2aca3a5f Mon Sep 17 00:00:00 2001 From: Marak Date: Tue, 19 May 2015 22:47:47 +0200 Subject: [PATCH 011/963] [view] [minor] Copy updates and UI changes. --- package.json | 2 +- view/account.html | 6 ++++++ view/billing.html | 48 +++++++++++++++++++++++++++++++++++++++++---- view/billingForm.js | 2 ++ view/domains.js | 7 +++++-- view/hooks.js | 10 ++++++++-- view/index.html | 12 +++++++----- view/layout.html | 26 ++++++++++++------------ view/referrals.html | 10 ++++++++-- 9 files changed, 94 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 39e1dc75..d6ad5867 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "stripe": "^3.3.4", "through2": "^0.6.3", "trycatch": "^1.5.11", - "view": "^0.6.0" + "view": "0.6.x" }, "devDependencies": { "gulp-rename": "*", diff --git a/view/account.html b/view/account.html index f3834fe1..0bf8c5af 100644 --- a/view/account.html +++ b/view/account.html @@ -21,6 +21,10 @@ .billingForm { text-align: left; } + + .container { + text-align: left; + } #addPaymentMethod { font-size: 36px; @@ -40,6 +44,8 @@
+

Referral Links

+
diff --git a/view/billing.html b/view/billing.html index 61fda1f1..f6c7f0e6 100644 --- a/view/billing.html +++ b/view/billing.html @@ -28,19 +28,59 @@ cursor: pointer; } + #addPaymentMethod { + -moz-box-shadow: 0px 1px 38px 0px #ffffff; + -webkit-box-shadow: 0px 1px 38px 0px #ffffff; + box-shadow: 0px 1px 38px 0px #ffffff; + background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9)); + background:-moz-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); + background:-webkit-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); + background:-o-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); + background:-ms-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); + background:linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e9e9e9',GradientType=0); + background-color:#f9f9f9; + -moz-border-radius:33px; + -webkit-border-radius:33px; + border-radius:33px; + border:7px solid #dcdcdc; + display:inline-block; + cursor:pointer; + color:#666666; + font-family:Arial; + font-size:27px; + font-weight:bold; + padding:27px 64px; + text-decoration:none; + text-shadow:0px 1px 0px #ffffff; + min-width: 435px; + } + #addPaymentMethod:hover { + background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e9e9e9), color-stop(1, #f9f9f9)); + background:-moz-linear-gradient(top, #e9e9e9 5%, #f9f9f9 100%); + background:-webkit-linear-gradient(top, #e9e9e9 5%, #f9f9f9 100%); + background:-o-linear-gradient(top, #e9e9e9 5%, #f9f9f9 100%); + background:-ms-linear-gradient(top, #e9e9e9 5%, #f9f9f9 100%); + background:linear-gradient(to bottom, #e9e9e9 5%, #f9f9f9 100%); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e9e9e9', endColorstr='#f9f9f9',GradientType=0); + background-color:#e9e9e9; + } + #addPaymentMethod:active { + position:relative; + top:1px; + } + +/* #addPaymentMethod { font-size: 36px; height: 120px; width: 600px; - /* - background: #6bc40c; - color: red; - */ } #addPaymentMethod:hover { border: black; } + */ diff --git a/view/billingForm.js b/view/billingForm.js index 38afe531..b568f2e8 100644 --- a/view/billingForm.js +++ b/view/billingForm.js @@ -5,12 +5,14 @@ module['exports'] = function billingForm (data, cb) { var billingSchema = billingSchema || {}; +/* billingSchema.name = { type: "string", default: data.name, disabled: true }; +*/ billingSchema.method = { type: "string", default: data.type, diff --git a/view/domains.js b/view/domains.js index e8375765..9be66970 100644 --- a/view/domains.js +++ b/view/domains.js @@ -41,14 +41,17 @@ module['exports'] = function view (opts, callback) { schema: { name: { type: 'string', - description: 'marak.com', + description: 'Your custom domain name. Example: marak.com', + placeholder: 'marak.com', required: true, minLength: 1, maxLength: 50 }, forwardUrl: { type: 'string', - description: '/Marak/echo', + label: "hook", + placeholder: "/Marak/echo", + description: 'The Hook to point your domain to. Example: /Marak/echo', required: true, minLength: 1, maxLength: 50 diff --git a/view/hooks.js b/view/hooks.js index 1fe1e660..bac22702 100644 --- a/view/hooks.js +++ b/view/hooks.js @@ -10,12 +10,18 @@ module['exports'] = function view (opts, callback) { req.session.referredBy = req.params.username; return res.redirect("/"); } - + if (!opts.request.isAuthenticated()) { $('.navBar').remove() } - for(var h in opts.hooks) { + for (var h in opts.hooks) { + // TODO: add ability to delete hooks https://github.com/bigcompany/hook.io/issues/47 + if (req.params.username.toLowerCase() === req.user.username.toLowerCase()) { + // $('.hooks').append('' + opts.hooks[h].name + 'Delete') + } else { + // $('.hooks').append('' + opts.hooks[h].name + '') + } $('.hooks').append('' + opts.hooks[h].name + '') } diff --git a/view/index.html b/view/index.html index effe489a..a6674de3 100644 --- a/view/index.html +++ b/view/index.html @@ -154,11 +154,11 @@

Build and deploy tinynpm - (c) npmjs.org setuptocat - (c) Github --> - JavaScript! - Node.js - npm - Github - Unix + JavaScript! + Node.js + npm + Github + Unix

@@ -168,8 +168,10 @@

Build and deploy
Create Hook
My Hooks
+ Custom Domains
Account Information
Billing Information
+ Affiliates Program
Logout diff --git a/view/layout.html b/view/layout.html index 2883b00b..e83562a3 100644 --- a/view/layout.html +++ b/view/layout.html @@ -6,16 +6,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -118,6 +129,7 @@
Copyright hook.io 2014 A Big company +
npm modules
Support
diff --git a/view/stats.html b/view/stats.html index 1fe4460b..7ccb26c2 100644 --- a/view/stats.html +++ b/view/stats.html @@ -1,8 +1,15 @@ + +
-

project statistics

+

Site Statistics

1 hooks executed
1 active hooks
1 active users
- 1 github stars
- project forks
+
\ No newline at end of file diff --git a/view/stats.js b/view/stats.js index e1ed557d..b6d0fd68 100644 --- a/view/stats.js +++ b/view/stats.js @@ -26,8 +26,6 @@ module['exports'] = function view (opts, callback) { if (err) { console.log(err.message); } - $('.githubStars').html(output.stargazers_count); - $('.projectForks').html(output.forks_count); callback(null, $.html()); }); }); From 8cf826e2a9907ae01e17c538d91e98aceb97a0ef Mon Sep 17 00:00:00 2001 From: Marak Date: Wed, 27 May 2015 14:49:59 +0200 Subject: [PATCH 025/963] [fix] [regression] Ensure hook errors are continued. Blame: https://github.com/bigcompany/hook.io/commit/7d1172f0e4ab6a9197d35cc3583372bb012c7819#diff-11950558b3f472bacb88f6b7a1ee7a12L167 --- lib/resources/hook/runUntrustedHook.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/resources/hook/runUntrustedHook.js b/lib/resources/hook/runUntrustedHook.js index 34ff60af..cd45f827 100644 --- a/lib/resources/hook/runUntrustedHook.js +++ b/lib/resources/hook/runUntrustedHook.js @@ -156,6 +156,7 @@ module['exports'] = function runUntrustedHook (opts, untrustedHook, cb) { }); }, function(err) { console.log('Error', opts.req.url, err.stack); + return cb(err, opts, untrustedHook); }); if (req.resource.params.format === "raw") { From 2f81f03909aed0f06707c66e5d885707c041dd15 Mon Sep 17 00:00:00 2001 From: Marak Date: Thu, 4 Jun 2015 11:49:41 +0200 Subject: [PATCH 026/963] [view] [api] Add ability to destroy hooks. Closes #47 --- lib/server/index.js | 30 ++++++++++++++++++++++++++++++ view/hooks.html | 19 +++++++++++++++---- view/hooks.js | 17 ++++++++++++----- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/lib/server/index.js b/lib/server/index.js index fd9c281e..2489c781 100644 --- a/lib/server/index.js +++ b/lib/server/index.js @@ -132,6 +132,36 @@ server.start = function start (opts, cb) { if (req.resource.params.fork) { return hook.fork(req, res); } + // if ?delete=true has been passed to the hook, + // attempt to destroy the hook + if (req.resource.params.delete) { + var user = req.session.id; + if (typeof req.session.user !== 'undefined') { + user = req.session.user.toLowerCase(); + } + + // check the owner of the hook versus the current session, + // if the session does not match the owner, do not allow hook to be deleted + if (req.params.username.toLowerCase() === user) { + return hook.find({owner: req.params.username, name: req.params.hook }, function (err, result){ + if (err) { + return res.end(err.message); + } + if (result.length === 0) { + return res.end('Not found'); + } + var h = result[0]; + return h.destroy(function(err){ + if (err) { + return res.end(err.message); + } + return res.end('deleted ' + h.owner + "/" + h.name); + }); + }); + } else { + return res.end(user + ' does not have the permission to destroy ' + req.params.username + "/" + req.params.hook); + } + } // run hook on remote worker return hook.runRemote(req, res, function(){ // do nothing with the result diff --git a/view/hooks.html b/view/hooks.html index 06bb19f2..7619ac95 100644 --- a/view/hooks.html +++ b/view/hooks.html @@ -31,11 +31,23 @@ + +
-