serve 1.5.0.pre2 → 1.5.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,6 +1,12 @@
1
1
  = Change Log
2
2
 
3
3
  == edge
4
+ * Make Textile partials work. Closes #29. [rmetzler, jlong]
5
+ * Fixed problem with export that caused filenames with underscore to be excluded. [bmaland]
6
+ * Updated generated config.ru to require Sass. Closes #20. [jlong]
7
+ * Updated project README and other files to be more friendly to new users [jlong]
8
+ * Changed Sass directory name to "stylesheets" to be more consistent with Rails. [jlong]
9
+ * Modified redirects so that only the last line is interpreted as the URL, everything else is ignored. This is useful for adding a comment at the beginning of the file. [jlong]
4
10
  * Modified params helper to work with POST params in addition to GET. Closes #19. [jlong]
5
11
  * Added an export command which allows you to convert a Serve site to static HTML. Closes #10. [jlong]
6
12
 
data/README.rdoc CHANGED
@@ -1,40 +1,27 @@
1
1
  = Serve - A Rapid Prototyping Framework for Web Applications
2
2
 
3
- link:/downloads/jlong/serve/logo-hifi-1.png
3
+ link:../../downloads/jlong/serve/logo-hifi-1.png
4
4
 
5
5
  Serve is a small Rack-based web server that makes it easy to serve HTML, ERB,
6
- Haml, or Slim templates from any directory.
6
+ Haml, or a variety of template languages from any directory.
7
7
 
8
8
  But Serve is much more than a simple web server.
9
9
 
10
- Serve's primary purpose is to provide a rapid prototyping framework for Web
11
- applications (specifically Rails apps). It is designed to complement web
12
- application development and enforce a strict separation of concerns between
13
- designer and developer. Using Serve allows the designer to work in a separate
14
- prototype project, while the developer can work on the actual application and
15
- utilize resources from the prototype as needed. This allows the designer to
16
- focus on presentation and flow, while the developer can focus on
17
- implementation.
18
-
19
- This "Design First" approach can help a designer identify and fix a large
10
+ Serve is meant to be a lightweight version of the Views part of the Rails MVC.
11
+ This makes Serve an ideal framework for prototyping Rails applications or
12
+ creating simple websites. Serve also has full support for Rails-style partials
13
+ and layouts.
14
+
15
+ If you use a "Design First" approach to Web application development, you may
16
+ find Serve especially useful. Create a separate "prototype" project for your
17
+ application (using Serve) and copy views over into actual application when
18
+ they are ready to go. This workflow can allow the designer to focus on
19
+ presentation and flow, while the developer can focus on implementation. One
20
+ benefit to this approach is that the designer can identify and fix a large
20
21
  number of problems before a feature is ever touched by the developer. Once a
21
22
  feature has been completed in the prototype project it can also be estimated
22
23
  with a high degree of accuracy.
23
24
 
24
- A Serve prototype can work much like the finished application and be virtually
25
- indistinguishable. The only difference being that state is not saved as a user
26
- clicks around.
27
-
28
- Serve can be used alongside any Web development framework, but Rails
29
- developers will find it especially familiar. One way of thinking about Serve
30
- is that it is essentially a Rails application with only one part of the Rails
31
- MVC stack -- the views. Serve basically allows you to have a separate project
32
- just for designing the views for the application. When views are ready, they
33
- can be copied over from the prototype to the application almost as is. This
34
- process is eased since Serve has full support for partials and layouts with
35
- either ERB or Haml. Serve can also handle SASS, Slim, Textile, and Markdown
36
- if the appropriate libraries are installed.
37
-
38
25
 
39
26
  == Installation
40
27
 
@@ -47,7 +34,7 @@ Some systems, like the Mac, may require that you type:
47
34
 
48
35
  sudo gem install serve
49
36
 
50
- If you are a Mac user and are new to the command prompt see:
37
+ If you are new to the command prompt and are a Mac user see:
51
38
 
52
39
  http://wiseheartdesign.com/articles/2010/11/12/the-designers-guide-to-the-osx-command-prompt/
53
40
 
@@ -122,9 +109,9 @@ This will create a new project with the following directory structure:
122
109
  | |
123
110
  | `-- javascripts/
124
111
  |
125
- +-- sass/ # Store Sass source files here
112
+ +-- stylesheets/ # Sass and SCSS source files
126
113
  | |
127
- | `-- application.sass # Example Sass file for application
114
+ | `-- application.scss # Example SCSS file for application
128
115
  |
129
116
  +-- tmp/ # Needed for Passenger (mod_passenger)
130
117
  | |
@@ -136,6 +123,8 @@ This will create a new project with the following directory structure:
136
123
  |
137
124
  +-- hello.html.erb # Example view
138
125
  |
126
+ +-- index.redirect # Example redirect
127
+ |
139
128
  `-- view_helpers.rb # Example view helpers
140
129
 
141
130
  If you would like to generate the project with a specific JavaScript framework
@@ -282,7 +271,7 @@ slim :: Evaluates the document using the Slim template language (requires the Sl
282
271
  sass :: Evaluates the document as Sass (requires the Haml gem)
283
272
  scss :: Evaluates the document as SCSS (requires the Haml gem)
284
273
  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
285
- redirect :: Redirects to the URL contained in the document
274
+ redirect :: Redirects to the URL contained on the last line of the file
286
275
 
287
276
 
288
277
  == Exporting a Serve Project
@@ -294,26 +283,29 @@ project to HTML. To get started with the prerelease version:
294
283
 
295
284
  To export your project, use the new "export" command:
296
285
 
297
- serve export <project_dir>:<output_dir>
286
+ serve export project:output
298
287
 
299
- Where <project_dir> is the path to the project and <output_dir> is the path to
300
- the directory where you would like your HTML and CSS generated.
288
+ Where "project" is the path to the project and "output" is the path to the
289
+ directory where you would like your HTML and CSS generated.
301
290
 
302
291
  Please note! This feature is in beta. If you have issues with this approach,
303
292
  please post them to the GitHub issue tracker.
304
293
 
305
294
 
295
+ == Mailing List
296
+
297
+ Have questions? Please don't be ashamed to ask. Post them on the mailing list:
298
+
299
+ http://groups.google.com/group/serve-users
300
+
301
+
306
302
  == More Information
307
303
 
308
- You can find more information about Serve, including a detailed Screencast, on
304
+ You can find more information about Serve, including a detailed screencast, on
309
305
  the GitHub wiki:
310
306
 
311
307
  http://wiki.github.com/jlong/serve
312
308
 
313
- Have questions? Feel free to ask them on the mailing list:
314
-
315
- http://groups.google.com/group/serve-users
316
-
317
309
 
318
310
  == License
319
311
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0.pre2
1
+ 1.5.0.pre3
data/lib/serve/export.rb CHANGED
@@ -41,7 +41,7 @@ module Serve
41
41
  files.reject! { |fn| fn =~ /view_helpers.rb$/} # remove view_helpers.rb
42
42
  @redirects, @public = files.partition { |fn| fn =~ %r{\.redirect$} }
43
43
  end
44
- @views.reject! { |v| v =~ %r{_[^\/]+$} } # remove partials
44
+ @views.reject! { |v| v =~ /(^_|\/_)/ } # remove partials
45
45
  end
46
46
 
47
47
  def compile_compass_sass
@@ -100,7 +100,8 @@ module Serve
100
100
 
101
101
  ensure_path to_path
102
102
 
103
- url = IO.read(from_path).strip
103
+ lines = IO.read(from_path).strip.split("\n")
104
+ url = lines.pop.strip
104
105
  contents = %{<html><head><meta http-equiv="refresh" content="0;#{url}" /></head></html>}
105
106
 
106
107
  File.open(to_path, 'w+') { |f| f.puts contents }
@@ -3,7 +3,8 @@ module Serve #:nodoc:
3
3
  extension 'redirect'
4
4
 
5
5
  def process(request, response)
6
- url = super.strip
6
+ lines = super.strip.split("\n")
7
+ url = lines.last.strip
7
8
  unless url =~ %r{^\w[\w\d+.-]*:.*}
8
9
  url = request.protocol + request.host_with_port + url
9
10
  end
data/lib/serve/project.rb CHANGED
@@ -25,13 +25,13 @@ module Serve #:nodoc:
25
25
  public/images
26
26
  public/javascripts
27
27
  public/stylesheets
28
- sass
28
+ stylesheets
29
29
  ).each { |path| make_path path }
30
- create_file 'sass/application.sass', read_template('application.sass')
31
- create_file 'views/_layout.html.erb', read_template('_layout.html.erb')
32
- create_file 'views/hello.html.erb', read_template('hello.html.erb')
33
- create_file 'views/view_helpers.rb', read_template('view_helpers.rb')
34
- create_file 'views/index.redirect', read_template('index.redirect')
30
+ create_file 'stylesheets/application.scss', read_template('application.scss')
31
+ create_file 'views/_layout.html.erb', read_template('_layout.html.erb')
32
+ create_file 'views/hello.html.erb', read_template('hello.html.erb')
33
+ create_file 'views/view_helpers.rb', read_template('view_helpers.rb')
34
+ create_file 'views/index.redirect', read_template('index.redirect')
35
35
  install_javascript_framework @framework
36
36
  end
37
37
 
@@ -49,7 +49,7 @@ module Serve #:nodoc:
49
49
  else
50
50
  make_path 'public/javascripts'
51
51
  end
52
- move_file 'src', 'sass'
52
+ move_file 'src', 'stylesheets'
53
53
  install_javascript_framework @framework
54
54
  note_old_compass_config
55
55
  end
@@ -73,7 +73,6 @@ module Serve #:nodoc:
73
73
  views
74
74
  ).each { |path| make_path path }
75
75
  create_file 'config.ru', read_template('config.ru')
76
- create_file 'LICENSE', read_template('license')
77
76
  create_file '.gitignore', read_template('gitignore')
78
77
  create_file 'compass.config', read_template('compass.config')
79
78
  create_file 'README.markdown', read_template('README.markdown')
@@ -4,20 +4,21 @@ What is this?
4
4
  This is a simple HTML prototype written in HAML or ERB that is designed to be
5
5
  viewed with Serve.
6
6
 
7
- What is Serve? Serve is a rapid prototyping framework for Rails applications.
8
- It is designed to compliment Rails development and enforce a strict separation
9
- of concerns between designer and developer. Using Serve with Rails allows the
10
- designer to happily work in his own space creating an HTML prototype of the
11
- application, while the developer works on the Rails application and copies
12
- over HTML from the prototype as needed. This allows the designer to focus on
13
- presentation and flow while the developer can focus on the implementation.
7
+ What is Serve? Serve is an open-source rapid prototyping framework for Web
8
+ applications. It makes it easy to prototype functionality without writing a
9
+ single line of backend code.
14
10
 
15
11
 
16
12
  How do I install and run Serve?
17
13
  -------------------------------
18
14
 
19
- Serve is distributed as a gem to make it easy to get up and running. To
20
- install, type the following at the command prompt:
15
+ Serve is distributed as a Ruby gem to make it easy to get up and running. You
16
+ must have Ruby installed in order to download and use Serve. The Ruby download
17
+ page provides instructions for getting Ruby setup on different platforms:
18
+
19
+ <http://www.ruby-lang.org/en/downloads/>
20
+
21
+ After you have Ruby installed, open up the command prompt and type:
21
22
 
22
23
  gem install serve
23
24
 
@@ -32,15 +33,55 @@ Web browser at this URL:
32
33
 
33
34
  <http://localhost:4000>
34
35
 
35
- Click around. You will find that Serve enables you to prototype most
36
- functionality without writing a single line of backend code.
36
+
37
+ Compass and Sass
38
+ ----------------
39
+
40
+ This prototype uses Compass and Sass to generate CSS. Both are distributed as
41
+ Ruby gems and can be easily installed from the command prompt. Since the
42
+ Compass gem depends on Sass, you can install them both with one command:
43
+
44
+ gem install compass
45
+
46
+ Learn more about Sass:
47
+
48
+ <http://sass-lang.org>
49
+
50
+ Learn more about Compass:
51
+
52
+ <http://compass-style.org>
37
53
 
38
54
 
39
55
  Rack and Passenger
40
56
  ------------------
41
57
 
42
58
  Astute users may notice that this project is also a simple Rack application.
43
- This means that it is easy to deploy it on Passenger or rack it up with the
44
- `rackup` command. For more information about using Serve and Passenger see:
59
+ This means that it is easy to deploy it on Passenger or in any other
60
+ Rack-friendly environment. Rack it up with the `rackup` command. For more
61
+ information about using Serve and Passenger see:
62
+
63
+ <http://bit.ly/serve-and-passenger>
64
+
65
+
66
+ Exporting
67
+ ---------
68
+
69
+ To export this project to pure HTML and CSS you will need the prerelease
70
+ version of Serve. To get started with the prerelease version:
71
+
72
+ gem install --pre serve
73
+
74
+ To export your project, use the new "export" command:
75
+
76
+ serve export <project>:<output>
77
+
78
+ Where "project" is the path to the project and "output" is the path to the
79
+ directory where you would like your HTML and CSS generated.
80
+
81
+
82
+ Learning More
83
+ -------------
84
+
85
+ You can learn more about Serve on the GitHub project page:
45
86
 
46
- <http://bit.ly/serve-and-passenger>
87
+ <http://github.com/jlong/serve>
@@ -0,0 +1,18 @@
1
+ //
2
+ // Application Stylesheet
3
+ //
4
+
5
+ @import "compass";
6
+
7
+ @include global-reset;
8
+
9
+ body {
10
+ font-size: 90%;
11
+ padding: 20px;
12
+ }
13
+
14
+ h1 {
15
+ font-family: "Trebuchet MS", Helvetica, Arial, sans-serif;
16
+ font-size: 260%;
17
+ font-weight: bold;
18
+ }
@@ -9,7 +9,7 @@ http_images_path = '/images'
9
9
  http_javascripts_path = '/javascripts'
10
10
 
11
11
  # File system locations
12
- sass_dir = 'sass'
12
+ sass_dir = 'stylesheets'
13
13
  css_dir = 'public/stylesheets'
14
14
  images_dir = 'public/images'
15
15
  javascripts_dir = 'public/javascripts'
@@ -1,6 +1,5 @@
1
1
  #\\ -p 4000
2
2
 
3
- gem 'activesupport'
4
3
  gem 'serve'
5
4
 
6
5
  require 'serve'
@@ -13,6 +12,7 @@ root = ::File.dirname(__FILE__)
13
12
  # don't allow you to write to the file system on the fly (like Heroku).
14
13
  # Remove this conditional if you want to compile Sass in production.
15
14
  if ENV['RACK_ENV'] != 'production'
15
+ require 'sass'
16
16
  require 'sass/plugin/rack'
17
17
  require 'compass'
18
18
 
@@ -1 +1,15 @@
1
+ Serve has a special file type for mapping HTTP redirects. Redirects make nice
2
+ end points for form posts or short URLs.
3
+
4
+ Redirect URLs can be fully formed, like this:
5
+
6
+ http://wiseheartdesign.com/
7
+
8
+ Or, relative to the site root, like this:
9
+
10
+ /action
11
+
12
+ Extra lines at the beginning of a redirect file are ignored. By convention,
13
+ the last line of a redirect file is the URL to redirect to:
14
+
1
15
  /hello
@@ -1,5 +1,34 @@
1
+ #
2
+ # Place methods here that you want available to you in your views.
3
+ # View helpers allow you keep templates clean.
4
+ #
1
5
  module ViewHelpers
6
+
7
+ # Example helper method
2
8
  def hello(name)
3
9
  "Hello \#{name}!"
4
10
  end
11
+
12
+ # Handy for hiding a block of unfinished code
13
+ def hidden(&block)
14
+ #no-op
15
+ end
16
+
17
+ # Shorthand for referencing images in the images folder
18
+ def image(name, options = {})
19
+ path = "/images/\#{name}"
20
+ path += ".png" unless path.match(/\.[A-za-z]{3,4}$/)
21
+ image_tag(name, {:alt => ""}.update(options))
22
+ end
23
+
24
+ # Calculate the years for a copyright
25
+ def copyright_years(start_year)
26
+ end_year = Date.today.year
27
+ if start_year == end_year
28
+ "\#{start_year}"
29
+ else
30
+ "\#{start_year}&#8211;\#{end_year}"
31
+ end
32
+ end
33
+
5
34
  end
@@ -140,7 +140,7 @@ module Serve #:nodoc:
140
140
  template = template[1..-1]
141
141
  path = @root_path
142
142
  end
143
- filename = template_filename(File.join(path, template), :partial => options.delete(:partial))
143
+ filename = template_filename(File.join(path, template), :partial => options[:partial])
144
144
  if File.file?(filename)
145
145
  parser.parse_file(filename, options[:locals])
146
146
  else
@@ -153,15 +153,16 @@ module Serve #:nodoc:
153
153
  def template_filename(name, options)
154
154
  path = File.dirname(name)
155
155
  template = File.basename(name)
156
- template = "_" + template if options.delete(:partial)
157
- template += extname(parser.script_filename) unless name =~ /\.[a-z]{3,4}$/
156
+ template = "_" + template if options[:partial]
157
+ template += extname(parser.script_filename) unless name =~ /\.[a-z]+$/
158
158
  File.join(path, template)
159
159
  end
160
160
 
161
161
  def extname(filename)
162
- /(\.[a-z]{3,4}\.[a-z]{3,4})$/.match(filename)
162
+ /(\.[a-z]+\.[a-z]+)$/.match(filename)
163
163
  $1 || File.extname(filename) || ''
164
164
  end
165
+
165
166
  end
166
167
 
167
168
  module TagHelpers
@@ -9,11 +9,14 @@ describe Serve::Application do
9
9
  :help => false,
10
10
  :version => false,
11
11
  :environment => 'development',
12
+
12
13
  :port => 4000,
13
14
  :address => '0.0.0.0',
14
15
  :root => Dir.pwd,
16
+
15
17
  :convert => nil,
16
- :create => nil
18
+ :create => nil,
19
+ :export => nil
17
20
  }
18
21
  end
19
22
 
data/spec/project_spec.rb CHANGED
@@ -13,6 +13,9 @@ describe Serve::Project do
13
13
 
14
14
  before(:all) do
15
15
  @options = {
16
+ :port => 4000,
17
+ :address => '0.0.0.0',
18
+
16
19
  :name => 'test_mockup',
17
20
  :directory => File.dirname(__FILE__),
18
21
  :framework => 'jquery'
@@ -67,7 +70,7 @@ describe Serve::Project do
67
70
  end
68
71
 
69
72
  it "should have a sass directory" do
70
- File.exists?(File.join(@mockup_file, 'sass')).should be_true
73
+ File.exists?(File.join(@mockup_file, 'stylesheets')).should be_true
71
74
  end
72
75
 
73
76
  it "should have a tmp directory" do
@@ -86,10 +89,6 @@ describe Serve::Project do
86
89
  File.exists?(File.join(@mockup_file, 'compass.config')).should be_true
87
90
  end
88
91
 
89
- it "should have a LICENSE file" do
90
- File.exists?(File.join(@mockup_file, 'LICENSE')).should be_true
91
- end
92
-
93
92
  it "should have a dot gitignore file" do
94
93
  File.exists?(File.join(@mockup_file, '.gitignore')).should be_true
95
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serve
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988199
4
+ hash: -1876988218
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 0
10
- - pre2
11
- version: 1.5.0.pre2
10
+ - pre3
11
+ version: 1.5.0.pre3
12
12
  platform: ruby
13
13
  authors:
14
14
  - John W. Long
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-06-08 00:00:00 -04:00
21
+ date: 2011-06-22 00:00:00 -04:00
22
22
  default_executable: serve
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -167,10 +167,9 @@ files:
167
167
  - lib/serve/project.rb
168
168
  - lib/serve/rack.rb
169
169
  - lib/serve/router.rb
170
- - lib/serve/templates/LICENSE
171
170
  - lib/serve/templates/README.markdown
172
171
  - lib/serve/templates/_layout.html.erb
173
- - lib/serve/templates/application.sass
172
+ - lib/serve/templates/application.scss
174
173
  - lib/serve/templates/compass.config
175
174
  - lib/serve/templates/config.ru
176
175
  - lib/serve/templates/gitignore
@@ -1,20 +0,0 @@
1
- Copyright (c) #{Time.now.year} #{@full_name}
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,12 +0,0 @@
1
- @import "compass"
2
-
3
- +global-reset
4
-
5
- body
6
- font-size: 90%
7
- padding: 20px
8
-
9
- h1
10
- font-family: "Trebuchet MS", Helvetica, Arial, sans-serif
11
- font-size: 260%
12
- font-weight: bold