Socket
Socket
Sign inDemoInstall

prismic.io

Package Overview
Dependencies
Maintainers
2
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prismic.io - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

bower.json

14

changelog.md
## Changelog for prismic.io JavaScript development kit
### 1.0.6
#### Potentially breaking changes
* None
#### Bugfixes
* Fixed issues with the embed fragments, and `Prismic.Fragments.Embed.asHtml()`
* Fixed issues with the "Link.file" and "Link.image" types of links (which now have their own classes)
* Previous slugs were inaccessible for a document (therefore, it was impossible in the projects to redirect a document properly when the slug is simply obsolete); now in new fields `Prismic.Doc.slugs`
#### New features
* Access to the repository's tags and types in the `Prismic.Api` object
* Support for bower
* Waiting for the [JSDoc bug](#10) to be fixed, the documentation within the code and in the README was much improved
### 1.0.5

@@ -5,0 +19,0 @@

376

dist/prismic.io.js

@@ -5,4 +5,11 @@ (function (Global, undefined) {

// -- Main entry point
/**
* The kit's main entry point; initialize your API like this: Prismic.Api(url, onReady, 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 {string} accessToken - The optional accessToken for the OAuth2 connection
* @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
* @returns {Api} - The Api object that can be manipulated
*/
var prismic = function(url, onReady, accessToken, maybeRequestHandler) {

@@ -109,3 +116,6 @@ var api = new prismic.fn.init(url, accessToken, maybeRequestHandler);

// --
/**
* The Api object you can manipulate, notably to perform queries in your repository.
* Most useful fields: bookmarks, refs, types, tags, ...
*/

@@ -117,3 +127,9 @@ prismic.fn = prismic.prototype = {

// Retrieve and parse the entry document
/**
* Requests (with the proper handler), parses, and returns the /api document.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*
* @param {function} cb - Optional callback to call upon success, you may pass the API object to it
* @returns {Api} - The Api object that can be manipulated
*/
get: function(cb) {

@@ -132,2 +148,9 @@ var self = this;

/**
* Parses and returns the /api document.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*
* @param {string} data - The JSON document responded on the API's endpoint
* @returns {Api} - The Api object that can be manipulated
*/
parse: function(data) {

@@ -138,2 +161,4 @@ var refs,

form,
types,
tags,
f,

@@ -179,2 +204,6 @@ i;

types = data.types;
tags = data.tags;
if (master.length === 0) {

@@ -189,2 +218,4 @@ throw ("No master ref.");

master: master[0],
types: types,
tags: tags,
oauthInitiate: data['oauth_initiate'],

@@ -196,2 +227,6 @@ oauthToken: data['oauth_token']

/**
* Initialisation of the API object.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*/
init: function(url, accessToken, maybeRequestHandler) {

@@ -204,3 +239,6 @@ this.url = url + (accessToken ? (url.indexOf('?') > -1 ? '&' : '?') + 'access_token=' + accessToken : '');

// For compatibility
/**
* @deprecated use form() now
* Returns a useable form from its id, as described in the RESTful description of the API.
*/
forms: function(formId) {

@@ -210,2 +248,9 @@ return this.form(formId);

/**
* Returns a useable form from its id, as described in the RESTful description of the API.
* For instance: api.form("everything") works on every repository (as "everything" exists by default)
* You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit()
*
* @returns {SearchForm} - the SearchForm that can be used.
*/
form: function(formId) {

@@ -218,2 +263,9 @@ var form = this.data.forms[formId];

/**
* The ID of the master ref on this prismic.io API.
* Do not use like this: searchForm.ref(api.master()).
* Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.
*
* @returns {string}
*/
master: function() {

@@ -223,2 +275,9 @@ return this.data.master.ref;

/**
* Returns the ref ID for a given ref's label.
* Do not use like this: searchForm.ref(api.ref("Future release label")).
* Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.
*
* @returns {string}
*/
ref: function(label) {

@@ -236,2 +295,5 @@ for(var i=0; i<this.data.refs.length; i++) {

/**
* Embodies a submittable RESTful form as described on the API endpoint (as per RESTful standards)
*/
function Form(name, fields, form_method, rel, enctype, action) {

@@ -249,4 +311,3 @@ this.name = name;

/**
* Creates a SearchForm objects from scratch. To create SearchForm objects
* that are allowed in the API, please use the API.forms() method.
* Embodies a SearchForm object. To create SearchForm objects that are allowed in the API, please use the API.form() method.
* @constructor

@@ -273,3 +334,3 @@ */

* Please prefer using dedicated methods like query(), orderings(), ...
*
*
* @param {string} field - The name of the field to set

@@ -300,3 +361,3 @@ * @param {string} value - The value that gets assigned

* will not work.
*
*
* @param {Ref} ref - The Ref object defining the ref to query

@@ -313,3 +374,3 @@ * @returns {SearchForm} - The SearchForm itself

* You can pass an empty string, the method will simply not send that query.
*
*
* @param {string} query - The query to perform

@@ -324,3 +385,3 @@ * @returns {SearchForm} - The SearchForm itself

* Submits the query, and calls the callback function.
*
*
* @param {function} cb - Function that carries one parameter: an array of Document objects

@@ -375,11 +436,15 @@ */

function getFragments(field) {
if (!this.fragments || !this.fragments[field]) {
/**
* An array of the fragments with the given fragment name.
* The array is often a single-element array, expect when the field is a multiple field.
*/
function getFragments(name) {
if (!this.fragments || !this.fragments[name]) {
return [];
}
if (Array.isArray(this.fragments[field])) {
return this.fragments[field];
if (Array.isArray(this.fragments[name])) {
return this.fragments[name];
} else {
return [this.fragments[field]];
return [this.fragments[name]];
}

@@ -389,2 +454,6 @@

/**
* Embodies a document as returned by the API.
* Most useful fields: id, type, tags, slug, slugs, ...
*/
function Doc(id, type, href, tags, slugs, fragments) {

@@ -397,2 +466,3 @@

this.slug = slugs ? slugs[0] : "-";
this.slugs = slugs;
this.fragments = fragments;

@@ -407,12 +477,18 @@ }

*
* @param {string} field - The name of the field to get, with its type; for instance, "blog-post.author"
* @returns {object} - The json object to manipulate
* @param {string} name - The name of the field to get, with its type; for instance, "blog-post.author"
* @returns {object} - The JavaScript Fragment object to manipulate
*/
get: function(field) {
var frags = getFragments.call(this, field);
get: function(name) {
var frags = getFragments.call(this, name);
return frags.length ? Global.Prismic.Fragments.initField(frags[0]) : null;
},
getAll: function(field) {
return getFragments.call(this, field).map(function (fragment) {
/**
* Builds an array of all the fragments in case they are multiple.
*
* @param {string} name - The name of the multiple fragment to get, with its type; for instance, "blog-post.author"
* @returns {array} - An array of each JavaScript fragment object to manipulate.
*/
getAll: function(name) {
return getFragments.call(this, name).map(function (fragment) {
return Global.Prismic.Fragments.initField(fragment);

@@ -591,10 +667,10 @@ }, this);

* @param {string} field - The name of the field to get, with its type; for instance, "blog-post.body"
* @param {function} linkResolver - The function to apply to resolve found links, with one parameter: the current ref
* @param {function} ctx - The ctx object that contains the context: ctx.api, ctx.ref, ctx.maybeRef, ctx.oauth(), et ctx.linkResolver()
* @returns {string} - The HTML output
*/
getHtml: function(field, linkResolver) {
getHtml: function(field, ctx) {
var fragment = this.get(field);
if(fragment && fragment.asHtml) {
return fragment.asHtml(linkResolver);
return fragment.asHtml(ctx);
}

@@ -621,2 +697,5 @@ },

/**
* Embodies a prismic.io ref (a past or future point in time you can query )
*/
function Ref(ref, label, isMaster) {

@@ -641,2 +720,5 @@ this.ref = ref;

/**
* Embodies a plain text fragment (beware: not a structured text)
*/
function Text(data) {

@@ -646,2 +728,8 @@ this.value = data;

Text.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -652,2 +740,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a document link fragment (a link that is internal to a prismic.io repository)
*/
function DocumentLink(data) {

@@ -659,7 +750,26 @@ this.value = data;

DocumentLink.prototype = {
asHtml: function () {
return "<a></a>";
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @params {object} ctx - mandatory ctx object, with a useable linkResolver function (please read prismic.io online documentation about this)
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function (ctx) {
return "<a href=\""+this.url(ctx)+"\">"+this.url(ctx)+"</a>";
},
/**
* Returns the URL of the document link.
*
* @params {object} ctx - mandatory ctx object, with a useable linkResolver function (please read prismic.io online documentation about this)
* @returns {string} - the proper URL to use
*/
url: function (ctx) {
return ctx.linkResolver(ctx, this.document, this.isBroken);
}
};
/**
* Embodies a web link fragment
*/
function WebLink(data) {

@@ -669,7 +779,76 @@ this.value = data;

WebLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href='"+this.value.url+"'>"+this.value.url+"</a>";
return "<a href=\""+this.url()+"\">"+this.url()+"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.url;
}
};
/**
* Embodies a file link fragment
*/
function FileLink(data) {
this.value = data;
}
FileLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href=\""+this.url()+"\">"+this.value.file.name+"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.file.url;
}
};
/**
* Embodies an image link fragment
*/
function ImageLink(data) {
this.value = data;
}
ImageLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href=\""+this.url()+"\"><img src=\""+this.url()+"\"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.image.url;
}
};
/**
* Embodies a select fragment
*/
function Select(data) {

@@ -679,2 +858,8 @@ this.value = data;

Select.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -685,2 +870,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a color fragment
*/
function Color(data) {

@@ -690,2 +878,8 @@ this.value = data;

Color.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -696,2 +890,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a Number fragment
*/
function Num(data) {

@@ -701,2 +898,8 @@ this.value = data;

Num.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -707,2 +910,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a DateTime fragment
*/
function DateTime(data) {

@@ -716,3 +922,8 @@ this.value = new Date(data);

},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -723,2 +934,5 @@ return "<time>" + this.value + "</time>";

/**
* Embodies an embed fragment
*/
function Embed(data) {

@@ -729,7 +943,16 @@ this.value = data;

Embed.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<span>" + this.value + "</span>";
return this.oembed.html;
}
};
/**
* Embodies an Image fragment
*/
function ImageEl(main, views) {

@@ -740,9 +963,21 @@ this.main = main;

ImageEl.prototype = {
getView: function (key) {
/**
* Gets the view of the image, from its name
*
* @param {string} name - the name of the view to get
* @returns {ImageView} - the proper view
*/
getView: function(name) {
if (key === "main") {
return this.main;
} else {
return this.views[key];
return this.views[name];
}
},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -753,2 +988,5 @@ return this.main.asHtml()

/**
* Embodies an image view (an image in prismic.io can be defined with several different thumbnail sizes, each size is called a "view")
*/
function ImageView(url, width, height) {

@@ -763,3 +1001,8 @@ this.url = url;

},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -775,3 +1018,5 @@ return "<img src=" + this.url + " width=" + this.width + " height=" + this.height + ">";

/**
* Embodies a structured text fragment
*/
function StructuredText(blocks) {

@@ -831,2 +1076,8 @@

/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function(ctx) {

@@ -838,2 +1089,9 @@ return StructuredTextAsHtml.call(this, this.blocks, ctx);

/**
* Transforms a list of blocks as proper HTML.
*
* @param {array} blocks - the array of blocks to deal with
* @param {object} ctx - the context object, containing the linkResolver function to build links that may be in the fragment (please read prismic.io's online documentation about this)
* @returns {string} - the HTML output
*/
function StructuredTextAsHtml (blocks, ctx) {

@@ -902,19 +1160,10 @@

//Takes in a link of any type (Link.web or Link.document etc) and returns a uri to use inside of a link tag or such
//Should pass in linkResolver when support added for that
function linkToURI(link, ctx){
if(link.type == "Link.web") {
return link.value.url
}
else if(link.type == "Link.image") {
return link.value.image.url;
}
else if(link.type == "Link.document") {
return ctx.linkResolver(ctx, link.value.document, link.value.document.isBroken);
}
else {
throw new Error(link.type+" not implemented in linkToURI");
}
}
/**
* Parses a block that has spans, and inserts the proper HTML code.
*
* @param {string} text - the original text of the block
* @param {object} span - the spans as returned by the API
* @param {object} ctx - the context object, containing the linkResolver function to build links that may be in the fragment (please read prismic.io's online documentation about this)
* @returns {string} - the HTML output
*/
function insertSpans(text, spans, ctx) {

@@ -949,3 +1198,4 @@ var textBits = [];

if(tag.type == "hyperlink"){
html.push('<a href="'+ linkToURI(tag.data, ctx) +'">');
// Since the content of tag.data is similar to a link fragment, we can initialize it just like a fragment.
html.push('<a href="'+ initField(tag.data).url(ctx) +'">');
html.push(textBits.shift());

@@ -964,2 +1214,8 @@ html.push('</a>');

/**
* From a fragment's name, casts it into the proper object type (like Prismic.Fragments.StructuredText)
*
* @param {string} field - the fragment's name
* @returns {object} - the object of the proper Fragments type.
*/
function initField(field) {

@@ -989,3 +1245,3 @@

case "Embed":
throw new Error("not implemented");
output = new Embed(field.value);
break;

@@ -1021,4 +1277,12 @@

case "Link.file":
output = new FileLink(field.value);
break;
case "Link.image":
output = new ImageLink(field.value);
break;
default:
console.log("Type not found:", field.type);
console.log("Link type not supported: ", field.type);
break;

@@ -1040,2 +1304,6 @@ }

StructuredText: StructuredText,
WebLink: WebLink,
DocumentLink: DocumentLink,
ImageLink: ImageLink,
FileLink: FileLink,
initField: initField

@@ -1042,0 +1310,0 @@ }

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
*/
grunt.initConfig({
VERSION: '1.0.5',
VERSION: grunt.file.readJSON('bower.json').version,
pkg: grunt.file.readJSON('package.json'),
qunit: {

@@ -14,3 +27,3 @@ files: ['test/**/*.html']

clean: {
src: ['dist']
src: ['dist/prismic.io.js','dist/prismic.io.min.js']
},

@@ -31,6 +44,29 @@

src: 'dist/prismic.io.js',
dest: 'dist/prismic.io.min.js'
}
},
copy: {
main: {
src: 'dist/prismic.io.min.js',
dest: 'dist/prismic.io-<%= VERSION %>.min.js'
}
}
},
bump: {
options: {
files: ['package.json', 'bower.json', 'README.md'],
updateConfigs: [],
commit: false,
commitMessage: 'Release v%VERSION%',
commitFiles: ['-a'], // '-a' for all files
createTag: true,
tagName: '%VERSION%',
tagMessage: 'Version %VERSION%',
push: false,
pushTo: 'upstream',
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
}
},
});

@@ -43,2 +79,4 @@

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-bump');

@@ -48,2 +86,8 @@ // Default task.

// bump task to increment version numbers in bower.json and package.json, and create a git tag. Remember to push your tag if you want a release available on bower.
grunt.registerTask('bump', ['bump']);
// copying the minified file to freeze it as this version on the master (can not be done before bump)
grunt.registerTask('copy', ['copy']);
};

7

package.json

@@ -6,3 +6,3 @@ {

"keywords": ["prismic", "prismic.io", "cms", "content", "api"],
"version": "1.0.5",
"version": "1.0.6",
"devDependencies": {

@@ -13,5 +13,8 @@ "grunt": "~0.4.1",

"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.2"
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-copy": "~0.5.0",
"grunt-bump":"~0.0.13"
},
"repository" : { "type" : "git", "url" : "http://github.com/prismicio/javascript-kit.git" },
"main": "dist/prismic.io"
}
## JavaScript development kit for prismic.io
### Minified, ready to use, version
### Getting started
You can find the latest version of the library at:
#### Install the kit
You can find the minified latest (unstable) version of the library at:
```
https://github.com/prismicio/repository/raw/master/javascript/prismic.io-1.0.5.min.js
https://raw.github.com/prismicio/javascript-kit/master/dist/prismic.io-1.0.6.min.js
```
*(you may need to adapt the version number)*
You can install a stable version using __npm__:
Or fetch it from __npm__:
```sh

@@ -19,13 +19,55 @@ npm install prismic.io

#### Getting started with prismic.io
Or using __bower__:
On our [prismic.io developer's portal](https://developers.prismic.io/), on top of the complete documentation, you will:
* get a better understanding of [what prismic.io is and how to get started with it](https://developers.prismic.io/documentation/UjBaQsuvzdIHvE4D/getting-started).
* get a thorough understanding of [how prismic.io kits work](https://developers.prismic.io/documentation/UjBe8bGIJ3EKtgBZ/api-documentation#kits-and-helpers), including this one.
* see [what else is available for Javascript](https://developers.prismic.io/technologies/UjBh28uvzeMJvE4i/javascript): starter kits, examples, ...
```sh
bower install prismic.io
```
#### Changelog
#### Get started with prismic.io
You can find out [how to get started with prismic.io](https://developers.prismic.io/documentation/UjBaQsuvzdIHvE4D/getting-started) on our [prismic.io developer's portal](https://developers.prismic.io/).
#### Get started using the kit
Also on our [prismic.io developer's portal](https://developers.prismic.io/), on top of our full documentation, you will:
* get a thorough introduction of [how to use prismic.io kits](https://developers.prismic.io/documentation/UjBe8bGIJ3EKtgBZ/api-documentation#kits-and-helpers), including this one.
* see [what else is available for Javascript](https://developers.prismic.io/technologies/UjBh28uvzeMJvE4i/javascript): starter projects, examples, ...
You can also browse the [full documentation of the JS development kit](http://prismicio.github.io/javascript-kit/) (there is currently a known [issue](#10) about it)
### Changelog
Need to see what changed, or to upgrade your kit? Check out [this kit's changelog](changelog.md).
### Contribute to the kit
Contribution is open to all developer levels, read our "[Contribute to the official kits](https://developers.prismic.io/documentation/UszOeAEAANUlwFpp/contribute-to-the-official-kits)" documentation to learn more.
#### Install the kit locally
You can simply execute this JavaScript kit with a web browser, but more advanced users can feel free to use grunt tasks.
To install grunt and other required packages: [install Node.js and npm](http://www.joyent.com/blog/installing-node-and-npm/), and then run this from your kit's repository, as an administrator:
```
npm install -g grunt
npm install
```
#### Test
Please write tests in [test/test.js](test/test.js) for any bugfix or new feature, following the [very simple QUnit syntax](http://qunitjs.com/).
Execute the tests either by opening [test/test.html](test/test.html) in a browser, or by running ```grunt qunit```.
If you find existing code that is not optimally tested and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.
#### Documentation
Please document any new feature or bugfix using the [JSDoc](http://usejsdoc.org/) syntax. You don't need to generate the documentation, we'll do that.
If you feel an existing area of code is lacking documentation, feel free to write it; but please do so on its own branch and pull-request.
If you find existing code that is not optimally documented and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.
### Licence

@@ -32,0 +74,0 @@

@@ -5,4 +5,11 @@ (function (Global, undefined) {

// -- Main entry point
/**
* The kit's main entry point; initialize your API like this: Prismic.Api(url, onReady, 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 {string} accessToken - The optional accessToken for the OAuth2 connection
* @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
* @returns {Api} - The Api object that can be manipulated
*/
var prismic = function(url, onReady, accessToken, maybeRequestHandler) {

@@ -109,3 +116,6 @@ var api = new prismic.fn.init(url, accessToken, maybeRequestHandler);

// --
/**
* The Api object you can manipulate, notably to perform queries in your repository.
* Most useful fields: bookmarks, refs, types, tags, ...
*/

@@ -117,3 +127,9 @@ prismic.fn = prismic.prototype = {

// Retrieve and parse the entry document
/**
* Requests (with the proper handler), parses, and returns the /api document.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*
* @param {function} cb - Optional callback to call upon success, you may pass the API object to it
* @returns {Api} - The Api object that can be manipulated
*/
get: function(cb) {

@@ -132,2 +148,9 @@ var self = this;

/**
* Parses and returns the /api document.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*
* @param {string} data - The JSON document responded on the API's endpoint
* @returns {Api} - The Api object that can be manipulated
*/
parse: function(data) {

@@ -138,2 +161,4 @@ var refs,

form,
types,
tags,
f,

@@ -179,2 +204,6 @@ i;

types = data.types;
tags = data.tags;
if (master.length === 0) {

@@ -189,2 +218,4 @@ throw ("No master ref.");

master: master[0],
types: types,
tags: tags,
oauthInitiate: data['oauth_initiate'],

@@ -196,2 +227,6 @@ oauthToken: data['oauth_token']

/**
* Initialisation of the API object.
* This is for internal use, from outside this kit, you should call Prismic.Api()
*/
init: function(url, accessToken, maybeRequestHandler) {

@@ -204,3 +239,6 @@ this.url = url + (accessToken ? (url.indexOf('?') > -1 ? '&' : '?') + 'access_token=' + accessToken : '');

// For compatibility
/**
* @deprecated use form() now
* Returns a useable form from its id, as described in the RESTful description of the API.
*/
forms: function(formId) {

@@ -210,2 +248,9 @@ return this.form(formId);

/**
* Returns a useable form from its id, as described in the RESTful description of the API.
* For instance: api.form("everything") works on every repository (as "everything" exists by default)
* You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit()
*
* @returns {SearchForm} - the SearchForm that can be used.
*/
form: function(formId) {

@@ -218,2 +263,9 @@ var form = this.data.forms[formId];

/**
* The ID of the master ref on this prismic.io API.
* Do not use like this: searchForm.ref(api.master()).
* Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.
*
* @returns {string}
*/
master: function() {

@@ -223,2 +275,9 @@ return this.data.master.ref;

/**
* Returns the ref ID for a given ref's label.
* Do not use like this: searchForm.ref(api.ref("Future release label")).
* Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.
*
* @returns {string}
*/
ref: function(label) {

@@ -236,2 +295,5 @@ for(var i=0; i<this.data.refs.length; i++) {

/**
* Embodies a submittable RESTful form as described on the API endpoint (as per RESTful standards)
*/
function Form(name, fields, form_method, rel, enctype, action) {

@@ -249,4 +311,3 @@ this.name = name;

/**
* Creates a SearchForm objects from scratch. To create SearchForm objects
* that are allowed in the API, please use the API.forms() method.
* Embodies a SearchForm object. To create SearchForm objects that are allowed in the API, please use the API.form() method.
* @constructor

@@ -273,3 +334,3 @@ */

* Please prefer using dedicated methods like query(), orderings(), ...
*
*
* @param {string} field - The name of the field to set

@@ -300,3 +361,3 @@ * @param {string} value - The value that gets assigned

* will not work.
*
*
* @param {Ref} ref - The Ref object defining the ref to query

@@ -313,3 +374,3 @@ * @returns {SearchForm} - The SearchForm itself

* You can pass an empty string, the method will simply not send that query.
*
*
* @param {string} query - The query to perform

@@ -324,3 +385,3 @@ * @returns {SearchForm} - The SearchForm itself

* Submits the query, and calls the callback function.
*
*
* @param {function} cb - Function that carries one parameter: an array of Document objects

@@ -375,11 +436,15 @@ */

function getFragments(field) {
if (!this.fragments || !this.fragments[field]) {
/**
* An array of the fragments with the given fragment name.
* The array is often a single-element array, expect when the field is a multiple field.
*/
function getFragments(name) {
if (!this.fragments || !this.fragments[name]) {
return [];
}
if (Array.isArray(this.fragments[field])) {
return this.fragments[field];
if (Array.isArray(this.fragments[name])) {
return this.fragments[name];
} else {
return [this.fragments[field]];
return [this.fragments[name]];
}

@@ -389,2 +454,6 @@

/**
* Embodies a document as returned by the API.
* Most useful fields: id, type, tags, slug, slugs, ...
*/
function Doc(id, type, href, tags, slugs, fragments) {

@@ -397,2 +466,3 @@

this.slug = slugs ? slugs[0] : "-";
this.slugs = slugs;
this.fragments = fragments;

@@ -407,12 +477,18 @@ }

*
* @param {string} field - The name of the field to get, with its type; for instance, "blog-post.author"
* @returns {object} - The json object to manipulate
* @param {string} name - The name of the field to get, with its type; for instance, "blog-post.author"
* @returns {object} - The JavaScript Fragment object to manipulate
*/
get: function(field) {
var frags = getFragments.call(this, field);
get: function(name) {
var frags = getFragments.call(this, name);
return frags.length ? Global.Prismic.Fragments.initField(frags[0]) : null;
},
getAll: function(field) {
return getFragments.call(this, field).map(function (fragment) {
/**
* Builds an array of all the fragments in case they are multiple.
*
* @param {string} name - The name of the multiple fragment to get, with its type; for instance, "blog-post.author"
* @returns {array} - An array of each JavaScript fragment object to manipulate.
*/
getAll: function(name) {
return getFragments.call(this, name).map(function (fragment) {
return Global.Prismic.Fragments.initField(fragment);

@@ -591,10 +667,10 @@ }, this);

* @param {string} field - The name of the field to get, with its type; for instance, "blog-post.body"
* @param {function} linkResolver - The function to apply to resolve found links, with one parameter: the current ref
* @param {function} ctx - The ctx object that contains the context: ctx.api, ctx.ref, ctx.maybeRef, ctx.oauth(), et ctx.linkResolver()
* @returns {string} - The HTML output
*/
getHtml: function(field, linkResolver) {
getHtml: function(field, ctx) {
var fragment = this.get(field);
if(fragment && fragment.asHtml) {
return fragment.asHtml(linkResolver);
return fragment.asHtml(ctx);
}

@@ -621,2 +697,5 @@ },

/**
* Embodies a prismic.io ref (a past or future point in time you can query )
*/
function Ref(ref, label, isMaster) {

@@ -623,0 +702,0 @@ this.ref = ref;

@@ -5,2 +5,5 @@ (function (Global, undefined) {

/**
* Embodies a plain text fragment (beware: not a structured text)
*/
function Text(data) {

@@ -10,2 +13,8 @@ this.value = data;

Text.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -16,2 +25,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a document link fragment (a link that is internal to a prismic.io repository)
*/
function DocumentLink(data) {

@@ -23,7 +35,26 @@ this.value = data;

DocumentLink.prototype = {
asHtml: function () {
return "<a></a>";
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @params {object} ctx - mandatory ctx object, with a useable linkResolver function (please read prismic.io online documentation about this)
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function (ctx) {
return "<a href=\""+this.url(ctx)+"\">"+this.url(ctx)+"</a>";
},
/**
* Returns the URL of the document link.
*
* @params {object} ctx - mandatory ctx object, with a useable linkResolver function (please read prismic.io online documentation about this)
* @returns {string} - the proper URL to use
*/
url: function (ctx) {
return ctx.linkResolver(ctx, this.document, this.isBroken);
}
};
/**
* Embodies a web link fragment
*/
function WebLink(data) {

@@ -33,7 +64,76 @@ this.value = data;

WebLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href='"+this.value.url+"'>"+this.value.url+"</a>";
return "<a href=\""+this.url()+"\">"+this.url()+"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.url;
}
};
/**
* Embodies a file link fragment
*/
function FileLink(data) {
this.value = data;
}
FileLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href=\""+this.url()+"\">"+this.value.file.name+"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.file.url;
}
};
/**
* Embodies an image link fragment
*/
function ImageLink(data) {
this.value = data;
}
ImageLink.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<a href=\""+this.url()+"\"><img src=\""+this.url()+"\"</a>";
},
/**
* Returns the URL of the link.
*
* @returns {string} - the proper URL to use
*/
url: function() {
return this.value.image.url;
}
};
/**
* Embodies a select fragment
*/
function Select(data) {

@@ -43,2 +143,8 @@ this.value = data;

Select.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -49,2 +155,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a color fragment
*/
function Color(data) {

@@ -54,2 +163,8 @@ this.value = data;

Color.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -60,2 +175,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a Number fragment
*/
function Num(data) {

@@ -65,2 +183,8 @@ this.value = data;

Num.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -71,2 +195,5 @@ return "<span>" + this.value + "</span>";

/**
* Embodies a DateTime fragment
*/
function DateTime(data) {

@@ -80,3 +207,8 @@ this.value = new Date(data);

},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -87,2 +219,5 @@ return "<time>" + this.value + "</time>";

/**
* Embodies an embed fragment
*/
function Embed(data) {

@@ -93,7 +228,16 @@ this.value = data;

Embed.prototype = {
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {
return "<span>" + this.value + "</span>";
return this.oembed.html;
}
};
/**
* Embodies an Image fragment
*/
function ImageEl(main, views) {

@@ -104,9 +248,21 @@ this.main = main;

ImageEl.prototype = {
getView: function (key) {
/**
* Gets the view of the image, from its name
*
* @param {string} name - the name of the view to get
* @returns {ImageView} - the proper view
*/
getView: function(name) {
if (key === "main") {
return this.main;
} else {
return this.views[key];
return this.views[name];
}
},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -117,2 +273,5 @@ return this.main.asHtml()

/**
* Embodies an image view (an image in prismic.io can be defined with several different thumbnail sizes, each size is called a "view")
*/
function ImageView(url, width, height) {

@@ -127,3 +286,8 @@ this.url = url;

},
/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function () {

@@ -139,3 +303,5 @@ return "<img src=" + this.url + " width=" + this.width + " height=" + this.height + ">";

/**
* Embodies a structured text fragment
*/
function StructuredText(blocks) {

@@ -195,2 +361,8 @@

/**
* Turns the fragment into a useable HTML version of it.
* If the native HTML code doesn't suit your design, this function is meant to be overriden.
*
* @returns {string} - basic HTML code for the fragment
*/
asHtml: function(ctx) {

@@ -202,2 +374,9 @@ return StructuredTextAsHtml.call(this, this.blocks, ctx);

/**
* Transforms a list of blocks as proper HTML.
*
* @param {array} blocks - the array of blocks to deal with
* @param {object} ctx - the context object, containing the linkResolver function to build links that may be in the fragment (please read prismic.io's online documentation about this)
* @returns {string} - the HTML output
*/
function StructuredTextAsHtml (blocks, ctx) {

@@ -266,19 +445,10 @@

//Takes in a link of any type (Link.web or Link.document etc) and returns a uri to use inside of a link tag or such
//Should pass in linkResolver when support added for that
function linkToURI(link, ctx){
if(link.type == "Link.web") {
return link.value.url
}
else if(link.type == "Link.image") {
return link.value.image.url;
}
else if(link.type == "Link.document") {
return ctx.linkResolver(ctx, link.value.document, link.value.document.isBroken);
}
else {
throw new Error(link.type+" not implemented in linkToURI");
}
}
/**
* Parses a block that has spans, and inserts the proper HTML code.
*
* @param {string} text - the original text of the block
* @param {object} span - the spans as returned by the API
* @param {object} ctx - the context object, containing the linkResolver function to build links that may be in the fragment (please read prismic.io's online documentation about this)
* @returns {string} - the HTML output
*/
function insertSpans(text, spans, ctx) {

@@ -313,3 +483,4 @@ var textBits = [];

if(tag.type == "hyperlink"){
html.push('<a href="'+ linkToURI(tag.data, ctx) +'">');
// Since the content of tag.data is similar to a link fragment, we can initialize it just like a fragment.
html.push('<a href="'+ initField(tag.data).url(ctx) +'">');
html.push(textBits.shift());

@@ -328,2 +499,8 @@ html.push('</a>');

/**
* From a fragment's name, casts it into the proper object type (like Prismic.Fragments.StructuredText)
*
* @param {string} field - the fragment's name
* @returns {object} - the object of the proper Fragments type.
*/
function initField(field) {

@@ -353,3 +530,3 @@

case "Embed":
throw new Error("not implemented");
output = new Embed(field.value);
break;

@@ -385,4 +562,12 @@

case "Link.file":
output = new FileLink(field.value);
break;
case "Link.image":
output = new ImageLink(field.value);
break;
default:
console.log("Type not found:", field.type);
console.log("Link type not supported: ", field.type);
break;

@@ -404,2 +589,6 @@ }

StructuredText: StructuredText,
WebLink: WebLink,
DocumentLink: DocumentLink,
ImageLink: ImageLink,
FileLink: FileLink,
initField: initField

@@ -406,0 +595,0 @@ }

@@ -14,2 +14,6 @@ (function(Prismic) {

/************************************/
/* API document retrieval & parsing */
/************************************/
asyncTest('Retrieve the API', 2, function() {

@@ -23,5 +27,24 @@ Prismic.Api(testRepository, function(Api) {

asyncTest('Parsing stores types and tags', 2, function() {
Prismic.Api(testRepository, function(Api) {
equal(Object.keys(Api.data.types).length, 6);
equal(Api.data.tags.length, 4);
start();
});
});
asyncTest('Retrieve the API with master+releases privilege', 1, function() {
Prismic.Api(testRepository, function(Api) {
equal(Api.data.refs.length, 3);
start();
}, previewToken);
});
/************************/
/* API form submissions */
/************************/
asyncTest('Submit the `everything` form', 1, function() {
Prismic.Api(testRepository, function(Api) {
Api.forms('everything').ref(Api.master()).submit(function(results) {
Api.form('everything').ref(Api.master()).submit(function(results) {
equal(results.length, 20);

@@ -35,3 +58,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').ref(Api.master()).query('[[:d = at(document.type, "product")]]').submit(function(results) {
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "product")]]').submit(function(results) {
equal(results.length, 16);

@@ -45,3 +68,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').ref(Api.master()).query('[[:d = at(document.type, "youhou")]]').submit(function(results) {
Api.form('everything').ref(Api.master()).query('[[:d = at(document.type, "youhou")]]').submit(function(results) {
equal(results.length, 0);

@@ -55,3 +78,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('products').ref(Api.master()).submit(function(results) {
Api.form('products').ref(Api.master()).submit(function(results) {
equal(results.length, 16);

@@ -65,3 +88,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('products').ref(Api.master()).query('[[:d = at(my.product.flavour, "Chocolate")]]').submit(function(results) {
Api.form('products').ref(Api.master()).query('[[:d = at(my.product.flavour, "Chocolate")]]').submit(function(results) {
equal(results.length, 5);

@@ -75,3 +98,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('products').ref(Api.master()).query('').submit(function(results) {
Api.form('products').ref(Api.master()).query('').submit(function(results) {
equal(results.length, 16);

@@ -83,27 +106,44 @@ start();

asyncTest('Render a document to Html', 1, function() {
asyncTest('Submit the `products` form in the future', 1, function() {
Prismic.Api(testRepository, function(Api) {
Api.forms('everything').ref(Api.master()).submit(function(results) {
var first = results[0];
notEqual(null, first);
first.asHtml();
Api.form('products').ref(Api.ref('Announcement of new SF shop')).submit(function(results) {
equal(results.length, 17);
start();
});
});
}, previewToken);
});
asyncTest('Retrieve the API with master+releases privilege', 1, function() {
/*************************/
/* Document manipulation */
/*************************/
asyncTest('Stores and retrieves all document slugs well', 1, function() {
Prismic.Api(testRepository, function(Api) {
equal(Api.data.refs.length, 3);
start();
}, previewToken);
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpV")]]').ref(Api.master()).submit(function(results) {
var doc = results[0];
equal(doc.slugs.length, 2);
start();
});
});
});
asyncTest('Submit the `products` form in the future', 1, function() {
asyncTest('Render a document to Html', 1, function() {
var ctx = {
api: undefined,
ref: { ref: 'XXXXX', label: 'Future release', isMaster: false },
maybeRef: 'XXXXX',
oauth: function() { },
linkResolver: function(ctx, doc, isBroken) {
if (isBroken) return '#broken';
return "/testing_url/"+doc.id+"/"+doc.slug+( ctx.maybeRef ? '?ref=' + ctx.maybeRef : '' );
}
};
Prismic.Api(testRepository, function(Api) {
Api.forms('products').ref(Api.ref('Announcement of new SF shop')).submit(function(results) {
equal(results.length, 17);
Api.form('everything').ref(Api.master()).submit(function(results) {
var first = results[0];
notEqual(null, first);
first.asHtml(ctx);
start();
});
}, previewToken);
});
});

@@ -113,3 +153,3 @@

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(results) {
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(results) {
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>');

@@ -123,3 +163,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCps")]]').ref(Api.master()).submit(function(results) {
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCps")]]').ref(Api.master()).submit(function(results) {
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>');

@@ -133,3 +173,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCph")]]').ref(Api.master()).submit(function(results) {
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCph")]]').ref(Api.master()).submit(function(results) {
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>');

@@ -153,3 +193,3 @@ start();

Prismic.Api(testRepository, function(Api) {
Api.forms('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpo")]]').ref(Api.master()).submit(function(results) {
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpo")]]').ref(Api.master()).submit(function(results) {
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>');

@@ -161,2 +201,28 @@ start();

asyncTest('StructuredTexts asHtml handles span Link.file', 1, function() {
var jsonString = '{"type":"StructuredText","value":[{"type":"paragraph","text":"2012 Annual Report","spans":[{"start":0,"end":18,"type":"hyperlink","data":{"type":"Link.file","value":{"file":{"name":"2012_annual.report.pdf","kind":"document","url":"https://prismic-io.s3.amazonaws.com/annual.report.pdf","size":"1282484"}}}}]},{"type":"paragraph","text":"2012 Annual Budget","spans":[{"start":0,"end":18,"type":"hyperlink","data":{"type":"Link.file","value":{"file":{"name":"2012_smec.annual.budget.pdf","kind":"document","url":"https://prismic-io.s3.amazonaws.com/annual.budget.pdf","size":"59229"}}}}]},{"type":"paragraph","text":"2015 Vision & Strategic Plan","spans":[{"start":0,"end":28,"type":"hyperlink","data":{"type":"Link.file","value":{"file":{"name":"2015_vision.strategic.plan_.sm_.pdf","kind":"document","url":"https://prismic-io.s3.amazonaws.com/vision.strategic.plan_.sm_.pdf","size":"1969956"}}}}]}]}';
var jsonObject = eval("(" + jsonString + ')');
equal(Prismic.Fragments.initField(jsonObject).asHtml(), '<p><a href=\"https://prismic-io.s3.amazonaws.com/annual.report.pdf\">2012 Annual Report</a></p><p><a href=\"https://prismic-io.s3.amazonaws.com/annual.budget.pdf\">2012 Annual Budget</a></p><p><a href=\"https://prismic-io.s3.amazonaws.com/vision.strategic.plan_.sm_.pdf\">2015 Vision & Strategic Plan</a></p>');
start();
});
asyncTest('Handles multiple fields', 1, function() {
var ctx = {
api: undefined,
ref: { ref: 'XXXXX', label: 'Future release', isMaster: false },
maybeRef: 'XXXXX',
oauth: function() { },
linkResolver: function(ctx, doc, isBroken) {
if (isBroken) return '#broken';
return "/testing_url/"+doc.id+"/"+doc.slug+( ctx.maybeRef ? '?ref=' + ctx.maybeRef : '' );
}
};
Prismic.Api(testRepository, function(Api) {
Api.form('everything').query('[[:d = at(document.id, "UkL0gMuvzYUANCpr")]]').ref(Api.master()).submit(function(results) {
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>');
start();
});
}, previewToken);
});
}(window.Prismic));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc