Getting started with Serve is easy. Because Serve is built with Ruby, you will need to have Ruby installed on your system. Mac OSX ships with Ruby. If you are on Windows you can install Ruby with this easy installation package.
Once Ruby is installed, open up the command prompt, and type:
gem install serve
Using the serve command
Serve ships with an easy to use command that makes it easy to turn any directory into into a browseable set of web pages. To use it, simply change to the project directory, and type serve:
~$ cd my-project ~/my-project$ serve
This will start Serve up on your local box on port 4000. To view files with Serve, navigate to http://localhost:4000 in your web browser.
As you navigate around in your browser, Serve will print out a log of it’s activity on the command prompt. When you are ready to stop Serve type: Ctrl+C, or close the command prompt window.
Serve also includes a number of useful sub-commands:
- Create – Create a structured Serve project
- Export – Export a Serve project to regular HTML and CSS
- Convert – Convert an existing Compass project to a Serve project
Reading source code is a great way to improve your coding prowess. You may want to study one or more of the following projects to get a better idea of how to use Serve effectively.
- Serve Website Source
- Check out the code that is being used for the Serve website. It’s a good example of using Serve to build a static site. We use the Serve export command to generate the site, and a handy rsync rake task to deploy.
- Radiant CMS Prototype
- The Radiant CMS prototype project is a superb example of using Serve to prototype a Rails application. It’s a fully functional, clickable prototype without the backend. HTML prototypes are a great way to work out design issues before spending a lot of time on the programming.
- Adam Stacoviak’s Serve Bootstrap
- The Changelog’s very own Adam Stacoviak has put together a Serve bootstrap project with some of his favorite defaults. It comes packed with Haml, Sass, Compass, his own Grid Coordinates CSS grid framework, jQuery and Modernizer. It also comes ready to deploy on Heroku.
- Command Line Usage
- View Helpers
- Template Engines and File Types
- Prototyping Rails Applications with Serve
- Using Coffee Script with Serve
- Contributing to Serve