ramaze 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/Rakefile +360 -0
  2. data/bin/ramaze +152 -0
  3. data/doc/CHANGELOG +2021 -0
  4. data/doc/COPYING +56 -0
  5. data/doc/COPYING.ja +51 -0
  6. data/doc/README +275 -0
  7. data/doc/TODO +33 -0
  8. data/doc/allison/LICENSE +184 -0
  9. data/doc/allison/README +37 -0
  10. data/doc/allison/allison.css +300 -0
  11. data/doc/allison/allison.gif +0 -0
  12. data/doc/allison/allison.js +307 -0
  13. data/doc/allison/allison.rb +287 -0
  14. data/doc/allison/cache/BODY +588 -0
  15. data/doc/allison/cache/CLASS_INDEX +4 -0
  16. data/doc/allison/cache/CLASS_PAGE +1 -0
  17. data/doc/allison/cache/FILE_INDEX +4 -0
  18. data/doc/allison/cache/FILE_PAGE +1 -0
  19. data/doc/allison/cache/FONTS +1 -0
  20. data/doc/allison/cache/FR_INDEX_BODY +1 -0
  21. data/doc/allison/cache/IMGPATH +1 -0
  22. data/doc/allison/cache/INDEX +1 -0
  23. data/doc/allison/cache/JAVASCRIPT +307 -0
  24. data/doc/allison/cache/METHOD_INDEX +4 -0
  25. data/doc/allison/cache/METHOD_LIST +1 -0
  26. data/doc/allison/cache/SRC_PAGE +1 -0
  27. data/doc/allison/cache/STYLE +322 -0
  28. data/doc/allison/cache/URL +1 -0
  29. data/examples/blog/main.rb +16 -0
  30. data/examples/blog/public/screen.css +106 -0
  31. data/examples/blog/src/controller.rb +50 -0
  32. data/examples/blog/src/element.rb +53 -0
  33. data/examples/blog/src/model.rb +29 -0
  34. data/examples/blog/template/edit.xhtml +6 -0
  35. data/examples/blog/template/index.xhtml +24 -0
  36. data/examples/blog/template/new.xhtml +5 -0
  37. data/examples/blog/template/view.xhtml +15 -0
  38. data/examples/blog/test/tc_entry.rb +18 -0
  39. data/examples/caching.rb +23 -0
  40. data/examples/element.rb +40 -0
  41. data/examples/hello.rb +23 -0
  42. data/examples/simple.rb +60 -0
  43. data/examples/templates/template/external.haml +21 -0
  44. data/examples/templates/template/external.liquid +28 -0
  45. data/examples/templates/template/external.mab +27 -0
  46. data/examples/templates/template/external.rhtml +29 -0
  47. data/examples/templates/template/external.rmze +24 -0
  48. data/examples/templates/template_erubis.rb +50 -0
  49. data/examples/templates/template_haml.rb +48 -0
  50. data/examples/templates/template_liquid.rb +64 -0
  51. data/examples/templates/template_markaby.rb +52 -0
  52. data/examples/templates/template_ramaze.rb +49 -0
  53. data/examples/whywiki/main.rb +56 -0
  54. data/examples/whywiki/template/edit.xhtml +14 -0
  55. data/examples/whywiki/template/show.xhtml +17 -0
  56. data/lib/proto/conf/benchmark.yaml +35 -0
  57. data/lib/proto/conf/debug.yaml +34 -0
  58. data/lib/proto/conf/live.yaml +33 -0
  59. data/lib/proto/conf/silent.yaml +31 -0
  60. data/lib/proto/conf/stage.yaml +33 -0
  61. data/lib/proto/main.rb +18 -0
  62. data/lib/proto/public/404.jpg +0 -0
  63. data/lib/proto/public/css/coderay.css +105 -0
  64. data/lib/proto/public/css/ramaze_error.css +42 -0
  65. data/lib/proto/public/error.xhtml +74 -0
  66. data/lib/proto/public/favicon.ico +0 -0
  67. data/lib/proto/public/js/jquery.js +1923 -0
  68. data/lib/proto/public/ramaze.png +0 -0
  69. data/lib/proto/src/controller/main.rb +7 -0
  70. data/lib/proto/src/element/page.rb +16 -0
  71. data/lib/proto/src/model.rb +5 -0
  72. data/lib/proto/template/index.xhtml +6 -0
  73. data/lib/ramaze.rb +317 -0
  74. data/lib/ramaze/adapter/mongrel.rb +111 -0
  75. data/lib/ramaze/adapter/webrick.rb +161 -0
  76. data/lib/ramaze/cache.rb +11 -0
  77. data/lib/ramaze/cache/memcached.rb +52 -0
  78. data/lib/ramaze/cache/memory.rb +6 -0
  79. data/lib/ramaze/cache/yaml_store.rb +37 -0
  80. data/lib/ramaze/controller.rb +10 -0
  81. data/lib/ramaze/dispatcher.rb +315 -0
  82. data/lib/ramaze/error.rb +11 -0
  83. data/lib/ramaze/gestalt.rb +108 -0
  84. data/lib/ramaze/global.rb +120 -0
  85. data/lib/ramaze/helper.rb +32 -0
  86. data/lib/ramaze/helper/aspect.rb +189 -0
  87. data/lib/ramaze/helper/auth.rb +120 -0
  88. data/lib/ramaze/helper/cache.rb +52 -0
  89. data/lib/ramaze/helper/feed.rb +135 -0
  90. data/lib/ramaze/helper/form.rb +204 -0
  91. data/lib/ramaze/helper/link.rb +80 -0
  92. data/lib/ramaze/helper/redirect.rb +48 -0
  93. data/lib/ramaze/helper/stack.rb +67 -0
  94. data/lib/ramaze/http_status.rb +66 -0
  95. data/lib/ramaze/inform.rb +166 -0
  96. data/lib/ramaze/snippets.rb +5 -0
  97. data/lib/ramaze/snippets/hash/keys_to_sym.rb +19 -0
  98. data/lib/ramaze/snippets/kernel/aquire.rb +22 -0
  99. data/lib/ramaze/snippets/kernel/autoreload.rb +79 -0
  100. data/lib/ramaze/snippets/kernel/caller_lines.rb +58 -0
  101. data/lib/ramaze/snippets/kernel/constant.rb +24 -0
  102. data/lib/ramaze/snippets/kernel/rescue_require.rb +12 -0
  103. data/lib/ramaze/snippets/kernel/self_method.rb +41 -0
  104. data/lib/ramaze/snippets/kernel/silently.rb +13 -0
  105. data/lib/ramaze/snippets/object/traits.rb +60 -0
  106. data/lib/ramaze/snippets/openstruct/temp.rb +10 -0
  107. data/lib/ramaze/snippets/string/DIVIDE.rb +16 -0
  108. data/lib/ramaze/snippets/string/camel_case.rb +14 -0
  109. data/lib/ramaze/snippets/string/snake_case.rb +12 -0
  110. data/lib/ramaze/snippets/symbol/to_proc.rb +14 -0
  111. data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +11 -0
  112. data/lib/ramaze/store/default.rb +48 -0
  113. data/lib/ramaze/template.rb +102 -0
  114. data/lib/ramaze/template/amrita2.rb +40 -0
  115. data/lib/ramaze/template/erubis.rb +58 -0
  116. data/lib/ramaze/template/haml.rb +65 -0
  117. data/lib/ramaze/template/haml/actionview_stub.rb +20 -0
  118. data/lib/ramaze/template/liquid.rb +74 -0
  119. data/lib/ramaze/template/markaby.rb +68 -0
  120. data/lib/ramaze/template/ramaze.rb +177 -0
  121. data/lib/ramaze/template/ramaze/element.rb +166 -0
  122. data/lib/ramaze/template/ramaze/morpher.rb +156 -0
  123. data/lib/ramaze/tool/create.rb +70 -0
  124. data/lib/ramaze/tool/tidy.rb +71 -0
  125. data/lib/ramaze/trinity.rb +38 -0
  126. data/lib/ramaze/trinity/request.rb +244 -0
  127. data/lib/ramaze/trinity/response.rb +41 -0
  128. data/lib/ramaze/trinity/session.rb +129 -0
  129. data/lib/ramaze/version.rb +14 -0
  130. data/spec/spec_all.rb +73 -0
  131. data/spec/spec_helper.rb +215 -0
  132. data/spec/tc_adapter_mongrel.rb +24 -0
  133. data/spec/tc_adapter_webrick.rb +22 -0
  134. data/spec/tc_cache.rb +79 -0
  135. data/spec/tc_controller.rb +39 -0
  136. data/spec/tc_element.rb +100 -0
  137. data/spec/tc_error.rb +23 -0
  138. data/spec/tc_gestalt.rb +90 -0
  139. data/spec/tc_global.rb +46 -0
  140. data/spec/tc_helper_aspect.rb +65 -0
  141. data/spec/tc_helper_auth.rb +61 -0
  142. data/spec/tc_helper_cache.rb +81 -0
  143. data/spec/tc_helper_feed.rb +129 -0
  144. data/spec/tc_helper_form.rb +146 -0
  145. data/spec/tc_helper_link.rb +58 -0
  146. data/spec/tc_helper_redirect.rb +51 -0
  147. data/spec/tc_helper_stack.rb +55 -0
  148. data/spec/tc_morpher.rb +90 -0
  149. data/spec/tc_params.rb +84 -0
  150. data/spec/tc_request.rb +111 -0
  151. data/spec/tc_session.rb +56 -0
  152. data/spec/tc_store.rb +25 -0
  153. data/spec/tc_template_amrita2.rb +34 -0
  154. data/spec/tc_template_erubis.rb +41 -0
  155. data/spec/tc_template_haml.rb +44 -0
  156. data/spec/tc_template_liquid.rb +98 -0
  157. data/spec/tc_template_markaby.rb +74 -0
  158. data/spec/tc_template_ramaze.rb +54 -0
  159. data/spec/tc_tidy.rb +14 -0
  160. data/spec/template/amrita2/data.html +6 -0
  161. data/spec/template/amrita2/index.html +1 -0
  162. data/spec/template/amrita2/sum.html +1 -0
  163. data/spec/template/erubis/sum.rhtml +1 -0
  164. data/spec/template/haml/index.haml +5 -0
  165. data/spec/template/haml/with_vars.haml +4 -0
  166. data/spec/template/liquid/index.liquid +1 -0
  167. data/spec/template/liquid/products.liquid +45 -0
  168. data/spec/template/markaby/external.mab +8 -0
  169. data/spec/template/markaby/sum.mab +1 -0
  170. data/spec/template/ramaze/file_only.rmze +1 -0
  171. data/spec/template/ramaze/index.rmze +1 -0
  172. data/spec/template/ramaze/nested.rmze +1 -0
  173. data/spec/template/ramaze/sum.rmze +1 -0
  174. metadata +317 -0
@@ -0,0 +1,37 @@
1
+
2
+ COPYRIGHT
3
+
4
+ Allison template for RDoc, copyright 2006 Cloudburst, LLC (see the LICENSE file)
5
+
6
+ DETAILED DOCUMENTATION
7
+
8
+ http://blog.evanweaver.com/articles/2006/06/02/allison
9
+
10
+ QUICKSTART
11
+
12
+ The best way to use the template is to set up a Rake task for your Ruby project or Rails app:
13
+ in Rakefile
14
+
15
+ require 'rake/rdoctask'
16
+
17
+ Rake::RDocTask.new do |rdoc|
18
+ files = ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb',
19
+ 'doc/**/*.rdoc', 'test/*.rb']
20
+ rdoc.rdoc_files.add(files)
21
+ rdoc.main = "README" # page to start on
22
+ rdoc.title = "My App's Documentation"
23
+ rdoc.template = "/path/to/allison/allison.rb"
24
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
25
+ rdoc.options << '--line-numbers' << '--inline-source'
26
+ end
27
+
28
+ Then you can run rake rdoc to invoke the task and everything will be super awesome.
29
+
30
+ Note, pop-up source view is not supported. You have to use --inline-source.
31
+
32
+ CHANGELOG
33
+
34
+ 2.2 how come "require_gem" isn't called "activate_gem", since that's what it does. bah.
35
+ 2.1 hack to make gem versioning work
36
+ 2. caching in order to remove Markaby dependency
37
+ 1. first release
@@ -0,0 +1,300 @@
1
+
2
+ /* Stylesheet for Allison RDoc template */
3
+ /* Copyright 2006 Cloudburst LLC */
4
+
5
+ /* default styles */
6
+
7
+ * {
8
+ margin: 0
9
+ padding: 0
10
+ border: none
11
+ }
12
+
13
+ a {
14
+ color: @dark_teal = "#244"
15
+ font-weight: bold
16
+ text-decoration: none
17
+ }
18
+
19
+ a:hover {
20
+ text-decoration: underline
21
+ } a:visited {
22
+ font-weight: normal
23
+ }
24
+
25
+ html, body {
26
+ color: @body_color = "#270f2b"
27
+ background-color: @background_teal = "#eeffff"
28
+ text-align: center
29
+ margin: 0
30
+ padding: 0
31
+ }
32
+
33
+ p, ul, ol, li {
34
+ line-height: @lh = "1.4em"
35
+ margin: .4em
36
+ } p {
37
+ margin: @lh
38
+ } h1 {
39
+ margin-top: .4em
40
+ } #item_name {
41
+ margin-top: -.4em
42
+ }
43
+
44
+ h2 {
45
+ font-size: 2em
46
+ margin-top: 1em
47
+ margin-right: -1em
48
+ }
49
+
50
+
51
+ /* center everything */
52
+
53
+ #container {
54
+ margin: 20px auto 0 auto
55
+ width: @width = 900
56
+ text-align: left
57
+ }
58
+
59
+
60
+ @buffer = 10
61
+
62
+ /* header stuff */
63
+
64
+ #header {
65
+ padding: @buffer
66
+ padding-top: 0
67
+ width: @width - @buffer * 2
68
+ height: @d= 91 - @buffer * 2
69
+ _height: @d + @buffer
70
+ margin-bottom: 25px
71
+ vertical-align: baseline
72
+ background: url('data:image/gif;base64,%allison.gif%') no-repeat top right
73
+ background-color: @red_purple = "#cee"
74
+ overflow: hidden
75
+ } .curve {
76
+ background-color: @red_purple
77
+ margin: 0
78
+ padding: 0
79
+ height: 1px
80
+ overflow: hidden /* again, ie problem */
81
+ }
82
+
83
+ def curve(div_id, curve_array, width); s = ""; curve_array.length.times {|n| s += "\n##{div_id}#{curve_array.length - 1 - n}{border-left: #{curve_array[n]}px solid #{@background_teal}; border-right: #{curve_array[n]}px solid #{@background_teal}; width: #{width - curve_array[n]*2}px; _width: #{width - 20}px; }"}; s; end
84
+ @curves = [0, 1, 1, 1, 2, 2, 3, 4, 5, 7, 10]
85
+
86
+ curve("preheader_curve_", @curves, @width)
87
+
88
+ #header h1 {
89
+ color: @white = "#122"
90
+ font-size: 3em
91
+ margin: 0
92
+ } #header p {
93
+ margin: 0
94
+ padding: 0
95
+ padding-left: 3px
96
+ color: @white
97
+ } #header a {
98
+ color: @white
99
+ text-decoration: none
100
+ font-weight: bold
101
+ }
102
+
103
+ /* basic layout and navigation bars */
104
+
105
+ #left {
106
+ background-color: @deep_purple = "#cdd"
107
+ width: @left_width = 220
108
+ float: left
109
+ _width: @left_width - @buffer * 2
110
+ } #left a {
111
+ line-height: 1.2em
112
+ } #left div.curve {
113
+ float: left
114
+ background-color: @deep_purple
115
+ }
116
+
117
+ /* navigation bar colors and text styles */
118
+
119
+ .navigation {
120
+ width: @left_width - @buffer * 4
121
+ margin: @buffer
122
+ padding: @buffer
123
+ text-align: left
124
+ background-color: @background_teal
125
+ overflow: hidden
126
+ } .navigation a, {
127
+ margin-left: @buffer
128
+ } .navigation h3 {
129
+ font-weight: bold
130
+ margin-bottom: 5px
131
+ } .dark {
132
+ background-color: @gray_purple = "#bcc"
133
+ } .dark a, .dark span {
134
+ color: @white
135
+ margin-left: @buffer
136
+ } span.bpink {
137
+ color: @dark_teal
138
+ font-weight: bold
139
+ margin-left: @buffer
140
+ } span.bpink a, .dark span a {
141
+ margin-left: 0
142
+ } #spacer {
143
+ background-color: @background_teal
144
+ height: @buffer * 3
145
+ display: none
146
+ }
147
+
148
+ #content {
149
+ padding: @content_padding = 20
150
+ width: @width - @left_width - @content_padding * 2
151
+ background-color: @background_teal
152
+ float: left
153
+ }
154
+
155
+ .clear {
156
+ clear: both
157
+ }
158
+
159
+ #footer {
160
+ margin: 0 auto
161
+ text-align: right
162
+ background-color: @background_teal
163
+ font-size: .8em
164
+ padding: @buffer
165
+ } #footer a {
166
+ font-weight: normal
167
+ color: @gray_purple
168
+ }
169
+
170
+ /* for that dumb redirect index page I can't avoid */
171
+
172
+ #redirect {
173
+ text-align: center
174
+ } #redirect a {
175
+ color: @deep_purple
176
+ }
177
+
178
+ /* tables */
179
+
180
+ table {
181
+ width: @width - @left_width - @buffer * 8
182
+ border-collapse: collapse
183
+ }
184
+ td, th {
185
+ background-color: @background_teal
186
+ text-align: left
187
+ padding-left: @td = @buffer / 2
188
+ padding-right: @td
189
+ padding-top: @td
190
+ line-height: 1.2em
191
+ } th {
192
+ color: @white
193
+ background-color: @red_purple
194
+ } th.description {
195
+ text-align: center
196
+ } td.highlight {
197
+ color: @dark_teal
198
+ } td.first, th.first {
199
+ background-color: @red_purple
200
+ }
201
+
202
+
203
+ /* method details */
204
+
205
+ div.a_method {
206
+ background: @red_purple
207
+ padding: @buffer
208
+ margin-left: @buffer * 2 + 2
209
+ } div.a_method h3 {
210
+ color: @dark_teal
211
+ } div.a_method div {
212
+ background: #bdd
213
+ padding-left: @buffer
214
+ } div.a_method a.small {
215
+ font-size: .1em
216
+ line-height: .1em
217
+ } div.a_method p {
218
+ margin: .6em
219
+ margin-left: @lh
220
+ }
221
+
222
+ div.section_spacer {
223
+ height: 0
224
+ margin-top: @buffer * 2
225
+ }
226
+
227
+
228
+ /* index includes on the navigation bar */
229
+
230
+ div.index a {
231
+ font-size: .8em
232
+ } #method {
233
+ display: none
234
+ } #file, #class {
235
+ display: block
236
+ } div.list_header {
237
+ float: left
238
+ } div.list_header_link {
239
+ float: right
240
+ padding-top: 3px
241
+ } div.list_header_link a {
242
+ font-weight: normal
243
+ } #method_wrapper {
244
+ margin-bottom: 0
245
+ }
246
+
247
+ .index label {
248
+ font-size: 0.8em
249
+ } .index form input {
250
+ width: @left_width - @buffer * 11
251
+ } .index form {
252
+ margin-bottom: @buffer
253
+ }
254
+
255
+ curve("left_curve_", @curves.reverse, @left_width)
256
+
257
+ ol, ul {
258
+ margin-left: @buffer * 5
259
+ } ul {
260
+ list-style-type: square
261
+ }
262
+
263
+ p.source_link a {
264
+ text-align: right
265
+ font-weight: normal
266
+ } div.source {
267
+ display: none
268
+ } pre {
269
+ color: black
270
+ font-weight: normal
271
+ /* font-family: Courier, Courier New, monospace */
272
+ font-size: .8em
273
+ padding: @buffer
274
+ margin-left: @buffer * 2
275
+ overflow: auto
276
+ /* next 4 lines because IE sucks */
277
+ _position: relative
278
+ _width: @width - @left_width - (@buffer * 11 + 3)
279
+ _overflow-x:scroll
280
+ _overflow-y:visible
281
+ } div.source pre {
282
+ margin-left: 0
283
+ } p.source_link {
284
+ text-align: center
285
+ }
286
+
287
+ /* source code highlighting */
288
+
289
+ pre .ruby-value, pre .ruby-symbol {
290
+ color: @blue = "#1104bb"
291
+ } pre .ruby-value.str, pre .ruby-node {
292
+ color: @dark_teal #red = "#d20000"
293
+ } pre .ruby-ivar, pre .ruby-cvar {
294
+ } pre .ruby-comment {
295
+ color: @green = "#009500"
296
+ } pre .ruby-constant {
297
+ color: @orange = "#cd8802"
298
+ } pre .ruby-keyword {
299
+ color: @purple = "#8d04aa"
300
+ }
Binary file
@@ -0,0 +1,307 @@
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);