xray-rails 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/app/assets/javascripts/xray.js.coffee +33 -19
- data/app/assets/stylesheets/xray.css +1 -1
- data/lib/xray/engine.rb +1 -1
- data/lib/xray/middleware.rb +2 -1
- data/lib/xray/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0be94e713039493a6168e678b79e2f17767bfdb8
|
4
|
+
data.tar.gz: ff587e289d5ff5afd817a3ab1aad742b2181c7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
*
|
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
|
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
|
-
|
200
|
-
|
201
|
-
|
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
|
-
@$
|
204
|
-
@$
|
205
|
-
@$
|
206
|
-
@$
|
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
|
-
|
222
|
-
|
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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2L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-ratio: 2), (min-resolution:
|
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/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0Q0ZGQkRGRTdGRTMxMUUyQjBGQ0NBRTc5RDQ3MEJFNSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0Q0ZGQkRGRjdGRTMxMUUyQjBGQ0NBRTc5RDQ3MEJFNSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkNGQ0ExNTA5N0ZFMjExRTJCMEZDQ0FFNzlENDcwQkU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkNGQ0ExNTBBN0ZFMjExRTJCMEZDQ0FFNzlENDcwQkU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+T6y4zwAAAIZJREFUeNrkkjEKwCAMRWMbERw8gE5O3v9q6lIEbbDQMZJ2Kv0gBOSR8HkqxphzBgDnnDEGJNkRsfc+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)
|
data/lib/xray/middleware.rb
CHANGED
@@ -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
|
-
|
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
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.
|
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:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|