rack-reshow

the little toolbar that could

Rack::Reshow adds a toolbar to rendered views that stores different versions of the page. Afterwards, reviewing and comparing outputted changes is a single click away.

use

To install:

gem install rack-reshow

With Rails:

config.gem “rack-reshow”, :lib => “rack/reshow” config.middleware.use “Rack::Reshow”

In your rackup file:

require ‘rack/reshow’ use Rack::Reshow

why

Development of a view is a trial and error process by far: change code, reload the browser, change to previous version, reload the browser, compare the two versions, repeat until satisfied.

By storing the rendered views each time they change, Rack::Reshow tightens the review loop, effectively creating a history for each page that can be clicked through.

how

Rack::Reshow uses PStore to store different versions of a page.

Each time a request is received, Rack::Reshow checks if the <body> of the response differs from what it last was. If so, it adds it to the store. Afterwards, it injects all previous versions into the response, and makes them transversable via a small, elegant bar.

limitations

Rack::Reshow only works on responses that have a <head> and <body>, namely the type of page one works with when dealing with a layout’s look and feel.

Furthermore, it works best when javascript is applied unobtrusively; if there’s any javascript inside the response’s <body>, it’ll get called once for each time said javascript code appears in the page’s history.

Finally, the same page may have different content depending on session variables (i.e. after one logs in), or simply dynamic variables (i.e. displaying the date/time). Rack::Reshow will store both versions separately, even though there’s no code modification going on behind the scenes.

thanks

famfamfam for the elegant icons. Rack::Bug for insight into how to serve static content and inject content into a response. Jeweler for making publishing gems so simple.

copyright

Copyright © 2010 copypastel. See LICENSE for details.