sproutcore 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +269 -0
- data/README.txt +67 -0
- data/Rakefile +4 -0
- data/app_generators/sproutcore/USAGE +5 -0
- data/app_generators/sproutcore/sproutcore_generator.rb +66 -0
- data/app_generators/sproutcore/templates/README +77 -0
- data/app_generators/sproutcore/templates/environment.yml +4 -0
- data/bin/sc-build +145 -0
- data/bin/sc-gen +24 -0
- data/bin/sc-server +63 -0
- data/bin/sproutcore +21 -0
- data/clients/sc_docs/controllers/docs.js +118 -0
- data/clients/sc_docs/core.js +19 -0
- data/clients/sc_docs/english.lproj/body.css +159 -0
- data/clients/sc_docs/english.lproj/body.rhtml +33 -0
- data/clients/sc_docs/english.lproj/controls.css +0 -0
- data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
- data/clients/sc_docs/english.lproj/images/indicator.gif +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/no_docs.rhtml +7 -0
- data/clients/sc_docs/english.lproj/strings.js +14 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +6 -0
- data/clients/sc_docs/fixtures/doc.js +11 -0
- data/clients/sc_docs/main.js +21 -0
- data/clients/sc_docs/models/doc.js +9 -0
- data/clients/sc_docs/tests/controllers/docs.rhtml +21 -0
- data/clients/sc_docs/tests/models/doc.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_frame.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +21 -0
- data/clients/sc_docs/views/doc_frame.js +33 -0
- data/clients/sc_docs/views/doc_label.js +20 -0
- data/clients/sc_test_runner/controllers/runner.js +175 -0
- data/clients/sc_test_runner/core.js +19 -0
- data/clients/sc_test_runner/english.lproj/body.css +151 -0
- data/clients/sc_test_runner/english.lproj/body.rhtml +35 -0
- data/clients/sc_test_runner/english.lproj/controls.css +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/gradients.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/indicator.gif +0 -0
- data/clients/sc_test_runner/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_test_runner/english.lproj/no_tests.rhtml +6 -0
- data/clients/sc_test_runner/english.lproj/strings.js +14 -0
- data/clients/sc_test_runner/english.lproj/warning.rhtml +6 -0
- data/clients/sc_test_runner/fixtures/test.js +12 -0
- data/clients/sc_test_runner/main.js +26 -0
- data/clients/sc_test_runner/models/test.js +11 -0
- data/clients/sc_test_runner/views/runner_frame.js +72 -0
- data/clients/sc_test_runner/views/test_label.js +20 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/environment.yml +9 -0
- data/frameworks/prototype/prototype.js +4186 -0
- data/frameworks/sproutcore/Core.js +378 -0
- data/frameworks/sproutcore/README +3 -0
- data/frameworks/sproutcore/controllers/array.js +236 -0
- data/frameworks/sproutcore/controllers/collection.js +305 -0
- data/frameworks/sproutcore/controllers/controller.js +323 -0
- data/frameworks/sproutcore/controllers/object.js +372 -0
- data/frameworks/sproutcore/drag/drag.js +549 -0
- data/frameworks/sproutcore/drag/drag_data_source.js +32 -0
- data/frameworks/sproutcore/drag/drag_source.js +64 -0
- data/frameworks/sproutcore/drag/drop_target.js +153 -0
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/buttons.css +589 -0
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/inline_text_editor.css +21 -0
- data/frameworks/sproutcore/english.lproj/menu.css +121 -0
- data/frameworks/sproutcore/english.lproj/panels/background-fat.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/background-thin.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/left-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/overlay.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/right-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panes.css +155 -0
- data/frameworks/sproutcore/english.lproj/picker.css +22 -0
- data/frameworks/sproutcore/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/english.lproj/tab.css +23 -0
- data/frameworks/sproutcore/english.lproj/tests.css +67 -0
- data/frameworks/sproutcore/english.lproj/theme.css +77 -0
- data/frameworks/sproutcore/foundation/animator.js +670 -0
- data/frameworks/sproutcore/foundation/application.js +199 -0
- data/frameworks/sproutcore/foundation/array.js +348 -0
- data/frameworks/sproutcore/foundation/benchmark.js +211 -0
- data/frameworks/sproutcore/foundation/binding.js +384 -0
- data/frameworks/sproutcore/foundation/date.js +357 -0
- data/frameworks/sproutcore/foundation/error.js +39 -0
- data/frameworks/sproutcore/foundation/input_manager.js +153 -0
- data/frameworks/sproutcore/foundation/json.js +296 -0
- data/frameworks/sproutcore/foundation/mock.js +42 -0
- data/frameworks/sproutcore/foundation/node_descriptor.js +56 -0
- data/frameworks/sproutcore/foundation/object.js +777 -0
- data/frameworks/sproutcore/foundation/observable.js +451 -0
- data/frameworks/sproutcore/foundation/page.js +63 -0
- data/frameworks/sproutcore/foundation/path_module.js +413 -0
- data/frameworks/sproutcore/foundation/responder.js +310 -0
- data/frameworks/sproutcore/foundation/routes.js +371 -0
- data/frameworks/sproutcore/foundation/run_loop.js +21 -0
- data/frameworks/sproutcore/foundation/server.js +491 -0
- data/frameworks/sproutcore/foundation/set.js +96 -0
- data/frameworks/sproutcore/foundation/string.js +149 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +186 -0
- data/frameworks/sproutcore/foundation/unittest.js +622 -0
- data/frameworks/sproutcore/foundation/utils.js +61 -0
- data/frameworks/sproutcore/globals/panels.js +182 -0
- data/frameworks/sproutcore/globals/popups.js +60 -0
- data/frameworks/sproutcore/globals/window.js +381 -0
- data/frameworks/sproutcore/lib/index.rhtml +66 -0
- data/frameworks/sproutcore/models/collection.js +395 -0
- data/frameworks/sproutcore/models/record.js +622 -0
- data/frameworks/sproutcore/models/store.js +295 -0
- data/frameworks/sproutcore/panes/dialog.js +16 -0
- data/frameworks/sproutcore/panes/manager.js +164 -0
- data/frameworks/sproutcore/panes/menu.js +45 -0
- data/frameworks/sproutcore/panes/overlay.js +231 -0
- data/frameworks/sproutcore/panes/pane.js +90 -0
- data/frameworks/sproutcore/panes/panel.js +19 -0
- data/frameworks/sproutcore/panes/picker.js +45 -0
- data/frameworks/sproutcore/tests/controllers/array.rhtml +86 -0
- data/frameworks/sproutcore/tests/controllers/controller.rhtml +273 -0
- data/frameworks/sproutcore/tests/controllers/object.rhtml +327 -0
- data/frameworks/sproutcore/tests/foundation/application.rhtml +125 -0
- data/frameworks/sproutcore/tests/foundation/array.rhtml +221 -0
- data/frameworks/sproutcore/tests/foundation/object.rhtml +69 -0
- data/frameworks/sproutcore/tests/globals/window.rhtml +45 -0
- data/frameworks/sproutcore/tests/panes/pane.rhtml +88 -0
- data/frameworks/sproutcore/tests/views/collection.rhtml +137 -0
- data/frameworks/sproutcore/tests/views/popup_button.rhtml +115 -0
- data/frameworks/sproutcore/tests/views/text_field.rhtml +37 -0
- data/frameworks/sproutcore/validators/credit_card.js +92 -0
- data/frameworks/sproutcore/validators/date.js +36 -0
- data/frameworks/sproutcore/validators/email.js +29 -0
- data/frameworks/sproutcore/validators/not_empty.js +24 -0
- data/frameworks/sproutcore/validators/number.js +55 -0
- data/frameworks/sproutcore/validators/password.js +78 -0
- data/frameworks/sproutcore/validators/validator.js +304 -0
- data/frameworks/sproutcore/views/button.js +425 -0
- data/frameworks/sproutcore/views/checkbox_field.js +30 -0
- data/frameworks/sproutcore/views/collection.js +1521 -0
- data/frameworks/sproutcore/views/container.js +62 -0
- data/frameworks/sproutcore/views/error_explanation.js +45 -0
- data/frameworks/sproutcore/views/field.js +214 -0
- data/frameworks/sproutcore/views/filter_button.js +29 -0
- data/frameworks/sproutcore/views/form.js +591 -0
- data/frameworks/sproutcore/views/image.js +141 -0
- data/frameworks/sproutcore/views/inline_text_editor.js +96 -0
- data/frameworks/sproutcore/views/label.js +176 -0
- data/frameworks/sproutcore/views/menu_item.js +90 -0
- data/frameworks/sproutcore/views/pagination.js +54 -0
- data/frameworks/sproutcore/views/popup_button.js +86 -0
- data/frameworks/sproutcore/views/popup_menu.js +137 -0
- data/frameworks/sproutcore/views/progress.js +100 -0
- data/frameworks/sproutcore/views/radio_field.js +107 -0
- data/frameworks/sproutcore/views/radio_group.js +48 -0
- data/frameworks/sproutcore/views/segmented.js +80 -0
- data/frameworks/sproutcore/views/select_field.js +272 -0
- data/frameworks/sproutcore/views/spinner.js +11 -0
- data/frameworks/sproutcore/views/tab.js +126 -0
- data/frameworks/sproutcore/views/text_field.js +179 -0
- data/frameworks/sproutcore/views/textarea_field.js +14 -0
- data/frameworks/sproutcore/views/toolbar.js +29 -0
- data/frameworks/sproutcore/views/view.js +1389 -0
- data/frameworks/sproutcore/views/workspace.js +170 -0
- data/generators/client/README +3 -0
- data/generators/client/USAGE +12 -0
- data/generators/client/client_generator.rb +53 -0
- data/generators/client/templates/core.js +19 -0
- data/generators/client/templates/english.lproj/body.css +0 -0
- data/generators/client/templates/english.lproj/body.rhtml +3 -0
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/client/templates/english.lproj/strings.js +14 -0
- data/generators/client/templates/main.js +37 -0
- data/generators/controller/USAGE +16 -0
- data/generators/controller/controller_generator.rb +51 -0
- data/generators/controller/templates/controller.js +21 -0
- data/generators/controller/templates/test.rhtml +21 -0
- data/generators/framework/README +7 -0
- data/generators/framework/USAGE +12 -0
- data/generators/framework/framework_generator.rb +53 -0
- data/generators/framework/templates/core.js +20 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +3 -0
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/strings.js +14 -0
- data/generators/language/USAGE +16 -0
- data/generators/language/language_generator.rb +47 -0
- data/generators/language/templates/strings.js +10 -0
- data/generators/model/USAGE +24 -0
- data/generators/model/model_generator.rb +55 -0
- data/generators/model/templates/fixture.js +11 -0
- data/generators/model/templates/model.js +20 -0
- data/generators/model/templates/test.rhtml +21 -0
- data/generators/test/USAGE +16 -0
- data/generators/test/templates/test.rhtml +21 -0
- data/generators/test/test_generator.rb +47 -0
- data/generators/view/USAGE +16 -0
- data/generators/view/templates/test.rhtml +21 -0
- data/generators/view/templates/view.js +20 -0
- data/generators/view/view_generator.rb +51 -0
- data/jsdoc/README.txt +119 -0
- data/jsdoc/app/DocFile.js +137 -0
- data/jsdoc/app/DocTag.js +110 -0
- data/jsdoc/app/Doclet.js +63 -0
- data/jsdoc/app/Dumper.js +143 -0
- data/jsdoc/app/JsDoc.js +103 -0
- data/jsdoc/app/JsHilite.js +45 -0
- data/jsdoc/app/JsIO.js +163 -0
- data/jsdoc/app/JsParse.js +385 -0
- data/jsdoc/app/JsPlate.js +130 -0
- data/jsdoc/app/JsTestrun.js +129 -0
- data/jsdoc/app/JsToke.js +564 -0
- data/jsdoc/app/Symbol.js +298 -0
- data/jsdoc/app/Transformer.js +14 -0
- data/jsdoc/app/Util.js +97 -0
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/app/run.js +144 -0
- data/jsdoc/plugins/min.js +316 -0
- data/jsdoc/plugins/strip.js +20 -0
- data/jsdoc/templates/sproutcore/class.tmpl +438 -0
- data/jsdoc/templates/sproutcore/default.css +241 -0
- data/jsdoc/templates/sproutcore/index.html +13 -0
- data/jsdoc/templates/sproutcore/index.tmpl +21 -0
- data/jsdoc/templates/sproutcore/prototype.js +4186 -0
- data/jsdoc/templates/sproutcore/publish.js +236 -0
- data/jsdoc/templates/sproutcore/splash.html +7 -0
- data/lib/sproutcore/build_tools/html_builder.rb +88 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +194 -0
- data/lib/sproutcore/build_tools.rb +44 -0
- data/lib/sproutcore/bundle.rb +517 -0
- data/lib/sproutcore/bundle_manifest.rb +397 -0
- data/lib/sproutcore/generator_helper.rb +170 -0
- data/lib/sproutcore/helpers/capture_helper.rb +42 -0
- data/lib/sproutcore/helpers/static_helper.rb +80 -0
- data/lib/sproutcore/helpers/tag_helper.rb +110 -0
- data/lib/sproutcore/helpers/text_helper.rb +336 -0
- data/lib/sproutcore/helpers.rb +3 -0
- data/lib/sproutcore/jsdoc.rb +40 -0
- data/lib/sproutcore/jsmin.rb +247 -0
- data/lib/sproutcore/library.rb +258 -0
- data/lib/sproutcore/merb/bundle_controller.rb +179 -0
- data/lib/sproutcore/merb/router.rb +43 -0
- data/lib/sproutcore/merb.rb +27 -0
- data/lib/sproutcore/version.rb +9 -0
- data/lib/sproutcore/view_helpers/button_views.rb +302 -0
- data/lib/sproutcore/view_helpers/core_views.rb +284 -0
- data/lib/sproutcore/view_helpers/form_views.rb +258 -0
- data/lib/sproutcore/view_helpers/menu_views.rb +94 -0
- data/lib/sproutcore/view_helpers.rb +628 -0
- data/lib/sproutcore.rb +30 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/sproutcore_spec.rb +11 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- metadata +365 -0
@@ -0,0 +1,236 @@
|
|
1
|
+
require("app/JsHilite.js");
|
2
|
+
|
3
|
+
function basename(filename) {
|
4
|
+
filename.match(/([^\/\\]+)\.[^\/\\]+$/);
|
5
|
+
return RegExp.$1;
|
6
|
+
}
|
7
|
+
|
8
|
+
// This is the orginial function from Stuart Langridge at http://www.kryogenix.org/
|
9
|
+
// This is the update function from Jeff Minard - http://www.jrm.cc/
|
10
|
+
function superTextile(s) {
|
11
|
+
|
12
|
+
// CAJ - First, strip out extra newlines and whitespace at the start
|
13
|
+
// of comments. This will yield more appropriate text for formatting.
|
14
|
+
s = s.split("\n").map(function(l) { return ((l=='') || (l.match(/^\s+$/))) ? "" : l.replace(/^\s+/,'') ; }).join("\n") ;
|
15
|
+
|
16
|
+
var r = s;
|
17
|
+
// quick tags first
|
18
|
+
qtags = [ ['\\*', '\\*', 'strong'],
|
19
|
+
['\\?\\?', '\\?\\?', 'cite'],
|
20
|
+
['\\+', '\\+', 'ins'], //fixed
|
21
|
+
['~', '~', 'sub'],
|
22
|
+
['\\^', '\\^', 'sup'], // me
|
23
|
+
['{{{', '}}}', 'code']];
|
24
|
+
|
25
|
+
for (var i=0;i<qtags.length;i++) {
|
26
|
+
var ttag_o = qtags[i][0], ttag_c = qtags[i][1], htag = qtags[i][2];
|
27
|
+
re = new RegExp(ttag_o+'\\b(.+?)\\b'+ttag_c,'g');
|
28
|
+
r = r.replace(re,'<'+htag+'>'+'$1'+'</'+htag+'>');
|
29
|
+
};
|
30
|
+
|
31
|
+
// underscores count as part of a word, so do them separately
|
32
|
+
re = new RegExp('\\b_(.+?)_\\b','g');
|
33
|
+
r = r.replace(re,'<em>$1</em>');
|
34
|
+
|
35
|
+
//jeff: so do dashes
|
36
|
+
re = new RegExp('[\s\n]-(.+?)-[\s\n]','g');
|
37
|
+
r = r.replace(re,'<del>$1</del>');
|
38
|
+
|
39
|
+
// links
|
40
|
+
re = new RegExp('"\\b(.+?)\\(\\b(.+?)\\b\\)":([^\\s]+)','g');
|
41
|
+
r = r.replace(re,'<a href="$3" title="$2">$1</a>');
|
42
|
+
|
43
|
+
re = new RegExp('"\\b(.+?)\\b":([^\\s]+)','g');
|
44
|
+
r = r.replace(re,'<a href="$2">$1</a>');
|
45
|
+
|
46
|
+
// images
|
47
|
+
re = new RegExp('!\\b(.+?)\\(\\b(.+?)\\b\\)!','g');
|
48
|
+
r = r.replace(re,'<img src="$1" alt="$2">');
|
49
|
+
re = new RegExp('!\\b(.+?)\\b!','g');
|
50
|
+
r = r.replace(re,'<img src="$1">');
|
51
|
+
|
52
|
+
// block level formatting
|
53
|
+
lines = r.split('\n');
|
54
|
+
out = [] ;
|
55
|
+
nr = '';
|
56
|
+
var incode = 0 ;
|
57
|
+
var cur_block = [] ; // collect lines into a block before processing them.
|
58
|
+
for (var i=0;i<lines.length;i++) {
|
59
|
+
var line = lines[i].replace(/\s*$/,'');
|
60
|
+
changed = 0;
|
61
|
+
|
62
|
+
// handle incode behavior.
|
63
|
+
if (incode) {
|
64
|
+
|
65
|
+
// Look for end closing bracket and process it.
|
66
|
+
if (line.match(/^\s*}}}\s*$/)) {
|
67
|
+
incode = 0 ;
|
68
|
+
out.push("<p class=\"code\"><code>" + cur_block.join("<br />") + "</code></p>") ;
|
69
|
+
cur_block = [] ;
|
70
|
+
|
71
|
+
// otherwise, just add the line to the current block
|
72
|
+
} else {
|
73
|
+
cur_block.push(line) ;
|
74
|
+
}
|
75
|
+
|
76
|
+
// for normal text, look for line-level items to replace. If no
|
77
|
+
// replacement is found, then add the line to the current block.
|
78
|
+
} else {
|
79
|
+
|
80
|
+
// an empty line means we should end the current paragraph
|
81
|
+
if ((line == '') || line.match(/^\s+$/)) {
|
82
|
+
changed = 1 ;
|
83
|
+
line = '' ;
|
84
|
+
|
85
|
+
// convert bq. => blockquote.
|
86
|
+
} else if (line.search(/^\s*bq\.\s+/) != -1) {
|
87
|
+
line = line.replace(/^\s*bq\.\s+/,'\t<blockquote>')+'</blockquote>';
|
88
|
+
changed = 1;
|
89
|
+
|
90
|
+
// convert h* => heading
|
91
|
+
} else if (line.search(/^\s*h[1|2|3|4|5|6]\.\s+/) != -1) {
|
92
|
+
line = line.replace(/^\s*h([1|2|3|4|5|6])\.(.+)/, '<h$1>$2</h$1>');
|
93
|
+
changed = 1;
|
94
|
+
|
95
|
+
// convert * to bulletted list. liu tag will be fixed later.
|
96
|
+
} else if (line.search(/^\s*\*\s+/) != -1) {
|
97
|
+
line = line.replace(/^\s*\*\s+/,'\t<liu>') + '</liu>'; changed = 1;
|
98
|
+
changed = 1;
|
99
|
+
|
100
|
+
// convert # to numbered list. lio tag will be fixed later.
|
101
|
+
} else if (line.search(/^\s*#\s+/) != -1) {
|
102
|
+
line = line.replace(/^\s*#\s+/,'\t<lio>') + '</lio>'; changed = 1;
|
103
|
+
changed = 1;
|
104
|
+
|
105
|
+
// open code tag will start code
|
106
|
+
} else if (line.match(/^\s*\{\{\{\s*$/)) {
|
107
|
+
incode++ ;
|
108
|
+
line = '' ;
|
109
|
+
changed = 1;
|
110
|
+
}
|
111
|
+
|
112
|
+
// if the line was changed, the emit the current block as a paragraph
|
113
|
+
// and emit the line itself. Otherwise, just push the line into the
|
114
|
+
// current block.
|
115
|
+
if (changed > 0) {
|
116
|
+
if (cur_block.length > 0) {
|
117
|
+
out.push("<p>" + cur_block.join(" ") + '</p>') ;
|
118
|
+
cur_block = [] ;
|
119
|
+
}
|
120
|
+
out.push(line) ;
|
121
|
+
} else {
|
122
|
+
cur_block.push(line) ;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
// done. if there are any lines left, in the current block, emit it.
|
128
|
+
if (cur_block.length > 0) {
|
129
|
+
out.push("<p>" + cur_block.join(" ") + '</p>') ;
|
130
|
+
cur_block = [] ;
|
131
|
+
}
|
132
|
+
|
133
|
+
// Second pass to do lists. This will wrap the lists in <li> | <ol> tags.
|
134
|
+
inlist = 0;
|
135
|
+
listtype = '';
|
136
|
+
for (var i=0;i<out.length;i++) {
|
137
|
+
line = out[i];
|
138
|
+
var addin = null ;
|
139
|
+
|
140
|
+
if (inlist && listtype == 'ul' && !line.match(/^\t<liu/)) {
|
141
|
+
addin = '</ul>\n'; inlist = 0;
|
142
|
+
}
|
143
|
+
|
144
|
+
if (inlist && listtype == 'ol' && !line.match(/^\t<lio/)) {
|
145
|
+
addin = '</ol>\n'; inlist = 0;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (!inlist && line.match(/^\t<liu/)) {
|
149
|
+
line = '<ul>' + line; inlist = 1; listtype = 'ul';
|
150
|
+
}
|
151
|
+
|
152
|
+
if (!inlist && line.match(/^\t<lio/)) {
|
153
|
+
line = '<ol>' + line; inlist = 1; listtype = 'ol';
|
154
|
+
}
|
155
|
+
|
156
|
+
if (addin) line = addin + line ;
|
157
|
+
out[i] = line;
|
158
|
+
}
|
159
|
+
|
160
|
+
// Now we can join the string. Yay!
|
161
|
+
r = out.join('\n');
|
162
|
+
|
163
|
+
// jeff added : will correctly replace <li(o|u)> AND </li(o|u)>
|
164
|
+
r = r.replace(/li[o|u]>/g,'li>');
|
165
|
+
|
166
|
+
return r;
|
167
|
+
} ;
|
168
|
+
|
169
|
+
function publish(fileGroup, context) {
|
170
|
+
var classTemplate = new JsPlate(context.t+"class.tmpl");
|
171
|
+
var indexTemplate = new JsPlate(context.t+"index.tmpl");
|
172
|
+
|
173
|
+
var allFiles = {};
|
174
|
+
var allClasses = {};
|
175
|
+
var globals = {methods:[], properties:[], alias:"GLOBALS", isStatic:true};
|
176
|
+
|
177
|
+
for (var i = 0; i < fileGroup.files.length; i++) {
|
178
|
+
var file_basename = basename(fileGroup.files[i].filename);
|
179
|
+
var file_srcname = file_basename+".src.html";
|
180
|
+
|
181
|
+
for (var s = 0; s < fileGroup.files[i].symbols.length; s++) {
|
182
|
+
if (fileGroup.files[i].symbols[s].isa == "CONSTRUCTOR") {
|
183
|
+
var thisClass = fileGroup.files[i].symbols[s];
|
184
|
+
// sort inherited methods by class
|
185
|
+
var inheritedMethods = fileGroup.files[i].symbols[s].getInheritedMethods();
|
186
|
+
if (inheritedMethods.length > 0) {
|
187
|
+
thisClass.inherited = {};
|
188
|
+
for (var n = 0; n < inheritedMethods.length; n++) {
|
189
|
+
if (! thisClass.inherited[inheritedMethods[n].memberof]) thisClass.inherited[inheritedMethods[n].memberof] = [];
|
190
|
+
thisClass.inherited[inheritedMethods[n].memberof].push(inheritedMethods[n]);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
thisClass.name = fileGroup.files[i].symbols[s].alias;
|
195
|
+
thisClass.source = file_srcname;
|
196
|
+
thisClass.filename = fileGroup.files[i].filename;
|
197
|
+
thisClass.docs = thisClass.name+".html";
|
198
|
+
|
199
|
+
if (!allClasses[thisClass.name]) allClasses[thisClass.name] = [];
|
200
|
+
allClasses[thisClass.name].push(thisClass);
|
201
|
+
}
|
202
|
+
else if (fileGroup.files[i].symbols[s].alias == fileGroup.files[i].symbols[s].name) {
|
203
|
+
if (fileGroup.files[i].symbols[s].isa == "FUNCTION") {
|
204
|
+
globals.methods.push(fileGroup.files[i].symbols[s]);
|
205
|
+
}
|
206
|
+
else {
|
207
|
+
globals.properties.push(fileGroup.files[i].symbols[s]);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
if (!allFiles[fileGroup.files[i].path]) {
|
213
|
+
var hiliter = new JsHilite(IO.readFile(fileGroup.files[i].path), JsDoc.opt.e);
|
214
|
+
IO.saveFile(context.d, file_srcname, hiliter.hilite());
|
215
|
+
}
|
216
|
+
fileGroup.files[i].source = file_srcname;
|
217
|
+
allFiles[fileGroup.files[i].path] = true;
|
218
|
+
}
|
219
|
+
|
220
|
+
for (var c in allClasses) {
|
221
|
+
outfile = c+".html";
|
222
|
+
allClasses[c].outfile = outfile;
|
223
|
+
var output = classTemplate.process(allClasses[c]);
|
224
|
+
IO.saveFile(context.d, outfile, output);
|
225
|
+
}
|
226
|
+
|
227
|
+
output = classTemplate.process([globals]);
|
228
|
+
IO.saveFile(context.d, "globals.html", output);
|
229
|
+
|
230
|
+
var output = indexTemplate.process(allClasses);
|
231
|
+
IO.saveFile(context.d, "classes.js", output);
|
232
|
+
IO.copyFile(context.t+"index.html", context.d);
|
233
|
+
IO.copyFile(context.t+"splash.html", context.d);
|
234
|
+
IO.copyFile(context.t+"default.css", context.d) ;
|
235
|
+
IO.copyFile(context.t+"prototype.js", context.d) ;
|
236
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
require 'sproutcore/helpers'
|
3
|
+
require 'sproutcore/view_helpers'
|
4
|
+
|
5
|
+
module SproutCore
|
6
|
+
|
7
|
+
module BuildTools
|
8
|
+
|
9
|
+
# Whenever you build an HTML file for a SproutCore client, an instance of this class
|
10
|
+
# is created to actually process and build the HTML using Erubus. If you want to add
|
11
|
+
# more methods to use in your HTML files, just include them in HtmlContext.
|
12
|
+
#
|
13
|
+
class HtmlContext
|
14
|
+
|
15
|
+
include SproutCore::Helpers::TagHelper
|
16
|
+
include SproutCore::Helpers::TextHelper
|
17
|
+
include SproutCore::Helpers::CaptureHelper
|
18
|
+
include SproutCore::Helpers::StaticHelper
|
19
|
+
include SproutCore::ViewHelpers
|
20
|
+
|
21
|
+
attr_reader :entry, :bundle, :filenames, :filename, :language, :library
|
22
|
+
|
23
|
+
def initialize(entry, bundle)
|
24
|
+
@entry = nil
|
25
|
+
@language = entry.language
|
26
|
+
@filenames = entry.composite.nil? ? [entry.filename] : entry.composite
|
27
|
+
@bundle = bundle
|
28
|
+
@library = bundle.library
|
29
|
+
end
|
30
|
+
|
31
|
+
# Actually builds the HTML file from the entry (actually from any composite entries)
|
32
|
+
def build
|
33
|
+
|
34
|
+
@layout_path = bundle.layout_path
|
35
|
+
|
36
|
+
# Render each filename. By default, the output goes to the resources string
|
37
|
+
@content_for_resources = ''
|
38
|
+
filenames.each { |fn| _render_one(fn) }
|
39
|
+
|
40
|
+
# Finally, render the layout. This should produce the final output to return
|
41
|
+
input = File.read(@layout_path)
|
42
|
+
return eval(Erubis::Eruby.new.convert(input))
|
43
|
+
end
|
44
|
+
|
45
|
+
# render a single entry
|
46
|
+
def _render_one(filename)
|
47
|
+
@filename = filename
|
48
|
+
@entry = bundle.entry_for(filename, :hidden => :include, :language => language)
|
49
|
+
|
50
|
+
# avoid double render of layout path
|
51
|
+
return if @entry.source_path == @layout_path
|
52
|
+
|
53
|
+
# render. Result goes into @content_for_resources
|
54
|
+
input = File.read(@entry.source_path)
|
55
|
+
@content_for_resources += eval(Erubis::Eruby.new.convert(input))
|
56
|
+
|
57
|
+
@filename =nil
|
58
|
+
@entry = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Returns the current bundle name. Often useful for generating titles, etc.
|
63
|
+
def bundle_name; bundle.bundle_name; end
|
64
|
+
|
65
|
+
#### For Rails Compatibility. render() does not do anything useful since the
|
66
|
+
# new build system is nice about putting things into the right place for output.
|
67
|
+
def render; ''; end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.build_html(entry, bundle)
|
72
|
+
context = HtmlContext.new(entry,bundle)
|
73
|
+
output = context.build
|
74
|
+
|
75
|
+
puts "saving: #{entry.filename} to #{entry.build_path}: size: #{output.size}"
|
76
|
+
FileUtils.mkdir_p(File.dirname(entry.build_path))
|
77
|
+
f = File.open(entry.build_path, 'w')
|
78
|
+
f.write(output)
|
79
|
+
f.close
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# Building a test is just like building a single page except that we do not include
|
84
|
+
# all the other html templates in the project
|
85
|
+
def self.build_test(entry, bundle); build_html(entry, bundle); end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module SproutCore
|
2
|
+
|
3
|
+
module BuildTools
|
4
|
+
|
5
|
+
# Set to override the default behavior (which will follow the build mode)
|
6
|
+
def self.minify?; @minify.nil? ? (Bundle.build_mode != :development) : @minify; end
|
7
|
+
def self.minify=(setting); @minify = setting; end
|
8
|
+
|
9
|
+
# The ResourceBuilder can combine all of the source files listed in the passed entry
|
10
|
+
# including some basic pre-processing. The JavaScriptBuilder extends this to do some
|
11
|
+
# JavaScript specific rewriting of URLs, etc. as well.
|
12
|
+
#
|
13
|
+
# The ResourceBuilder knows how
|
14
|
+
class ResourceBuilder
|
15
|
+
|
16
|
+
attr_reader :bundle, :language, :filenames
|
17
|
+
|
18
|
+
# Utility method you can call to get the items sorted by load order
|
19
|
+
def self.sort_entries_by_load_order(entries, language, bundle)
|
20
|
+
filenames = entries.map { |e| e.filename }
|
21
|
+
hashed = {}
|
22
|
+
entries.each { |e| hashed[e.filename] = e }
|
23
|
+
|
24
|
+
sorted = self.new(filenames, language, bundle).required
|
25
|
+
sorted.map { |filename| hashed[filename] }
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(filenames, language, bundle)
|
29
|
+
@bundle = bundle; @language = language; @filenames = filenames
|
30
|
+
end
|
31
|
+
|
32
|
+
# Simply returns the filenames in the order that they were required
|
33
|
+
def required
|
34
|
+
lines = []; required = []
|
35
|
+
while filename = next_filename
|
36
|
+
lines, required = _build_one(filename, lines, required, true)
|
37
|
+
end
|
38
|
+
return lines
|
39
|
+
end
|
40
|
+
|
41
|
+
# Actually perform the build. Returns the compiled resource as a single string.
|
42
|
+
def build
|
43
|
+
|
44
|
+
# setup context
|
45
|
+
lines = []
|
46
|
+
required = []
|
47
|
+
|
48
|
+
# process files
|
49
|
+
while filename = next_filename
|
50
|
+
lines, required = _build_one(filename, lines, required)
|
51
|
+
end
|
52
|
+
|
53
|
+
return join(lines)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Join the lines together. This is one last chance to do some prep of the data
|
57
|
+
# (such as minifcation and comment stripping)
|
58
|
+
def join(lines); lines.join; end
|
59
|
+
|
60
|
+
# Tries to build a single resource. This may call itself recursively to handle
|
61
|
+
# requires.
|
62
|
+
#
|
63
|
+
# ==== Returns
|
64
|
+
# [lines, required] to be passed into the next call
|
65
|
+
#
|
66
|
+
def _build_one(filename, lines, required, link_only = false)
|
67
|
+
return [lines, required] if required.include?(filename)
|
68
|
+
required << filename
|
69
|
+
|
70
|
+
entry = bundle.entry_for(filename, :hidden => :include, :language => language)
|
71
|
+
if entry.nil?
|
72
|
+
puts "WARNING: Could not find require file: #{filename}"
|
73
|
+
return [lines, required]
|
74
|
+
end
|
75
|
+
|
76
|
+
file_lines = []
|
77
|
+
io = entry.source_path.nil? ? [] : File.new(entry.source_path)
|
78
|
+
io.each do | line |
|
79
|
+
|
80
|
+
# check for requires. Only follow a require if the require is in the list
|
81
|
+
# of filenames.
|
82
|
+
required_file = _require_for(filename, line)
|
83
|
+
unless required_file.nil? || !filenames.include?(required_file)
|
84
|
+
lines, required = _build_one(required_file, lines, required, link_only)
|
85
|
+
end
|
86
|
+
|
87
|
+
file_lines << _rewrite_static_urls(line) unless link_only
|
88
|
+
end
|
89
|
+
|
90
|
+
# The list of already required filenames is slightly out of order from the actual
|
91
|
+
# load order. Instead, we use the lines array to hold the list of filenames as they
|
92
|
+
# are processed.
|
93
|
+
if link_only
|
94
|
+
lines << filename
|
95
|
+
|
96
|
+
elsif file_lines.size > 0
|
97
|
+
lines += file_lines
|
98
|
+
lines << "\n"
|
99
|
+
end
|
100
|
+
|
101
|
+
return [lines, required]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Overridden by subclasses to choose first filename.
|
105
|
+
def next_filename; filenames.delete(filenames.first); end
|
106
|
+
|
107
|
+
# This will look for calls to static_url() and rewrite them with an actual
|
108
|
+
# string to the URL. Assumes the input text is JavaScript or CSS.
|
109
|
+
def _rewrite_static_urls(line)
|
110
|
+
line.gsub(/static_url\([\'\"](.+)[\'\"]\)/) do | rsrc |
|
111
|
+
entry = bundle.find_resource_entry($1, :language => language)
|
112
|
+
static_url(entry.nil? ? '' : entry.url)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Overridden by subclass to handle static_url() in a language specific way.
|
117
|
+
def static_url(url); "url('#{url}')"; end
|
118
|
+
|
119
|
+
# check line for required() pattern. understands JS and CSS.
|
120
|
+
def _require_for(filename,line)
|
121
|
+
new_file = line.scan(/require\(['"](.*)['"]\)/)
|
122
|
+
ret = (new_file.size > 0) ? new_file.first.first : nil
|
123
|
+
ret.nil? ? nil : filename_for_require(ret)
|
124
|
+
end
|
125
|
+
|
126
|
+
def filename_for_require(ret); "#{ret}.css"; end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
class JavaScriptResourceBuilder < ResourceBuilder
|
131
|
+
|
132
|
+
# Final processing of file. Remove comments & minify
|
133
|
+
def join(lines)
|
134
|
+
|
135
|
+
if BuildTools.minify?
|
136
|
+
# first suck out any comments that should be retained
|
137
|
+
comments = []
|
138
|
+
include_line = false
|
139
|
+
lines.each do | line |
|
140
|
+
is_mark = (line =~ /@license/)
|
141
|
+
unless include_line
|
142
|
+
include_line = true if is_mark
|
143
|
+
is_mark = false
|
144
|
+
end
|
145
|
+
|
146
|
+
comments << line if include_line
|
147
|
+
include_line = false if include_line && is_mark
|
148
|
+
end
|
149
|
+
|
150
|
+
# now minify and prepend any static
|
151
|
+
comments.push "\n" unless comments.empty?
|
152
|
+
comments.push SproutCore::JSMin.run(lines * '')
|
153
|
+
lines = comments
|
154
|
+
end
|
155
|
+
|
156
|
+
lines.join
|
157
|
+
end
|
158
|
+
|
159
|
+
def static_url(url); "'#{url}'"; end
|
160
|
+
def filename_for_require(ret); "#{ret}.js"; end
|
161
|
+
|
162
|
+
def next_filename
|
163
|
+
filenames.delete('strings.js') || filenames.delete('core.js') || filenames.delete('Core.js') || filenames.delete('utils.js') || filenames.delete(filenames.first)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.build_stylesheet(entry, bundle)
|
169
|
+
filenames = entry.composite.nil? ? [entry.filename] : entry.composite
|
170
|
+
builder = ResourceBuilder.new(filenames, entry.language, bundle)
|
171
|
+
if output = builder.build
|
172
|
+
FileUtils.mkdir_p(File.dirname(entry.build_path))
|
173
|
+
f = File.open(entry.build_path, 'w')
|
174
|
+
f.write(output)
|
175
|
+
f.close
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.build_javascript(entry, bundle)
|
180
|
+
filenames = entry.composite.nil? ? [entry.filename] : entry.composite
|
181
|
+
builder = JavaScriptResourceBuilder.new(filenames, entry.language, bundle)
|
182
|
+
if output = builder.build
|
183
|
+
FileUtils.mkdir_p(File.dirname(entry.build_path))
|
184
|
+
f = File.open(entry.build_path, 'w')
|
185
|
+
f.write(output)
|
186
|
+
f.close
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.build_fixture(entry, bundle); build_javascript(entry, bundle); end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module SproutCore
|
2
|
+
|
3
|
+
# This module contains entry points to builds tools that handle various types of resources
|
4
|
+
# in a SproutCore client. Each build tool has a method "build_xx(entry, bundle)" that can
|
5
|
+
# be called here.
|
6
|
+
#
|
7
|
+
# You can add your own build tools to the system here .
|
8
|
+
#
|
9
|
+
module BuildTools
|
10
|
+
|
11
|
+
# Resources are sometimes accessed through a symlink while running in devmode. This
|
12
|
+
# method should simply ensure that symlink exists.
|
13
|
+
#
|
14
|
+
def self.build_symlink(entry, bundle)
|
15
|
+
symlink_path = File.join(bundle.build_root, '_src')
|
16
|
+
source_path = bundle.source_root
|
17
|
+
unless File.exist?(symlink_path)
|
18
|
+
FileUtils.mkdir_p(bundle.build_root)
|
19
|
+
FileUtils.ln_sf(source_path, symlink_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Regular resources and tests are simply copied. Note that normally in development mode,
|
24
|
+
# these resources will be accessed via a symlink
|
25
|
+
def self.copy_resource(entry, bundle)
|
26
|
+
FileUtils.mkdir_p(File.dirname(entry.build_path))
|
27
|
+
|
28
|
+
# Make the source file exists
|
29
|
+
unless File.exists?(entry.source_path)
|
30
|
+
raise "Could not copy resource #{entry.filename} because source: #{entry.source_path} does not exist!"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Now do the copy
|
34
|
+
FileUtils.cp_r(entry.source_path, entry.build_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.build_resource(entry, bundle); copy_resource(entry, bundle); end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# Load other build tools. The above are the simple ones.
|
44
|
+
Dir.glob(File.join(File.dirname(__FILE__),'build_tools','**','*.rb')).each { |x| require x }
|