@catlab/requirejs-plugins 0.0.0-stage → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/mdown.js ADDED
@@ -0,0 +1,59 @@
1
+ /** @license
2
+ * RequireJS plugin for loading Markdown files and converting them into HTML.
3
+ * Author: Miller Medeiros
4
+ * Version: 0.1.1 (2012/02/17)
5
+ * Released under the MIT license
6
+ */
7
+
8
+ // NOTE :: if you don't need to load markdown files in production outside of
9
+ // the build, precompile them into modules and set
10
+ // `pragmasOnSave.excludeMdown=true`
11
+
12
+ define(
13
+ [
14
+ //>>excludeStart('excludeMdown', pragmas.excludeMdown)
15
+ 'text',
16
+ 'markdownConverter'
17
+ //>>excludeEnd('excludeMdown')
18
+ ],
19
+ function (
20
+ //>>excludeStart('excludeMdown', pragmas.excludeMdown)
21
+ text, markdownConverter
22
+ //>>excludeEnd('excludeMdown')
23
+ ) {
24
+
25
+ //>>excludeStart('excludeMdown', pragmas.excludeMdown)
26
+ var buildMap = {};
27
+ //>>excludeEnd('excludeMdown')
28
+
29
+ //API
30
+ return {
31
+
32
+ load : function(name, req, onLoad, config) {
33
+ //>>excludeStart('excludeMdown', pragmas.excludeMdown)
34
+ text.get(req.toUrl(name), function(data){
35
+ data = markdownConverter.makeHtml(data);
36
+ if (config.isBuild) {
37
+ buildMap[name] = data;
38
+ onLoad(data);
39
+ } else {
40
+ onLoad(data);
41
+ }
42
+ });
43
+ },
44
+
45
+ //write method based on RequireJS official text plugin by James Burke
46
+ //https://github.com/jrburke/requirejs/blob/master/text.js
47
+ write : function(pluginName, moduleName, write){
48
+ if(moduleName in buildMap){
49
+ var content = text.jsEscape(buildMap[moduleName]);
50
+ write.asModule(pluginName + "!" + moduleName,
51
+ "define(function () { return '" +
52
+ content +
53
+ "';});\n");
54
+ }
55
+ //>>excludeEnd('excludeMdown')
56
+ }
57
+
58
+ };
59
+ });
package/src/noext.js ADDED
@@ -0,0 +1,28 @@
1
+ /** @license
2
+ * RequireJS plugin for loading files without adding the JS extension, useful for
3
+ * JSONP services and any other kind of resource that already contain a file
4
+ * extension or that shouldn't have one (like dynamic scripts).
5
+ * Author: Miller Medeiros
6
+ * Version: 0.3.1 (2011/12/07)
7
+ * Released under the MIT license
8
+ */
9
+ define(function(){
10
+
11
+ var QUERY_PARAM = 'noext';
12
+
13
+ //API
14
+ return {
15
+ load : function(name, req, onLoad, config){
16
+ req([req.toUrl(name)], function(mod){
17
+ onLoad(mod);
18
+ });
19
+ },
20
+ normalize : function(name, norm){
21
+ //append query string to avoid adding .js extension
22
+ //needs to be on normalize otherwise it won't work after build
23
+ name += (name.indexOf('?') < 0)? '?' : '&';
24
+ return name + QUERY_PARAM +'=1';
25
+ }
26
+
27
+ };
28
+ });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Basic parser for URL properties
3
+ * @author Miller Medeiros
4
+ * @version 0.1.0 (2011/12/06)
5
+ * MIT license
6
+ */
7
+ define(function(){
8
+
9
+ var rProps = /([\w-]+)\s*:\s*(?:(\[[^\]]+\])|([^,]+)),?/g, //match "foo:bar" and "lorem:[ipsum,dolor]" capturing name as $1 and val as $2 or $3
10
+ rArr = /^\[([^\]]+)\]$/; //match "[foo,bar]" capturing "foo,bar"
11
+
12
+ function parseProperties(str){
13
+ var match, obj = {};
14
+ while (match = rProps.exec(str)) {
15
+ obj[ match[1] ] = typecastVal(match[2] || match[3]);
16
+ }
17
+ return obj;
18
+ }
19
+
20
+ function typecastVal(val){
21
+ if (rArr.test(val)){
22
+ val = val.replace(rArr, '$1').split(',');
23
+ } else if (val === 'null'){
24
+ val = null;
25
+ } else if (val === 'false'){
26
+ val = false;
27
+ } else if (val === 'true'){
28
+ val = true;
29
+ } else if (val === '' || val === "''" || val === '""'){
30
+ val = '';
31
+ } else if (! isNaN(val)) {
32
+ //isNaN('') == false
33
+ val = +val;
34
+ }
35
+ return val;
36
+ }
37
+
38
+ //API
39
+ return {
40
+ parseProperties : parseProperties,
41
+ typecastVal : typecastVal
42
+ };
43
+ });
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.