Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:mozilla/napkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jen Fong-Adwent committed Sep 6, 2012
2 parents 70cdc3b + 515c3b6 commit 3b0b0d7
Show file tree
Hide file tree
Showing 87 changed files with 2,171 additions and 5,110 deletions.
22 changes: 18 additions & 4 deletions export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,26 @@ function renderEjsTemplate(template, attributes, screensById) {
template = template.replace(
/\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/#\{screenId\}/g, '');

/* Replaces a screen id with its corresponding title slug. Returns a function
* that should be used as a regular expression replace callback.
* Requires: format for the replacement string, where %s will be replaced
* with the slug
* Returns: regular expression replace callback assuming that the first
* capture group is the screen id
*/
function replaceLink(format) {
return function(match, screenId) {
screenId = parseInt(screenId, 10);
return format.replace(/%s/g, screensById[screenId].titleSlug);
};
}

// screen link targets need to be translated to screen routes
template = template.replace(/\/share\/#\{userId\}\/project\/#\{projectId\}\/screen\/(\d+)/g,
function(match, screenId) {
screenId = parseInt(screenId, 10);
return '/' + screensById[screenId].titleSlug;
});
replaceLink('/%s'));
template = template.replace(/\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/(\d+)/g,
replaceLink('/%s'));
template = template.replace(/\?redirect=(\d+)/, replaceLink('?redirect=%s'));

// no need for unescaped attributes
template = template.replace(/!=/g, '=');
Expand Down
Binary file added public/images/220x220.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/javascripts/collections/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(['jquery', 'backbone', './extended', 'models/component'],
function($, Backbone, ExtendedCollection, ComponentModel) {
return ExtendedCollection.extend({
url: function() {
return '/projects/' + this.options.projectId + '/screens/' +
this.options.screenId + '/components';
},

model: ComponentModel
});
});
12 changes: 12 additions & 0 deletions public/javascripts/collections/element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define(['jquery', 'backbone', './extended', 'models/element'],
function($, Backbone, ExtendedCollection, ElementModel) {
return ExtendedCollection.extend({
url: function() {
return '/projects/' + this.options.projectId + '/screens/' +
this.options.screenId + '/components/' + this.options.componentId +
'/elements';
},

model: ElementModel
});
});
15 changes: 15 additions & 0 deletions public/javascripts/collections/extended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
define(['jquery', 'backbone'],
function($, Backbone) {
var ExtendedCollection = Backbone.Collection.extend({
initialize: function(models, options) {
this.options = options;
},

constructParent: function(args) {
args = Array.prototype.slice.call(args, 0);
ExtendedCollection.prototype.initialize.apply(this, args);
}
});

return ExtendedCollection;
});
11 changes: 11 additions & 0 deletions public/javascripts/collections/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(['jquery', 'backbone', './extended', 'models/project'],
function($, Backbone, ExtendedCollection, ProjectModel) {
return ExtendedCollection.extend({
url: '/projects',
model: ProjectModel,

comparator: function(project) {
return project.get('id');
}
});
});
13 changes: 13 additions & 0 deletions public/javascripts/collections/screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define(['jquery', 'backbone', './extended', 'models/screen'],
function($, Backbone, ExtendedCollection, ScreenModel) {
return ExtendedCollection.extend({
url: function() {
return '/projects/' + this.options.projectId + '/screens';
},

model: ScreenModel,
comparator: function(screen) {
return screen.get('id');
}
});
});
64 changes: 0 additions & 64 deletions public/javascripts/controllers/component-list.js

This file was deleted.

Loading

0 comments on commit 3b0b0d7

Please sign in to comment.