Reverse ERB Proxy

Get Version

0.0.1

→ ‘reverb’

What

Reverb is an ERB aware reverse proxy to integrate distributed applications using a simple plugin API.

Installing

sudo gem install reverb

The basics

Http proxy for integrating distributed applications via ERB templates and plugins.

The payload should be a typical Http response with the following properties:

The http header defines page level properties such as:
Header Property
X-Reverb-Title Title
X-Reverb-Description Meta description
X-Reverb-Keywords Meta keyword
X-Reverb-Styles CSS styles (comma separated list)
X-Reverb-Javascripts Javascripts (comma separated list)
X-Reverb-Template Template

If the content type is text/x-ruby-source then the body is eval’ed with the reverb (plugin) context.

Plugins are easy to write and follow the Capistrano plugin model (see more on Plugins below).

Demonstration of usage

With HTTP header:


X-Reverb-Enable: 1
X-Reverb-Template: default
X-Reverb-Title: The title
X-Reverb-Description: This is the description
X-Reverb-Keywords: keyword1,keyword2
X-Reverb-Styles: /foo/bars.css,/baz/boom.css
X-Reverb-Javascript: /foo/bar.js,/baz/boom.js

Content-Type: text/x-ruby-source

And HTTP body:


<h1>Test body</h1>
<p>The page title is '<%= page.title %>'</p>

With provided template:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title><%= page.title %></title>
  <meta name="description" content="<%= page.description %>" />
  <meta name="keywords" content="<%= page.keywords %>" />
  <%= page.styles %>  
</head>
<body>
  <%= page.body %>  
  <%= page.scripts %>  
</body>
</html>


Gets evaluated to:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>The title</title>
  <meta name="description" content="This is the description" />
  <meta name="keywords" content="keyword1,keyword2" />
   <link type="text/css" rel="stylesheet" href="/foo/bar.css"/> 
 <link type="text/css" rel="stylesheet" href="/baz/boom.css"/> 
  
</head>
<body>
<h1>Test body</h1>
<p>The page title is 'The title'</p>
</body>
</html>

The page plugin gives you access to markup for scripts, styles, title, and any other information provided by the http headers.

Plugins

Plugins are just modules installed with a namespace:


module MyPlugin

  def analytics(account_id)
    "<!-- provide analytics js here -->"
  end
    
end

Reverb.plugin :my, MyPlugin

Now you can use this in your erb template.


<h1>Test body</h1>
<p>Putting analytics in: <%= my.analytics("UA-1989388-1") %></p>

Forum

http://groups.google.com/group/reverb

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The trunk repository is awaiting approval.

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome via the forum

9th April 2008
Theme extended from Paul Battley