xray-rails 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a615b22a493e07b3115b382f002c36c50b7268f
4
- data.tar.gz: b97fa1653ebed9c29ec48397e97e918c722d33b2
3
+ metadata.gz: 0be94e713039493a6168e678b79e2f17767bfdb8
4
+ data.tar.gz: ff587e289d5ff5afd817a3ab1aad742b2181c7da
5
5
  SHA512:
6
- metadata.gz: cd87e68ea5c4844c4c9f871cbae0d7cf7232218132c3c733f74ff2d599f309e89049f055758768612e84c143afbf99348869cf1dcbd4ac88b1d7c42da1cad697
7
- data.tar.gz: f19ecffa3407856add279ed5af297ff9b93719caebfb3d7e01c94ff81b798f33210e1569d9ab0c54bd423b697bb71c14a4749c70477a24f84df84fbbe7a40559
6
+ metadata.gz: 070abce68bfd8b9c26d4367c6a53b758502b51cb188475f808cbb70c462f053457a8c5026d18fb5be8f830d219e8f37658d136f1f7007c364166625379fcdd80
7
+ data.tar.gz: 9b2b354cd8fc4fbbb832dc0dfc2085b4377465c8edc76e204a3880039ba9cf6480d5eea1619a75b53c8455b2d289053cd4c76641901096fabb39ffb89beaadb0
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Xray
2
- ====
1
+ Xray-rails
2
+ ==========
3
3
 
4
4
  ### Reveal your UI's bones
5
5
 
@@ -11,7 +11,7 @@ Xray is the missing link between the browser and your app code. Press **cmd+shif
11
11
 
12
12
  ## Current Support
13
13
 
14
- Xray is intended for Rails 3.1+ and Ruby 1.9.
14
+ Xray is intended for Rails 3.1+ and Ruby 1.9+.
15
15
 
16
16
  So far, Xray can reveal:
17
17
 
@@ -75,10 +75,10 @@ Or for something more complex, use the `$file` placeholder.
75
75
 
76
76
  ## How this works
77
77
 
78
- * During asset compilation, JS files and templates are modified to contain file path information.
78
+ * At run time, HTML responses from Rails are wrapped with HTML comments containing filepath info.
79
+ * Additionally, JS templates and Backbone view constructors are modified during asset compilation.
79
80
  * A middleware inserts `xray.js`, `xray.css`, and the Xray bar into all successful HTML response bodies.
80
- * When the overlay is shown, `xray.js` examines the file path information inserted during asset compilation.
81
- * Another middleware piggybacks the Rails server to respond to requests to open file paths with the user's desired editor.
81
+ * When the overlay is shown, `xray.js` examines the inserted filepath info to build the overlay.
82
82
 
83
83
  ## Disabling Xray in particular templates
84
84
 
@@ -110,7 +110,7 @@ class Xray.Specimen
110
110
 
111
111
  makeBox: ->
112
112
  @bounds = util.computeBoundingBox(@$contents)
113
- @$box = $("<div class='xray-specimen #{@constructor.name}'>").css(@bounds)
113
+ @$box = $("<div class='xray-specimen #{@constructor.name}'>").css(@bounds).attr('title', @path)
114
114
 
115
115
  # If the element is fixed, override the computed position with the fixed one.
116
116
  if @$contents.css('position') == 'fixed'
@@ -155,7 +155,7 @@ class Xray.Overlay
155
155
  @reset()
156
156
  Xray.isShowing = true
157
157
  util.bm 'show', =>
158
- @bar.$el.find('#xray-bar-togglers .xray-bar-btn').removeClass('active')
158
+ @bar.$el().find('#xray-bar-togglers .xray-bar-btn').removeClass('active')
159
159
  unless @$overlay.is(':visible')
160
160
  $('body').append @$overlay
161
161
  @bar.show()
@@ -163,14 +163,14 @@ class Xray.Overlay
163
163
  when 'templates'
164
164
  Xray.findTemplates()
165
165
  specimens = Xray.TemplateSpecimen.all
166
- @bar.$el.find('.xray-bar-templates-toggler').addClass('active')
166
+ @bar.$el().find('.xray-bar-templates-toggler').addClass('active')
167
167
  when 'views'
168
168
  specimens = Xray.ViewSpecimen.all
169
- @bar.$el.find('.xray-bar-views-toggler').addClass('active')
169
+ @bar.$el().find('.xray-bar-views-toggler').addClass('active')
170
170
  else
171
171
  Xray.findTemplates()
172
172
  specimens = Xray.specimens()
173
- @bar.$el.find('.xray-bar-all-toggler').addClass('active')
173
+ @bar.$el().find('.xray-bar-all-toggler').addClass('active')
174
174
  for element in specimens
175
175
  continue unless element.isVisible()
176
176
  element.makeBox()
@@ -196,37 +196,51 @@ class Xray.Overlay
196
196
  # toggle buttons for showing the different types of specimens in the overlay.
197
197
  class Xray.Bar
198
198
  constructor: (el) ->
199
- @$el = $(el)
200
- @$el.css(zIndex: MAX_ZINDEX)
201
- @$el.find('#xray-bar-controller-path .xray-bar-btn').click ->
199
+ @el = el
200
+
201
+ # Defer wiring up jQuery event handlers until needed and then memoize the
202
+ # result. If the Bar element no longer exists in the DOM, re-wire it.
203
+ # This allows the Bar to keep working even if e.g. Turbolinks replaces the
204
+ # DOM out from under us.
205
+ $el: ->
206
+ return @$el_memo if @$el_memo? && $.contains(window.document, @$el_memo[0])
207
+ @$el_memo = $(@el)
208
+ @$el_memo.css(zIndex: MAX_ZINDEX)
209
+ @$el_memo.find('#xray-bar-controller-path .xray-bar-btn').click ->
202
210
  Xray.open($(this).attr('data-path'))
203
- @$el.find('.xray-bar-all-toggler').click -> Xray.show()
204
- @$el.find('.xray-bar-templates-toggler').click -> Xray.show('templates')
205
- @$el.find('.xray-bar-views-toggler').click -> Xray.show('views')
206
- @$el.find('.xray-bar-settings-btn').click -> Xray.toggleSettings()
211
+ @$el_memo.find('.xray-bar-all-toggler').click -> Xray.show()
212
+ @$el_memo.find('.xray-bar-templates-toggler').click -> Xray.show('templates')
213
+ @$el_memo.find('.xray-bar-views-toggler').click -> Xray.show('views')
214
+ @$el_memo.find('.xray-bar-settings-btn').click -> Xray.toggleSettings()
215
+ @$el_memo
207
216
 
208
217
  show: ->
209
- @$el.show()
218
+ @$el().show()
210
219
  @originalPadding = parseInt $('html').css('padding-bottom')
211
220
  if @originalPadding < 40
212
221
  $('html').css paddingBottom: 40
213
222
 
214
223
  hide: ->
215
- @$el.hide()
224
+ @$el().hide()
216
225
  $('html').css paddingBottom: @originalPadding
217
226
 
218
227
 
219
228
  class Xray.Settings
220
229
  constructor: (el) ->
221
- @$el = $(el)
222
- @$el.find('form').submit @save
230
+ @el = el
231
+
232
+ $el: ->
233
+ return @$el_memo if @$el_memo? && $.contains(window.document, @$el_memo[0])
234
+ @$el_memo = $(@el)
235
+ @$el_memo.find('form').submit @save
236
+ @$el_memo
223
237
 
224
238
  toggle: =>
225
- @$el.toggle()
239
+ @$el().toggle()
226
240
 
227
241
  save: (e) =>
228
242
  e.preventDefault()
229
- editor = @$el.find('#xray-editor-input').val()
243
+ editor = @$el().find('#xray-editor-input').val()
230
244
  $.ajax
231
245
  url: '/_xray/config'
232
246
  type: 'POST'
@@ -239,7 +253,7 @@ class Xray.Settings
239
253
  $msg = $("<span class='xray-settings-success xray-settings-update-msg'>Success!</span>")
240
254
  else
241
255
  $msg = $("<span class='xray-settings-error xray-settings-update-msg'>Uh oh, something went wrong!</span>")
242
- @$el.append($msg)
256
+ @$el().append($msg)
243
257
  $msg.delay(2000).fadeOut(500, => $msg.remove(); @toggle())
244
258
 
245
259
 
@@ -97,7 +97,7 @@
97
97
  url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpDRkNBMTUwNzdGRTIxMUUyQjBGQ0NBRTc5RDQ3MEJFNSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpDRkNBMTUwODdGRTIxMUUyQjBGQ0NBRTc5RDQ3MEJFNSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkNGQ0ExNTA1N0ZFMjExRTJCMEZDQ0FFNzlENDcwQkU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNGQ0ExNTA2N0ZFMjExRTJCMEZDQ0FFNzlENDcwQkU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+aIv7XwAAAEVJREFUeNpiFBMTY2BgEBISYsAGWICAATdgkZeXB1Lv37/HLo1LAgKYGPACdOl3YIAwHNOpKFw0aTSXokujuZSA0wACDABh2BIyJ1wQkwAAAABJRU5ErkJggg==);
98
98
  }
99
99
 
100
- @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
100
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dppx) {
101
101
  #xray-bar {
102
102
  background-image: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.3)),
103
103
  url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVz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ERw8gE5O3v9q6lIEbbDQMZJ2Kv0gBOSR8HkqxphzBgDnnDEGJNkRsfc+xmitWWtF8KaUuqZ7EMDee1qutQ4hSGGkl1Kis2utYviYgUfZ4EU+CiP/TV0y/i02l1L6DA3is3n/FjDvHy5bYfxbF8b490fDTgEGAJveOCvuYEabAAAAAElFTkSuQmCC);
data/lib/xray/engine.rb CHANGED
@@ -31,7 +31,7 @@ module Xray
31
31
  def render_with_xray(*args, &block)
32
32
  path = identifier
33
33
  source = render_without_xray(*args, &block)
34
- suitable_template = path =~ /\.(html|slim|haml)(\.|$)/ && !path.match(/\.(js|json)\./) && !path.include?('_xray_bar')
34
+ suitable_template = path =~ /\.(html|slim|haml)(\.|$)/ && !path.match(/\.(js|json|css)\./) && !path.include?('_xray_bar')
35
35
  options = args.last.kind_of?(Hash) ? args.last : {}
36
36
  if suitable_template && !(options.has_key?(:xray) && (options[:xray] == false))
37
37
  Xray.augment_template(source, path)
@@ -73,7 +73,8 @@ module Xray
73
73
  # <script src="/assets/jquery.js"></script>
74
74
  # <script src="/assets/jquery-min.js"></script>
75
75
  # <script src="/assets/jquery.min.1.9.1.js"></script>
76
- html.sub!(/<script[^>]+\/#{after_script_name}([-.]{1}[\d\.]+)?([-.]{1}min)?\.js[^>]+><\/script>/) do
76
+ # <script src="/assets/jquery.min.1.9.1-89255b9dbf3de2fbaa6754b3a00db431.js"></script>
77
+ html.sub!(/<script[^>]+\/#{after_script_name}([-.]{1}[\d\.]+)?([-.]{1}min)?(-\h{32})?\.js[^>]+><\/script>/) do
77
78
  h = ActionController::Base.helpers
78
79
  "#{$~}\n" + h.javascript_include_tag(script_name)
79
80
  end
data/lib/xray/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xray
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xray-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Dillingham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails