ramaze 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/Rakefile +4 -12
  2. data/bin/ramaze +95 -171
  3. data/doc/CHANGELOG +387 -4
  4. data/doc/README +81 -13
  5. data/doc/meta/announcement.txt +51 -8
  6. data/doc/meta/configuration.txt +17 -34
  7. data/doc/meta/internals.txt +34 -4
  8. data/doc/migrate/1110_to_1111.txt +131 -0
  9. data/doc/readme_chunks/features.txt +81 -12
  10. data/doc/readme_chunks/installing.txt +0 -1
  11. data/doc/tutorial/todolist.html +293 -65
  12. data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
  13. data/examples/blog/main.rb +1 -1
  14. data/examples/blog/src/model.rb +0 -1
  15. data/examples/hello.rb +2 -5
  16. data/examples/templates/template/external.haml +5 -5
  17. data/examples/templates/template/external.liquid +1 -1
  18. data/examples/templates/template/external.mab +8 -8
  19. data/examples/templates/template/external.rem +30 -0
  20. data/examples/templates/template/external.rhtml +6 -7
  21. data/examples/templates/template/external.zmr +13 -9
  22. data/examples/templates/template_amrita2.rb +8 -8
  23. data/examples/templates/template_erubis.rb +11 -11
  24. data/examples/templates/template_ezamar.rb +9 -11
  25. data/examples/templates/template_haml.rb +13 -13
  26. data/examples/templates/template_liquid.rb +10 -10
  27. data/examples/templates/template_markaby.rb +13 -10
  28. data/examples/templates/template_remarkably.rb +59 -0
  29. data/examples/todolist/main.rb +1 -7
  30. data/examples/todolist/src/controller/main.rb +26 -13
  31. data/examples/todolist/src/element/page.rb +5 -0
  32. data/examples/whywiki/main.rb +1 -1
  33. data/lib/proto/main.rb +0 -8
  34. data/lib/proto/public/css/ramaze_error.css +12 -4
  35. data/lib/proto/public/error.zmr +6 -25
  36. data/lib/ramaze.rb +35 -245
  37. data/lib/ramaze/action.rb +21 -0
  38. data/lib/ramaze/adapter.rb +94 -29
  39. data/lib/ramaze/adapter/base.rb +57 -0
  40. data/lib/ramaze/adapter/mongrel.rb +12 -19
  41. data/lib/ramaze/adapter/webrick.rb +21 -20
  42. data/lib/ramaze/cache.rb +47 -3
  43. data/lib/ramaze/cache/memcached.rb +22 -0
  44. data/lib/ramaze/cache/yaml_store.rb +19 -0
  45. data/lib/ramaze/controller.rb +47 -271
  46. data/lib/ramaze/controller/error.rb +43 -0
  47. data/lib/ramaze/controller/render.rb +90 -0
  48. data/lib/ramaze/controller/resolve.rb +147 -0
  49. data/lib/ramaze/dispatcher.rb +41 -9
  50. data/lib/ramaze/dispatcher/file.rb +1 -1
  51. data/lib/ramaze/global.rb +73 -158
  52. data/lib/ramaze/global/dsl.rb +29 -0
  53. data/lib/ramaze/global/globalstruct.rb +90 -0
  54. data/lib/ramaze/helper.rb +1 -1
  55. data/lib/ramaze/helper/aspect.rb +39 -179
  56. data/lib/ramaze/helper/cache.rb +8 -9
  57. data/lib/ramaze/helper/cgi.rb +23 -0
  58. data/lib/ramaze/helper/file.rb +3 -0
  59. data/lib/ramaze/helper/inform.rb +3 -0
  60. data/lib/ramaze/helper/link.rb +56 -63
  61. data/lib/ramaze/helper/nitroform.rb +4 -0
  62. data/lib/ramaze/helper/redirect.rb +1 -1
  63. data/lib/ramaze/inform.rb +6 -2
  64. data/lib/ramaze/inform/analogger.rb +5 -1
  65. data/lib/ramaze/inform/hub.rb +1 -1
  66. data/lib/ramaze/inform/informing.rb +7 -0
  67. data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
  68. data/lib/ramaze/snippets/kernel/constant.rb +2 -0
  69. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
  70. data/lib/ramaze/snippets/object/traits.rb +4 -0
  71. data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
  72. data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
  73. data/lib/ramaze/snippets/string/camel_case.rb +2 -0
  74. data/lib/ramaze/snippets/string/color.rb +2 -0
  75. data/lib/ramaze/snippets/string/each.rb +2 -0
  76. data/lib/ramaze/snippets/string/snake_case.rb +3 -0
  77. data/lib/ramaze/snippets/struct/fill.rb +8 -2
  78. data/lib/ramaze/snippets/struct/values_at.rb +16 -0
  79. data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
  80. data/lib/ramaze/sourcereload.rb +89 -0
  81. data/lib/ramaze/template.rb +21 -12
  82. data/lib/ramaze/template/amrita2.rb +6 -6
  83. data/lib/ramaze/template/erubis.rb +4 -9
  84. data/lib/ramaze/template/ezamar.rb +13 -57
  85. data/lib/ramaze/template/ezamar/element.rb +10 -12
  86. data/lib/ramaze/template/ezamar/engine.rb +40 -101
  87. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  88. data/lib/ramaze/template/haml.rb +3 -6
  89. data/lib/ramaze/template/liquid.rb +4 -9
  90. data/lib/ramaze/template/markaby.rb +16 -22
  91. data/lib/ramaze/template/remarkably.rb +28 -0
  92. data/lib/ramaze/tool/mime.rb +2 -0
  93. data/lib/ramaze/tool/record.rb +6 -0
  94. data/lib/ramaze/trinity/request.rb +44 -54
  95. data/lib/ramaze/trinity/response.rb +1 -1
  96. data/lib/ramaze/trinity/session.rb +15 -37
  97. data/lib/ramaze/version.rb +1 -1
  98. data/rake_tasks/gem.rake +2 -2
  99. data/rake_tasks/maintaince.rake +42 -1
  100. data/rake_tasks/spec.rake +45 -0
  101. data/spec/examples/caching.rb +1 -1
  102. data/spec/examples/simple.rb +1 -1
  103. data/spec/examples/templates/template_amrita2.rb +1 -0
  104. data/spec/examples/templates/template_erubis.rb +2 -1
  105. data/spec/examples/templates/template_ezamar.rb +1 -1
  106. data/spec/examples/templates/template_haml.rb +2 -1
  107. data/spec/examples/templates/template_liquid.rb +2 -1
  108. data/spec/examples/templates/template_markaby.rb +2 -1
  109. data/spec/examples/templates/template_remarkably.rb +22 -0
  110. data/spec/examples/todolist.rb +125 -0
  111. data/spec/helper.rb +2 -23
  112. data/spec/helper/minimal.rb +20 -0
  113. data/spec/helper/mock_http.rb +24 -30
  114. data/spec/helper/simple_http.rb +2 -2
  115. data/spec/helper/wrap.rb +6 -9
  116. data/spec/ramaze/adapter.rb +1 -1
  117. data/spec/ramaze/adapter/record.rb +31 -0
  118. data/spec/ramaze/cache.rb +41 -54
  119. data/spec/ramaze/controller.rb +121 -137
  120. data/spec/ramaze/controller/template/list.xhtml +1 -0
  121. data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
  122. data/spec/ramaze/controller/template_resolving.rb +27 -3
  123. data/spec/ramaze/element.rb +11 -7
  124. data/spec/ramaze/error.rb +1 -1
  125. data/spec/ramaze/gestalt.rb +2 -0
  126. data/spec/ramaze/helper/aspect.rb +30 -21
  127. data/spec/ramaze/helper/auth.rb +1 -1
  128. data/spec/ramaze/helper/cache.rb +2 -1
  129. data/spec/ramaze/helper/form.rb +14 -11
  130. data/spec/ramaze/helper/link.rb +18 -41
  131. data/spec/ramaze/localize.rb +29 -2
  132. data/spec/ramaze/morpher.rb +23 -12
  133. data/spec/ramaze/params.rb +46 -24
  134. data/spec/ramaze/request.rb +6 -2
  135. data/spec/ramaze/store/yaml.rb +5 -0
  136. data/spec/ramaze/template.rb +22 -27
  137. data/spec/ramaze/template/amrita2.rb +1 -2
  138. data/spec/ramaze/template/erubis.rb +1 -1
  139. data/spec/ramaze/template/ezamar.rb +1 -2
  140. data/spec/ramaze/template/haml.rb +2 -2
  141. data/spec/ramaze/template/haml/with_vars.haml +1 -1
  142. data/spec/ramaze/template/liquid.rb +1 -1
  143. data/spec/ramaze/template/markaby.rb +1 -1
  144. data/spec/ramaze/template/remarkably.rb +56 -0
  145. data/spec/ramaze/template/remarkably/external.rem +8 -0
  146. data/spec/ramaze/template/remarkably/sum.rem +1 -0
  147. metadata +38 -63
  148. data/doc/README.html +0 -637
  149. data/doc/allison/LICENSE +0 -184
  150. data/doc/allison/README +0 -37
  151. data/doc/allison/allison.css +0 -299
  152. data/doc/allison/allison.gif +0 -0
  153. data/doc/allison/allison.js +0 -307
  154. data/doc/allison/allison.rb +0 -287
  155. data/doc/allison/cache/BODY +0 -588
  156. data/doc/allison/cache/CLASS_INDEX +0 -4
  157. data/doc/allison/cache/CLASS_PAGE +0 -1
  158. data/doc/allison/cache/FILE_INDEX +0 -4
  159. data/doc/allison/cache/FILE_PAGE +0 -1
  160. data/doc/allison/cache/FONTS +0 -1
  161. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  162. data/doc/allison/cache/IMGPATH +0 -1
  163. data/doc/allison/cache/INDEX +0 -1
  164. data/doc/allison/cache/JAVASCRIPT +0 -307
  165. data/doc/allison/cache/METHOD_INDEX +0 -4
  166. data/doc/allison/cache/METHOD_LIST +0 -1
  167. data/doc/allison/cache/SRC_PAGE +0 -1
  168. data/doc/allison/cache/STYLE +0 -321
  169. data/doc/allison/cache/URL +0 -1
  170. data/doc/changes.txt +0 -3375
  171. data/doc/changes.xml +0 -3378
  172. data/examples/todolist/conf/benchmark.yaml +0 -35
  173. data/examples/todolist/conf/debug.yaml +0 -34
  174. data/examples/todolist/conf/live.yaml +0 -33
  175. data/examples/todolist/conf/silent.yaml +0 -31
  176. data/examples/todolist/conf/stage.yaml +0 -33
  177. data/examples/todolist/public/css/coderay.css +0 -105
  178. data/examples/todolist/public/css/ramaze_error.css +0 -42
  179. data/lib/proto/conf/benchmark.yaml +0 -21
  180. data/lib/proto/conf/debug.yaml +0 -21
  181. data/lib/proto/conf/live.yaml +0 -21
  182. data/lib/proto/conf/silent.yaml +0 -21
  183. data/lib/proto/conf/stage.yaml +0 -21
  184. data/lib/proto/public/css/coderay.css +0 -105
  185. data/lib/ramaze/http_status.rb +0 -66
  186. data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
  187. data/lib/ramaze/snippets/kernel/method.rb +0 -26
  188. data/lib/ramaze/snippets/method/name.rb +0 -22
  189. data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
  190. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
  191. data/spec/all.rb +0 -32
  192. data/spec/ramaze/conf/locale_de.yaml +0 -6
  193. data/spec/ramaze/conf/locale_en.yaml +0 -6
  194. data/spec/ramaze/dependencies.rb +0 -16
  195. data/spec/ramaze/global.rb +0 -44
Binary file
@@ -1,307 +0,0 @@
1
-
2
- // Javascript for Allison RDoc template
3
- // Copyright 2006 Cloudburst LLC
4
- // Some sections originally from public domain material
5
-
6
- var href_base = '%style_url%'.replace(/(.*\/).*/, '$1'); // haha! inline js is good for something
7
-
8
- function $(id) {
9
- if (document.getElementById)
10
- elem = document.getElementById(id);
11
- else if ( document.all )
12
- elem = eval("document.all." + id);
13
- else
14
- return false;
15
- return elem;
16
- }
17
-
18
- function toggle(id) {
19
- elem = $(id);
20
- elemStyle = elem.style;
21
- if (elemStyle.display == "block") {
22
- elemStyle.display = "none"
23
- } else {
24
- elemStyle.display = "block"
25
- }
26
- return true;
27
- }
28
-
29
- function toggleText(id) {
30
- elem = $(id)
31
- if (m = elem.innerHTML.match(/(Hide)(.*)/)) {
32
- elem.innerHTML = "Show" + m[2];
33
- } else if (m = elem.innerHTML.match(/(Show)(.*)/)) {
34
- elem.innerHTML = "Hide" + m[2];
35
- }
36
- return true;
37
- }
38
-
39
- function span(s, klass) {
40
- return '<span class="' + klass + '">' + s + '</span>';
41
- }
42
-
43
- function highlightSymbols() {
44
- pres = document.getElementsByTagName('pre');
45
- for(var i = 0; i < pres.length; i++) {
46
- pre = pres[i];
47
- spans = pre.getElementsByTagName('span');
48
- for(var k = 0; k < spans.length; k++) {
49
- span = spans[k];
50
- if (span.className.match(/ruby-identifier/)) {
51
- if (span.innerHTML.match(/^:/)) {
52
- span.className += " ruby-symbol";
53
- }
54
- }
55
- }
56
- }
57
- }
58
-
59
- function hasClass(obj) {
60
- var result = false;
61
- if (obj.getAttributeNode("class") != null) {
62
- result = obj.getAttributeNode("class").value;
63
- }
64
- return result;
65
- }
66
-
67
- function stripe() {
68
- var even = true;
69
- var color = "#f4eefd";
70
- var tables = document.getElementsByTagName('table');
71
- if (tables.length == 0) { return; }
72
- for (var h = 0; h < tables.length; h++) {
73
- var trs = tables[h].getElementsByTagName("tr");
74
- for (var i = 0; i < trs.length; i++) {
75
- var tds = trs[i].getElementsByTagName("td");
76
- for (var j = 0; j < tds.length; j++) {
77
- if (hasClass(tds[j]) != "first") {
78
- var mytd = tds[j];
79
- if (even) {
80
- mytd.style.backgroundColor = color;
81
- }
82
- }
83
- }
84
- even = ! even;
85
- }
86
- }
87
- }
88
-
89
- function ajaxGet(url) {
90
- url = (href_base + url).replace('/./', '/')
91
- var req = false;
92
-
93
- if (window.ActiveXObject) {
94
- try {
95
- // stupid hack because IE7 disables local Ajax with the native xmlhttprequest object
96
- // for security purposes. Yet ActiveX still works. Thanks, Microsoft. I hate you. Die.
97
- req = new ActiveXObject("MSXML2.XMLHTTP.3.0");
98
- } catch (e) {
99
- try {
100
- /* IE 6 and maybe 5, don't know, don't care */
101
- req = new ActiveXObject("Msxml2.XMLHTTP");
102
- } catch (e) {
103
- try {
104
- req = new ActiveXObject("Microsoft.XMLHTTP");
105
- } catch (e) {
106
- req = false;
107
- }
108
- }
109
- }
110
- }
111
-
112
- /* real browsers */
113
- if (!req && window.XMLHttpRequest) {
114
- try {
115
- req = new XMLHttpRequest();
116
- } catch (e) {
117
- req = false;
118
- }
119
- }
120
-
121
- if (req) {
122
- req.open('GET', url, false);
123
- req.send(null);
124
- return req.responseText;
125
- } else {
126
- return "Ajax error";
127
- }
128
- }
129
-
130
-
131
- function addEvent(elm, evType, fn, useCapture) {
132
- if (elm.addEventListener) {
133
- elm.addEventListener(evType, fn, useCapture);
134
- return true;
135
- } else if (elm.attachEvent) {
136
- var r = elm.attachEvent('on' + evType, fn);
137
- return r;
138
- } else {
139
- elm['on' + evType] = fn;
140
- }
141
- }
142
-
143
- function insertIndices() {
144
- pages = ["class", "file", "method"]
145
- for (x in pages) {
146
- $(pages[x]).innerHTML += ajaxGet('fr_' + pages[x] + '_index.html').replace(/(href=")/g, '$1' + href_base);
147
- }
148
- /* mouseoverify method links */
149
- links = $('method').getElementsByTagName('a');
150
- for (var x = 0; x < links.length; x++) {
151
- if (m = links[x].innerHTML.match(/(.*)\s\((.*)\)/)) {
152
- links[x].innerHTML = m[1] + '<br>';
153
- links[x].title = m[2];
154
- }
155
- }
156
- /* this is stupid */
157
- $('class').style.display = "block";
158
- $('file').style.display = "block";
159
-
160
- /* has to be here because IE7 does not guarantee the onLoad callback order */
161
- abbreviateIndicesInner(["class", "file"], 25, "a");
162
- /* same, linkTitle() depends on the class link list */
163
- linkTitle();
164
- }
165
-
166
- function abbreviateIndices() {
167
- abbreviateIndicesInner(["defined_in", "child_of", "includes"], 20, 'a');
168
- abbreviateIndicesInner(["defined_in", "requires", "child_of", "includes"], 20, 'span');
169
- }
170
-
171
- function abbreviateIndicesInner(indices, amount, tag) {
172
- for (var x = 0; x < indices.length; x++) {
173
- var the_index = $(indices[x]);
174
- if (the_index) {
175
- links = the_index.getElementsByTagName(tag);
176
- for (var y = 0; y < links.length; y++) {
177
- var link = links[y];
178
- if (link.getElementsByTagName('span').length == 0 && link.getElementsByTagName('a').length == 0) {
179
- // avoid nesting
180
- link.innerHTML = abbreviate(link.innerHTML, amount);
181
- }
182
- }
183
- }
184
- }
185
- }
186
-
187
- function linkTitle() {
188
- /* grab the correct title element from the index */
189
- var index_page = ajaxGet('index.html');
190
- title_text = index_page.match(/<title>(.*)<\/title>/m)[1];
191
- document.title = title_text + " - " + document.title;
192
- var p = $('header').getElementsByTagName('p')[0]
193
- if (p.innerHTML.match(/^\s*$/)) {
194
- p.innerHTML = title_text;
195
- } else {
196
- p.innerHTML = title_text + ": " + p.innerHTML;
197
- }
198
- /* set the link properly */
199
- title_link = index_page.match(/<a\s+href="(.*?)"/)[1];
200
- var element = $('title');
201
- var item_type = "";
202
- var item_name = "";
203
- if (m = element.innerHTML.match(/(Class:|Module:|File:)\s*(.*)/)) {
204
- item_type = m[1];
205
- item_name = m[2];
206
- } else {
207
- item_name = element.innerHTML;
208
- }
209
- element.innerHTML = '<a href="' + href_base + title_link + '">' + item_type + " " + abbreviate(item_name, 25) + '</a>';
210
- /* breadcrumb navigation for the win */
211
- items = item_name.split("::");
212
- items_new = item_name.split("::");
213
- var s = ""
214
- file_links = $('class').getElementsByTagName('a');
215
- for (var x = 0; x < items.length - 1; x++ ){
216
- var item = items[x];
217
- link = ("/classes/" + items.slice(0,x).join("/") + "/" + item + ".html").replace('//', '/');
218
- regex = new RegExp(RegExp.escape(link) + '$');
219
- for (var y = 0; y < file_links.length; y++) {
220
- if (file_links[y].href.match(regex)) {
221
- items_new[x] = '<a href="' + href_base + link + '">' + item + '</a>';
222
- break;
223
- }
224
- }
225
- }
226
- $('item_name').innerHTML = item_type + ' ' + items_new.join(" :: ");
227
- }
228
-
229
- function abbreviate(s, size) {
230
- while (s.length > size) {
231
- var old_s = s;
232
- s = s.replace(/\s|\n/mg, '');
233
- s = s.replace(/([A-Z])[a-z]+/m, '$1');
234
- if (!s || old_s == s) {
235
- return "..." + s.substring(s.length - size, s.length);
236
- }
237
- }
238
- return s;
239
- }
240
-
241
- function disableSubmit(event) {
242
- var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
243
- if (keyCode == 13) {
244
- return false;
245
- } else {
246
- return true;
247
- }
248
- }
249
-
250
- function filterList(id, s, event) {
251
-
252
- /* some half-assed escaping */
253
- s = s.replace(/[^\w\d\.\_\-\/\:\=\[\]\?\!]/g, '');
254
- s = RegExp.escape(s);
255
-
256
- var show_all = false;
257
- if (s.match(/^\s*$/)) {
258
- show_all = true;
259
- }
260
-
261
- links = $(id).getElementsByTagName('a')
262
- regex = new RegExp(s, 'i');
263
-
264
- for (var x = 0; x < links.length; x++) {
265
- var link = links[x];
266
- if (show_all) {
267
- link.style.display = 'inline';
268
- } else {
269
- if (link.innerHTML.match(regex)) {
270
- link.style.display = 'inline';
271
- } else {
272
- link.style.display = 'none';
273
- }
274
- }
275
- }
276
- return true;
277
- }
278
-
279
- RegExp.escape = function(text) {
280
- if (!arguments.callee.sRE) {
281
- var specials = [
282
- '/', '.', '*', '+', '?', '|',
283
- '(', ')', '[', ']', '{', '}', '\\\\'
284
- ];
285
- arguments.callee.sRE = new RegExp(
286
- '(\\\\' + specials.join('|\\\\') + ')', 'g'
287
- );
288
- }
289
- return text.replace(arguments.callee.sRE, '\\\\$1');
290
- }
291
-
292
-
293
- function hacks() {
294
- // show the spacer if necessary,
295
- divs = document.getElementsByTagName('div');
296
- for (x in divs) {
297
- if (divs[x].className && divs[x].className.match(/top/)) {
298
- document.getElementById('spacer').style.display = 'block';
299
- }
300
- }
301
- }
302
-
303
- addEvent(window, 'load', insertIndices, false);
304
- addEvent(window, 'load', abbreviateIndices, false);
305
- addEvent(window, 'load', stripe, false);
306
- addEvent(window, 'load', highlightSymbols, false);
307
- addEvent(window, 'load', hacks, false);
@@ -1,287 +0,0 @@
1
- # Allison RDoc template
2
- # Copyright 2006 Cloudburst LLC
3
-
4
- class String
5
- # fuck this stupid rdoc templater system
6
- def if_exists (item = nil)
7
- unless item
8
- self unless self =~ /(%(\w+)%)/
9
- "\nIF:#{$2}\n#{self}\nENDIF:#{$2}\n"
10
- else
11
- "\nIF:#{item}\n#{self}\nENDIF:#{item}\n"
12
- end
13
- end
14
- def loop(item)
15
- "\nSTART:#{item}\n#{self}\nEND:#{item}\n"
16
- end
17
- end
18
-
19
- module RDoc
20
- module Page
21
-
22
- puts "Invoking Allison template..."
23
-
24
- require 'pathname'
25
- CACHE_DIR = Pathname.new(__FILE__).dirname.to_s + "/cache"
26
-
27
- begin
28
- require 'rubygems'
29
- gem 'markaby', '>= 0.5' # how come this isn't activate_gem(), since that's what it does?
30
- require 'markaby'
31
- require 'base64'
32
-
33
- module Allison
34
- # markaby page says markaby is better in its own module...
35
-
36
- URL = "http://blog.evanweaver.com/articles/2006/06/02/allison"
37
- IMGPATH = 'allison.gif'
38
-
39
- FONTS = METHOD_LIST = SRC_PAGE = FILE_PAGE = CLASS_PAGE = ""
40
-
41
- FR_INDEX_BODY = "!INCLUDE!" # who knows
42
-
43
- STYLE, JAVASCRIPT = ["css", "js"].map do |extension|
44
- s = File.open(File.dirname(__FILE__) + "/allison.#{extension}").read
45
- # programmatic css, because we're so badass
46
- if extension == "css"
47
- puts "Compiling CSS..."
48
- s_lines = s.split("\n")
49
- meths = []
50
- s_lines.collect! do |line|
51
- line = line.squeeze(" ").strip
52
- if line =~ /(\w+)/ and meths.include? $1
53
- line = instance_eval line
54
- #puts "Called method #{$1}"
55
- elsif line !~ /\*\/|\/\*/ and line =~ /(@.*|^def (\w+).*)/
56
- #printf "Evalled #{$1}"
57
- result = instance_eval $1
58
- #puts " to #{result.inspect}"
59
- result = (result.is_a?(Fixnum) ? result.to_s + "px" : result.to_s)
60
- line = (line == $1 ? "" : line.gsub($1, result))
61
- meths.push $2 if $2
62
- elsif line =~ /\%#{IMGPATH}\%/
63
- img = Base64.encode64(File.open(File.dirname(__FILE__) + "/#{IMGPATH}") {|f| f.read}).gsub("\n", '')
64
- line.sub!(/\%#{IMGPATH}\%/, img)
65
- end
66
- line !~ /^\s*$|\s*^\/\*.*\*\/\s*$|\{|\}/ ? line + ";" : line
67
- end
68
- s = s_lines.join("\n")
69
- else
70
- puts "Inlining Javascript..."
71
- end
72
- s
73
- end
74
-
75
- puts "Compiling XHTML..."
76
-
77
- INDEX = Markaby::Builder.new.xhtml_strict do
78
- head do
79
- title '%title%'
80
- link :rel => 'stylesheet', :type => 'text/css', :href => 'rdoc-style.css', :media => 'screen'
81
- tag! :meta, 'http-equiv' => 'refresh', 'content' => '0;url=%initial_page%'
82
- end
83
- body do
84
- div.container! do
85
- 10.times {|n| div('', :class => "curve", :id => "preheader_curve_#{n}") }
86
- div.header! do
87
- span.title! do
88
- p { '&nbsp;' }
89
- h1 "Ruby Documentation"
90
- end
91
- end
92
- div.clear {}
93
- div.redirect! do
94
- a :href => '%initial_page%' do
95
- h1 "Redirect"
96
- end
97
- end
98
- end
99
- end
100
- end.to_s
101
-
102
- FILE_INDEX = METHOD_INDEX = CLASS_INDEX = Markaby::Builder.new.capture do
103
- a :href => '%href%' do
104
- self << '%name%'
105
- br
106
- end
107
- end.loop('entries')
108
-
109
- BODY = Markaby::Builder.new.xhtml_strict do
110
- head do
111
- title "%title%"
112
- link :rel => 'stylesheet', :type => 'text/css', :href => '%style_url%', :media => 'screen'
113
- script :type => 'text/javascript' do
114
- JAVASCRIPT
115
- end
116
- end
117
- body do
118
- div.container! do
119
- 10.times {|n| div('', :class => "curve", :id => "preheader_curve_#{n}") }
120
- div.header! do
121
- p {'%full_path%'.if_exists}
122
- span do
123
- h1.title! '%title%'.if_exists
124
- end
125
- self << "!INCLUDE!" # always empty
126
- end
127
- div.clear {}
128
- div.left! do
129
- self << (div.navigation.dark.top.child_of! do
130
- # death to you, horrible templater >:(
131
- h3 "Child of"
132
- self << "<span>\n#{"<a href='%par_url%'>".if_exists}%parent%#{"</a>".if_exists('par_url')}</span>"
133
- end).if_exists('parent')
134
-
135
- self << div.navigation.dark.top.defined_in! do
136
- h3('Defined in')
137
- self << a('%full_path%', :href => '%full_path_url%').if_exists.loop('infiles')
138
- end.if_exists('infiles')
139
-
140
- ['includes', 'requires', 'methods'].each do |item|
141
- self << div.navigation.top(:id => item) do
142
- self << h3(item.capitalize)
143
- self << "<span class='bpink'>\n#{"<a href='%aref%'>".if_exists}%name%#{br}#{"</a>".if_exists('aref')}</span>".if_exists('name').loop(item)
144
- end.if_exists(item)
145
- end
146
-
147
- div.spacer! ''
148
-
149
- # for the javascript ajaxy includes
150
- ['class', 'file', 'method'].each do |item|
151
- div.navigation.dark.index :id => "#{item}_wrapper" do
152
- div.list_header do
153
- h3 'All ' + (item == 'class' ? 'classes' : item + 's')
154
- end
155
- div.list_header_link do
156
- a((item == 'method' ? 'Show...' : 'Hide...'),
157
- :id => "#{item}_link", :href => "#",
158
- :onclick=> "toggle('#{item}'); toggleText('#{item}_link'); return false;")
159
- end
160
- div.clear {}
161
- div(:id => item) do
162
- form do
163
- label(:for => "filter_#{item}") { 'Filter:' + '&nbsp;' * 2 }
164
- input '', :type => 'text', :id => "filter_#{item}",
165
- :onKeyUp => "return filterList('#{item}', this.value, event);",
166
- :onKeyPress => "return disableSubmit(event);"
167
- end
168
- end
169
- end
170
- end
171
-
172
- 10.times {|n| div('', :class => "curve", :id => "left_curve_#{n}") }
173
- end
174
-
175
- div.content! do
176
- self << capture do
177
- h1.item_name! '%title%'
178
- end.if_exists('title')
179
-
180
- self << capture do
181
- h1 'Description'
182
- self << '%description%'
183
- end.if_exists('description')
184
-
185
- self << capture do
186
- self << h1 {a '%sectitle%', :name => '%secsequence%'}.if_exists('sectitle')
187
- self << p {'%seccomment%'}.if_exists
188
-
189
- self << capture do
190
- h1 "Child modules and classes"
191
- p '%classlist%'
192
- end.if_exists('classlist')
193
-
194
- ['constants', 'aliases', 'attributes'].each do |item|
195
- self << capture do
196
- h1(item.capitalize)
197
- p do
198
- table do
199
- fields = %w[name value old_name new_name rw desc a_desc]
200
- self << tr do
201
- # header row
202
- th.first " "
203
- if item == 'constants'
204
- th 'Name'
205
- th 'Value'
206
- elsif item == 'aliases'
207
- th 'Old name'
208
- th 'New name'
209
- elsif item == 'attributes'
210
- th 'Name'
211
- th 'Read/write?'
212
- end
213
- th.description(:colspan => 2){"Description"}
214
- end
215
- self << tr do
216
- # looped item rows
217
- td.first " "
218
- fields.each do |field|
219
- if field !~ /desc/
220
- self << td('%' + field + '%', :class => field =~ /^old|^name/ ? "highlight" : "normal").if_exists
221
- else
222
- self << td(('%' + field+ '%').if_exists)
223
- end
224
- end
225
- end.loop(item)
226
- end
227
- end
228
- end.if_exists(item)
229
- end
230
-
231
- self << capture do
232
- div.section_spacer ''
233
- h1('%type% %category% methods')
234
- self << capture do
235
- self << a.small(:name => '%aref%') {br}.if_exists
236
- div.a_method do
237
- div do
238
- h3 { "<a href='#%aref%'>".if_exists + '%callseq%'.if_exists + '%name%'.if_exists + '%params%'.if_exists + "</a>".if_exists('aref')}
239
- self << '%m_desc%'.if_exists
240
-
241
- self << capture do
242
- p.source_link :id => '%aref%-show-link' do
243
- a "Show source...", :id => '%aref%-link', :href => "#",
244
- :onclick=> "toggle('%aref%-source'); toggleText('%aref%-link'); return false;"
245
- end
246
- div.source :id => '%aref%-source' do
247
- pre { '%sourcecode%' }
248
- end
249
- end.if_exists('sourcecode')
250
- end
251
- end
252
-
253
- end.loop('methods').if_exists('methods')
254
- end.loop('method_list').if_exists('method_list')
255
-
256
- end.loop('sections').if_exists('sections')
257
-
258
- end
259
- end
260
-
261
- div.footer!.clear do
262
- a 'Allison', :href => URL
263
- end
264
-
265
- end
266
- end.to_s
267
- end
268
-
269
- Allison.constants.each do |c|
270
- eval "#{c} = Allison::#{c}" # jump out of the namespace
271
- File.open("#{CACHE_DIR}/#{c}", 'w') do |f|
272
- f.puts eval(c) # write cache
273
- end
274
- end
275
-
276
- rescue LoadError => e
277
- # guess we don't have some dependency. hope the cache is fresh!
278
- lib = (e.to_s[/(.*)\(/, 1] or e.to_s).split(" ").last.capitalize
279
- puts "Loading from cache (#{lib} was missing)..."
280
- Dir[CACHE_DIR + '/*'].each do |filename|
281
- eval("#{filename.split("/").last} = File.open(filename) {|s| s.read}")
282
- end
283
- end
284
-
285
- end
286
-
287
- end