From b1e33bdce5cc68569165012e04c48cf71b289e3d Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 2 Oct 2013 14:26:06 +0200 Subject: [PATCH] split 3rd-party packages to vendor and components Then, use bower to fetch components and put libraries not available as (web) component into vendor/. Move crypto parts and identicon generation modules into app/lib. --- .gitignore | 6 +- README.md | 10 +- isso/js/.bowerrc | 1 + isso/js/Makefile | 8 + isso/js/app/api.js | 8 +- isso/js/app/isso.js | 31 +- isso/js/app/lib.js | 7 + isso/js/{ => app}/lib/identicons.js | 2 +- isso/js/{ => app}/lib/pbkdf2.js | 2 +- isso/js/{ => app}/lib/sha1.js | 0 isso/js/app/markup.js | 2 +- isso/js/{ => app}/text/arrow-down.svg | 0 isso/js/{ => app}/text/arrow-up.svg | 0 isso/js/{ => app}/text/comment.html | 0 isso/js/{ => app}/text/forward.svg | 0 isso/js/{ => app}/text/html.js | 0 isso/js/{ => app}/text/postbox.html | 0 isso/js/{ => app}/text/svg.js | 0 isso/js/app/utils.js | 2 +- isso/js/build.count.js | 4 +- isso/js/build.embed.js | 4 +- isso/js/config.js | 8 + isso/js/count.js | 2 +- isso/js/embed.js | 2 +- isso/js/lib/HTML.js | 4 - isso/js/lib/almond.js | 410 ------ isso/js/lib/q.js | 1937 ------------------------- isso/js/lib/ready.js | 55 - isso/js/require.js | 36 - isso/js/text.js | 386 ----- isso/js/vendor/behave.js | 633 ++++++++ isso/js/{lib => vendor}/markup.js | 0 32 files changed, 694 insertions(+), 2866 deletions(-) create mode 100644 isso/js/.bowerrc create mode 100644 isso/js/Makefile create mode 100644 isso/js/app/lib.js rename isso/js/{ => app}/lib/identicons.js (98%) rename isso/js/{ => app}/lib/pbkdf2.js (99%) rename isso/js/{ => app}/lib/sha1.js (100%) rename isso/js/{ => app}/text/arrow-down.svg (100%) rename isso/js/{ => app}/text/arrow-up.svg (100%) rename isso/js/{ => app}/text/comment.html (100%) rename isso/js/{ => app}/text/forward.svg (100%) rename isso/js/{ => app}/text/html.js (100%) rename isso/js/{ => app}/text/postbox.html (100%) rename isso/js/{ => app}/text/svg.js (100%) create mode 100644 isso/js/config.js delete mode 100644 isso/js/lib/HTML.js delete mode 100644 isso/js/lib/almond.js delete mode 100644 isso/js/lib/q.js delete mode 100644 isso/js/lib/ready.js delete mode 100644 isso/js/require.js delete mode 100644 isso/js/text.js create mode 100644 isso/js/vendor/behave.js rename isso/js/{lib => vendor}/markup.js (100%) diff --git a/.gitignore b/.gitignore index f56f32f..a44a28e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,11 @@ *.pyc .Python -/isso.egg-info/ -/isso/client/node_modules /bin /include /lib /share +/isso.egg-info/ +/isso/js/components +/isso/js/embed.min.js +/isso/js/count.min.js diff --git a/README.md b/README.md index 21d3478..c9999e6 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Installation Requirements: - Python 2.6 or 2.7 -- [NPM](https://npmjs.org/) +- [NPM](https://npmjs.org/) and [Bower](http://bower.io/) For now (as long as there is no stable version), you need to manually build everything: @@ -45,6 +45,11 @@ build everything: ~> cd isso/ ~> python setup.py develop +To fetch the requires JS components (and CSS framework), run: + + ~> cd isso/js/ + ~> bower install almond q requirejs requirejs-domready requirejs-text + You can now either use the JS client as-is (using [require.js][r.js], see below) or compile all JS into a single file: @@ -126,7 +131,8 @@ when using [require.js][r.js]: ```html - + + ``` diff --git a/isso/js/.bowerrc b/isso/js/.bowerrc new file mode 100644 index 0000000..5250f39 --- /dev/null +++ b/isso/js/.bowerrc @@ -0,0 +1 @@ +{"directory": "components/"} diff --git a/isso/js/Makefile b/isso/js/Makefile new file mode 100644 index 0000000..575d90d --- /dev/null +++ b/isso/js/Makefile @@ -0,0 +1,8 @@ +all: js + +js: + r.js -o build.embed.js + r.js -o build.count.js + +init: + bower install almond q requirejs requirejs-domready requirejs-text diff --git a/isso/js/app/api.js b/isso/js/app/api.js index bd6547a..64cb887 100644 --- a/isso/js/app/api.js +++ b/isso/js/app/api.js @@ -3,7 +3,7 @@ * License: BSD Style, 2 clauses. See isso/__init__.py. */ -define(["lib/q"], function(Q) { +define(["q"], function(Q) { "use strict"; @@ -18,8 +18,8 @@ define(["lib/q"], function(Q) { // guess Isso API location var js = document.getElementsByTagName("script"); for (var i = 0; i < js.length; i++) { - if (js[i].src.match("/js/require\\.js$")) { - endpoint = js[i].src.substring(0, js[i].src.length - 14); + if (js[i].src.match("/js/components/requirejs/require\\.js$")) { + endpoint = js[i].src.substring(0, js[i].src.length - 35); break; } else if (js[i].src.match("/js/embed\\.min\\.js$")) { endpoint = js[i].src.substring(0, js[i].src.length - 16); @@ -27,7 +27,7 @@ define(["lib/q"], function(Q) { } } - if (endpoint == null) { + if (! endpoint) { throw "no Isso API location found"; } diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 77b7a69..a84846f 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -1,12 +1,7 @@ /* Isso – Ich schrei sonst! - * - * Copyright 2013, Martin Zimmermann . All rights reserved. - * License: BSD Style, 2 clauses. See isso/__init__.py. */ - - -define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api", "./markup", "./i18n"], - function(pbkdf2, identicons, templates, $, utils, api, Mark, i18n) { +define(["behave", "app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i18n", "app/lib"], + function(behave, templates, $, utils, api, Mark, i18n, lib) { "use strict"; @@ -30,13 +25,13 @@ define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api" // add a blank identicon to not waste CPU cycles // XXX show a space invader instead :> - $(".avatar > canvas", el).replace(identicons.blank(48, 48)); + $(".avatar > canvas", el).replace(lib.identicons.blank(48, 48)); // on text area focus, generate identicon from IP address $(".textarea-wrapper > textarea", el).on("focus", function() { if ($(".avatar canvas", el).classList.contains("blank")) { $(".avatar canvas", el).replace( - identicons.generate(pbkdf2(api.remote_addr, api.salt, 1000, 6), 48, 48)); + lib.identicons.generate(lib.pbkdf2(api.remote_addr, api.salt, 1000, 6), 48, 48)); } }); @@ -47,9 +42,9 @@ define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api" clearTimeout(active); } active = setTimeout(function() { - pbkdf2($(".input-wrapper > [type=email]", el).value || api.remote_addr, api.salt, 1000, 6) + lib.pbkdf2($(".input-wrapper > [type=email]", el).value || api.remote_addr, api.salt, 1000, 6) .then(function(rv) { - $(".avatar canvas", el).replace(identicons.generate(rv, 48, 48)); + $(".avatar canvas", el).replace(lib.identicons.generate(rv, 48, 48)); }); }, 200); }, false); @@ -90,6 +85,8 @@ define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api" }); }); + var editor = new behave({textarea: $("textarea", el)}); + return el; }; @@ -109,7 +106,7 @@ define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api" setTimeout(refresh, 60*1000); }; refresh(); - $("div.avatar > canvas", el).replace(identicons.generate(comment.hash, 48, 48)); + $("div.avatar > canvas", el).replace(lib.identicons.generate(comment.hash, 48, 48)); var entrypoint; if (comment.parent === null) { @@ -209,16 +206,6 @@ define(["lib/pbkdf2", "lib/identicons", "text/html", "./dom", "./utils", "./api" }, 1500); } }); - - return; - -// var votes = node.footer.add("span.votes{" + (comment.likes - comment.dislikes) + "}"); -// node.footer.add(forms.like(comment.id, function(rv) { -// votes.textContent = rv.likes - rv.dislikes; -// })) -// node.footer.add(forms.dislike(comment.id, function(rv) { -// votes.textContent = rv.likes - rv.dislikes; -// })) }; return { diff --git a/isso/js/app/lib.js b/isso/js/app/lib.js new file mode 100644 index 0000000..10bdab2 --- /dev/null +++ b/isso/js/app/lib.js @@ -0,0 +1,7 @@ +define(function (require) { + return { + identicons: require("app/lib/identicons"), + pbkdf2: require("app/lib/pbkdf2"), + sha1: require("app/lib/sha1") + }; +}); \ No newline at end of file diff --git a/isso/js/lib/identicons.js b/isso/js/app/lib/identicons.js similarity index 98% rename from isso/js/lib/identicons.js rename to isso/js/app/lib/identicons.js index b8a2652..118f04c 100644 --- a/isso/js/lib/identicons.js +++ b/isso/js/app/lib/identicons.js @@ -1,4 +1,4 @@ -define(["lib/q"], function(Q) { +define(["q"], function(Q) { "use strict"; diff --git a/isso/js/lib/pbkdf2.js b/isso/js/app/lib/pbkdf2.js similarity index 99% rename from isso/js/lib/pbkdf2.js rename to isso/js/app/lib/pbkdf2.js index ed5c1a7..1f8f165 100644 --- a/isso/js/lib/pbkdf2.js +++ b/isso/js/app/lib/pbkdf2.js @@ -1,4 +1,4 @@ -define(["lib/q", "lib/sha1"], function(Q, sha1) { +define(["q", "app/lib/sha1"], function(Q, sha1) { /* * JavaScript implementation of Password-Based Key Derivation Function 2 * (PBKDF2) as defined in RFC 2898. diff --git a/isso/js/lib/sha1.js b/isso/js/app/lib/sha1.js similarity index 100% rename from isso/js/lib/sha1.js rename to isso/js/app/lib/sha1.js diff --git a/isso/js/app/markup.js b/isso/js/app/markup.js index f9b4eb9..89db8c4 100644 --- a/isso/js/app/markup.js +++ b/isso/js/app/markup.js @@ -1,4 +1,4 @@ -define(["lib/markup", "./i18n", "text/svg"], function(Mark, i18n, svg) { +define(["vendor/markup", "app/i18n", "app/text/svg"], function(Mark, i18n, svg) { "use strict"; diff --git a/isso/js/text/arrow-down.svg b/isso/js/app/text/arrow-down.svg similarity index 100% rename from isso/js/text/arrow-down.svg rename to isso/js/app/text/arrow-down.svg diff --git a/isso/js/text/arrow-up.svg b/isso/js/app/text/arrow-up.svg similarity index 100% rename from isso/js/text/arrow-up.svg rename to isso/js/app/text/arrow-up.svg diff --git a/isso/js/text/comment.html b/isso/js/app/text/comment.html similarity index 100% rename from isso/js/text/comment.html rename to isso/js/app/text/comment.html diff --git a/isso/js/text/forward.svg b/isso/js/app/text/forward.svg similarity index 100% rename from isso/js/text/forward.svg rename to isso/js/app/text/forward.svg diff --git a/isso/js/text/html.js b/isso/js/app/text/html.js similarity index 100% rename from isso/js/text/html.js rename to isso/js/app/text/html.js diff --git a/isso/js/text/postbox.html b/isso/js/app/text/postbox.html similarity index 100% rename from isso/js/text/postbox.html rename to isso/js/app/text/postbox.html diff --git a/isso/js/text/svg.js b/isso/js/app/text/svg.js similarity index 100% rename from isso/js/text/svg.js rename to isso/js/app/text/svg.js diff --git a/isso/js/app/utils.js b/isso/js/app/utils.js index 9abdbf2..20a8406 100644 --- a/isso/js/app/utils.js +++ b/isso/js/app/utils.js @@ -4,7 +4,7 @@ * utility functions */ -define(["./markup"], function(Mark) { +define(["app/markup"], function(Mark) { // return `cookie` string if set var cookie = function(cookie) { diff --git a/isso/js/build.count.js b/isso/js/build.count.js index 57be274..d2da9ed 100644 --- a/isso/js/build.count.js +++ b/isso/js/build.count.js @@ -1,6 +1,8 @@ ({ baseUrl: ".", - name: "lib/almond", + mainConfigFile: 'config.js', + + name: "components/almond/almond", include: ['count'], out: "count.min.js", wrap: true diff --git a/isso/js/build.embed.js b/isso/js/build.embed.js index 6dd1fd4..28fbf4b 100644 --- a/isso/js/build.embed.js +++ b/isso/js/build.embed.js @@ -1,6 +1,8 @@ ({ baseUrl: ".", - name: "lib/almond", + mainConfigFile: 'config.js', + + name: "components/almond/almond", include: ['embed'], out: "embed.min.js", diff --git a/isso/js/config.js b/isso/js/config.js new file mode 100644 index 0000000..2924116 --- /dev/null +++ b/isso/js/config.js @@ -0,0 +1,8 @@ +var requirejs = { + paths: { + q: "components/q/q", + text : "components/requirejs-text/text", + ready: "components/requirejs-domready/domReady", + behave: "vendor/behave" + } +}; diff --git a/isso/js/count.js b/isso/js/count.js index 420cc75..633da8f 100644 --- a/isso/js/count.js +++ b/isso/js/count.js @@ -1,4 +1,4 @@ -require(["lib/ready", "app/count"], function(domready, count) { +require(["ready", "app/count"], function(domready, count) { domready(function() { count(); }) diff --git a/isso/js/embed.js b/isso/js/embed.js index 940055e..df2ccd1 100644 --- a/isso/js/embed.js +++ b/isso/js/embed.js @@ -1,4 +1,4 @@ -require(["lib/ready", "app/api", "app/isso", "app/count", "app/dom", "app/markup"], function(domready, api, isso, count, $, Mark) { +require(["ready", "app/api", "app/isso", "app/count", "app/dom", "app/markup"], function(domready, api, isso, count, $, Mark) { "use strict"; diff --git a/isso/js/lib/HTML.js b/isso/js/lib/HTML.js deleted file mode 100644 index 3814e62..0000000 --- a/isso/js/lib/HTML.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! HTML - v0.10.2 - 2013-08-25 -* http://nbubna.github.io/HTML/ -* Copyright (c) 2013 ESHA Research; Licensed MIT, GPL */ -!function(a,b,c){"use strict";var d={version:"0.10.2",slice:Array.prototype.slice,list:function(a,b){return 1===a.length?d.node(a[0],b):((b||!a.each)&&(a.slice||(a=d.slice.call(a)),d.methods(a),a.length&&d.children(a[0],a)),a)},node:function(a,b){return(b||!a.each)&&(d.methods(a),d.children(a)),a},methods:function(a){for(var b in d.fn)d.define(a,b,d.fn[b])},children:function(a,b){for(var c=a._children={},e=0,f=a.childNodes.length;f>e;e++){var g=a.childNodes[e],h=d.key(g);(c[h]||(c[h]=[])).push(g),d.define(a,h),b&&d.define(b,h,void 0,a)}return c},key:function(a){return a.tagName?a.tagName.toLowerCase():"_other"},define:function(a,b,c,e){if(!(b in a))try{e=e||a,Object.defineProperty(a,b,void 0!==c?{value:c}:{get:function(){return e._children||d.children(e),d.list(e._children[b]||[])}})}catch(f){}},mutation:function(a){var b=a.target;delete b[b._internal?"_internal":"_children"]},unique:function(a,b,c){return c.indexOf(a)===b},fn:{each:function(a){var b,c,e=this.forEach?this:[this],f=[];"string"==typeof a&&(b=d.resolve[a]||a,c=d.slice.call(arguments,1),a=function(a,e){return d.resolve(b,a,c,e)});for(var g,h=0,i=e.length;i>h;h++)g=a.call(e,d.node(e[h]),h,e),(g||b&&void 0!==g)&&(g.forEach?f.push.apply(f,g):f.push(g));return f[0]||f[0]===!1?f[0].matches?d.list(f.filter(d.unique)):f:this},find:function(){try{a.console.warn("find() is deprecated. Please use query().")}finally{return this.query.apply(this,arguments)}},query:function(a){for(var b=this.forEach?this:[this],c=[],e=0,f=b.length;f>e;e++)for(var g=b[e].querySelectorAll(a),h=0,i=g.length;i>h;h++)c.push(g[h]);return d.list(c)},only:function(a,b){var c=this.forEach?this:[this];return d.list(a>=0||0>a?c.slice(a,b||a+1||void 0):c.filter("function"==typeof a?a:function(b){return b.matches(a)}))}},resolve:function(a,b,c,e){var f=a,g=b;if(c=c.length?d.fill(c,e,g):null,f.indexOf(".")>0){for(var h=f.split(".");h.length>1&&(g=g[f=h.shift()]););g=g||b,f=g?h[0]:a}var i=g[f];if(void 0!==i){if("function"==typeof i)return i.apply(g,c);if(!c)return i;g[f]=c[0]}else{if(!c)return b.getAttribute(a);null===c[0]?b.removeAttribute(a):b.setAttribute(a,c[0])}},fill:function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++){var g=a[e],h=typeof g;d[e]="string"===h?g.replace(/\$\{i\}/g,b):"function"===h?g(c,b,a):g}return d}},e=d.node(b.documentElement);e._=d,d.define(e,"ify",function(a,b){return!a||"length"in a?d.list(a||[],b):d.node(a,b)});var f=Element.prototype,g="atchesSelector";d.define(f,"matches",f.m||f["webkitM"+g]||f["mozM"+g]||f["msM"+g]),c?new c(function(a){a.forEach(d.mutation)}).observe(e,{childList:!0,subtree:!0}):b.addEventListener("DOMSubtreeModified",d.mutation),"function"==typeof define&&define.amd?define(function(){return e}):"undefined"!=typeof module&&module.exports?module.exports=e:a[e.getAttribute("data-html-reference")||"HTML"]=e,b.addEventListener("DOMContentLoaded",function(){d.node(e,!0)})}(window,document,window.MutationObserver),function(a,b){"use strict";var c=b.fn.add=function(a,b){return this.each(function(d){return c.all(d,a,b)})};c.all=function(a,b,d){if("string"==typeof b)return c.create(a,b,d);if("length"in b){for(var e=[],f=0,g=b.length;g>f;f++)e.push(c.all(a,b[f],d));return e}return c.insert(a,b,d),b},c.create=function(b,d,e){return c.insert(b,a.createElement(d),e)},c.insert=function(a,d,e){var f=c.find(a,e);return f?a.insertBefore(d,f):a.appendChild(d),b.updated(a),d},c.find=function(a,b){switch(typeof b){case"string":return a[b+"Child"];case"number":return a.children[b];case"object":return b;case"function":return b.call(a,a)}},b.updated=function(a){a._internal=!0,b.children(a)},b.fn.remove=function(a){return this.each(function(c){var d=c.parentNode;return d&&(d.removeChild(c),b.updated(d),a)?d:void 0})}}(document,document.documentElement._),function(a,b){"use strict";var c=b._,d=c.fn.event=function(){try{window.console.warn("event() is deprecated. https://github.com/nbubna/HTML/issues/1")}catch(a){}var b,e=c.slice.call(arguments),f=this,g=[];return e[0]?!e[1]||e[1].forEach?b="trigger":(b="on",1===e[0]&&(e[4]=e.shift()),(!e[2]||e[2].forEach)&&(e.splice(1,0,!1),e.splice(4,1)),e[3]=(e[3]||[]).slice(0),"string"==typeof e[2]&&(e[5]=e[2],e[3].unshift(e[2]),e[2]=c.fn.each)):(b="off",e.shift(),"function"==typeof e[1]&&e.splice(1,0,!1)),(e[0]||"").split(" ").forEach(function(a){e[0]=a,f.each(function(a){g.push(d[b].apply(a,e))})}),"trigger"===b?1===g.length?g[0]:g:this},e=Array.prototype.concat;d.on=function(a,b,e,f,g,h){var i=function(a){d.heard.call(this,a,b,e,f,g,h)};this.addEventListener(a,i),c.define(this,"_evt",[]),this._evt.push([a,b,h||e,i])},d.off=function(a,b,c){if(this._evt)for(var d=0;di;i++){var k=f[i];h=c.emmet[k.charAt(0)].call(h,k.substr(1),g)||h}return c.insert(b,g,e),h},c.emmetRE=function(){var a="\\"+Object.keys(c.emmet).join("|\\");return new RegExp("(?="+a+")","g")},c.emmet={"#":function(a){this.id=a},".":function(a){var b=this.getAttribute("class")||"";b=b+(b?" ":"")+a,this.setAttribute("class",b)},"[":function(a){a=a.substr(0,a.length-1).match(/(?:[^\s"]+|"[^"]*")+/g);for(var b=0,c=a.length;c>b;b++){var d=a[b].split("=");this.setAttribute(d[0],(d[1]||"").replace(/"/g,""))}},">":function(b){if(b){var c=a.createElement(b);return this.appendChild(c),c}return this},"+":function(a,b){return c.emmet[">"].call(this.parentNode||b,a)},"*":function(a){for(var b=this.parentNode,c=[this],d=1;a>d;d++)c.push(this.cloneNode(!0)),b.appendChild(c[d]);return c},"^":function(a,b){return c.emmet["+"].call(this.parentNode||b,a,b)},"{":function(b){this.appendChild(a.createTextNode(b.substr(0,b.length-1)))}}}(document,document.documentElement._); \ No newline at end of file diff --git a/isso/js/lib/almond.js b/isso/js/lib/almond.js deleted file mode 100644 index 807815c..0000000 --- a/isso/js/lib/almond.js +++ /dev/null @@ -1,410 +0,0 @@ -/** - * almond 0.2.6 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/almond for details - */ -//Going sloppy to avoid 'use strict' string cost, but strict practices should -//be followed. -/*jslint sloppy: true */ -/*global setTimeout: false */ - -var requirejs, require, define; -(function (undef) { - var main, req, makeMap, handlers, - defined = {}, - waiting = {}, - config = {}, - defining = {}, - hasOwn = Object.prototype.hasOwnProperty, - aps = [].slice; - - function hasProp(obj, prop) { - return hasOwn.call(obj, prop); - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @returns {String} normalized name - */ - function normalize(name, baseName) { - var nameParts, nameSegment, mapValue, foundMap, - foundI, foundStarMap, starI, i, j, part, - baseParts = baseName && baseName.split("/"), - map = config.map, - starMap = (map && map['*']) || {}; - - //Adjust any relative paths. - if (name && name.charAt(0) === ".") { - //If have a base name, try to normalize against it, - //otherwise, assume it is a top-level require that will - //be relative to baseUrl in the end. - if (baseName) { - //Convert baseName to array, and lop off the last part, - //so that . matches that "directory" and not name of the baseName's - //module. For instance, baseName of "one/two/three", maps to - //"one/two/three.js", but we want the directory, "one/two" for - //this normalization. - baseParts = baseParts.slice(0, baseParts.length - 1); - - name = baseParts.concat(name.split("/")); - - //start trimDots - for (i = 0; i < name.length; i += 1) { - part = name[i]; - if (part === ".") { - name.splice(i, 1); - i -= 1; - } else if (part === "..") { - if (i === 1 && (name[2] === '..' || name[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - name.splice(i - 1, 2); - i -= 2; - } - } - } - //end trimDots - - name = name.join("/"); - } else if (name.indexOf('./') === 0) { - // No baseName, so this is ID is resolved relative - // to baseUrl, pull off the leading dot. - name = name.substring(2); - } - } - - //Apply map config if available. - if ((baseParts || starMap) && map) { - nameParts = name.split('/'); - - for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join("/"); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = map[baseParts.slice(0, j).join('/')]; - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = mapValue[nameSegment]; - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - foundI = i; - break; - } - } - } - } - - if (foundMap) { - break; - } - - //Check for a star map match, but just hold on to it, - //if there is a shorter segment match later in a matching - //config, then favor over this star map. - if (!foundStarMap && starMap && starMap[nameSegment]) { - foundStarMap = starMap[nameSegment]; - starI = i; - } - } - - if (!foundMap && foundStarMap) { - foundMap = foundStarMap; - foundI = starI; - } - - if (foundMap) { - nameParts.splice(0, foundI, foundMap); - name = nameParts.join('/'); - } - } - - return name; - } - - function makeRequire(relName, forceSync) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync])); - }; - } - - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; - } - - function makeLoad(depName) { - return function (value) { - defined[depName] = value; - }; - } - - function callDep(name) { - if (hasProp(waiting, name)) { - var args = waiting[name]; - delete waiting[name]; - defining[name] = true; - main.apply(undef, args); - } - - if (!hasProp(defined, name) && !hasProp(defining, name)) { - throw new Error('No ' + name); - } - return defined[name]; - } - - //Turns a plugin!resource to [plugin, resource] - //with the plugin being undefined if the name - //did not have a plugin prefix. - function splitPrefix(name) { - var prefix, - index = name ? name.indexOf('!') : -1; - if (index > -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - return [prefix, name]; - } - - /** - * Makes a name map, normalizing the name, and using a plugin - * for normalization if necessary. Grabs a ref to plugin - * too, as an optimization. - */ - makeMap = function (name, relName) { - var plugin, - parts = splitPrefix(name), - prefix = parts[0]; - - name = parts[1]; - - if (prefix) { - prefix = normalize(prefix, relName); - plugin = callDep(prefix); - } - - //Normalize according - if (prefix) { - if (plugin && plugin.normalize) { - name = plugin.normalize(name, makeNormalize(relName)); - } else { - name = normalize(name, relName); - } - } else { - name = normalize(name, relName); - parts = splitPrefix(name); - prefix = parts[0]; - name = parts[1]; - if (prefix) { - plugin = callDep(prefix); - } - } - - //Using ridiculous property names for space reasons - return { - f: prefix ? prefix + '!' + name : name, //fullName - n: name, - pr: prefix, - p: plugin - }; - }; - - function makeConfig(name) { - return function () { - return (config && config.config && config.config[name]) || {}; - }; - } - - handlers = { - require: function (name) { - return makeRequire(name); - }, - exports: function (name) { - var e = defined[name]; - if (typeof e !== 'undefined') { - return e; - } else { - return (defined[name] = {}); - } - }, - module: function (name) { - return { - id: name, - uri: '', - exports: defined[name], - config: makeConfig(name) - }; - } - }; - - main = function (name, deps, callback, relName) { - var cjsModule, depName, ret, map, i, - args = [], - usingExports; - - //Use name if no relName - relName = relName || name; - - //Call the callback to define the module, if necessary. - if (typeof callback === 'function') { - - //Pull out the defined dependencies and pass the ordered - //values to the callback. - //Default to [require, exports, module] if no deps - deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; - for (i = 0; i < deps.length; i += 1) { - map = makeMap(deps[i], relName); - depName = map.f; - - //Fast path CommonJS standard dependencies. - if (depName === "require") { - args[i] = handlers.require(name); - } else if (depName === "exports") { - //CommonJS module spec 1.1 - args[i] = handlers.exports(name); - usingExports = true; - } else if (depName === "module") { - //CommonJS module spec 1.1 - cjsModule = args[i] = handlers.module(name); - } else if (hasProp(defined, depName) || - hasProp(waiting, depName) || - hasProp(defining, depName)) { - args[i] = callDep(depName); - } else if (map.p) { - map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); - args[i] = defined[depName]; - } else { - throw new Error(name + ' missing ' + depName); - } - } - - ret = callback.apply(defined[name], args); - - if (name) { - //If setting exports via "module" is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. - if (cjsModule && cjsModule.exports !== undef && - cjsModule.exports !== defined[name]) { - defined[name] = cjsModule.exports; - } else if (ret !== undef || !usingExports) { - //Use the return value from the function. - defined[name] = ret; - } - } - } else if (name) { - //May just be an object definition for the module. Only - //worry about defining if have a module name. - defined[name] = callback; - } - }; - - requirejs = require = req = function (deps, callback, relName, forceSync, alt) { - if (typeof deps === "string") { - if (handlers[deps]) { - //callback in this case is really relName - return handlers[deps](callback); - } - //Just return the module wanted. In this scenario, the - //deps arg is the module name, and second arg (if passed) - //is just the relName. - //Normalize module name, if it contains . or .. - return callDep(makeMap(deps, callback).f); - } else if (!deps.splice) { - //deps is a config object, not an array. - config = deps; - if (callback.splice) { - //callback is an array, which means it is a dependency list. - //Adjust args if there are dependencies - deps = callback; - callback = relName; - relName = null; - } else { - deps = undef; - } - } - - //Support require(['a']) - callback = callback || function () {}; - - //If relName is a function, it is an errback handler, - //so remove it. - if (typeof relName === 'function') { - relName = forceSync; - forceSync = alt; - } - - //Simulate async callback; - if (forceSync) { - main(undef, deps, callback, relName); - } else { - //Using a non-zero value because of concern for what old browsers - //do, and latest browsers "upgrade" to 4 if lower value is used: - //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: - //If want a value immediately, use require('id') instead -- something - //that works in almond on the global level, but not guaranteed and - //unlikely to work in other AMD implementations. - setTimeout(function () { - main(undef, deps, callback, relName); - }, 4); - } - - return req; - }; - - /** - * Just drops the config on the floor, but returns req in case - * the config return value is used. - */ - req.config = function (cfg) { - config = cfg; - if (config.deps) { - req(config.deps, config.callback); - } - return req; - }; - - /** - * Expose module registry for debugging and tooling - */ - requirejs._defined = defined; - - define = function (name, deps, callback) { - - //This module may not have dependencies - if (!deps.splice) { - //deps is not an array, so probably means - //an object literal or factory function for - //the value. Adjust args. - callback = deps; - deps = []; - } - - if (!hasProp(defined, name) && !hasProp(waiting, name)) { - waiting[name] = [name, deps, callback]; - } - }; - - define.amd = { - jQuery: true - }; -}()); diff --git a/isso/js/lib/q.js b/isso/js/lib/q.js deleted file mode 100644 index fe96ca8..0000000 --- a/isso/js/lib/q.js +++ /dev/null @@ -1,1937 +0,0 @@ -// vim:ts=4:sts=4:sw=4: -/*! - * - * Copyright 2009-2012 Kris Kowal under the terms of the MIT - * license found at http://github.com/kriskowal/q/raw/master/LICENSE - * - * With parts by Tyler Close - * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found - * at http://www.opensource.org/licenses/mit-license.html - * Forked at ref_send.js version: 2009-05-11 - * - * With parts by Mark Miller - * Copyright (C) 2011 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -(function (definition) { - // Turn off strict mode for this function so we can assign to global.Q - /* jshint strict: false */ - - // This file will function properly as a