serve 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,12 @@
1
+ == 0.9.8 (July 18, 2008)
2
+
3
+ * Added experimental support for ERB layouts. [Lawjoskar]
4
+
5
+ == 0.9.7 (July 17, 2008)
6
+
7
+ * Added experimental support for view helpers. [aiwilliams]
8
+ * Added limited support for ERB. Layouts are not yet supported. [jlong]
9
+
1
10
  == 0.9.6 (February 20, 2008)
2
11
 
3
12
  * Changed default port to 4000 so that serve plays nicely with Rails apps.
@@ -32,3 +32,9 @@ tasks/environment.rake
32
32
  tasks/rspec.rake
33
33
  tasks/undefine.rake
34
34
  tasks/website.rake
35
+ test_project/_layout.haml
36
+ test_project/erb/_layout.html.erb
37
+ test_project/erb/index.html.erb
38
+ test_project/test.haml
39
+ test_project/test.html.erb
40
+ test_project/view_helpers.rb
@@ -50,7 +50,7 @@ h3. Creating Our First Screen
50
50
 
51
51
  Now that we have the prototype directory set up, let's create our first page so that you can get a feel for how Serve works. This will be a simple HTML login page for our application.
52
52
 
53
- Insert the following HTML into an file named "login.html":
53
+ Insert the following HTML into an file named "login.html.erb":
54
54
 
55
55
  <pre><code>
56
56
  <form action="/dashboard/" method="put">
@@ -96,7 +96,7 @@ Name Last modified Size
96
96
  Parent Directory 2008/02/23 15:35 -
97
97
  images/ 2008/02/23 15:35 -
98
98
  javascripts/ 2008/02/23 15:35 -
99
- login.html 2008/02/23 15:36 346
99
+ login.html.erb 2008/02/23 15:36 346
100
100
  stylesheets/ 2008/02/23 15:35 -
101
101
  </pre>
102
102
 
@@ -111,7 +111,7 @@ h3. Layouts
111
111
 
112
112
  One thing to note about the source that I gave you for the login page. I intentionally left out the <html>, <head>, and <body> tags because they belong a layout---not the source file. Let's go ahead and create that layout now.
113
113
 
114
- Insert the following HTML into a file named "_layout.html" in the root directory of your prototype:
114
+ Insert the following HTML into a file named "_layout.html.erb" in the root directory of your prototype:
115
115
 
116
116
  <pre><code>
117
117
  <html>
@@ -129,7 +129,7 @@ This layout includes a small amount of ERB(Embedded Ruby) to indicate the title
129
129
 
130
130
  Embedded Ruby is delineated with the opening and closing sequence <% and %> respectively. Sequences that begin with an addition equals sign insert their output directly into the HTML. In this case we want to render the @title variable as the title in the head and as the first heading in the document body. The yield keyword is used to insert the content of the page at that point.
131
131
 
132
- We need to make one small change to our login page before continuing. Insert the following line at the top of login.html file:
132
+ We need to make one small change to our login page before continuing. Insert the following line at the top of login.html.erb file:
133
133
 
134
134
  <pre>
135
135
  <% @title = "Login" %>
data/README.txt CHANGED
@@ -52,12 +52,24 @@ Serve presently does special processing for files with following extensions:
52
52
 
53
53
  textile :: Evaluates the document as Textile (requires the Redcloth gem)
54
54
  markdown :: Evaluates the document as Markdown (requires the Bluecloth gem)
55
+ erb :: Experimental support for ERB is partial implemented
55
56
  haml :: Evaluates the document as Haml (requires the Haml gem)
56
57
  sass :: Evaluates the document as Sass (requires the Haml gem)
57
- email :: Evaluates the document as if it is an e-mail message; the format is identicle to a plain/text e-mail message's source
58
+ email :: Evaluates the document as if it is an e-mail message; the format is identical to a plain/text e-mail message's source
58
59
  redirect :: Redirects to the URL contained in the document
59
60
 
60
61
 
62
+ == View Helpers
63
+
64
+ If you drop a file called view_helpers.rb in the root of a project, you can define custom helpers for your Haml and ERB views. Just declare the ViewHelpers module and begin declaring your helpers:
65
+
66
+ module ViewHelpers
67
+ def custom_method
68
+ "Request object: #{request.headers['user-agent']}"
69
+ end
70
+ end
71
+
72
+
61
73
  === Installation and Setup
62
74
 
63
75
  It is recommended that you install serve via RubyGems:
@@ -76,10 +88,14 @@ Or visit the project page here:
76
88
 
77
89
  * http://rubyforge.org/projects/serve
78
90
 
91
+ All development now takes place on GitHub:
92
+
93
+ * http://github.com/jlong/serve
94
+
79
95
 
80
96
  === License
81
97
 
82
- Serve is released under the MIT license and is copyright (c) 2006-2007
98
+ Serve is released under the MIT license and is copyright (c) 2006-2008
83
99
  John W. Long. A copy of the MIT license can be found in the License.txt file.
84
100
 
85
101
 
data/bin/serve CHANGED
File without changes
@@ -33,11 +33,18 @@ module Serve #:nodoc:
33
33
  root = Dir.pwd
34
34
  path = filename[root.size..-1]
35
35
  layout = nil
36
- begin
36
+
37
+ until layout or path == "/"
37
38
  path = File.dirname(path)
38
- l = File.join(root, path, '_layout.haml')
39
- layout = l if File.file?(l)
40
- end until layout or path == "/"
39
+
40
+ possible_layouts = ['_layout.haml', '_layout.html.erb'].map do |l|
41
+ possible_layout = File.join(root, path, l)
42
+ File.file?(possible_layout) ? possible_layout : false
43
+ end
44
+
45
+ layout = possible_layouts.detect {|o| o }
46
+ end
47
+
41
48
  layout
42
49
  end
43
50
 
@@ -2,7 +2,7 @@ module Serve #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ !!! Strict
2
+ %html
3
+ %head
4
+ %title= @title
5
+ %body
6
+ %h1= @title
7
+ = yield
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html>
3
+ <head>
4
+ <title><%= @title %></title>
5
+ </head>
6
+ <body>
7
+ <h1><%= @title %></h1>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,5 @@
1
+ <% @title = "ERB Template" %>
2
+
3
+ <p>Hello World!</p>
4
+
5
+ <%= custom_method %>
@@ -0,0 +1,3 @@
1
+ = render :template => "test.html.erb"
2
+ = custom_method
3
+ - @title = "Haml Template"
@@ -0,0 +1,3 @@
1
+ <% @title = "ERB Template" %>
2
+
3
+ <p>Hello World!</p>
@@ -0,0 +1,5 @@
1
+ module ViewHelpers
2
+ def custom_method
3
+ "Request object: #{request.headers['user-agent']}"
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - John W. Long
@@ -30,10 +30,19 @@ cert_chain:
30
30
  qXI=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-07-17 00:00:00 -04:00
33
+ date: 2008-07-18 00:00:00 -04:00
34
34
  default_executable:
35
- dependencies: []
36
-
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.7.0
45
+ version:
37
46
  description: Serve is a small Ruby script that makes it easy to start up a WEBrick server in any directory. Serve is ideal for HTML prototyping and simple file sharing. If the haml, redcloth, and bluecloth gems are installed serve can handle Haml, Sass, Textile, and Markdown (in addition to HTML).
38
47
  email: me@johnwlong.com
39
48
  executables:
@@ -80,6 +89,12 @@ files:
80
89
  - tasks/rspec.rake
81
90
  - tasks/undefine.rake
82
91
  - tasks/website.rake
92
+ - test_project/_layout.haml
93
+ - test_project/erb/_layout.html.erb
94
+ - test_project/erb/index.html.erb
95
+ - test_project/test.haml
96
+ - test_project/test.html.erb
97
+ - test_project/view_helpers.rb
83
98
  has_rdoc: true
84
99
  homepage: http://serve.rubyforge.org
85
100
  post_install_message:
@@ -103,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
118
  requirements: []
104
119
 
105
120
  rubyforge_project: serve
106
- rubygems_version: 1.0.1
121
+ rubygems_version: 1.2.0
107
122
  signing_key:
108
123
  specification_version: 2
109
124
  summary: Serve is a small Ruby script that makes it easy to start up a WEBrick server in any directory. Serve is ideal for HTML prototyping and simple file sharing. If the haml, redcloth, and bluecloth gems are installed serve can handle Haml, Sass, Textile, and Markdown (in addition to HTML).
metadata.gz.sig CHANGED
Binary file