commonplace
Advanced tools
Comparing version 0.5.7 to 0.6.0
@@ -5,3 +5,3 @@ { | ||
"description": "Reusable components for the Firefox Marketplace", | ||
"version": "0.5.7", | ||
"version": "0.6.0", | ||
"ignore": [ | ||
@@ -8,0 +8,0 @@ "bin", |
@@ -46,2 +46,38 @@ define('login', | ||
function logIn(data) { | ||
var should_reload = !user.logged_in(); | ||
user.set_token(data.token, data.settings); | ||
user.update_permissions(data.permissions); | ||
user.update_apps(data.apps); | ||
console.log('Login succeeded, preparing the app'); | ||
z.body.addClass('logged-in'); | ||
$('.loading-submit').removeClass('loading-submit'); | ||
z.page.trigger('reload_chrome').trigger('logged_in'); | ||
function resolve_pending() { | ||
_.invoke(pending_logins, 'resolve'); | ||
pending_logins = []; | ||
} | ||
if (should_reload && !z.context.dont_reload_on_login) { | ||
require('views').reload().done(function() { | ||
resolve_pending(); | ||
signInNotification(); | ||
}); | ||
} else { | ||
console.log('Reload on login aborted by current view'); | ||
} | ||
} | ||
function logInFailed(message) { | ||
message = message || gettext('Sign in failed'); | ||
notification.notification({message: message}); | ||
$('.loading-submit').removeClass('loading-submit'); | ||
z.page.trigger('login_fail'); | ||
_.invoke(pending_logins, 'reject'); | ||
pending_logins = []; | ||
} | ||
z.body.on('click', '.persona', function(e) { | ||
@@ -110,24 +146,2 @@ e.preventDefault(); | ||
if (capabilities.fallbackFxA()) { | ||
window.addEventListener('message', function (msg) { | ||
if (!msg.data || !msg.data.auth_code || msg.origin !== settings.api_url) { | ||
return; | ||
} | ||
var data = { | ||
'auth_response': msg.data.auth_code, | ||
'state': settings.fxa_auth_state | ||
}; | ||
z.page.trigger('before_login'); | ||
requests.post(urls.api.url('fxa-login'), data).done(function(data) { | ||
user.set_token(data.token, data.settings); | ||
user.update_permissions(data.permissions); | ||
user.update_apps(data.apps); | ||
console.log('Login succeeded, preparing the app'); | ||
z.body.addClass('logged-in'); | ||
$('.loading-submit').removeClass('loading-submit'); | ||
z.page.trigger('reload_chrome').trigger('logged_in'); | ||
_.invoke(pending_logins, 'resolve'); | ||
pending_logins = []; | ||
}); | ||
}, false); | ||
var fxa_url; | ||
@@ -194,29 +208,5 @@ if (user.canMigrate()) { | ||
requests.post(urls.api.url('login'), data).done(function(data) { | ||
var should_reload = !user.logged_in(); | ||
user.set_token(data.token, data.settings); | ||
user.update_permissions(data.permissions); | ||
user.update_apps(data.apps); | ||
console.log('Login succeeded, preparing the app'); | ||
z.body.addClass('logged-in'); | ||
$('.loading-submit').removeClass('loading-submit'); | ||
z.page.trigger('reload_chrome').trigger('logged_in'); | ||
function resolve_pending() { | ||
_.invoke(pending_logins, 'resolve'); | ||
pending_logins = []; | ||
} | ||
if (should_reload && !z.context.dont_reload_on_login) { | ||
require('views').reload().done(function() { | ||
resolve_pending(); | ||
signInNotification(); | ||
}); | ||
} else { | ||
console.log('Reload on login aborted by current view'); | ||
} | ||
}).fail(function(jqXHR, textStatus, error) { | ||
requests.post(urls.api.url('login'), data) | ||
.done(logIn) | ||
.fail(function(jqXHR, textStatus, error) { | ||
console.warn('Assertion verification failed!', textStatus, error); | ||
@@ -233,8 +223,3 @@ | ||
} | ||
$('.loading-submit').removeClass('loading-submit'); | ||
notification.notification({message: err}); | ||
z.page.trigger('login_fail'); | ||
_.invoke(pending_logins, 'reject'); | ||
pending_logins = []; | ||
logInFailed(err); | ||
}); | ||
@@ -309,2 +294,12 @@ } | ||
function registerFxAPostMessageHandler() { | ||
window.addEventListener('message', function (msg) { | ||
if (!msg.data || !msg.data.auth_code || | ||
msg.origin !== settings.api_url) { | ||
return; | ||
} | ||
handle_fxa_login(msg.data.auth_code); | ||
}); | ||
} | ||
siteConfig.promise.done(function(data) { | ||
@@ -322,2 +317,5 @@ if (!capabilities.fallbackFxA()) { | ||
z.body.addClass('persona-loaded'); | ||
// Register the "message" handler here to avoid it being registered | ||
// multiple times. | ||
registerFxAPostMessageHandler(); | ||
} | ||
@@ -335,6 +333,21 @@ }); | ||
function handle_fxa_login(auth_code, state) { | ||
var loginData = { | ||
'auth_response': auth_code, | ||
'state': state || settings.fxa_auth_state, | ||
}; | ||
z.page.trigger('before_login'); | ||
requests.post(urls.api.url('fxa-login'), loginData) | ||
.done(logIn) | ||
.fail(function(jqXHR, textStatus, error) { | ||
console.warn('FxA login failed', jqXHR, textStatus, error); | ||
logInFailed(); | ||
}); | ||
} | ||
return { | ||
login: startLogin, | ||
get_fxa_auth_url: get_fxa_auth_url | ||
get_fxa_auth_url: get_fxa_auth_url, | ||
handle_fxa_login: handle_fxa_login, | ||
}; | ||
}); |
var amdOptimize = require('amd-optimize'); | ||
var fs = require('fs'); | ||
var glob = require('glob'); | ||
@@ -7,4 +8,3 @@ var gulp = require('gulp'); | ||
var eventStream = require('event-stream'); | ||
var uglify = require('gulp-uglify'); | ||
var gulpUtil = require('gulp-util'); | ||
var gulpFile = require('gulp-file'); | ||
var ignore = require('gulp-ignore'); | ||
@@ -17,4 +17,7 @@ var insert = require("gulp-insert"); | ||
var stylus = require('gulp-stylus'); | ||
var uglify = require('gulp-uglify'); | ||
var gulpUtil = require('gulp-util'); | ||
var webserver = require('gulp-webserver'); | ||
var mergeStream = require('merge-stream'); | ||
var path = require('path'); | ||
var requireDir = require('require-dir'); | ||
@@ -130,9 +133,19 @@ var _ = require('underscore'); | ||
return gulp.src([paths.css].concat(excludes)) | ||
// Determine which CSS files and which order to concat through index.html. | ||
var css_files = []; | ||
var data = fs.readFileSync(path.resolve('src', 'index.html')); | ||
data = data.toString(); | ||
var css_pattern = new RegExp('href="/media/css/(.+.css)"', 'g'); | ||
while (match = css_pattern.exec(data)) { | ||
css_files.push(match[1]); | ||
} | ||
css_src = css_files.map(function(css) { | ||
return config.CSS_DEST_PATH + css; | ||
}); | ||
return gulp.src(css_src.concat(excludes)) | ||
.pipe(stylus({compress: true})) | ||
.pipe(imgurlsCachebust()) | ||
.pipe(imgurlsAbsolutify()) | ||
.pipe(minifyCSS()) | ||
// Order by base styles first. | ||
.pipe(order(['base/*.styl.css', '*.styl.css'], | ||
.pipe(order(css_files, | ||
{base: config.CSS_DEST_PATH})) | ||
@@ -148,2 +161,3 @@ .pipe(concat(paths.include_css)) | ||
return gulp.src(config.CSS_DEST_PATH + paths.include_css) | ||
.pipe(imgurlsAbsolutify()) | ||
.pipe(imgurlsParse()) | ||
@@ -155,3 +169,11 @@ .pipe(rename('imgurls.txt')) | ||
gulp.task('js_build', function() { | ||
gulp.task('buildID_write', function() { | ||
// Writes build ID to src/media/build_id.txt. | ||
var buildID = new Date().getTime().toString(); | ||
return gulpFile('build_id.txt', buildID) | ||
.pipe(gulp.dest('src/media')); | ||
}); | ||
gulp.task('js_build', ['templates_build'], function() { | ||
// Uses the AMD optimizer to bundle our JS modules. | ||
@@ -223,4 +245,4 @@ // Will read our RequireJS config to handle shims, paths, and name | ||
gulp.task('update', ['bower_copy', 'require_config']); | ||
gulp.task('build', ['css_build', 'js_build', 'templates_build', | ||
'imgurls_write']); | ||
gulp.task('build', ['buildID_write', 'css_build', 'js_build', | ||
'templates_build', 'imgurls_write']); | ||
@@ -227,0 +249,0 @@ |
@@ -61,3 +61,5 @@ var CORE_MODULES = [ | ||
// 'nunjucks/browser/nunjucks-slim.js': LIB_DEST_PATH, | ||
'underscore/underscore.js': LIB_DEST_PATH | ||
'underscore/underscore.js': LIB_DEST_PATH, | ||
'commonplace/dist/core-templates/tests.html': 'src/templates/commonplace/', | ||
'commonplace/dist/core/tests/**/*.js': 'src/tests/commonplace/' | ||
}; | ||
@@ -64,0 +66,0 @@ CORE_MODULES.forEach(function(module) { |
{ | ||
"name": "commonplace", | ||
"description": "Reusable components for Firefox Marketplace frontend projects.", | ||
"version": "0.5.7", | ||
"version": "0.6.0", | ||
"main": "lib/commonplace", | ||
@@ -6,0 +6,0 @@ "preferGlobal": true, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
885101
321
7357
8