serverside 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGELOG +16 -0
  2. data/Rakefile +16 -1
  3. data/lib/serverside/caching.rb +56 -0
  4. data/lib/serverside/request.rb +8 -4
  5. data/lib/serverside/static.rb +29 -51
  6. data/test/functional/static_server.rb +7 -0
  7. data/test/spec/caching_spec.rb +101 -0
  8. data/test/spec/connection_spec.rb +0 -2
  9. data/test/unit/request_test.rb +31 -1
  10. data/test/unit/static_test.rb +21 -25
  11. metadata +30 -75
  12. data/doc/rdoc/classes/Daemon/Base.html +0 -148
  13. data/doc/rdoc/classes/Daemon/Cluster/PidFile.html +0 -230
  14. data/doc/rdoc/classes/Daemon/Cluster.html +0 -308
  15. data/doc/rdoc/classes/Daemon/PidFile.html +0 -178
  16. data/doc/rdoc/classes/Daemon.html +0 -253
  17. data/doc/rdoc/classes/Object.html +0 -151
  18. data/doc/rdoc/classes/Proc.html +0 -151
  19. data/doc/rdoc/classes/ServerSide/Application.html +0 -172
  20. data/doc/rdoc/classes/ServerSide/HTTP/Connection.html +0 -202
  21. data/doc/rdoc/classes/ServerSide/HTTP/Request.html +0 -768
  22. data/doc/rdoc/classes/ServerSide/HTTP/Server.html +0 -164
  23. data/doc/rdoc/classes/ServerSide/HTTP.html +0 -121
  24. data/doc/rdoc/classes/ServerSide/Router.html +0 -496
  25. data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +0 -204
  26. data/doc/rdoc/classes/ServerSide/StaticFiles.html +0 -282
  27. data/doc/rdoc/classes/ServerSide/Template.html +0 -200
  28. data/doc/rdoc/classes/ServerSide.html +0 -174
  29. data/doc/rdoc/classes/String.html +0 -212
  30. data/doc/rdoc/classes/Symbol.html +0 -158
  31. data/doc/rdoc/created.rid +0 -1
  32. data/doc/rdoc/files/CHANGELOG.html +0 -356
  33. data/doc/rdoc/files/COPYING.html +0 -129
  34. data/doc/rdoc/files/README.html +0 -199
  35. data/doc/rdoc/files/lib/serverside/application_rb.html +0 -109
  36. data/doc/rdoc/files/lib/serverside/cluster_rb.html +0 -101
  37. data/doc/rdoc/files/lib/serverside/connection_rb.html +0 -101
  38. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +0 -107
  39. data/doc/rdoc/files/lib/serverside/daemon_rb.html +0 -108
  40. data/doc/rdoc/files/lib/serverside/request_rb.html +0 -108
  41. data/doc/rdoc/files/lib/serverside/routing_rb.html +0 -101
  42. data/doc/rdoc/files/lib/serverside/server_rb.html +0 -108
  43. data/doc/rdoc/files/lib/serverside/static_rb.html +0 -108
  44. data/doc/rdoc/files/lib/serverside/template_rb.html +0 -108
  45. data/doc/rdoc/files/lib/serverside_rb.html +0 -131
  46. data/doc/rdoc/fr_class_index.html +0 -45
  47. data/doc/rdoc/fr_file_index.html +0 -40
  48. data/doc/rdoc/fr_method_index.html +0 -79
  49. data/doc/rdoc/index.html +0 -24
  50. data/doc/rdoc/rdoc-style.css +0 -208
@@ -1,204 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Module: ServerSide::StaticFiles::Const</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">ServerSide::StaticFiles::Const</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/serverside/static_rb.html">
59
- lib/serverside/static.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
- <div id="description">
76
- <p>
77
- Frozen constants to be used by the module.
78
- </p>
79
-
80
- </div>
81
-
82
-
83
- </div>
84
-
85
-
86
- </div>
87
-
88
-
89
- <!-- if includes -->
90
-
91
- <div id="section">
92
-
93
-
94
- <div id="constants-list">
95
- <h3 class="section-bar">Constants</h3>
96
-
97
- <div class="name-list">
98
- <table summary="Constants">
99
- <tr class="top-aligned-row context-row">
100
- <td class="context-item-name">ETag</td>
101
- <td>=</td>
102
- <td class="context-item-value">'ETag'.freeze</td>
103
- </tr>
104
- <tr class="top-aligned-row context-row">
105
- <td class="context-item-name">ETagFormat</td>
106
- <td>=</td>
107
- <td class="context-item-value">'%x:%x:%x'.inspect.freeze</td>
108
- </tr>
109
- <tr class="top-aligned-row context-row">
110
- <td class="context-item-name">CacheControl</td>
111
- <td>=</td>
112
- <td class="context-item-value">'Cache-Control'.freeze</td>
113
- </tr>
114
- <tr class="top-aligned-row context-row">
115
- <td class="context-item-name">MaxAge</td>
116
- <td>=</td>
117
- <td class="context-item-value">&quot;max-age=#{86400 * 30}&quot;.freeze</td>
118
- </tr>
119
- <tr class="top-aligned-row context-row">
120
- <td class="context-item-name">IfNoneMatch</td>
121
- <td>=</td>
122
- <td class="context-item-value">'If-None-Match'.freeze</td>
123
- </tr>
124
- <tr class="top-aligned-row context-row">
125
- <td class="context-item-name">IfModifiedSince</td>
126
- <td>=</td>
127
- <td class="context-item-value">'If-Modified-Since'.freeze</td>
128
- </tr>
129
- <tr class="top-aligned-row context-row">
130
- <td class="context-item-name">LastModified</td>
131
- <td>=</td>
132
- <td class="context-item-value">&quot;Last-Modified&quot;.freeze</td>
133
- </tr>
134
- <tr class="top-aligned-row context-row">
135
- <td class="context-item-name">NotModifiedClose</td>
136
- <td>=</td>
137
- <td class="context-item-value">&quot;HTTP/1.1 304 Not Modified\r\nDate: %s\r\nConnection: close\r\nLast-Modified: %s\r\nETag: %s\r\nCache-Control: #{MaxAge}\r\n\r\n&quot;.freeze</td>
138
- </tr>
139
- <tr class="top-aligned-row context-row">
140
- <td class="context-item-name">NotModifiedPersist</td>
141
- <td>=</td>
142
- <td class="context-item-value">&quot;HTTP/1.1 304 Not Modified\r\nDate: %s\r\nLast-Modified: %s\r\nETag: %s\r\nCache-Control: #{MaxAge}\r\n\r\n&quot;.freeze</td>
143
- </tr>
144
- <tr class="top-aligned-row context-row">
145
- <td class="context-item-name">TextPlain</td>
146
- <td>=</td>
147
- <td class="context-item-value">'text/plain'.freeze</td>
148
- </tr>
149
- <tr class="top-aligned-row context-row">
150
- <td class="context-item-name">TextHTML</td>
151
- <td>=</td>
152
- <td class="context-item-value">'text/html'.freeze</td>
153
- </tr>
154
- <tr class="top-aligned-row context-row">
155
- <td class="context-item-name">MaxCacheFileSize</td>
156
- <td>=</td>
157
- <td class="context-item-value">100000.freeze # 100KB for the moment</td>
158
- </tr>
159
- <tr class="top-aligned-row context-row">
160
- <td class="context-item-name">DirListingStart</td>
161
- <td>=</td>
162
- <td class="context-item-value">'&lt;html&gt;&lt;head&gt;&lt;title&gt;Directory Listing for %s&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h2&gt;Directory listing for %s:&lt;/h2&gt;'.freeze</td>
163
- </tr>
164
- <tr class="top-aligned-row context-row">
165
- <td class="context-item-name">DirListing</td>
166
- <td>=</td>
167
- <td class="context-item-value">'&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;&lt;br/&gt;'.freeze</td>
168
- </tr>
169
- <tr class="top-aligned-row context-row">
170
- <td class="context-item-name">DirListingStop</td>
171
- <td>=</td>
172
- <td class="context-item-value">'&lt;/body&gt;&lt;/html&gt;'.freeze</td>
173
- </tr>
174
- <tr class="top-aligned-row context-row">
175
- <td class="context-item-name">FileNotFound</td>
176
- <td>=</td>
177
- <td class="context-item-value">'File not found.'.freeze</td>
178
- </tr>
179
- <tr class="top-aligned-row context-row">
180
- <td class="context-item-name">RHTML</td>
181
- <td>=</td>
182
- <td class="context-item-value">/\.rhtml$/.freeze</td>
183
- </tr>
184
- </table>
185
- </div>
186
- </div>
187
-
188
-
189
-
190
-
191
-
192
-
193
- <!-- if method_list -->
194
-
195
-
196
- </div>
197
-
198
-
199
- <div id="validator-badges">
200
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
201
- </div>
202
-
203
- </body>
204
- </html>
@@ -1,282 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Module: ServerSide::StaticFiles</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">ServerSide::StaticFiles</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/serverside/static_rb.html">
59
- lib/serverside/static.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
- <div id="description">
76
- <p>
77
- This module provides functionality for serving files and directory listings
78
- over <a href="HTTP.html">HTTP</a>.
79
- </p>
80
-
81
- </div>
82
-
83
-
84
- </div>
85
-
86
- <div id="method-list">
87
- <h3 class="section-bar">Methods</h3>
88
-
89
- <div class="name-list">
90
- <a href="#M000023">serve_dir</a>&nbsp;&nbsp;
91
- <a href="#M000022">serve_file</a>&nbsp;&nbsp;
92
- <a href="#M000025">serve_static</a>&nbsp;&nbsp;
93
- <a href="#M000024">serve_template</a>&nbsp;&nbsp;
94
- </div>
95
- </div>
96
-
97
- </div>
98
-
99
-
100
- <!-- if includes -->
101
-
102
- <div id="section">
103
-
104
- <div id="class-list">
105
- <h3 class="section-bar">Classes and Modules</h3>
106
-
107
- Module <a href="StaticFiles/Const.html" class="link">ServerSide::StaticFiles::Const</a><br />
108
-
109
- </div>
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
- <!-- if method_list -->
118
- <div id="methods">
119
- <h3 class="section-bar">Public Instance methods</h3>
120
-
121
- <div id="method-M000023" class="method-detail">
122
- <a name="M000023"></a>
123
-
124
- <div class="method-heading">
125
- <a href="#M000023" class="method-signature">
126
- <span class="method-name">serve_dir</span><span class="method-args">(dir)</span>
127
- </a>
128
- </div>
129
-
130
- <div class="method-description">
131
- <p>
132
- Serves a directory listing over <a href="HTTP.html">HTTP</a> in the form of
133
- an HTML page.
134
- </p>
135
- <p><a class="source-toggle" href="#"
136
- onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
137
- <div class="method-source-code" id="M000023-source">
138
- <pre>
139
- <span class="ruby-comment cmt"># File lib/serverside/static.rb, line 80</span>
140
- 80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_dir</span>(<span class="ruby-identifier">dir</span>)
141
- 81: <span class="ruby-identifier">html</span> = (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">DirListingStart</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@path</span>, <span class="ruby-ivar">@path</span>]) <span class="ruby-operator">+</span>
142
- 82: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">dir</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-value str">''</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">fn</span><span class="ruby-operator">|</span>
143
- 83: (<span class="ruby-identifier">fn</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'.'</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">DirListing</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@path</span><span class="ruby-operator">/</span><span class="ruby-identifier">fn</span>, <span class="ruby-identifier">fn</span>]
144
- 84: } <span class="ruby-operator">+</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">DirListingStop</span>
145
- 85: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">200</span>, <span class="ruby-value str">'text/html'</span>, <span class="ruby-identifier">html</span>)
146
- 86: <span class="ruby-keyword kw">end</span>
147
- </pre>
148
- </div>
149
- </div>
150
- </div>
151
-
152
- <div id="method-M000022" class="method-detail">
153
- <a name="M000022"></a>
154
-
155
- <div class="method-heading">
156
- <a href="#M000022" class="method-signature">
157
- <span class="method-name">serve_file</span><span class="method-args">(fn)</span>
158
- </a>
159
- </div>
160
-
161
- <div class="method-description">
162
- <p>
163
- Serves a file over <a href="HTTP.html">HTTP</a>. The file is cached in
164
- memory for later retrieval. If the If-None-Match header is included with an
165
- ETag, it is checked against the file&#8217;s current ETag. If there&#8217;s
166
- a match, a 304 response is rendered.
167
- </p>
168
- <p><a class="source-toggle" href="#"
169
- onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
170
- <div class="method-source-code" id="M000022-source">
171
- <pre>
172
- <span class="ruby-comment cmt"># File lib/serverside/static.rb, line 47</span>
173
- 47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_file</span>(<span class="ruby-identifier">fn</span>)
174
- 48: <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">fn</span>)
175
- 49: <span class="ruby-identifier">etag</span> = (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETagFormat</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">ino</span>]).<span class="ruby-identifier">freeze</span>
176
- 50: <span class="ruby-identifier">date</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">httpdate</span>
177
- 51:
178
- 52: <span class="ruby-identifier">etag_match</span> = <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">IfNoneMatch</span>]
179
- 53: <span class="ruby-identifier">last_date</span> = <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">IfModifiedSince</span>]
180
- 54:
181
- 55: <span class="ruby-identifier">modified</span> = (<span class="ruby-operator">!</span><span class="ruby-identifier">etag_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">last_date</span>) <span class="ruby-operator">||</span>
182
- 56: (<span class="ruby-identifier">etag_match</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">etag</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">etag_match</span>)) <span class="ruby-operator">||</span> (<span class="ruby-identifier">last_date</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">last_date</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">date</span>))
183
- 57:
184
- 58: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">modified</span>
185
- 59: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@static_files</span>[<span class="ruby-identifier">fn</span>] <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-ivar">@@static_files</span>[<span class="ruby-identifier">fn</span>][<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">etag</span>)
186
- 60: <span class="ruby-identifier">content</span> = <span class="ruby-ivar">@@static_files</span>[<span class="ruby-identifier">fn</span>][<span class="ruby-value">1</span>]
187
- 61: <span class="ruby-keyword kw">else</span>
188
- 62: <span class="ruby-identifier">content</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">fn</span>).<span class="ruby-identifier">freeze</span>
189
- 63: <span class="ruby-ivar">@@static_files</span>[<span class="ruby-identifier">fn</span>] = [<span class="ruby-identifier">etag</span>.<span class="ruby-identifier">freeze</span>, <span class="ruby-identifier">content</span>]
190
- 64: <span class="ruby-keyword kw">end</span>
191
- 65:
192
- 66: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">200</span>, <span class="ruby-ivar">@@mime_types</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">fn</span>)], <span class="ruby-identifier">content</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>, {
193
- 67: <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETag</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">etag</span>,
194
- 68: <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LastModified</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">date</span>,
195
- 69: <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CacheControl</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MaxAge</span>
196
- 70: })
197
- 71: <span class="ruby-keyword kw">else</span>
198
- 72: <span class="ruby-ivar">@socket</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-ivar">@persistent</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">NotModifiedPersist</span> <span class="ruby-operator">:</span>
199
- 73: <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">NotModifiedClose</span>) <span class="ruby-operator">%</span> [<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">httpdate</span>, <span class="ruby-identifier">date</span>, <span class="ruby-identifier">etag</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>])
200
- 74: <span class="ruby-keyword kw">end</span>
201
- 75: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
202
- 76: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">404</span>, <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">TextPlain</span>, <span class="ruby-value str">'Error reading file.'</span>)
203
- 77: <span class="ruby-keyword kw">end</span>
204
- </pre>
205
- </div>
206
- </div>
207
- </div>
208
-
209
- <div id="method-M000025" class="method-detail">
210
- <a name="M000025"></a>
211
-
212
- <div class="method-heading">
213
- <a href="#M000025" class="method-signature">
214
- <span class="method-name">serve_static</span><span class="method-args">(path)</span>
215
- </a>
216
- </div>
217
-
218
- <div class="method-description">
219
- <p>
220
- Serves static files and directory listings.
221
- </p>
222
- <p><a class="source-toggle" href="#"
223
- onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
224
- <div class="method-source-code" id="M000025-source">
225
- <pre>
226
- <span class="ruby-comment cmt"># File lib/serverside/static.rb, line 95</span>
227
- 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_static</span>(<span class="ruby-identifier">path</span>)
228
- 96: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">path</span>)
229
- 97: <span class="ruby-identifier">serve_file</span>(<span class="ruby-identifier">path</span>)
230
- 98: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">serve_template</span>(<span class="ruby-identifier">path</span>)
231
- 99: <span class="ruby-keyword kw">return</span>
232
- 100: <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>)
233
- 101: <span class="ruby-identifier">serve_dir</span>(<span class="ruby-identifier">path</span>)
234
- 102: <span class="ruby-keyword kw">else</span>
235
- 103: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">404</span>, <span class="ruby-value str">'text'</span>, <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFound</span>)
236
- 104: <span class="ruby-keyword kw">end</span>
237
- 105: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
238
- 106: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">500</span>, <span class="ruby-value str">'text'</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>)
239
- 107: <span class="ruby-keyword kw">end</span>
240
- </pre>
241
- </div>
242
- </div>
243
- </div>
244
-
245
- <div id="method-M000024" class="method-detail">
246
- <a name="M000024"></a>
247
-
248
- <div class="method-heading">
249
- <a href="#M000024" class="method-signature">
250
- <span class="method-name">serve_template</span><span class="method-args">(fn, b = nil)</span>
251
- </a>
252
- </div>
253
-
254
- <div class="method-description">
255
- <p><a class="source-toggle" href="#"
256
- onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
257
- <div class="method-source-code" id="M000024-source">
258
- <pre>
259
- <span class="ruby-comment cmt"># File lib/serverside/static.rb, line 88</span>
260
- 88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_template</span>(<span class="ruby-identifier">fn</span>, <span class="ruby-identifier">b</span> = <span class="ruby-keyword kw">nil</span>)
261
- 89: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">fn</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">RHTML</span>) <span class="ruby-operator">||</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">fn</span> = <span class="ruby-identifier">fn</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.rhtml'</span>))
262
- 90: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">200</span>, <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">TextHTML</span>, <span class="ruby-constant">Template</span>.<span class="ruby-identifier">render</span>(<span class="ruby-identifier">fn</span>, <span class="ruby-identifier">b</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">binding</span>))
263
- 91: <span class="ruby-keyword kw">end</span>
264
- 92: <span class="ruby-keyword kw">end</span>
265
- </pre>
266
- </div>
267
- </div>
268
- </div>
269
-
270
-
271
- </div>
272
-
273
-
274
- </div>
275
-
276
-
277
- <div id="validator-badges">
278
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
279
- </div>
280
-
281
- </body>
282
- </html>