diff options
| -rw-r--r-- | server/lib/api/index.js | 1 | ||||
| -rw-r--r-- | server/lib/api/subscription.js | 22 | ||||
| -rw-r--r-- | server/lib/schemas/Subscription.js | 3 | ||||
| -rw-r--r-- | server/lib/webhook/recurly-config.js (renamed from server/lib/webhook/config.js) | 0 | ||||
| -rw-r--r-- | server/lib/webhook/webhook.js | 8 | ||||
| -rw-r--r-- | views/about/brochure.ejs | 12 | ||||
| -rw-r--r-- | views/partials/edit-subscription.ejs | 33 | ||||
| -rw-r--r-- | views/profile.ejs | 82 |
8 files changed, 113 insertions, 48 deletions
diff --git a/server/lib/api/index.js b/server/lib/api/index.js index 11e13fc..9478d9b 100644 --- a/server/lib/api/index.js +++ b/server/lib/api/index.js @@ -8,6 +8,7 @@ var api = { projects: require('./projects'), rooms: require('./rooms'), collaborator: require('./collaborator'), + subscription: require('./subscription'), } module.exports = api diff --git a/server/lib/api/subscription.js b/server/lib/api/subscription.js new file mode 100644 index 0000000..6fe8c61 --- /dev/null +++ b/server/lib/api/subscription.js @@ -0,0 +1,22 @@ +/* jshint node: true */ + +var _ = require('lodash'), + util = require('../util'), + upload = require('../upload'), + config = require('../../../config.json'), + User = require('../schemas/User'), + Project = require('../schemas/Project'), + Layout = require('../schemas/Layout'), + Subscription = require('../schemas/Subscription'); + +var subscription = module.exports = { + +/* + index: function(req, res){ + Project.find({ user_id: req.user._id }, function(err, docs){ + res.json(docs) + }) + }, +*/ + +};
\ No newline at end of file diff --git a/server/lib/schemas/Subscription.js b/server/lib/schemas/Subscription.js index 99e4ebf..2f49ea1 100644 --- a/server/lib/schemas/Subscription.js +++ b/server/lib/schemas/Subscription.js @@ -9,9 +9,8 @@ var mongoose = require('mongoose'), var SubscriptionSchema = new mongoose.Schema({ user_id: { type: mongoose.Schema.ObjectId, index: true }, - plan_level: { type: Number, default: 0 }, plan_type: { type: String, default: "free" }, - last_charged: { type: Date, default: null }, + plan_period: { type: String, default: "monthly" }, subscription_uuid: { type: String }, subscription_add_ons: [{ diff --git a/server/lib/webhook/config.js b/server/lib/webhook/recurly-config.js index 3d7e1c5..3d7e1c5 100644 --- a/server/lib/webhook/config.js +++ b/server/lib/webhook/recurly-config.js diff --git a/server/lib/webhook/webhook.js b/server/lib/webhook/webhook.js index 2e5e627..e9a7925 100644 --- a/server/lib/webhook/webhook.js +++ b/server/lib/webhook/webhook.js @@ -20,7 +20,7 @@ var User = require('../schemas/User'), moment = require('moment'), xml2js = require('xml2js'), Recurly = require('node-recurly'), - recurly = new Recurly(require('./config')); + recurly = new Recurly(require('./recurly-config')); var parser = new xml2js.Parser(); @@ -64,12 +64,14 @@ var subscribe = module.exports = { var plan_period = plan[1] user.plan_type = plan_type - user.plan_period = plan_period user.plan_level = subscribe.plan_level[plan_type] var subscriber = new Subscription () - subscriber.user_id = user._id subscriber.uuid = data.subscription.uuid + subscriber.user_id = user._id + subscriber.plan_type = plan_type + subscriber.plan_period = plan_period + subscriber.plan_level = subscribe.plan_level[plan_type] subscriber.add_ons = subscription.add_ons.map(function(add_on){ return { name: add_on.plan, diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs index cffa51f..1c808f8 100644 --- a/views/about/brochure.ejs +++ b/views/about/brochure.ejs @@ -35,9 +35,9 @@ <li> [[ if (! logged_in) { ]] <button href="/signup">Sign Up</button> - [[ } else if (! profile.plan_level || profile.plan_level < plan.level) { ]] - <button href="https://vvalls.recurly.com/subscribe/basic/[[- profile._id ]]/[[- profile.username ]]">Buy Now</button> - [[ } else if (profile.plan_level == plan.level) { ]] + [[ } else if (! user.plan_level || user.plan_level < plan.level) { ]] + <button href="https://vvalls.recurly.com/subscribe/basic/[[- user._id ]]/[[- user.username ]]">Buy Now</button> + [[ } else if (user.plan_level == plan.level) { ]] Current Level [[ } else { ]] [[ } ]] @@ -57,9 +57,9 @@ <li> [[ if (! logged_in) { ]] <button href="/signup">Sign Up</button> - [[ } else if (! profile.plan_level || profile.plan_level < plan.level) { ]] - <button href="https://vvalls.recurly.com/subscribe/pro/[[- profile._id ]]/[[- profile.username ]]">Buy Now</button> - [[ } else if (profile.plan_level == plan.level) { ]] + [[ } else if (! user.plan_level || user.plan_level < plan.level) { ]] + <button href="https://vvalls.recurly.com/subscribe/pro/[[- user._id ]]/[[- user.username ]]">Buy Now</button> + [[ } else if (user.plan_level == plan.level) { ]] Current Level [[ } ]] </ul> diff --git a/views/partials/edit-subscription.ejs b/views/partials/edit-subscription.ejs new file mode 100644 index 0000000..0aa5281 --- /dev/null +++ b/views/partials/edit-subscription.ejs @@ -0,0 +1,33 @@ +<div class="mediaDrawer fixed animate editSubscription"> + <span class="close">X</span> + <div id="form_container"> + <form enctype="multipart/form-data" method="post"> + <input type="hidden" name="_csrf" value="[[- token ]]"> + <ul> + <li class="section_break"> + <h3>Edit Subscription</h3> + </li> + <li> + [[ if (! user.plan_level) { ]] + You are currently using the free plan. For access to all of Vvalls features, + consider upgrading to a paid plan. + <p> + <a href="/about/brochure">View the Plans</a> + [[ } else { ]] + Your current plan level is XXX + You have been a member since XXX + $cost/month OR $cost/year + + You are using N basic layouts + Buy more + + You are using N pro layouts + Buy more / Upgrade your account + + Cancel your subscription + [[ } ]] + </li> + </ul> + </form> + </div> +</div> diff --git a/views/profile.ejs b/views/profile.ejs index 88af6b0..e149847 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -9,48 +9,53 @@ [[- include partials/header ]] <div class="profilepage"> - [[ if (profile.photo && profile.photo.length) { ]] - <div class="profilePic" style="background-image:url([[- profile.photo ]])"> - </div> - [[ } else { ]] - <div class="profilePic noPic"> - <span class="holder"> - <span class="ion-ios7-person-outline"></span> - [[ if (isOwnProfile) { ]] - <div>click to add profile pic</div> - <input id="profile_avatar" name="avatar" class="element file" type="file"> - [[ } ]] - </span> - </div> + [[ if (profile.photo && profile.photo.length) { ]] + <div class="profilePic" style="background-image:url([[- profile.photo ]])"> + </div> + [[ } else { ]] + <div class="profilePic noPic"> + <span class="holder"> + <span class="ion-ios7-person-outline"></span> + [[ if (isOwnProfile) { ]] + <div>click to add profile pic</div> + <input id="profile_avatar" name="avatar" class="element file" type="file"> [[ } ]] - <div class="bio"> - <div class="holder"> - <h2>[[- profile.displayName ]]</h2> - [[ if (profile.location) { ]] - <span> - [[- profile.location ]] - </span> - [[ } ]] - [[ if (profile.website && profile.website.length) { ]] - <span> - <a href="[[- profile.website ]]" target="_blank">[[- profile.website ]]</a> - </span> - [[ } ]] - [[ if (profile.twitterName && profile.twitterName.length) { ]] - <span> - <a href="https://twitter.com/[[- profile.twitterName ]]" target="_blank">@[[- profile.twitterName ]]</a> - </span> - [[ } ]] - </div> - </div> - + </span> + </div> + [[ } ]] + <div class="bio"> + <div class="holder"> + <h2>[[- profile.displayName ]]</h2> + [[ if (profile.location) { ]] + <span> + [[- profile.location ]] + </span> + [[ } ]] + [[ if (profile.website && profile.website.length) { ]] + <span> + <a href="[[- profile.website ]]" target="_blank">[[- profile.website ]]</a> + </span> + [[ } ]] + [[ if (profile.twitterName && profile.twitterName.length) { ]] + <span> + <a href="https://twitter.com/[[- profile.twitterName ]]" target="_blank">@[[- profile.twitterName ]]</a> + </span> + [[ } ]] + [[ if (profile.plan_level == 1) { ]] + <span class="plan_level premium">PREMIUM</span> + [[ } else if (profile.plan_level == 2) { ]] + <span class="plan_level pro">PRO</span> + [[ } ]] + </div> + </div> [[ if (projects.length) { ]] + <h1>[[- profile.username ]] has [[- projectCount ]] project[[- projectCount != 1 ? "s" : "" ]]</h1> - [[ include projects/list-projects ]] + [[ } else { ]] - + <h1>Welcome to VVALLS</h1> <div class="projectList about"> <h2> @@ -69,8 +74,11 @@ <h3>This person has no projects.</h3> [[ } ]] </div> + [[ } ]] - </div> + + </div> + [[ include partials/edit-subscription ]] [[ include partials/edit-profile ]] [[ include projects/layouts-modal ]] [[ include projects/edit-project ]] |
