• Stars
    star
    836
  • Rank 54,534 (Top 2 %)
  • Language
    Ruby
  • License
    Other
  • Created over 16 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.

Serve - Delicious ERB, Haml, and Sass

Serve is a small Rack-based web server that makes it easy to serve HTML, ERB, Haml, or a variety of template languages from any directory.

Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.

Serve is made with Rack & Tilt.

Installation

Serve is distributed as a Ruby gem and can be installed from the command prompt. Just type:

gem install serve -v 1.5.2

Some systems, like the Mac, may require that you type:

sudo gem install serve -v 1.5.2

If you are new to the command prompt and are a Mac user see:

wiseheartdesign.com/articles/2010/11/12/the-designers-guide-to-the-osx-command-prompt/

Search Google for “command prompt windows” if you are on a PC to find a simple tutorial.

Basic Usage

Once the gem is installed the ‘serve` command will be available from the command prompt. To launch Serve, just type the command and press enter:

serve

This will launch a simple web server which you can access from any web browser at the following address:

http://localhost:4000

Once the server is going it will output a running log of its activity. To stop the server at any time, type CTRL+C at the command prompt.

Learn more: get-serve.com/documentation/usage

Creating a Structured Serve Project

For simple projects, you don’t need to structure your files in a specific way. All ERB, Haml, and Sass files will be processed wherever they are found in the project root. But for more complex projects you may want add a bit of structure.

To create a structured Serve project in the “project” directory, type the following on the command line:

serve create project   # create a new project in the project directory

Learn more: get-serve.com/documentation/create

Layouts & Partials

Serve has full support for Rails-style layouts and partials.

Serve layouts are stored in “_layout.erb” or “_layout.haml” files in the same directory as the page they are rendering.

Learn more: get-serve.com/documentation/layouts

Serve partials (much like PHP includes) are rendered using the familiar render syntax:

<%= render "footer" %>

Learn more: get-serve.com/documentation/partials

View Helpers

If you drop a file called “view_helpers.rb” in your views directory, you can define custom helpers for your Haml and ERB views. Just create a ViewHelpers module and define your custom helper methods there:

module ViewHelpers

  # Calculate the years for a copyright
  def copyright_years(start_year)
    end_year = Date.today.year
    if start_year == end_year
      start_year
    else
      start_year.to_s + "&#8211;" + end_year.to_s
    end
  end

end

You can then use your custom helper methods inside a view or layout:

<%= copyright_years(2010) %>

Serve also provides a number of stock helpers methods that are very similar to their Rails counter parts.

Learn more: get-serve.com/documentation/view-helpers

Exporting

To export your project, use the new “export” command:

serve export project output

Where “project” is the path to the project and “output” is the path to the directory where you would like your HTML and CSS generated.

Learn more: get-serve.com/documentation/export

“Design First” Prototyping

If you use a “Design First” methodology, you may find Serve especially useful for prototyping your applications. Create a separate “prototype” project for your application (using Serve) and copy views over into actual application when they are ready to go. This workflow allows the designer to focus on presentation and flow, while the developer can focuses on implementation. One benefit to this approach is that the designer can identify and fix a large number of design-related problems before a feature is ever touched by the developer. Once a feature has been completed in the prototype project it can also be estimated with a high degree of accuracy.

Website & Documentation

Detailed documentation is available on the Serve website: get-serve.com Build status: <img src=“https://secure.travis-ci.org/jlong/serve.png?branch=master” />

Mailing List

Have questions? Please don’t be ashamed to ask. Post them on the mailing list:

groups.google.com/group/serve-users

Coming up

  • We are working on a new website for serve, with a new minimal design, estimated to be released in late Augest 2015.

License

Serve is released under a MIT-style license and is copyright © 2007-2011 John W. Long and Adam I. Williams. Portions have been contributed by Robert Evans and others. A copy of the license can be found in the LICENSE file.

More Repositories

1

css-spinners

Simple CSS spinners and throbbers made with CSS and minimal HTML markup.
CSS
924
star
2

radius

A small, but powerful tag-based template language for Ruby modeled after the ones used in MovableType and TextPattern. It has tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc...).
Ruby
101
star
3

popupjs

A prototype/lowpro based Facebook-style windowing solution
JavaScript
58
star
4

rubyblue

A collection of themes for different text editors that mimic the colors used in the code samples on ruby-lang.org
Vim Script
50
star
5

statusjs

Allows you to display a status message when submiting a form or performing other time consuming tasks
JavaScript
28
star
6

TrelloApp

A simple unofficial wrapper application for Trello.com. No longer maintained. Superseded by Trello's own app: https://apps.apple.com/app/trello/id1278508951?ls=1&mt=12
Swift
23
star
7

cheap-sass-tricks

CSS
22
star
8

radiant-bespin-editor-extension

Replaces all textareas in Radiant with the Bespin editor
JavaScript
18
star
9

feedchamp

A simple camping application that makes it easy to aggregate a bunch of feeds into a single website.
Ruby
10
star
10

sass-convert.vim

Simple commands for Vim for converting Sass from SCSS to Sass and back.
Vim Script
8
star
11

acoustic

A lightweight Ruby Web framework experiment based loosely on Django and Rails
Ruby
6
star
12

cookbook

A simple cookbook application designed to demo Rails 3. Made with Devise for authentication and Twitter Bootstrap for styles.
Ruby
5
star
13

javascript_spec

4
star
14

serve-heroku

An example Serve project deployed on Heroku
Ruby
4
star
15

MacRubyClock

A very simple clock written in MacRuby. Uses NSTimer and a label to display the current time.
Ruby
3
star
16

serve-slim

An example Serve project with Slim
Ruby
3
star
17

ChessClocks

A simple chess clock application for the iPhone
Objective-C
2
star
18

ruby-presentation

The source code for a presentation that John W. Long and Ryan Platte put together in 2005
Ruby
2
star
19

radiant3

A Rails 3 update and reboot of Radiant
Ruby
1
star
20

ChessClocksAssets

1
star
21

radiant

Ruby
1
star
22

snakejs

The micro selector and events library for IE8+ perfectly suited for widgets and simple applications or websites.
JavaScript
1
star
23

test_helpers

An older Rails plugin that adds support for test helpers
Ruby
1
star
24

css-workshop

The source files from a workshop I did several years ago. Students were supposed to style the provided HTML so that it looked like the provided mockup.
1
star
25

oxygen-moogle-example

CSS
1
star
26

styleguide

Gulp workflow for a styleguide
JavaScript
1
star
27

snakes-and-rubies

The source code for an application that collected questions for a debate that occurred between David Heinemeier Hansson and Adrian Holovaty about Rails and Django.
Ruby
1
star
28

angular-and-d3

Example code from my presentation on Angular and D3
JavaScript
1
star
29

stealth

Experimental work on a Javascript game
JavaScript
1
star
30

abstract_testcases

An older Rails plugin that adds support for abstract test cases
Ruby
1
star
31

hello-c

Canonical hello world program in C
Shell
1
star
32

serve-coffee

Basic demo of how to use Serve with Coffee Script. The tricky part is that you need to serve it from your views directory and make sure the layout is appropriate.
Ruby
1
star