prismic.io
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "grunt", | ||
"homepage": "https://github.com/gruntjs/grunt", | ||
"version": "0.4.1", | ||
"_release": "0.4.1", | ||
"version": "0.4.2", | ||
"_release": "0.4.2", | ||
"_resolution": { | ||
"type": "version", | ||
"tag": "v0.4.1", | ||
"commit": "c5cb63483aa5d0f933b914a1872b8c2366203a2e" | ||
"tag": "v0.4.2", | ||
"commit": "5ab7a3ed6885fdbf4b458d72d65d488cf9eedf48" | ||
}, | ||
"_source": "git://github.com/gruntjs/grunt.git", | ||
"_target": "~0.4.1", | ||
"_target": "~0.4.2", | ||
"_originalSource": "grunt", | ||
"_direct": true | ||
} |
@@ -53,7 +53,7 @@ /* | ||
// A fatal error occured. Abort immediately. | ||
// A fatal error occurred. Abort immediately. | ||
fail.fatal = function(e, errcode) { | ||
writeln(e, 'fatal'); | ||
dumpStack(e); | ||
process.exit(typeof errcode === 'number' ? errcode : fail.code.FATAL_ERROR); | ||
grunt.util.exit(typeof errcode === 'number' ? errcode : fail.code.FATAL_ERROR); | ||
}; | ||
@@ -65,3 +65,3 @@ | ||
// A warning ocurred. Abort immediately unless -f or --force was used. | ||
// A warning occurred. Abort immediately unless -f or --force was used. | ||
fail.warn = function(e, errcode) { | ||
@@ -75,3 +75,3 @@ var message = typeof e === 'string' ? e : e.message; | ||
grunt.log.writeln().fail('Aborted due to warnings.'); | ||
process.exit(typeof errcode === 'number' ? errcode : fail.code.WARNING); | ||
grunt.util.exit(typeof errcode === 'number' ? errcode : fail.code.WARNING); | ||
} | ||
@@ -78,0 +78,0 @@ }; |
@@ -216,2 +216,4 @@ /* | ||
file.defaultEncoding = 'utf8'; | ||
// Whether to preserve the BOM on file.read rather than strip it. | ||
file.preserveBOM = false; | ||
@@ -230,3 +232,3 @@ // Read a file, return its contents. | ||
// Strip any BOM that might exist. | ||
if (contents.charCodeAt(0) === 0xFEFF) { | ||
if (!file.preserveBOM && contents.charCodeAt(0) === 0xFEFF) { | ||
contents = contents.substring(1); | ||
@@ -233,0 +235,0 @@ } |
@@ -48,2 +48,4 @@ /* | ||
thisTask.fn = function(arg) { | ||
// Guaranteed to always be the actual task name. | ||
var name = thisTask.name; | ||
// Initialize the errorcount for this task. | ||
@@ -62,3 +64,3 @@ errorcount = grunt.fail.errorcount; | ||
this.requiresConfig = grunt.config.requires; | ||
// Return an options object with the specified defaults overriden by task- | ||
// Return an options object with the specified defaults overwritten by task- | ||
// specific overrides, via the "options" property. | ||
@@ -69,3 +71,5 @@ this.options = function() { | ||
]); | ||
return grunt.util._.extend.apply(null, args); | ||
var options = grunt.util._.extend.apply(null, args); | ||
grunt.verbose.writeflags(options, 'Options'); | ||
return options; | ||
}; | ||
@@ -234,3 +238,3 @@ // If this task was an alias or a multi task called without a target, | ||
this.requiresConfig([name, target]); | ||
// Return an options object with the specified defaults overriden by task- | ||
// Return an options object with the specified defaults overwritten by task- | ||
// and/or target-specific overrides, via the "options" property. | ||
@@ -243,3 +247,5 @@ this.options = function() { | ||
]); | ||
return grunt.util._.extend.apply(null, args); | ||
var options = grunt.util._.extend.apply(null, args); | ||
grunt.verbose.writeflags(options, 'Options'); | ||
return options; | ||
}; | ||
@@ -246,0 +252,0 @@ // Expose data on `this` (as well as task.current). |
@@ -22,6 +22,3 @@ /* | ||
util.task = require('../util/task'); | ||
util.namespace = require('../util/namespace'); | ||
// Use instead of process.exit to ensure stdout/stderr are flushed | ||
// before exiting in Windows (Tested in Node.js v0.8.7) | ||
util.exit = require('../util/exit').exit; | ||
util.namespace = require('getobject'); | ||
@@ -33,2 +30,4 @@ // External libs. | ||
var which = require('which').sync; | ||
// Instead of process.exit. See https://github.com/cowboy/node-exit | ||
util.exit = require('exit'); | ||
@@ -35,0 +34,0 @@ // Mixin Underscore.string methods. |
@@ -24,3 +24,3 @@ /* | ||
this._placeholder = {placeholder: true}; | ||
// Queue marker (for clearing the queue programatically). | ||
// Queue marker (for clearing the queue programmatically). | ||
this._marker = {marker: true}; | ||
@@ -181,3 +181,3 @@ // Options. | ||
// Add a marker to the queue to facilitate clearing it programatically. | ||
// Add a marker to the queue to facilitate clearing it programmatically. | ||
Task.prototype.mark = function() { | ||
@@ -184,0 +184,0 @@ this._push(this._marker); |
{ | ||
"name": "grunt", | ||
"description": "The JavaScript Task Runner", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"author": "\"Cowboy\" Ben Alman (http://benalman.com/)", | ||
@@ -49,24 +49,28 @@ "homepage": "http://gruntjs.com/", | ||
"coffee-script": "~1.3.3", | ||
"colors": "~0.6.0-1", | ||
"colors": "~0.6.2", | ||
"dateformat": "1.0.2-1.2.3", | ||
"eventemitter2": "~0.4.9", | ||
"findup-sync": "~0.1.0", | ||
"eventemitter2": "~0.4.13", | ||
"findup-sync": "~0.1.2", | ||
"glob": "~3.1.21", | ||
"hooker": "~0.2.3", | ||
"iconv-lite": "~0.2.5", | ||
"minimatch": "~0.2.6", | ||
"iconv-lite": "~0.2.11", | ||
"minimatch": "~0.2.12", | ||
"nopt": "~1.0.10", | ||
"rimraf": "~2.0.2", | ||
"lodash": "~0.9.0", | ||
"underscore.string": "~2.2.0rc", | ||
"rimraf": "~2.0.3", | ||
"lodash": "~0.9.2", | ||
"underscore.string": "~2.2.1", | ||
"which": "~1.0.5", | ||
"js-yaml": "~2.0.2" | ||
"js-yaml": "~2.0.5", | ||
"exit": "~0.1.1", | ||
"getobject": "~0.1.0" | ||
}, | ||
"devDependencies": { | ||
"temporary": "~0.0.4", | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt-contrib-watch": "~0.2.0", | ||
"difflet": "~0.2.3" | ||
"grunt-contrib-jshint": "~0.6.4", | ||
"grunt-contrib-nodeunit": "~0.2.0", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"difflet": "~0.2.3", | ||
"semver": "2.1.0", | ||
"shelljs": "~0.2.5" | ||
} | ||
} |
@@ -1,3 +0,9 @@ | ||
# Grunt: The JavaScript Task Runner [![Build Status](https://secure.travis-ci.org/gruntjs/grunt.png?branch=master)](http://travis-ci.org/gruntjs/grunt) | ||
# Grunt: The JavaScript Task Runner | ||
[![Build Status](https://secure.travis-ci.org/gruntjs/grunt.png?branch=master)](http://travis-ci.org/gruntjs/grunt) | ||
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) | ||
<img align="right" height="260" src="http://gruntjs.com/img/grunt-logo-no-wordmark.svg"> | ||
### Documentation | ||
@@ -10,5 +16,5 @@ | ||
You can find the grunt team in [#grunt on irc.freenode.net](irc://irc.freenode.net/#grunt). | ||
You can find the grunt team in [#grunt on irc.freenode.net](http://webchat.freenode.net/?channels=grunt). | ||
### Release History | ||
See the [CHANGELOG](CHANGELOG). |
{ | ||
"name": "prismic-js-SDK", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"homepage": "https://github.com/prismicio/javascript-kit", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -6,6 +6,6 @@ (function (Global, undefined) { | ||
/** | ||
* The kit's main entry point; initialize your API like this: Prismic.Api(url, onReady, accessToken, maybeRequestHandler) | ||
* The kit's main entry point; initialize your API like this: Prismic.Api(url, callback, accessToken, maybeRequestHandler) | ||
* | ||
* @param {string} url - The mandatory URL of the prismic.io API endpoint (like: https://lesbonneschoses.prismic.io/api) | ||
* @param {function} onReady - Optional callback function that is called after the API was retrieved, to which you may pass a parameter that is the API object | ||
* @param {function} callback - Optional callback function that is called after the API was retrieved, to which you may pass two parameters: a potential error (null if no problem), and the API object | ||
* @param {string} accessToken - The optional accessToken for the OAuth2 connection | ||
@@ -15,5 +15,5 @@ * @param {function} maybeRequestHandler - The kit knows how to handle the HTTP request in Node.js and in the browser (with Ajax); you will need to pass a maybeRequestHandler if you're in another JS environment | ||
*/ | ||
var prismic = function(url, onReady, accessToken, maybeRequestHandler) { | ||
var prismic = function(url, callback, accessToken, maybeRequestHandler) { | ||
var api = new prismic.fn.init(url, accessToken, maybeRequestHandler); | ||
onReady && api.get(onReady); | ||
callback && api.get(callback); | ||
return api; | ||
@@ -32,3 +32,3 @@ }; | ||
var resolve = function() { | ||
callback(JSON.parse(xhr.responseText)); | ||
callback(null, JSON.parse(xhr.responseText)); | ||
} | ||
@@ -39,3 +39,3 @@ | ||
var status = xhr.status; | ||
throw new Error("Unexpected status code [" + status + "]"); | ||
callback(new Error("Unexpected status code [" + status + "] on URL "+url)); | ||
} | ||
@@ -76,3 +76,3 @@ | ||
if(requestsCache[requestUrl]) { | ||
callback(requestsCache[requestUrl]); | ||
callback(null, requestsCache[requestUrl]); | ||
} else { | ||
@@ -107,6 +107,6 @@ | ||
callback(json); | ||
callback(null, json); | ||
}); | ||
} else { | ||
throw new Error("Unexpected status code [" + response.statusCode + "]") | ||
callback(new Error("Unexpected status code [" + response.statusCode + "] on URL "+requestUrl)); | ||
} | ||
@@ -135,13 +135,15 @@ }); | ||
* | ||
* @param {function} cb - Optional callback to call upon success, you may pass the API object to it | ||
* @param {function} callback - Optional callback function that is called after the query is made, to which you may pass two parameters: a potential error (null if no problem), and the API object | ||
* @returns {Api} - The Api object that can be manipulated | ||
*/ | ||
get: function(cb) { | ||
get: function(callback) { | ||
var self = this; | ||
this.requestHandler(this.url, function(data) { | ||
self.data = self.parse(data); | ||
self.bookmarks = self.data.bookmarks; | ||
if (cb) { | ||
cb(self, this); | ||
this.requestHandler(this.url, function(error, data) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
self.data = self.parse(data); | ||
self.bookmarks = self.data.bookmarks; | ||
callback(null, self, this); | ||
} | ||
@@ -376,5 +378,5 @@ }); | ||
* | ||
* @param {function} cb - Function that carries one parameter: an array of Document objects | ||
* @param {function} callback - Optional callback function that is called after the query was made, to which you may pass two parameters: a potential error (null if no problem), and the array of Document objects | ||
*/ | ||
submit: function(cb) { | ||
submit: function(callback) { | ||
var self = this, | ||
@@ -396,4 +398,6 @@ url = this.form.action; | ||
this.api.requestHandler(url, function (d) { | ||
this.api.requestHandler(url, function (err, d) { | ||
if (err) { callback(err); return; } | ||
var results = d.results || d; | ||
@@ -418,5 +422,3 @@ | ||
if (cb) { | ||
cb(docs || []); | ||
} | ||
callback(null, docs || []); | ||
}); | ||
@@ -423,0 +425,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! prismic.io 1.0.6 2014-01-10 */ | ||
!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d].default&&(this.data[d]=[b.fields[d].default])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.slugs=e,this.fragments=f}function g(a,b,c){this.ref=a,this.label=b,this.isMaster=c}var h=function(a,b,c,d){var e=new h.fn.init(a,c,d);return b&&e.get(b),e},i=function(){return"undefined"!=typeof XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(JSON.parse(c.responseText))},e=function(){var a=c.status;throw new Error("Unexpected status code ["+a+"]")};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d(c):e(c))},c.open("GET",a+"#json",!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},j=function(){if("function"==typeof require&&require("http")){{var a={},c=require("http"),d=require("https"),e=require("url");require("querystring")}return function(f,g){if(a[f])g(a[f]);else{var h=e.parse(f),i="https:"==h.protocol?d:c,j={hostname:h.hostname,path:h.path,query:h.query,headers:{Accept:"application/json"}};i.get(j,function(c){if(!c.statusCode||200!=c.statusCode)throw new Error("Unexpected status code ["+c.statusCode+"]");var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],h=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);h&&(a[f]=i),g(i)})})}}}};h.fn=h.prototype={constructor:h,data:null,get:function(a){var b=this;this.requestHandler(this.url,function(c){b.data=b.parse(c),b.bookmarks=b.data.bookmarks,a&&a(b,this)})},parse:function(a){var b,d,e,f,h,i,j,k={};for(j in a.forms)a.forms.hasOwnProperty(j)&&(i=a.forms[j],this.accessToken&&(i.fields.accessToken={type:"string","default":this.accessToken}),e=new c(i.name,i.fields,i.form_method,i.rel,i.enctype,i.action),k[j]=e);if(b=a.refs.map(function(a){return new g(a.ref,a.label,a.isMasterRef)})||[],d=b.filter(function(a){return a.isMaster===!0}),f=a.types,h=a.tags,0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:k,master:d[0],types:f,tags:h,oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||i()||j()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},h.fn.init.prototype=h.fn,c.prototype={},d.prototype={set:function(a,c){var d=this.form.fields[a];if(!d)throw new Error("Unknown field "+a);var e=this.data[a]||[];return(""===c||c===b)&&(c=null),d.multiple?null!=c&&e.push(c):e=null!=c&&[c],this.data[a]=e,this},ref:function(a){return this.set("ref",a)},query:function(a){return this.set("q",a)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var g=0;g<e.length;g++)b+=c+d+"="+encodeURIComponent(e[g]),c="&"}}this.api.requestHandler(b,function(b){var c=b.results||b,d=c.map(function(a){var b={};for(var c in a.data[a.type])b[a.type+"."+c]=a.data[a.type][c];return new f(a.id,a.type,a.href,a.tags,a.slugs,b)});a&&a(d||[])})}},f.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var d=this.get(b);if(d instanceof a.Prismic.Fragments.Image)return d.getView(c);if(d instanceof a.Prismic.Fragments.StructuredText)for(var e=0;e<d.blocks.length;e++)if("image"==d.blocks[e].type)return d.blocks[e];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Date?c.value:void 0},getBoolean:function(a){var b=this.get(a);return b.value&&("yes"==b.value.toLowerCase()||"on"==b.value.toLowerCase()||"true"==b.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.StructuredText?c:void 0},getNumber:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Number?c.value:void 0},getHtml:function(a,b){var c=this.get(a);return c&&c.asHtml?c.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")}},g.prototype={},a.Prismic={Api:h}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=a}function h(a){this.value=a}function i(a){this.value=a}function j(a){this.value=new Date(a)}function k(a){this.value=a}function l(a,b){this.main=a,this.views=b||{}}function m(a,b,c){this.url=a,this.width=b,this.height=c}function n(a,b){this.tag=a,this.blocks=b}function o(a){this.blocks=a}function p(a,b){var c,d,e=[],f=[];if(Array.isArray(a)){for(var g=0;g<a.length;g++)d=a[g],"list-item"!=d.type&&"o-list-item"!=d.type?(c=new n(d.type,[]),e.push(c)):c&&c.tag!=d.type&&(c=new n(d.type,[]),e.push(c)),c.blocks.push(d);e.forEach(function(a){if("heading1"==a.tag)f.push("<h1>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h1>");else if("heading2"==a.tag)f.push("<h2>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h2>");else if("heading3"==a.tag)f.push("<h3>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h3>");else if("paragraph"==a.tag)f.push("<p>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</p>");else if("image"==a.tag)f.push('<p><img src="'+a.blocks[0].url+'"></p>');else if("embed"==a.tag)f.push('<div data-oembed="'+a.blocks[0].embed_url+'" data-oembed-type="'+a.blocks[0].type+'" data-oembed-provider="'+a.blocks[0].provider_name+'">'+a.blocks[0].oembed.html+"</div>");else{if("list-item"!=a.tag&&"o-list-item"!=a.tag)throw new Error(a.tag+" not implemented");f.push("list-item"==a.tag?"<ul>":"<ol>"),a.blocks.forEach(function(a){f.push("<li>"+q(a.text,a.spans,b)+"</li>")}),f.push("list-item"==a.tag?"</ul>":"</ol>")}})}return f.join("")}function q(a,b,c){var d=[],e=[],f=0,g=[];return b.forEach(function(b){return b.end<b.start?a:b.start<f?a:(f=b.end,void 0)}),f=0,b.forEach(function(b){d.push(a.substring(0,b.start-f)),a=a.substring(b.start-f),f=b.start,d.push(a.substring(0,b.end-f)),a=a.substring(b.end-f),e.push(b),f=b.end}),d.push(a),e.forEach(function(a){g.push(d.shift()),"hyperlink"==a.type?(g.push('<a href="'+r(a.data).url(c)+'">'),g.push(d.shift()),g.push("</a>")):(g.push("<"+a.type+">"),g.push(d.shift()),g.push("</"+a.type+">"))}),g.push(d.shift()),g.join("")}function r(a){var n,p;switch(a.type){case"Color":n=new h(a.value);break;case"Number":n=new i(a.value);break;case"Date":n=new j(a.value);break;case"Text":n=new b(a.value);break;case"Embed":n=new k(a.value);break;case"Select":n=new g(a.value);break;case"Image":var p=a.value.main;n=new l(new m(p.url,p.dimensions.width,p.dimensions.height),{});for(var q in a.value.views){var p=a.value.views[q];n.views[q]=new m(p.url,p.dimensions.width,p.dimensions.height)}break;case"StructuredText":n=new o(a.value);break;case"Link.document":n=new c(a.value);break;case"Link.web":n=new d(a.value);break;case"Link.file":n=new e(a.value);break;case"Link.image":n=new f(a.value);break;default:console.log("Link type not supported: ",a.type)}return n}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},c.prototype={asHtml:function(a){return'<a href="'+this.url(a)+'">'+this.url(a)+"</a>"},url:function(a){return a.linkResolver(a,this.document,this.isBroken)}},d.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url}},e.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url}},f.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'"</a>'},url:function(){return this.value.image.url}},g.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},i.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},j.prototype={asText:function(){throw new Error("not implemented")},asHtml:function(){return"<time>"+this.value+"</time>"}},k.prototype={asHtml:function(){return this.oembed.html}},l.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()}},m.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return"<img src="+this.url+" width="+this.width+" height="+this.height+">"}},o.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new m(b.data.url,b.data.dimensions.width,b.data.dimensions.height)}},asHtml:function(a){return p.call(this,this.blocks,a)}},a.Prismic.Fragments={Image:l,ImageView:m,Text:b,Number:i,Date:j,Select:g,Color:h,StructuredText:o,WebLink:d,DocumentLink:c,ImageLink:f,FileLink:e,initField:r}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window); | ||
/*! prismic.io 1.0.7 2014-02-06 */ | ||
!function(a,b){"use strict";function c(a,b,c,d,e,f){this.name=a,this.fields=b,this.form_method=c,this.rel=d,this.enctype=e,this.action=f}function d(a,b,c){this.api=a,this.form=b,this.data=c||{};for(var d in b.fields)b.fields[d].default&&(this.data[d]=[b.fields[d].default])}function e(a){return this.fragments&&this.fragments[a]?Array.isArray(this.fragments[a])?this.fragments[a]:[this.fragments[a]]:[]}function f(a,b,c,d,e,f){this.id=a,this.type=b,this.href=c,this.tags=d,this.slug=e?e[0]:"-",this.slugs=e,this.fragments=f}function g(a,b,c){this.ref=a,this.label=b,this.isMaster=c}var h=function(a,b,c,d){var e=new h.fn.init(a,c,d);return b&&e.get(b),e},i=function(){return"undefined"!=typeof XMLHttpRequest?function(a,b){var c=new XMLHttpRequest,d=function(){b(null,JSON.parse(c.responseText))},e=function(){var d=c.status;b(new Error("Unexpected status code ["+d+"] on URL "+a))};c.onreadystatechange=function(){4===c.readyState&&(c.status&&200==c.status?d(c):e(c))},c.open("GET",a+"#json",!0),c.setRequestHeader("Accept","application/json"),c.send()}:void 0},j=function(){if("function"==typeof require&&require("http")){{var a={},c=require("http"),d=require("https"),e=require("url");require("querystring")}return function(f,g){if(a[f])g(null,a[f]);else{var h=e.parse(f),i="https:"==h.protocol?d:c,j={hostname:h.hostname,path:h.path,query:h.query,headers:{Accept:"application/json"}};i.get(j,function(c){if(c.statusCode&&200==c.statusCode){var d="";c.setEncoding("utf8"),c.on("data",function(a){d+=a}),c.on("end",function(){var e=c.headers["cache-control"],h=e&&/max-age=(\d+)/.test(e)?parseInt(/max-age=(\d+)/.exec(e)[1]):b,i=JSON.parse(d);h&&(a[f]=i),g(null,i)})}else g(new Error("Unexpected status code ["+c.statusCode+"] on URL "+f))})}}}};h.fn=h.prototype={constructor:h,data:null,get:function(a){var b=this;this.requestHandler(this.url,function(c,d){c?a(c):(b.data=b.parse(d),b.bookmarks=b.data.bookmarks,a(null,b,this))})},parse:function(a){var b,d,e,f,h,i,j,k={};for(j in a.forms)a.forms.hasOwnProperty(j)&&(i=a.forms[j],this.accessToken&&(i.fields.accessToken={type:"string","default":this.accessToken}),e=new c(i.name,i.fields,i.form_method,i.rel,i.enctype,i.action),k[j]=e);if(b=a.refs.map(function(a){return new g(a.ref,a.label,a.isMasterRef)})||[],d=b.filter(function(a){return a.isMaster===!0}),f=a.types,h=a.tags,0===d.length)throw"No master ref.";return{bookmarks:a.bookmarks||{},refs:b,forms:k,master:d[0],types:f,tags:h,oauthInitiate:a.oauth_initiate,oauthToken:a.oauth_token}},init:function(a,b,c){return this.url=a+(b?(a.indexOf("?")>-1?"&":"?")+"access_token="+b:""),this.accessToken=b,this.requestHandler=c||i()||j()||function(){throw new Error("No request handler available (tried XMLHttpRequest & NodeJS)")}(),this},forms:function(a){return this.form(a)},form:function(a){var b=this.data.forms[a];return b?new d(this,b,{}):void 0},master:function(){return this.data.master.ref},ref:function(a){for(var b=0;b<this.data.refs.length;b++)if(this.data.refs[b].label==a)return this.data.refs[b].ref}},h.fn.init.prototype=h.fn,c.prototype={},d.prototype={set:function(a,c){var d=this.form.fields[a];if(!d)throw new Error("Unknown field "+a);var e=this.data[a]||[];return(""===c||c===b)&&(c=null),d.multiple?null!=c&&e.push(c):e=null!=c&&[c],this.data[a]=e,this},ref:function(a){return this.set("ref",a)},query:function(a){return this.set("q",a)},submit:function(a){var b=this.form.action;if(this.data){var c=b.indexOf("?")>-1?"&":"?";for(var d in this.data){var e=this.data[d];if(e)for(var g=0;g<e.length;g++)b+=c+d+"="+encodeURIComponent(e[g]),c="&"}}this.api.requestHandler(b,function(b,c){if(b)return a(b),void 0;var d=c.results||c,e=d.map(function(a){var b={};for(var c in a.data[a.type])b[a.type+"."+c]=a.data[a.type][c];return new f(a.id,a.type,a.href,a.tags,a.slugs,b)});a(null,e||[])})}},f.prototype={get:function(b){var c=e.call(this,b);return c.length?a.Prismic.Fragments.initField(c[0]):null},getAll:function(b){return e.call(this,b).map(function(b){return a.Prismic.Fragments.initField(b)},this)},getImage:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Image?c:c instanceof a.Prismic.Fragments.StructuredText?c:null},getAllImages:function(b){var c=this.getAll(b);return c.map(function(b){if(b instanceof a.Prismic.Fragments.Image)return b;if(b instanceof a.Prismic.Fragments.StructuredText)throw new Error("Not done.");return null})},getImageView:function(b,c){var d=this.get(b);if(d instanceof a.Prismic.Fragments.Image)return d.getView(c);if(d instanceof a.Prismic.Fragments.StructuredText)for(var e=0;e<d.blocks.length;e++)if("image"==d.blocks[e].type)return d.blocks[e];return null},getAllImageViews:function(a,b){return this.getAllImages(a).map(function(a){return a.getView(b)})},getDate:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Date?c.value:void 0},getBoolean:function(a){var b=this.get(a);return b.value&&("yes"==b.value.toLowerCase()||"on"==b.value.toLowerCase()||"true"==b.value.toLowerCase())},getText:function(b,c){var d=this.get(b);return d instanceof a.Prismic.Fragments.StructuredText?d.blocks.map(function(a){return a.text?a.text+(c?c:""):void 0}).join("\n"):d instanceof a.Prismic.Fragments.Text&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Number&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Select&&d.value?d.value+(c?c:""):d instanceof a.Prismic.Fragments.Color&&d.value?d.value+(c?c:""):void 0},getStructuredText:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.StructuredText?c:void 0},getNumber:function(b){var c=this.get(b);return c instanceof a.Prismic.Fragments.Number?c.value:void 0},getHtml:function(a,b){var c=this.get(a);return c&&c.asHtml?c.asHtml(b):void 0},asHtml:function(a){var b=[];for(var c in this.fragments){var d=this.get(c);b.push(d&&d.asHtml?'<section data-field="'+c+'">'+d.asHtml(a)+"</section>":"")}return b.join("")}},g.prototype={},a.Prismic={Api:h}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window),function(a){"use strict";function b(a){this.value=a}function c(a){this.value=a,this.document=a.document,this.isBroken=a.isBroken}function d(a){this.value=a}function e(a){this.value=a}function f(a){this.value=a}function g(a){this.value=a}function h(a){this.value=a}function i(a){this.value=a}function j(a){this.value=new Date(a)}function k(a){this.value=a}function l(a,b){this.main=a,this.views=b||{}}function m(a,b,c){this.url=a,this.width=b,this.height=c}function n(a,b){this.tag=a,this.blocks=b}function o(a){this.blocks=a}function p(a,b){var c,d,e=[],f=[];if(Array.isArray(a)){for(var g=0;g<a.length;g++)d=a[g],"list-item"!=d.type&&"o-list-item"!=d.type?(c=new n(d.type,[]),e.push(c)):c&&c.tag!=d.type&&(c=new n(d.type,[]),e.push(c)),c.blocks.push(d);e.forEach(function(a){if("heading1"==a.tag)f.push("<h1>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h1>");else if("heading2"==a.tag)f.push("<h2>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h2>");else if("heading3"==a.tag)f.push("<h3>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</h3>");else if("paragraph"==a.tag)f.push("<p>"+q(a.blocks[0].text,a.blocks[0].spans,b)+"</p>");else if("image"==a.tag)f.push('<p><img src="'+a.blocks[0].url+'"></p>');else if("embed"==a.tag)f.push('<div data-oembed="'+a.blocks[0].embed_url+'" data-oembed-type="'+a.blocks[0].type+'" data-oembed-provider="'+a.blocks[0].provider_name+'">'+a.blocks[0].oembed.html+"</div>");else{if("list-item"!=a.tag&&"o-list-item"!=a.tag)throw new Error(a.tag+" not implemented");f.push("list-item"==a.tag?"<ul>":"<ol>"),a.blocks.forEach(function(a){f.push("<li>"+q(a.text,a.spans,b)+"</li>")}),f.push("list-item"==a.tag?"</ul>":"</ol>")}})}return f.join("")}function q(a,b,c){var d=[],e=[],f=0,g=[];return b.forEach(function(b){return b.end<b.start?a:b.start<f?a:(f=b.end,void 0)}),f=0,b.forEach(function(b){d.push(a.substring(0,b.start-f)),a=a.substring(b.start-f),f=b.start,d.push(a.substring(0,b.end-f)),a=a.substring(b.end-f),e.push(b),f=b.end}),d.push(a),e.forEach(function(a){g.push(d.shift()),"hyperlink"==a.type?(g.push('<a href="'+r(a.data).url(c)+'">'),g.push(d.shift()),g.push("</a>")):(g.push("<"+a.type+">"),g.push(d.shift()),g.push("</"+a.type+">"))}),g.push(d.shift()),g.join("")}function r(a){var n,p;switch(a.type){case"Color":n=new h(a.value);break;case"Number":n=new i(a.value);break;case"Date":n=new j(a.value);break;case"Text":n=new b(a.value);break;case"Embed":n=new k(a.value);break;case"Select":n=new g(a.value);break;case"Image":var p=a.value.main;n=new l(new m(p.url,p.dimensions.width,p.dimensions.height),{});for(var q in a.value.views){var p=a.value.views[q];n.views[q]=new m(p.url,p.dimensions.width,p.dimensions.height)}break;case"StructuredText":n=new o(a.value);break;case"Link.document":n=new c(a.value);break;case"Link.web":n=new d(a.value);break;case"Link.file":n=new e(a.value);break;case"Link.image":n=new f(a.value);break;default:console.log("Link type not supported: ",a.type)}return n}b.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},c.prototype={asHtml:function(a){return'<a href="'+this.url(a)+'">'+this.url(a)+"</a>"},url:function(a){return a.linkResolver(a,this.document,this.isBroken)}},d.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url}},e.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url}},f.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'"</a>'},url:function(){return this.value.image.url}},g.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},h.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},i.prototype={asHtml:function(){return"<span>"+this.value+"</span>"}},j.prototype={asText:function(){throw new Error("not implemented")},asHtml:function(){return"<time>"+this.value+"</time>"}},k.prototype={asHtml:function(){return this.oembed.html}},l.prototype={getView:function(a){return"main"===a?this.main:this.views[a]},asHtml:function(){return this.main.asHtml()}},m.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return"<img src="+this.url+" width="+this.width+" height="+this.height+">"}},o.prototype={getTitle:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if(0==b.type.indexOf("heading"))return b}},getFirstParagraph:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("paragraph"==b.type)return b}},getParagraphs:function(){for(var a=[],b=0;b<this.blocks.length;b++){var c=this.blocks[b];"paragraph"==c.type&&a.push(c)}return a},getParagraph:function(a){return this.getParagraphs()[a]},getFirstImage:function(){for(var a=0;a<this.blocks.length;a++){var b=this.blocks[a];if("image"==b.type)return new m(b.data.url,b.data.dimensions.width,b.data.dimensions.height)}},asHtml:function(a){return p.call(this,this.blocks,a)}},a.Prismic.Fragments={Image:l,ImageView:m,Text:b,Number:i,Date:j,Select:g,Color:h,StructuredText:o,WebLink:d,DocumentLink:c,ImageLink:f,FileLink:e,initField:r}}("object"==typeof exports&&exports?exports:"object"==typeof module&&module&&"object"==typeof module.exports?module.exports:window); |
module.exports = function(grunt) { | ||
/** | ||
* To bump: | ||
* * you need to be on the master branch and have a clean working tree | ||
* * edit changelog.md with what is new | ||
* * run `grunt` | ||
* * run `grunt bump` / if doesn't work: | ||
* * change version number in package.json, bower.json, and README.md | ||
* * git commit -am "Release vx.x.x" | ||
* * git tag x.x.x | ||
* * run `grunt copy`, or if it doesn't work, `cp dist/prismic.io.min.js dist/prismic.io-x.x.x.min.js` | ||
* * run `git add . && git commit -m "Freezing minified file on the master branch"` | ||
* * run `git push prismicio master --tags` | ||
* * update on npm and bower | ||
* Ideally, someday, it would be good to bump like that: | ||
* > grunt | ||
* > grunt bump | ||
* > grunt copy | ||
* > git push prismicio master --tags | ||
* But grunt bump doesn't quite work, so for now: | ||
* * run `grunt` | ||
* * change version number in package.json, bower.json, and README.md | ||
* * run `cp dist/prismic.io.min.js dist/prismic.io-x.x.x.min.js` to freeze the right minified version | ||
* * run `git add .` then `git commit -m "Release vx.x.x"` and finally `git tag x.x.x` | ||
* * run `git push https://github.com/prismicio/javascript-kit.git master --tags` | ||
* Once you're done, update npm and bower, and update the release's description if needed | ||
*/ | ||
@@ -17,0 +17,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"keywords": ["prismic", "prismic.io", "cms", "content", "api"], | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"devDependencies": { | ||
@@ -9,0 +9,0 @@ "grunt": "~0.4.1", |
@@ -10,3 +10,3 @@ ## JavaScript development kit for prismic.io | ||
``` | ||
https://raw.github.com/prismicio/javascript-kit/master/dist/prismic.io-1.0.7.min.js | ||
https://raw.github.com/prismicio/javascript-kit/master/dist/prismic.io-1.0.8.min.js | ||
``` | ||
@@ -41,3 +41,3 @@ | ||
Need to see what changed, or to upgrade your kit? Check out [this kit's changelog](changelog.md). | ||
Need to see what changed, or to upgrade your kit? We keep our changelog on [this repository's "Releases" tab](https://github.com/prismicio/javascript-kit/releases). | ||
@@ -44,0 +44,0 @@ ### Contribute to the kit |
@@ -6,6 +6,6 @@ (function (Global, undefined) { | ||
/** | ||
* The kit's main entry point; initialize your API like this: Prismic.Api(url, onReady, accessToken, maybeRequestHandler) | ||
* The kit's main entry point; initialize your API like this: Prismic.Api(url, callback, accessToken, maybeRequestHandler) | ||
* | ||
* @param {string} url - The mandatory URL of the prismic.io API endpoint (like: https://lesbonneschoses.prismic.io/api) | ||
* @param {function} onReady - Optional callback function that is called after the API was retrieved, to which you may pass a parameter that is the API object | ||
* @param {function} callback - Optional callback function that is called after the API was retrieved, to which you may pass two parameters: a potential error (null if no problem), and the API object | ||
* @param {string} accessToken - The optional accessToken for the OAuth2 connection | ||
@@ -15,5 +15,5 @@ * @param {function} maybeRequestHandler - The kit knows how to handle the HTTP request in Node.js and in the browser (with Ajax); you will need to pass a maybeRequestHandler if you're in another JS environment | ||
*/ | ||
var prismic = function(url, onReady, accessToken, maybeRequestHandler) { | ||
var prismic = function(url, callback, accessToken, maybeRequestHandler) { | ||
var api = new prismic.fn.init(url, accessToken, maybeRequestHandler); | ||
onReady && api.get(onReady); | ||
callback && api.get(callback); | ||
return api; | ||
@@ -32,3 +32,3 @@ }; | ||
var resolve = function() { | ||
callback(JSON.parse(xhr.responseText)); | ||
callback(null, JSON.parse(xhr.responseText)); | ||
} | ||
@@ -39,3 +39,3 @@ | ||
var status = xhr.status; | ||
throw new Error("Unexpected status code [" + status + "]"); | ||
callback(new Error("Unexpected status code [" + status + "] on URL "+url)); | ||
} | ||
@@ -76,3 +76,3 @@ | ||
if(requestsCache[requestUrl]) { | ||
callback(requestsCache[requestUrl]); | ||
callback(null, requestsCache[requestUrl]); | ||
} else { | ||
@@ -107,6 +107,6 @@ | ||
callback(json); | ||
callback(null, json); | ||
}); | ||
} else { | ||
throw new Error("Unexpected status code [" + response.statusCode + "]") | ||
callback(new Error("Unexpected status code [" + response.statusCode + "] on URL "+requestUrl)); | ||
} | ||
@@ -135,13 +135,15 @@ }); | ||
* | ||
* @param {function} cb - Optional callback to call upon success, you may pass the API object to it | ||
* @param {function} callback - Optional callback function that is called after the query is made, to which you may pass two parameters: a potential error (null if no problem), and the API object | ||
* @returns {Api} - The Api object that can be manipulated | ||
*/ | ||
get: function(cb) { | ||
get: function(callback) { | ||
var self = this; | ||
this.requestHandler(this.url, function(data) { | ||
self.data = self.parse(data); | ||
self.bookmarks = self.data.bookmarks; | ||
if (cb) { | ||
cb(self, this); | ||
this.requestHandler(this.url, function(error, data) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
self.data = self.parse(data); | ||
self.bookmarks = self.data.bookmarks; | ||
callback(null, self, this); | ||
} | ||
@@ -376,5 +378,5 @@ }); | ||
* | ||
* @param {function} cb - Function that carries one parameter: an array of Document objects | ||
* @param {function} callback - Optional callback function that is called after the query was made, to which you may pass two parameters: a potential error (null if no problem), and the array of Document objects | ||
*/ | ||
submit: function(cb) { | ||
submit: function(callback) { | ||
var self = this, | ||
@@ -396,4 +398,6 @@ url = this.form.action; | ||
this.api.requestHandler(url, function (d) { | ||
this.api.requestHandler(url, function (err, d) { | ||
if (err) { callback(err); return; } | ||
var results = d.results || d; | ||
@@ -418,5 +422,3 @@ | ||
if (cb) { | ||
cb(docs || []); | ||
} | ||
callback(null, docs || []); | ||
}); | ||
@@ -423,0 +425,0 @@ |
121
test/test.js
@@ -19,3 +19,4 @@ (function(Prismic) { | ||
asyncTest('Retrieve the API', 2, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
equal(Api.data.refs.length, 1); | ||
@@ -27,4 +28,16 @@ equal(Api.url, testRepository); | ||
asyncTest('Correctly handles the error if the URL is wrong', 2, function() { | ||
console.log('\n*** Note by tester: The following error is a "normal" error (see note in test.js): '); | ||
// We can't help it because whatever you do, the JS engine contains a "console.error" statement when this error occurs, | ||
// and we're exactly trying to test how the kit reacts when this error occurs. | ||
Prismic.Api(testRepository+"/errormaker", function(err, Api) { | ||
ok(err); | ||
equal(err.message, "Unexpected status code [0] on URL https://lesbonneschoses.prismic.io/api/errormaker"); | ||
start(); | ||
}); | ||
}); | ||
asyncTest('Parsing stores types and tags', 2, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
equal(Object.keys(Api.data.types).length, 6); | ||
@@ -37,3 +50,4 @@ equal(Api.data.tags.length, 4); | ||
asyncTest('Retrieve the API with master+releases privilege', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
equal(Api.data.refs.length, 3); | ||
@@ -49,4 +63,6 @@ start(); | ||
asyncTest('Submit the `everything` form', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 20); | ||
@@ -58,5 +74,18 @@ start(); | ||
asyncTest('Correctly handles the error if wrong submission', 2, function() { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').ref(Api.master()).query("wrongpredicate").submit(function(err, results) { | ||
ok(err); | ||
equal(err.message, "Unexpected status code [400] on URL https://lesbonneschoses.prismic.io/api/documents/search?page=1&pageSize=20&ref=UkL0hcuvzYUANCrm&q=wrongpredicate"); | ||
start(); | ||
}); | ||
}); | ||
}); | ||
asyncTest('Submit the `everything` form with a predicate', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "product")]]').submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "product")]]').submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 16); | ||
@@ -69,4 +98,6 @@ start(); | ||
asyncTest('Submit the `everything` form with a predicate that give no results', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "youhou")]]').submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "youhou")]]').submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 0); | ||
@@ -79,4 +110,6 @@ start(); | ||
asyncTest('Submit the `products` form', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('products').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('products').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 16); | ||
@@ -89,4 +122,6 @@ start(); | ||
asyncTest('Submit the `products` form with a predicate', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('products').ref(Api.master()).query('[[:d = at(my.product.flavour, "Chocolate")]]').submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('products').ref(Api.master()).query('[[:d = at(my.product.flavour, "Chocolate")]]').submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 5); | ||
@@ -99,4 +134,6 @@ start(); | ||
asyncTest('Submit the `products` form with an empty query', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('products').ref(Api.master()).query('').submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('products').ref(Api.master()).query('').submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 16); | ||
@@ -109,4 +146,6 @@ start(); | ||
asyncTest('Submit the `products` form in the future', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('products').ref(Api.ref('Announcement of new SF shop')).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('products').ref(Api.ref('Announcement of new SF shop')).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results.length, 17); | ||
@@ -123,4 +162,6 @@ start(); | ||
asyncTest('Stores and retrieves all document slugs well', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpV")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpV")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
var doc = results[0]; | ||
@@ -144,4 +185,6 @@ equal(doc.slugs.length, 2); | ||
}; | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
var first = results[0]; | ||
@@ -156,4 +199,6 @@ notEqual(null, first); | ||
asyncTest('StructuredTexts asHtml handles embeds and lists', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getStructuredText('blog-post.body').asHtml(), '<h1>Get the right approach to ganache</h1><p>A lot of people touch base with us to know about one of our key ingredients, and the essential role it plays in our creations: ganache.</p><p>Indeed, ganache is the macaron\'s softener, or else, macarons would be but tough biscuits; it is the cupcake\'s wrapper, or else, cupcakes would be but plain old cake. We even sometimes use ganache within our cupcakes, to soften the cake itself, or as a support to our pies\' content.</p><h2>How to approach ganache</h2><p><img src=\"https://prismic-io.s3.amazonaws.com/lesbonneschoses/ee7b984b98db4516aba2eabd54ab498293913c6c.jpg\"></p><p>Apart from the taste balance, which is always a challenge when it comes to pastry, the tough part about ganache is about thickness. It is even harder to predict through all the phases the ganache gets to meet (how long will it get melted? how long will it remain in the fridge?). Things get a hell of a lot easier to get once you consider that there are two main ways to get the perfect ganache:</p><ul><li><strong>working from the top down</strong>: start with a thick, almost hard material, and soften it by manipulating it, or by mixing it with a more liquid ingredient (like milk)</li><li><strong>working from the bottom up</strong>: start from a liquid-ish state, and harden it by miwing it with thicker ingredients, or by leaving it in the fridge longer.</li></ul><p>We do hope this advice will empower you in your ganache-making skills. Let us know how you did with it!</p><h2>Ganache at <em>Les Bonnes Choses</em></h2><p>We have a saying at Les Bonnes Choses: \"Once you can make ganache, you can make anything.\"</p><p>As you may know, we like to give our workshop artists the ability to master their art to the top; that is why our Preparation Experts always start off as being Ganache Specialists for Les Bonnes Choses. That way, they\'re given an opportunity to focus on one exercise before moving on. Once they master their ganache, and are able to provide the most optimal delight to our customers, we consider they\'ll thrive as they work on other kinds of preparations.</p><h2>About the chocolate in our ganache</h2><p>Now, we\'ve also had a lot of questions about how our chocolate gets made. It\'s true, as you might know, that we make it ourselves, from Columbian cocoa and French cow milk, with a process that much resembles the one in the following Discovery Channel documentary.</p><div data-oembed=\"undefined\" data-oembed-type=\"embed\" data-oembed-provider=\"undefined\"><iframe width=\"459\" height=\"344\" src=\"http://www.youtube.com/embed/Ye78F3-CuXY?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe></div>'); | ||
@@ -166,4 +211,6 @@ start(); | ||
asyncTest('StructuredTexts asHtml handles spans', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCps")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCps")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getStructuredText('blog-post.body').asHtml(), '<h1>The end of a chapter the beginning of a new one</h1><p><img src="https://prismic-io.s3.amazonaws.com/lesbonneschoses/8181933ff2f5032daff7d732e33a3beb6f57e09f.jpg"></p><p>Jean-Michel Pastranova, the founder of <em>Les Bonnes Choses</em>, and creator of the whole concept of modern fine pastry, has decided to step down as the CEO and the Director of Workshops of <em>Les Bonnes Choses</em>, to focus on other projects, among which his now best-selling pastry cook books, but also to take on a primary role in a culinary television show to be announced later this year.</p><p>"I believe I\'ve taken the <em>Les Bonnes Choses</em> concept as far as it can go. <em>Les Bonnes Choses</em> is already an entity that is driven by its people, thanks to a strong internal culture, so I don\'t feel like they need me as much as they used to. I\'m sure they are greater ways to come, to innovate in pastry, and I\'m sure <em>Les Bonnes Choses</em>\'s coming innovation will be even more mind-blowing than if I had stayed longer."</p><p>He will remain as a senior advisor to the board, and to the workshop artists, as his daughter Selena, who has been working with him for several years, will fulfill the CEO role from now on.</p><p>"My father was able not only to create a revolutionary concept, but also a company culture that puts everyone in charge of driving the company\'s innovation and quality. That gives us years, maybe decades of revolutionary ideas to come, and there\'s still a long, wonderful path to walk in the fine pastry world."</p>'); | ||
@@ -176,4 +223,6 @@ start(); | ||
asyncTest('StructuredTexts asHtml handles span Link.web', 1, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCph")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCph")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getStructuredText('job-offer.profile').asHtml(), '<p>As a company whose marketing is very content-centric, we expect our Content Director to have a tremendous experience, both in content strategy, and in content writing. We expect our applicants to show off some of the content strategies they set up themselves, explaining their choices, and to provide amazing contents they personally wrote.</p><p>Our contents get flexibly powerfully shared on various supports: our site, our in-store printed magazine, our mobile apps, our mailings ... Our Content Director must have experience with all of those, and with using modern adaptive content managers such as <a href=\"http://prismic.io\">prismic.io</a>.</p>'); | ||
@@ -196,4 +245,6 @@ start(); | ||
}; | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpo")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpo")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getStructuredText('blog-post.body').asHtml(ctx), '<h1>Our world-famous Pastry Art Brainstorm event</h1><p><img src=\"https://prismic-io.s3.amazonaws.com/lesbonneschoses/c38f9e5a1a6c43aa7aae516c154013a2cee2bc75.jpg\"></p><p>Each year, <em>Les Bonnes Choses</em> organizes a world-famous two-day event called the \"Pastry Art Brainstorm\", and which is the perfect excuse for every fine pastry artist in the world to exercise their art, and build their skills up. The event is a multiple win-win operation, at many levels: see what the event is, as seen by many point of views.</p><h2>As seen by the top pastry artists worldwide</h2><p>The event always starts with half a day of conference talks, given by the most insightful pastry artists in the world, selected for having made tremendous achievements in pastry that year. The list of invited guest speakers is decided jointly by the <em>Les Bonnes Choses</em> staff and the Fine Pastry Magazine editors.</p><p>This is great for the speakers, who get an occasion to share their work, and have people build up on it with them.</p><h2>As seen by the pastry professionals</h2><p>After half a day of thoughtful conference, the professionals will get to put what they learned to good use, and mingle with the best artists worldwide to make the most daring pastries together. There are no set rules about who does what during this giant innovation workshop, and many crazy ideas get created out of thin air. As a virtually infinite amount of ingredients is provided by the <em>Les Bonnes Choses</em> staff, many unexpected pastries happen on that day, and professionals taste each other\'s creations, and provide relevant feedback to each other. Most pieces get showcased to the amateur audience as well, who get invited to taste some of the pieces.</p><p>At noon on the second day, teams are expected to subscribe to our Pastry Art Challenge, during which they will make the best possible pastry, judged on many aspects (originality, taste, looks, ...) by a jury of amateurs and professionals. The team members of the three winning pieces share a substantial prize, and their pastries may even join the Les Bonnes Choses catalogue, and be offered in all the <em>Les Bonnes Choses</em> shops worldwide!</p><h2>As seen by the pastry amateurs</h2><p>The conference is limited with a reasonable fee; but the showcase is open to everyone, although visitors are often expected to pay the pastry chefs for the pastries they taste. The educated amateurs spend their day tasting the most daring pieces, giving some appreciated feedback to their chefs, and challenging their own tastebuds. The novice amateurs usually get a once-in-a-lifetime experience, and often mention being blown away by how rich the fine pastry art can be. All in all, every one goes home with a smile on their faces!</p><h2>As seen by the Les Bonnes Choses interns</h2><p>Every year, we recruit a very limited amount of interns, who get aboard a <a href=\"/testing_url/UkL0gMuvzYUANCpp/les-bonnes-chosess-internship-a-testimony?ref=XXXXX\">life-defining adventure around fine pastries</a>, discovering <em>Les Bonnes Choses</em> during half a year, with part of this time spent in one of our shops abroad. We always manage to get them on board at a time when we know they will be able to attend a Fine Pastry Brainstorm, because we consider it is a very defining element in the experience of being part of <em>Les Bonnes Choses</em>.</p><p>Not only do we invite them to the event (whatever the country they are stationed in when the event happens), but we give them a front-row seat! They are part of the jury for the Fine Pastry Challenge, they are introduced to every speaker as the next generation of pastry (thus having the occasion to learn even more, directly from them).</p><h2>As seen by fine pastry as a field</h2><p>There wasn\'t really an international occasion for pastry artists to join and share, before <em>Les Bonnes Choses</em> came up with the first Fine Pastry Brainstorm, in 2006. Fine Pastry Magazine\'s first edition was out in 2004, and initiated the idea that pastry art needed to be shared better between professionals. But a proper event to meet up in person was missing, and <em>Les Bonnes Choses</em> is proud to be the one to have come up with it first.</p><p>Since then, more local initiatives have been started (notably in Argentina, and Canada), but none comes close to the size of <em>Les Bonnes Choses</em>\'s international Fine Pastry Brainstorm.</p><h2>As seen by <em>Les Bonnes Choses</em></h2><p>As the almost only sponsor of every edition of the event, <em>Les Bonnes Choses</em> makes sure enough ingredients are available for everyone, rents the premises, makes sure the speakers are as comfortable as possible, and takes care of the whole organization! But through the operation, <em>Les Bonnes Choses</em> gains much more than any sponsoring can buy: not only does it get to secure <em>Les Bonnes Choses</em> as the world reference in pastry arts, but it also allows them to claim rightfully that they do offer in their shops the best pastries, created by the world top artists indeed.</p>'); | ||
@@ -223,4 +274,6 @@ start(); | ||
}; | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getAll('blog-post.relatedpost')[0].asHtml(ctx), '<a href="/testing_url/UkL0gMuvzYUANCpn/tips-to-dress-a-pastry?ref=XXXXX">/testing_url/UkL0gMuvzYUANCpn/tips-to-dress-a-pastry?ref=XXXXX</a>'); | ||
@@ -233,4 +286,6 @@ start(); | ||
asyncTest('ImageViews are well retrieved', 2, function() { | ||
Prismic.Api(testRepository, function(Api) { | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpR")]]').ref(Api.master()).submit(function(results) { | ||
Prismic.Api(testRepository, function(err, Api) { | ||
if (err) { console.log(err); return; } | ||
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpR")]]').ref(Api.master()).submit(function(err, results) { | ||
if (err) { console.log(err); return; } | ||
equal(results[0].getImageView('product.image', 'main').asHtml(), '<img src=https://prismic-io.s3.amazonaws.com/lesbonneschoses/f606ad513fcc2a73b909817119b84d6fd0d61a6d.png width=500 height=500>'); | ||
@@ -237,0 +292,0 @@ equal(results[0].getImageView('product.image', 'icon').asHtml(), '<img src=https://prismic-io.s3.amazonaws.com/lesbonneschoses/fe4f9379ee325456992d48204b8d94aeb60cc976.png width=250 height=250>'); |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
11552
3
511783
56
6
23