https://github.com/zh/yarf
Yet Another Rack Framework
https://github.com/zh/yarf
Last synced: about 1 year ago
JSON representation
Yet Another Rack Framework
- Host: GitHub
- URL: https://github.com/zh/yarf
- Owner: zh
- License: mit
- Created: 2012-01-24T13:50:44.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-02-03T05:50:21.000Z (over 14 years ago)
- Last Synced: 2025-02-17T11:44:35.430Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 129 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YARF - Yet Another Ruby(Rack) Framework
A minimalist (and relatively useless) Ruby web applications framework.
## Features
* Small (< 100 LOC) and fast
* Powered by [Rack](https://github.com/chneukirchen/rack)
* Templates via [Tilt](https://github.com/rtomayko/tilt)
* Routing via [HTTP-Router](https://github.com/joshbuddy/http_router)
* Routes with parameters - '/show/:id'
* Redirects with status - 301 or 302
* Global and per action layouts
* Partial views
* Nesting routes - with '/admin' do ... end
* Static assets - via *Rack::Static*
* Authentication *via Warden* (see the example application)
* Lots of tests included - using *rspec* and *rack-test*
## Pre-requirements
* rack
* erubis
* tilt
* http_router
## Usage
Install pre-requirements:
gem install bundler --pre # (if not installed)
bundle install
Example application in *myapp.rb*:
require 'yarf'
class MyApp < Yarf
static "/static", Yarf.root("public")
layout :bootstrap
get "/" do
render :index
end
get "/intro" do
redirect_to "/readme"
end
get "/readme" do
render :readme, :engine => :md
end
with "/admin" do
get "/dashboard" do
render :admin, :layout => :admin
end
end
end
Rackup script *config.ru*:
require 'myapp'
run HttpRouter.new {
add('/static').static(Yarf.root("public"))
add('/*').to {|env| MyApp.new.call(env) }
}
Use the Rackup script to launch the application:
thin start -R config.ru -p 8080
or
ruby myapp.rb -p 8080
## YARF in the wild
* [YARF development](https://github.com/zh/yarf)
* [YARF site](http://yarf.herokuapp.com/) itself
* [Travis CI building results](http://travis-ci.org/#!/zh/yarf)
## TODO
* support for helpers
* embedded templates - erb '<%= ... %>'
* more tests