rack-reshow 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/rack/reshow.rb +25 -23
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -116,32 +116,34 @@ module Rack
116
116
  status, headers, body = @app.call(env)
117
117
  if status == 200 and body.respond_to? :join
118
118
  body = body.join
119
- page = Page.new body, path, @app
120
- # Store response
121
- @store.transaction do |store|
122
- store[path] ||= []
123
- store[path] << page unless body.nil? or store[path].last.eql?(page)
124
- end
125
- # Insert Reshow assets
126
- page.append_to_tag '</head>', [style, javascript].join("\n")
127
- # Prepare for Reshow bar
128
- @store.transaction(true) do |store|
129
- page.body = %q{<div id="__reshow_bodies__"></div>}
130
- store[path].reverse.each do |p|
131
- page.prepend_to_tag '<div id="__reshow_bodies__">', Page.tag(:div, p.body, :class => '__reshow_body__')
119
+ if body[/<head>.*?<\/head>/] and body[/<body>.*?<\/body>/]
120
+ page = Page.new body, path, @app
121
+ # Store response
122
+ @store.transaction do |store|
123
+ store[path] ||= []
124
+ store[path] << page unless body.nil? or store[path].last.eql?(page)
132
125
  end
133
- versions = store[path].count
134
- # Insert Reshow Bar
135
- page.append_to_tag '</body>', toolbar(versions)
136
- # Insert versioned stylesheets
137
- versions.times do |v|
138
- escaped_path = Rack::Utils.escape(path)
139
- href = "/__reshow__/assets?path=#{escaped_path}&version=#{v}"
140
- page.append_to_tag '</head>', "<link charset='utf-8' href='#{href}' rel='stylesheet' type='text/css'>"
126
+ # Insert Reshow assets
127
+ page.append_to_tag '</head>', [style, javascript].join("\n")
128
+ # Prepare for Reshow bar
129
+ @store.transaction(true) do |store|
130
+ page.body = %q{<div id="__reshow_bodies__"></div>}
131
+ store[path].reverse.each do |p|
132
+ page.prepend_to_tag '<div id="__reshow_bodies__">', Page.tag(:div, p.body, :class => '__reshow_body__')
133
+ end
134
+ versions = store[path].count
135
+ # Insert Reshow Bar
136
+ page.append_to_tag '</body>', toolbar(versions)
137
+ # Insert versioned stylesheets
138
+ versions.times do |v|
139
+ escaped_path = Rack::Utils.escape(path)
140
+ href = "/__reshow__/assets?path=#{escaped_path}&version=#{v}"
141
+ page.append_to_tag '</head>', "<link charset='utf-8' href='#{href}' rel='stylesheet' type='text/css'>"
142
+ end
141
143
  end
144
+ headers['Content-Length'] = page.length.to_s
145
+ body = [page.to_s]
142
146
  end
143
- headers['Content-Length'] = page.length.to_s
144
- body = [page.to_s]
145
147
  end
146
148
  [status, headers, body]
147
149
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-reshow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ecin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-15 00:00:00 -04:00
12
+ date: 2010-01-16 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency