PKj“Ñ@Ø7ãŒð&ð&&bakejs-latest/scaffolding-recipes.html Scaffolding Recipes — bake-js 0.1.22 documentation

Scaffolding Recipes¶

Work smarter, not harder. With that in mind, I created a way to enable you to scaffold a library from a github repository:

bake scaffold %owner% %project%

For instance, I recently scaffolded Caolan McMahon‘s microjs library nimble with the following command:

bake scaffold caolan nimble

Which generated the following recipe (placed in the library/recipes/nimble file):

# dsc: A really tiny functional JavaScript and async flow-control library
# author: caolan
# url: http://caolan.github.com/nimble
# src: https://github.com/caolan/nimble
# bug: https://github.com/caolan/nimble/issues

[core]
js <= github://caolan/nimble/nimble.js

The information generated here is gleaned from the github api and together with a bit of convention over configuration magic.

Generally the main file that an author puts in their github repo is in the root folder with the name of the project with a .js extension (yes the case of a name that includes the .js extension is handled).

If for any reason your file sits in a different location, then you will need to modify the recipe to point to the correct location of the file.

Previous topic

Writing Recipes

Next topic

Building vs Composition

This Page

Fork me on GitHub


PKj“Ñ@¹Õðx¯$¯$ bakejs-latest/build-vs-bake.html Building vs Composition — bake-js 0.1.22 documentation

Building vs Composition¶

BakeJS aims to make combining multiple JS libraries when building a JS-powered application simple. It does not, however, aim to simplify the process of creating that library through allowing you to concatenate local files together into a single JS library.

We make this distinction where we consider the process behind creating a standalone Javascript library as building and bringing those libraries together for your application as composition. BakeJS is a tool designed to help with composition.

If you are creating a JS library and looking for a tool to help you with building it, then BakeJS probably isn’t the tool you are looking for. Instead check out one of the following alternatives, but remember to look into Writing Recipes:

Previous topic

Scaffolding Recipes

Next topic

Why BakeJS?

This Page

Fork me on GitHub


PKj“Ñ@%øU§À9À9"bakejs-latest/writing-recipes.html Writing Recipes — bake-js 0.1.22 documentation

Writing Recipes¶

Recipes are simply plain text files that are stored in the library/recipes folder in this repository. For example, the backbone recipe is shown below:

# dsc: Give your JS App some Backbone with Models, Views, Collections, and Events
# tag: mvc, framework
# url: http://backbonejs.org
# src: https://github.com/documentcloud/backbone
# bug: https://github.com/documentcloud/backbone/issues
# req: underscore

[core]
js <= github://documentcloud/backbone/backbone.js

The structure of the file is pretty simple. Lines starting with the hash character are used to describe attributes of the recipe, of which the most important one to take note of is the req attribute. This attribute is used to specify other recipes that are require to make this library work correctly. For multiple dependencies use a comma delimited list.

After the attribute definition section comes one or more getit URL schemes that reference the online location of the file(s) required to make this library work. In the case of most libraries, this will be a single file, but you can include multiple lines here for multiple files if necessary.

It starts with a fork¶

The first thing you are going to want to do if you are interested in creating your own recipes is fork the bakery repository. This will give you your own space to play and create recipes.

If you are handwriting a recipe, then the first thing to do is to create a file in the library/recipes folder in your forked repository. The name of your file should be simply the name of the library you are creating a recipe for (with no file extension).

I would definitely recommend looking at :ref:`scaffolding-recipes` instead though.

For instance, let’s say I want to create a recipe for Thomas Fuchs keymaster library. I’d start by taking a look at the github page for the repo and I’d glean some info from there to start my recipe file.

The first thing I would do is work out the location of the actual JS file that will be used in the recipe. My preference is to find a non-minified JS file. In the case of keymaster the file is located at:

https://raw.github.com/madrobby/keymaster/master/keymaster.js

But since BakeJS uses getit under the hood we can use the custom github url scheme implemented in getit (but feel free to use the standard http url as well if you prefer). So, first cut of our keymaster recipe looks like this:

[core]
js <= github://madrobby/keymaster/keymaster.js

Yep, that’s it - because keymaster has no dependencies our recipe really only needs to include the location of where it can be found on the web.

In general though, it’s good practice to include some extra information about the library that will be displayed in the BakeJS front-end (eventually). At a minimum I like to include the description of the library (generally the github description works nicely) and where the library can be found on the web.

With that additional information, the recipe looks like this:

# dsc: A simple micro-library for defining and dispatching keyboard shortcuts.
# url: https://github.com/madrobby/keymaster

[core]
js <= github://madrobby/keymaster/keymaster.js

Done. I can now build apps that require keymaster by simply referencing keymaster in a dep comment. e.g.:

// dep: keymaster

// define short of 'a'
key('a', function(){ alert('you pressed a!') });

Testing the new Recipe¶

Before submitting a pull-request to include the recipe in the main repository, it’s probably worth testing the recipe first.

Assuming you are in the bakery directory, then you should be able to run the check command, to validate the recipe is correct:

damo-mbair:bake-js damo$ bake check keymaster
✓ recipe ok

Submitting your Recipe¶

Once you have created your recipe and know that it works, then simply submit a pull request for your new recipe.

In general, the new recipe will be accepted straight in and available for everybody next time they run a bake update.

Table Of Contents

Previous topic

bake-js

Next topic

Scaffolding Recipes

This Page

Fork me on GitHub


PKj“Ñ@ª*f(4(4bakejs-latest/index.html bake-js — bake-js 0.1.22 documentation

bake-js¶

BakeJS is a project designed to ease the pain and complexity of creating client-side Javascript applications. It takes a similar approach to homebrew in that it uses a github repository to define a number of recipes for building various JS libraries.

Installation¶

To get started with BakeJS first install the command line tools via npm. If you don’t already have NodeJS installed then you will need to install it to get access to npm.:

npm install -g bake-js

Depending on your installation, you may need to run this with the ``sudo`` command.

Once BakeJS is installed, you will then be able to access the bake command. First thing you will want to do is fetch the current recipes from this github repo by running the update command:

bake update

If everything has gone to plan, you should see the following output:

retrieving recipes from https://github.com/DamonOehlman/bakery/tarball/master
extracting recipes
✓ done

The update command here performs the same task as brew update, except that bake downloads the latest .tar.gz of a bakery repo from github rather than interfacing with git. General intention is that while the process will be less optimal with regards to bandwidth it is something that should work natively in Windows.

Baking your Application¶

Using BakeJS to generate an application file that is packaged with your application dependencies all into a single file is very simple.

The following is an example of how you might create an application that has dependencies on both backbone and eve:

// dep: backbone, eve

var myApp = (function() {
    // your app code here...
})();

Then run bake against your target file:

bake examples/test.js

When run the dependencies are analysed, child dependencies resolved (e.g. underscore is specified as a dependency in the backbone recipe and then all required files are pulled down from their remote sources and pushed to the start of the resulting output.

The resulting file is then output to a dist folder (by default).

Indices and tables¶

Table Of Contents

Next topic

Writing Recipes

This Page

Fork me on GitHub


PKj“Ñ@D‡‹•ÝÝbakejs-latest/searchindex.jsSearch.setIndex({objects:{},terms:{all:[1,0],code:0,dist:0,consider:2,queri:1,follow:[0,5,3],nodej:0,depend:[0,4],under:4,worth:4,sourc:0,veri:0,recip:[0,1,2,3,4,5],magic:3,keymast:4,list:4,dsc:[4,3],dmitri:1,design:[0,5],download:0,bake:[0,4,3],even:1,index:0,what:1,section:4,abl:[0,4],current:[1,0],version:[1,2],diaz:1,"new":[1,0,4],hash:4,gener:[0,4,3],here:[1,0,3,4,2],let:4,modifi:3,sinc:4,search:0,implement:[4,2],via:0,love:1,extra:4,win:1,app:[0,4],prefer:4,api:3,instal:0,from:[0,4,3],describ:4,would:[4,2],distinct:5,next:4,everybodi:[1,4],few:2,recommend:4,more:[1,4],line:[1,0,4],fuch:4,retriev:0,dep:[0,4],analys:0,work:[1,0,4,3],tag:4,can:[1,4],root:3,fetch:0,control:3,tar:0,give:4,process:[1,0,5],sudo:0,accept:4,minimum:4,want:[0,4],tarbal:0,onlin:4,multipl:[5,4],sit:3,rather:0,write:[1,0,5,4],how:[1,0],instead:[5,4],simpl:[1,0,5,4],updat:[0,4],npm:[1,0],resourc:2,referenc:4,after:4,befor:4,wrong:1,mai:0,end:4,underscor:[0,4],bakeri:[0,4],github:[0,4,3],practic:4,issu:[1,4,3],inform:[4,3],maintain:1,combin:5,allow:5,indic:0,composit:[0,5],help:[5,2],ender:[1,0],over:3,becaus:4,own:4,through:5,keyboard:4,still:2,window:0,requir:[0,4],main:[1,4,3],might:0,non:[4,2],good:4,thei:4,handl:3,smarter:3,framework:4,front:4,now:4,discuss:2,name:[4,3],micro:4,found:4,side:[1,0],everyth:0,interleav:5,caolan:3,idea:1,realli:[1,4,3],our:4,extract:0,event:4,out:[1,5,4,2],shown:4,mcmahon:3,space:4,req:4,ref:4,correct:[4,3],given:2,free:[4,2],standard:4,standalon:5,reason:3,put:[1,3],org:4,thing:[0,4,2],mvc:4,place:[1,3],isn:5,confus:1,think:[1,2],first:[0,4],feel:[4,2],onc:[0,4],number:0,alreadi:0,done:[0,4],owner:3,miss:1,hood:4,differ:3,convent:3,master:[0,4],scheme:4,"final":1,store:4,tool:[1,0,5],specifi:[0,4],"short":4,grunt:5,than:[1,0],target:0,remot:0,structur:4,charact:4,project:[0,3],baranovskii:1,"function":[0,4,3],sai:4,mind:3,ani:3,raw:4,have:[1,0,4],tabl:0,need:[1,0,4,3],seem:1,lie:1,note:4,client:[1,0],take:[0,4],which:[4,3],thoma:4,singl:[0,5,4],simplifi:5,pain:0,though:4,most:4,plai:4,plan:0,deploi:1,why:[1,0],don:[1,0],url:[4,3],request:[1,4],doe:5,brew:0,scaffold:[0,4,3],text:4,bring:5,handwrit:4,find:4,absolut:1,onli:4,locat:[4,3],pretti:4,configur:3,solut:[1,0],behind:5,should:[0,4],microj:3,folder:[0,4,3],local:5,contribut:1,variou:0,get:[1,0,2],repo:[1,0,4,3],nativ:0,cannot:1,getit:4,dustin:1,enabl:3,comma:4,where:[5,4],view:4,roadmap:[0,2],see:0,result:0,correctli:4,someth:[1,0],written:1,"import":4,approach:0,attribut:4,altern:[1,0,5],kei:4,javascript:[1,0,5,3],extens:[4,3],pull:[1,0,4],homebrew:[1,0],come:4,addit:4,both:0,delimit:4,howev:[1,5],against:0,instanc:[4,3],com:[0,4,3],comment:4,simpli:4,point:[1,3],dispatch:4,assum:4,coupl:1,damo:4,interest:4,tini:3,great:[1,2],minifi:4,togeth:[5,3],child:0,madrobbi:4,those:5,"case":[1,4,3],look:[5,4],packag:[1,0],plain:4,straight:4,harder:3,aim:5,defin:[0,4],"while":[1,0],mbair:4,clutter:1,myapp:0,develop:[0,2],author:3,perform:0,make:[5,4],same:0,complex:0,eventu:4,http:[0,4,3],optim:0,alert:4,recent:3,task:0,well:[1,4],exampl:[0,4],command:[1,0,4,3],thi:[1,0,5,4],model:4,latest:0,just:1,less:0,when:[0,5],bandwidth:0,yep:4,web:4,cut:4,except:0,shortcut:4,valid:4,board:2,hat:1,modul:[1,0],build:[0,5,4],applic:[0,5],around:1,know:4,press:4,bit:3,backbon:[0,4],nimbl:3,like:4,success:1,backbonej:4,resolv:0,collect:4,necessari:4,output:0,page:[0,4],damonoehlman:0,some:[1,4],librari:[0,1,2,3,4,5],definit:4,refer:4,core:[1,4,3],run:[0,4],power:5,repositori:[0,4,3],async:3,src:[4,3],about:4,actual:4,manag:1,documentcloud:4,down:0,right:1,your:[0,5,4,3],git:0,wai:3,aren:1,glean:[4,3],support:2,submit:[1,0,4],custom:4,avail:[1,4],start:[0,4],interfac:0,includ:[1,4,3],lot:[1,2],"var":0,fork:[1,0,4],regard:0,eas:0,bug:[4,3],info:4,concaten:5,"default":0,access:0,displai:4,below:4,problem:1,similar:0,gone:0,featur:1,creat:[1,0,5,4,3],flow:3,doesn:1,exist:1,file:[0,5,4,3],check:[5,4],probabl:[5,4],tip:1,other:[1,4],rememb:5,test:[0,4],you:[1,0,5,4,3],nice:4,node:1,intent:0,consid:5,land:1,directori:4,descript:4,bakej:[1,0,5,4,2],time:[1,4],push:0},objtypes:{},titles:["bake-js","Why BakeJS?","Development Roadmap","Scaffolding Recipes","Writing Recipes","Building vs Composition"],objnames:{},filenames:["index","why-bake","roadmap","scaffolding-recipes","writing-recipes","build-vs-bake"]})PKj“Ñ@z)ìbakejs-latest/objects.inv# Sphinx inventory version 2 # Project: bake-js # Version: 0.1.22 # The remainder of this file is compressed using zlib. xÚËÍOÉÌKI­P(.I±ÊILJÍQÐ5T(¨ÔÍ…Jèe”äæ(+ø槔æ¤*x‚„¸Ê‹2K2óÒu‹R“3 R‹Qõ¢IBô«(„C„‚ Â\é©yX,†‰Bm…XWœšX”œª"U Q˜žÊUœœ˜––Ÿ“‚Ó}XÀÜŒ‚»r#fÉPKj“Ñ@7"SÝÝbakejs-latest/search.html Search — bake-js 0.1.22 documentation

Search

Please activate JavaScript to enable the search functionality.

From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list.

Fork me on GitHub


PKj“Ñ@~§îïllbakejs-latest/roadmap.html Development Roadmap — bake-js 0.1.22 documentation

Development Roadmap¶

There is still a lot to do with BakeJS so feel free to get on board and help out. Here are a few of the things I think would be great to discuss / implement:

  • Support for library versioning in recipes
  • Consideration given to non-JS resources

Previous topic

Why BakeJS?

This Page

Fork me on GitHub


PKj“Ñ@ñqv Index — bake-js 0.1.22 documentation

Index

Fork me on GitHub


PKj“Ñ@ôÚVtææbakejs-latest/.buildinfo# Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. config: 939d393f70c330aaad1703f043786d9b tags: fbb0d17656682115ca4d033fb2f83ba1 PKj“Ñ@‘U#3¨)¨)bakejs-latest/why-bake.html Why BakeJS? — bake-js 0.1.22 documentation

Why BakeJS?¶

One of the successes of homebrew seems to lie in how simple it is to fork the repo, create a new recipe and submit a pull request to have that recipe included in the main repo. This is something that I think is missing in the land of client-side Javascript.

At the core of BakeJS that is the idea. If you need a client-side library and an existing recipe doesn’t exist, then you fork the repo, get to Writing Recipes and then finally issue a pull request to have it included in the main repo.

It’s a simple process, and you can contribute recipes even if you aren’t the maintainer of the library. Everybody wins.

Alternative Solutions - Ender¶

I absolutely tip my hat to Dustin Diaz for Ender. It works really well, has some great command-line tools for querying what is available and lots of other great features, however, it has one problem:

Ender packages need to be managed in NPM

Don’t get me wrong, I love NPM, and I’ve written more than a couple node modules. I just don’t think it’s the right place for client-side libraries.

A great case in point for me is a library that I do a lot with: eve. At this current point in time the npm deployed version of eve was not put there by Dmitry Baranovskiy and as such it cannot be maintained by Dmitry.

While I’m not going into the ins and outs of it here, its a problem, and working around the problem creates more clutter in NPM and confusion for all of us.

Table Of Contents

Previous topic

Building vs Composition

Next topic

Development Roadmap

This Page

Fork me on GitHub


PKj“Ñ@:>«>«>$bakejs-latest/_static/searchtools.js/* * searchtools.js_t * ~~~~~~~~~~~~~~~~ * * Sphinx JavaScript utilties for the full-text search. * * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ /** * helper function to return a node containing the * search summary for a given text. keywords is a list * of stemmed words, hlwords is the list of normal, unstemmed * words. the first one is used to find the occurance, the * latter for highlighting it. */ jQuery.makeSearchSummary = function(text, keywords, hlwords) { var textLower = text.toLowerCase(); var start = 0; $.each(keywords, function() { var i = textLower.indexOf(this.toLowerCase()); if (i > -1) start = i; }); start = Math.max(start - 120, 0); var excerpt = ((start > 0) ? '...' : '') + $.trim(text.substr(start, 240)) + ((start + 240 - text.length) ? '...' : ''); var rv = $('
').text(excerpt); $.each(hlwords, function() { rv = rv.highlightText(this, 'highlighted'); }); return rv; } /** * Porter Stemmer */ var Stemmer = function() { var step2list = { ational: 'ate', tional: 'tion', enci: 'ence', anci: 'ance', izer: 'ize', bli: 'ble', alli: 'al', entli: 'ent', eli: 'e', ousli: 'ous', ization: 'ize', ation: 'ate', ator: 'ate', alism: 'al', iveness: 'ive', fulness: 'ful', ousness: 'ous', aliti: 'al', iviti: 'ive', biliti: 'ble', logi: 'log' }; var step3list = { icate: 'ic', ative: '', alize: 'al', iciti: 'ic', ical: 'ic', ful: '', ness: '' }; var c = "[^aeiou]"; // consonant var v = "[aeiouy]"; // vowel var C = c + "[^aeiouy]*"; // consonant sequence var V = v + "[aeiou]*"; // vowel sequence var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 var s_v = "^(" + C + ")?" + v; // vowel in stem this.stemWord = function (w) { var stem; var suffix; var firstch; var origword = w; if (w.length < 3) return w; var re; var re2; var re3; var re4; firstch = w.substr(0,1); if (firstch == "y") w = firstch.toUpperCase() + w.substr(1); // Step 1a re = /^(.+?)(ss|i)es$/; re2 = /^(.+?)([^s])s$/; if (re.test(w)) w = w.replace(re,"$1$2"); else if (re2.test(w)) w = w.replace(re2,"$1$2"); // Step 1b re = /^(.+?)eed$/; re2 = /^(.+?)(ed|ing)$/; if (re.test(w)) { var fp = re.exec(w); re = new RegExp(mgr0); if (re.test(fp[1])) { re = /.$/; w = w.replace(re,""); } } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1]; re2 = new RegExp(s_v); if (re2.test(stem)) { w = stem; re2 = /(at|bl|iz)$/; re3 = new RegExp("([^aeiouylsz])\\1$"); re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re2.test(w)) w = w + "e"; else if (re3.test(w)) { re = /.$/; w = w.replace(re,""); } else if (re4.test(w)) w = w + "e"; } } // Step 1c re = /^(.+?)y$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(s_v); if (re.test(stem)) w = stem + "i"; } // Step 2 re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step2list[suffix]; } // Step 3 re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step3list[suffix]; } // Step 4 re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; re2 = /^(.+?)(s|t)(ion)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); if (re.test(stem)) w = stem; } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1] + fp[2]; re2 = new RegExp(mgr1); if (re2.test(stem)) w = stem; } // Step 5 re = /^(.+?)e$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); re2 = new RegExp(meq1); re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) w = stem; } re = /ll$/; re2 = new RegExp(mgr1); if (re.test(w) && re2.test(w)) { re = /.$/; w = w.replace(re,""); } // and turn initial Y back to y if (firstch == "y") w = firstch.toLowerCase() + w.substr(1); return w; } } /** * Search Module */ var Search = { _index : null, _queued_query : null, _pulse_status : -1, init : function() { var params = $.getQueryParameters(); if (params.q) { var query = params.q[0]; $('input[name="q"]')[0].value = query; this.performSearch(query); } }, loadIndex : function(url) { $.ajax({type: "GET", url: url, data: null, success: null, dataType: "script", cache: true}); }, setIndex : function(index) { var q; this._index = index; if ((q = this._queued_query) !== null) { this._queued_query = null; Search.query(q); } }, hasIndex : function() { return this._index !== null; }, deferQuery : function(query) { this._queued_query = query; }, stopPulse : function() { this._pulse_status = 0; }, startPulse : function() { if (this._pulse_status >= 0) return; function pulse() { Search._pulse_status = (Search._pulse_status + 1) % 4; var dotString = ''; for (var i = 0; i < Search._pulse_status; i++) dotString += '.'; Search.dots.text(dotString); if (Search._pulse_status > -1) window.setTimeout(pulse, 500); }; pulse(); }, /** * perform a search for something */ performSearch : function(query) { // create the required interface elements this.out = $('#search-results'); this.title = $('

' + _('Searching') + '

').appendTo(this.out); this.dots = $('').appendTo(this.title); this.status = $('

').appendTo(this.out); this.output = $('