Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make "share" link to go straight to share.

  • Loading branch information...
commit 779efe4da953a852bb8f7dcd10cd25132840a583 1 parent d52fa26
@brianloveswords authored
View
31 controllers/share.js
@@ -94,22 +94,36 @@ function makeLinkUrl(path, configuration) {
}
exports.show = function (request, response, next) {
- var user = request.user;
- var group = request.group;
- var portfolio = group.get('portfolio');
+ var user, group, portfolio, owner, message;
- if (!portfolio) return response.send('no portfolio :(', 404);
+ user = request.user;
+ group = request.group;
+ portfolio = group.get('portfolio');
+ owner = user && group.get('user_id') === user.get('id');
+
+ // If there is no portfolio and this is the owner, create and save a new
+ // portfolio object. Otherwise, kick the user out.
+ if (!portfolio) {
+ if (!owner) return response.send('no portfolio :(', 404);
+ portfolio = new Portfolio({
+ group_id: group.get('id'),
+ title: group.get('name'),
+ stories: {}
+ });
+ portfolio.save();
+ }
// if this is the user's page, show SocialShare button
- if (user && group.get('user_id') === user.get('id')) {
- var message = '<p style="float: left;">This is how your portfolio page looks like to the public.</p>'
+ if (owner)
+ message = '<p style="float: left;">This is how your portfolio page looks like to the public.</p>'
+ '<div class="socialshare" style="float: right;" data-type="small-bubbles" data-tweet-at="openbadges"></div>';
- }
+
request.group.getBadgeObjects(function (err, badges) {
var badgesWithStories = _.map(badges, badgeModifierFactory(portfolio));
portfolio.badges = badgesWithStories;
portfolio.preamble = prepareText(portfolio.get('preamble'));
+
return response.render('portfolio', {
opengraph: [
{ property: 'title', content: portfolio.attributes.title },
@@ -117,7 +131,8 @@ exports.show = function (request, response, next) {
{ property: 'url', content: makeLinkUrl(request.url, configuration) }
],
portfolio: portfolio,
- message: message || ''
+ message: message || null,
+ owner: owner
});
});
};
View
4 static/css/style.css
@@ -455,6 +455,10 @@ table.information {
margin-top: 16px;
}
+.portfolio div.edit {
+ text-align: right;
+}
+
.portfolio ul {
list-style: none;
margin: 20px auto;
View
2  static/js/backpack.js
@@ -124,7 +124,7 @@ Group.View = Backbone.View.extend({
share: function (event) {
- window.location = '/share/' + this.model.get('url') + '/edit';
+ window.location = '/share/' + this.model.get('url') + '/';
return false;
},
View
5 views/portfolio.hogan.js
@@ -10,6 +10,11 @@
</div>
{{/message}}
+ {{#owner}}
+ <div class='edit'>
+ <a href="edit" class='edit btn btn-primary'>Edit this page</a>
+ </div>
+ {{/owner}}
<header>
{{#attributes.title}}<h1>{{attributes.title}}</h1>{{/attributes.title}}
Please sign in to comment.
Something went wrong with that request. Please try again.