commonplace
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "commonplace", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"repository": { | ||
@@ -13,3 +13,2 @@ "url": "git://github.com/mozilla/commonplace.git", | ||
"dependencies": { | ||
"bower": "0.9.x", | ||
"clean-css": "1.0.x", | ||
@@ -21,4 +20,5 @@ "nunjucks": "0.1.9", | ||
"bin": { | ||
"damper": "./bin/damper" | ||
"damper": "./bin/damper", | ||
"commonplace": "./bin/commonplace" | ||
} | ||
} |
@@ -5,8 +5,10 @@ # Commonplace | ||
## Installation | ||
## Getting Started | ||
### Getting node/npm | ||
### Install node/npm | ||
#### OS X | ||
Use `boxen` to install a node environment, or use `homebrew`: | ||
```bash | ||
@@ -21,1 +23,26 @@ brew install node | ||
``` | ||
### Setting up your repo | ||
Create a new repository for your project. In it, create a basic `package.json` file. You can do this very easily by running `npm init`. | ||
Next, install commonplace by running `npm install commonplace --save`. | ||
### Creating the commonplace base template | ||
At this point, simply run `commonplace install`. Running this command will create a `src/` directory in your project containing the minimum files needed to run your code. Other directories will also be created for L10n and other functions. | ||
## Updating Commonplace | ||
Once you've run an `npm update`, you'll be running the latest commonplace scripts, but your modules will be out of date. | ||
To update your commonplace installation, simply run `commonplace update` from the root of your project. Commonplace will update all of the shared modules in-place. | ||
## Things that haven't been built yet | ||
* `commonplace update` | ||
* `commonplace lint` | ||
* L10n tools | ||
* a bunch of other stuff |
define('builder', | ||
['templates', 'models', 'requests', 'settings', 'z', 'nunjucks.compat'], | ||
function(nunjucks, models, requests, settings, z) { | ||
['log', 'templates', 'models', 'requests', 'settings', 'z', 'nunjucks.compat'], | ||
function(log, nunjucks, models, requests, settings, z) { | ||
var console = log('builder'); | ||
var SafeString = nunjucks.require('runtime').SafeString; | ||
@@ -50,6 +51,3 @@ | ||
for (var i in extension) { | ||
if (defaults && i in base) { | ||
continue; | ||
} | ||
if (extension.hasOwnProperty(i)) { | ||
if (!(defaults && i in base) && extension.hasOwnProperty(i)) { | ||
base[i] = extension[i]; | ||
@@ -94,2 +92,3 @@ } | ||
injector(url, el.parentNode, target).done(function() { | ||
console.log('Pagination completed'); | ||
fire(page, 'loaded_more'); | ||
@@ -136,3 +135,3 @@ }).fail(function() { | ||
// `as` passes the data to the models for caching. | ||
if (!dont_cast && 'as' in signature) { | ||
if (data && !dont_cast && 'as' in signature) { | ||
console.groupCollapsed('Casting ' + signature.as + 's to model cache...'); | ||
@@ -143,3 +142,3 @@ models(signature.as).cast(data); | ||
var content = ''; | ||
if (empty && Array.isArray(data) && data.length === 0) { | ||
if (empty && (!data || Array.isArray(data) && data.length === 0)) { | ||
content = empty(); | ||
@@ -164,6 +163,7 @@ } else { | ||
var rendered; | ||
// This will run synchronously. | ||
request.done(function(data) { | ||
context.ctx['response'] = data; | ||
out = get_result(data, true); | ||
rendered = get_result(data, true); | ||
@@ -191,2 +191,9 @@ // Now update the response with the values from the model cache | ||
}); | ||
if (replace) { | ||
parse_and_replace(rendered, replace); | ||
} else { | ||
out = rendered; | ||
} | ||
if (signature.paginate) { | ||
@@ -193,0 +200,0 @@ pool.done(function() { |
(function() { | ||
var languages = [ | ||
'bg', 'ca', 'cs', 'de', 'en-US', 'es', 'eu', 'fr', 'ga-IE', 'hr', 'it', 'ja', | ||
'pl', 'pt-BR', 'sk', 'zh-TW', 'dbg' | ||
'bg', 'ca', 'cs', 'de', 'en-US', 'es', 'eu', 'fr', 'ga-IE', 'hr', 'hu', 'it', | ||
'ja', 'nl', 'pl', 'pt-BR', 'ru', 'sk', 'zh-TW', 'dbg' | ||
]; | ||
@@ -7,0 +7,0 @@ |
@@ -7,10 +7,2 @@ define('login', | ||
function flush_caches() { | ||
// We need to flush the global cache | ||
var cat_url = urls.api.url('categories'); | ||
cache.purge(function(key) {return key != cat_url;}); | ||
models('app').purge(); | ||
} | ||
function signOutNotification() { | ||
@@ -37,4 +29,3 @@ notification.notification({message: gettext('You have been signed out')}); | ||
z.body.removeClass('logged-in'); | ||
z.page.trigger('reload_chrome'); | ||
flush_caches(); | ||
z.page.trigger('reload_chrome').trigger('before_logout'); | ||
@@ -99,3 +90,3 @@ if (!capabilities.phantom) { | ||
flush_caches(); | ||
z.page.trigger('before_login'); | ||
@@ -102,0 +93,0 @@ requests.post(urls.api.url('login'), data).done(function(data) { |
@@ -90,2 +90,7 @@ define('requests', | ||
xhr.addEventListener('load', function() { | ||
if (xhr.getResponseHeader('API-Status') === 'Deprecated') { | ||
callHooks('deprecated', [xhr]); | ||
} | ||
var statusCode = xhr.status / 100 | 0; | ||
@@ -123,9 +128,16 @@ if (statusCode < 2 || statusCode > 3) { | ||
return def.promise(xhr); | ||
} | ||
function ajax() { | ||
var def = _ajax.apply(this, arguments); | ||
var type = arguments[0]; | ||
// then() returns a new promise, so don't return that. | ||
def.then(function() { | ||
callHooks('success', arguments); | ||
}, function() { | ||
}, function(xhr, error, status) { | ||
callHooks('failure', arguments); | ||
handle_errors(xhr, type, status); | ||
}); | ||
return def.promise(xhr); | ||
return def; | ||
} | ||
@@ -145,3 +157,3 @@ | ||
console.log('GETing', url); | ||
return _ajax('GET', url).done(function(data, xhr) { | ||
return ajax('GET', url).done(function(data, xhr) { | ||
console.log('GOT', url); | ||
@@ -154,4 +166,4 @@ if (!nocache) { | ||
function handle_errors(xhr, status) { | ||
console.log('Request failed: ', status); | ||
function handle_errors(xhr, type, status) { | ||
console.log('Request failed:', type, status); | ||
if (xhr.responseText) { | ||
@@ -171,3 +183,5 @@ try { | ||
console.log('DELETing', url); | ||
return _ajax('DELETE', url).fail(handle_errors); | ||
return ajax('DELETE', url).done(function() { | ||
console.log('DELETEd', url); | ||
}); | ||
} | ||
@@ -177,3 +191,5 @@ | ||
console.log('PATCHing', url); | ||
return _ajax('PATCH', url, data).fail(handle_errors); | ||
return ajax('PATCH', url, data).done(function() { | ||
console.log('PATCHed', url); | ||
}); | ||
} | ||
@@ -183,5 +199,5 @@ | ||
console.log('POSTing', url); | ||
return _ajax('POST', url, data).done(function(data) { | ||
return ajax('POST', url, data).done(function() { | ||
console.log('POSTed', url); | ||
}).fail(handle_errors); | ||
}); | ||
} | ||
@@ -191,3 +207,5 @@ | ||
console.log('PUTing', url); | ||
return _ajax('PUT', url, data).fail(handle_errors); | ||
return ajax('PUT', url, data).done(function() { | ||
console.log('PUT', url); | ||
}); | ||
} | ||
@@ -266,2 +284,3 @@ | ||
(hooks[event] = hooks[event] || []).push(callback); | ||
return {'on': on}; // For great chaining. | ||
} | ||
@@ -268,0 +287,0 @@ |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
794151
4
66
9580
47
5
- Removedbower@0.9.x
- Removedabbrev@1.0.9(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi@0.3.1(transitive)
- Removedansi-styles@1.0.0(transitive)
- Removedarchy@0.0.2(transitive)
- Removedargparse@1.0.10(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbinary@0.3.0(transitive)
- Removedblock-stream@0.0.9(transitive)
- Removedbower@0.9.2(transitive)
- Removedbuffers@0.1.1(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchainsaw@0.1.0(transitive)
- Removedchalk@0.4.0(transitive)
- Removedcolors@0.6.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedconfig-chain@0.3.4(transitive)
- Removedconfigstore@0.3.2(transitive)
- Removedcore-util-is@1.0.21.0.3(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedesprima@4.0.1(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedfstream@0.1.31(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglob@3.1.21(transitive)
- Removedgraceful-fs@1.1.141.2.33.0.12(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-color@0.1.7(transitive)
- Removedhogan.js@2.0.0(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedinherits@1.0.22.0.4(transitive)
- Removedini@1.0.5(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@0.0.1(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlodash@1.0.2(transitive)
- Removedlru-cache@2.0.42.7.3(transitive)
- Removedmatch-stream@0.0.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimatch@0.2.14(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedmute-stream@0.0.8(transitive)
- Removednatives@1.1.6(transitive)
- Removednopt@2.0.0(transitive)
- Removednpmlog@0.1.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-assign@2.1.1(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedover@0.0.5(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpromptly@0.1.0(transitive)
- Removedproto-list@1.2.4(transitive)
- Removedpsl@1.14.0(transitive)
- Removedpullstream@0.4.1(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrc@0.0.8(transitive)
- Removedread@1.0.7(transitive)
- Removedread-package-json@0.1.13(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.11.42.88.2(transitive)
- Removedrimraf@2.0.3(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsemver@1.1.42.3.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedslice-stream@1.0.0(transitive)
- Removedslide@1.1.6(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstable@0.1.8(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstrip-ansi@0.1.1(transitive)
- Removedtar@0.1.20(transitive)
- Removedtmp@0.0.33(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtraverse@0.3.9(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedunzip@0.1.7(transitive)
- Removedupdate-notifier@0.1.10(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduser-home@1.1.1(transitive)
- Removeduuid@2.0.33.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedxdg-basedir@1.0.1(transitive)