copy_tuner_client 0.1.1.beta7 → 0.1.1.beta8
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.
- data/.travis.yml +5 -5
- data/Appraisals +7 -10
- data/Gemfile.lock +1 -1
- data/README.md +16 -2
- data/app/assets/javascripts/copyray.js.coffee +57 -134
- data/app/assets/stylesheets/copyray.css +8 -276
- data/gemfiles/{2.3.gemfile → 3.2.gemfile} +1 -1
- data/gemfiles/3.2.gemfile.lock +170 -0
- data/gemfiles/{3.0.gemfile → 4.0.gemfile} +1 -1
- data/gemfiles/4.0.gemfile.lock +163 -0
- data/gemfiles/4.1.gemfile +7 -0
- data/gemfiles/4.1.gemfile.lock +167 -0
- data/lib/copy_tuner_client/copyray.rb +3 -3
- data/lib/copy_tuner_client/version.rb +1 -1
- data/spec/copy_tuner_client/request_sync_spec.rb +4 -4
- metadata +9 -8
- data/gemfiles/3.0.gemfile.lock +0 -153
- data/gemfiles/3.1.gemfile +0 -11
- data/gemfiles/3.1.gemfile.lock +0 -191
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
appraise '2
|
2
|
-
gem 'rails', '2.
|
1
|
+
appraise '3.2' do
|
2
|
+
gem 'rails', '3.2.19'
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise '
|
6
|
-
gem 'rails', '
|
5
|
+
appraise '4.0' do
|
6
|
+
gem 'rails', '4.0.8'
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
gem '
|
12
|
-
gem 'uglifier'
|
13
|
-
gem 'sass-rails'
|
14
|
-
gem 'coffee-rails'
|
9
|
+
|
10
|
+
appraise '4.1' do
|
11
|
+
gem 'rails', '4.1.4'
|
15
12
|
end
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,23 @@ CopyTuner Client
|
|
4
4
|
[TODO] Write After
|
5
5
|
|
6
6
|
|
7
|
+
|
8
|
+
Development
|
9
|
+
=================
|
10
|
+
|
7
11
|
## Spec
|
8
12
|
|
13
|
+
### default spec
|
14
|
+
|
15
|
+
$ bundle exec rake
|
16
|
+
|
9
17
|
### Appraisal for Multi Version Rails spec
|
10
18
|
|
11
|
-
rake appraisal:install
|
12
|
-
rake appraisal
|
19
|
+
$ bundle exec rake appraisal:install
|
20
|
+
$ bundle exec rake appraisal
|
21
|
+
|
22
|
+
## release gem
|
23
|
+
|
24
|
+
$ bundle exec rake build # build gem to pkg/ dir
|
25
|
+
$ bundle exec rake install # install to local gem
|
26
|
+
$ bundle exec rake release # release gem to rubygems.org
|
@@ -1,86 +1,85 @@
|
|
1
|
-
window.
|
1
|
+
window.Copyray = {}
|
2
2
|
return unless $ = window.jQuery
|
3
3
|
|
4
|
-
# Max CSS z-index. The overlay and
|
4
|
+
# Max CSS z-index. The overlay and copyray bar use this.
|
5
5
|
MAX_ZINDEX = 2147483647
|
6
6
|
|
7
|
-
# Initialize
|
8
|
-
|
9
|
-
return if
|
10
|
-
|
7
|
+
# Initialize Copyray. Called immediately, but some setup is deferred until DOM ready.
|
8
|
+
Copyray.init = do ->
|
9
|
+
return if Copyray.initialized
|
10
|
+
Copyray.initialized = true
|
11
11
|
|
12
12
|
is_mac = navigator.platform.toUpperCase().indexOf('MAC') isnt -1
|
13
13
|
|
14
14
|
# Register keyboard shortcuts
|
15
15
|
$(document).keydown (e) ->
|
16
|
-
# cmd+shift
|
17
|
-
if (is_mac and e.metaKey or !is_mac and e.ctrlKey) and e.shiftKey and e.keyCode is
|
18
|
-
if
|
19
|
-
if
|
20
|
-
|
16
|
+
# cmd + shift + k
|
17
|
+
if (is_mac and e.metaKey or !is_mac and e.ctrlKey) and e.shiftKey and e.keyCode is 75
|
18
|
+
if Copyray.isShowing then Copyray.hide() else Copyray.show()
|
19
|
+
if Copyray.isShowing and e.keyCode is 27 # esc
|
20
|
+
Copyray.hide()
|
21
21
|
|
22
22
|
$ ->
|
23
23
|
# Instantiate the overlay singleton.
|
24
|
-
new
|
24
|
+
new Copyray.Overlay
|
25
25
|
# Go ahead and do a pass on the DOM to find templates.
|
26
|
-
|
26
|
+
Copyray.findBlurbs()
|
27
27
|
# Ready to rock.
|
28
|
-
console?.log "Ready to
|
28
|
+
console?.log "Ready to Copyray. Press #{if is_mac then 'cmd+shift+k' else 'ctrl+shift+k'} to scan your UI."
|
29
29
|
|
30
|
-
# Returns all currently created
|
31
|
-
|
32
|
-
|
30
|
+
# Returns all currently created Copyray.Specimen objects.
|
31
|
+
Copyray.specimens = ->
|
32
|
+
Copyray.BlurbSpecimen.all
|
33
33
|
|
34
34
|
# Looks up the stored constructor info
|
35
|
-
|
36
|
-
if window.
|
37
|
-
for own info, func of window.
|
35
|
+
Copyray.constructorInfo = (constructor) ->
|
36
|
+
if window.CopyrayPaths
|
37
|
+
for own info, func of window.CopyrayPaths
|
38
38
|
return JSON.parse(info) if func == constructor
|
39
39
|
null
|
40
40
|
|
41
|
-
# Scans the document for
|
42
|
-
|
43
|
-
# Find all <!--
|
41
|
+
# Scans the document for blurbs, creating Copyray.BlurbSpecimen for them.
|
42
|
+
Copyray.findBlurbs = -> util.bm 'findBlurbs', ->
|
43
|
+
# Find all <!-- COPYRAY START ... --> comments
|
44
44
|
comments = $('*:not(iframe,script)').contents().filter ->
|
45
|
-
this.nodeType == 8 and this.data[0..
|
45
|
+
this.nodeType == 8 and this.data[0..12] == "COPYRAY START"
|
46
46
|
|
47
|
-
# Find the <!--
|
48
|
-
# start and end comment becomes the contents of an Xray.TemplateSpecimen.
|
47
|
+
# Find the <!-- COPYRAY END ... --> comment for each. Everything between the
|
49
48
|
for comment in comments
|
50
|
-
[_, id, path, url] = comment.data.match(/^
|
51
|
-
$
|
49
|
+
[_, id, path, url] = comment.data.match(/^COPYRAY START (\d+) (\S*) (\S*)/)
|
50
|
+
$blurbContents = new jQuery
|
52
51
|
el = comment.nextSibling
|
53
|
-
until !el or (el.nodeType == 8 and el.data == "
|
52
|
+
until !el or (el.nodeType == 8 and el.data == "COPYRAY END #{id}")
|
54
53
|
if el.nodeType == 1 and el.tagName != 'SCRIPT'
|
55
|
-
$
|
54
|
+
$blurbContents.push el
|
56
55
|
el = el.nextSibling
|
57
|
-
# Remove
|
56
|
+
# Remove COPYRAY template comments from the DOM.
|
58
57
|
el.parentNode.removeChild(el) if el?.nodeType == 8
|
59
58
|
comment.parentNode.removeChild(comment)
|
60
59
|
# Add the template specimen
|
61
|
-
|
60
|
+
Copyray.BlurbSpecimen.add $blurbContents,
|
62
61
|
name: path.split('/').slice(-1)[0]
|
63
62
|
path: path
|
64
63
|
url: url
|
65
64
|
|
66
|
-
# Open the given filesystem path by calling out to
|
67
|
-
|
65
|
+
# Open the given filesystem path by calling out to Copyray's server.
|
66
|
+
Copyray.open = (url) ->
|
68
67
|
window.open(url, null, 'width=700, height=500')
|
69
68
|
|
70
|
-
# Show the
|
71
|
-
|
72
|
-
|
69
|
+
# Show the Copyray overlay
|
70
|
+
Copyray.show = (type = null) ->
|
71
|
+
Copyray.Overlay.instance().show(type)
|
73
72
|
|
74
|
-
# Hide the
|
75
|
-
|
76
|
-
|
73
|
+
# Hide the Copyray overlay
|
74
|
+
Copyray.hide = ->
|
75
|
+
Copyray.Overlay.instance().hide()
|
77
76
|
|
78
|
-
|
79
|
-
|
77
|
+
Copyray.toggleSettings = ->
|
78
|
+
Copyray.Overlay.instance().settings.toggle()
|
80
79
|
|
81
|
-
# Wraps a DOM element that
|
82
|
-
#
|
83
|
-
class
|
80
|
+
# Wraps a DOM element that Copyray is tracking. This is subclassed by
|
81
|
+
# Copyray.Blurbsspecimen
|
82
|
+
class Copyray.Specimen
|
84
83
|
@add: (el, info = {}) ->
|
85
84
|
@all.push new this(el, info)
|
86
85
|
|
@@ -112,7 +111,7 @@ class Xray.Specimen
|
|
112
111
|
|
113
112
|
makeBox: ->
|
114
113
|
@bounds = util.computeBoundingBox(@$contents)
|
115
|
-
@$box = $("<div class='
|
114
|
+
@$box = $("<div class='copyray-specimen #{@constructor.name}'>").css(@bounds)
|
116
115
|
|
117
116
|
# If the element is fixed, override the computed position with the fixed one.
|
118
117
|
if @$contents.css('position') == 'fixed'
|
@@ -121,58 +120,35 @@ class Xray.Specimen
|
|
121
120
|
top : @$contents.css('top')
|
122
121
|
left : @$contents.css('left')
|
123
122
|
|
124
|
-
@$box.click =>
|
123
|
+
@$box.click => Copyray.open @url + '/blurbs/' + @path + '/edit'
|
125
124
|
@$box.append @makeLabel
|
126
125
|
|
127
126
|
makeLabel: =>
|
128
|
-
$("<div class='
|
127
|
+
$("<div class='copyray-specimen-handle #{@constructor.name}'>").append(@name)
|
129
128
|
|
130
|
-
|
131
|
-
|
132
|
-
# Backbone.View.
|
133
|
-
class Xray.ViewSpecimen extends Xray.Specimen
|
134
|
-
@all = []
|
135
|
-
|
136
|
-
|
137
|
-
# Wraps elements that were rendered by a template, e.g. a Rails partial or
|
138
|
-
# a client-side rendered JS template.
|
139
|
-
class Xray.TemplateSpecimen extends Xray.Specimen
|
129
|
+
# copy-tuner blurbs
|
130
|
+
class Copyray.BlurbSpecimen extends Copyray.Specimen
|
140
131
|
@all = []
|
141
132
|
|
142
|
-
|
143
|
-
|
144
|
-
class Xray.Overlay
|
133
|
+
# Singleton class for the Copyray "overlay" invoked by the keyboard shortcut
|
134
|
+
class Copyray.Overlay
|
145
135
|
@instance: ->
|
146
136
|
@singletonInstance ||= new this
|
147
137
|
|
148
138
|
constructor: ->
|
149
|
-
|
150
|
-
|
151
|
-
@settings = new Xray.Settings('#xray-settings')
|
139
|
+
Copyray.Overlay.singletonInstance = this
|
140
|
+
@$overlay = $('<div id="copyray-overlay">')
|
152
141
|
@shownBoxes = []
|
153
|
-
@$overlay = $('<div id="xray-overlay">')
|
154
142
|
@$overlay.click => @hide()
|
155
143
|
|
156
144
|
show: (type = null) ->
|
157
145
|
@reset()
|
158
|
-
|
146
|
+
Copyray.isShowing = true
|
159
147
|
util.bm 'show', =>
|
160
|
-
@bar.$el.find('#xray-bar-togglers .xray-bar-btn').removeClass('active')
|
161
148
|
unless @$overlay.is(':visible')
|
162
149
|
$('body').append @$overlay
|
163
|
-
|
164
|
-
|
165
|
-
when 'templates'
|
166
|
-
Xray.findTemplates()
|
167
|
-
specimens = Xray.TemplateSpecimen.all
|
168
|
-
@bar.$el.find('.xray-bar-templates-toggler').addClass('active')
|
169
|
-
when 'views'
|
170
|
-
specimens = Xray.ViewSpecimen.all
|
171
|
-
@bar.$el.find('.xray-bar-views-toggler').addClass('active')
|
172
|
-
else
|
173
|
-
Xray.findTemplates()
|
174
|
-
specimens = Xray.specimens()
|
175
|
-
@bar.$el.find('.xray-bar-all-toggler').addClass('active')
|
150
|
+
Copyray.findBlurbs()
|
151
|
+
specimens = Copyray.specimens()
|
176
152
|
for element in specimens
|
177
153
|
continue unless element.isVisible()
|
178
154
|
element.makeBox()
|
@@ -188,62 +164,9 @@ class Xray.Overlay
|
|
188
164
|
@shownBoxes = []
|
189
165
|
|
190
166
|
hide: ->
|
191
|
-
|
167
|
+
Copyray.isShowing = false
|
192
168
|
@$overlay.detach()
|
193
169
|
@reset()
|
194
|
-
@bar.hide()
|
195
|
-
|
196
|
-
|
197
|
-
# The Xray bar shows controller, action, and view information, and has
|
198
|
-
# toggle buttons for showing the different types of specimens in the overlay.
|
199
|
-
class Xray.Bar
|
200
|
-
constructor: (el) ->
|
201
|
-
@$el = $(el)
|
202
|
-
@$el.css(zIndex: MAX_ZINDEX)
|
203
|
-
@$el.find('#xray-bar-controller-path .xray-bar-btn').click ->
|
204
|
-
Xray.open($(this).attr('data-path'))
|
205
|
-
@$el.find('.xray-bar-all-toggler').click -> Xray.show()
|
206
|
-
@$el.find('.xray-bar-templates-toggler').click -> Xray.show('templates')
|
207
|
-
@$el.find('.xray-bar-views-toggler').click -> Xray.show('views')
|
208
|
-
@$el.find('.xray-bar-settings-btn').click -> Xray.toggleSettings()
|
209
|
-
|
210
|
-
show: ->
|
211
|
-
@$el.show()
|
212
|
-
@originalPadding = parseInt $('html').css('padding-bottom')
|
213
|
-
if @originalPadding < 40
|
214
|
-
$('html').css paddingBottom: 40
|
215
|
-
|
216
|
-
hide: ->
|
217
|
-
@$el.hide()
|
218
|
-
$('html').css paddingBottom: @originalPadding
|
219
|
-
|
220
|
-
|
221
|
-
class Xray.Settings
|
222
|
-
constructor: (el) ->
|
223
|
-
@$el = $(el)
|
224
|
-
@$el.find('form').submit @save
|
225
|
-
|
226
|
-
toggle: =>
|
227
|
-
@$el.toggle()
|
228
|
-
|
229
|
-
save: (e) =>
|
230
|
-
e.preventDefault()
|
231
|
-
editor = @$el.find('#xray-editor-input').val()
|
232
|
-
$.ajax
|
233
|
-
url: '/_xray/config'
|
234
|
-
type: 'POST'
|
235
|
-
data: {editor: editor}
|
236
|
-
success: => @displayUpdateMsg(true)
|
237
|
-
error: => @displayUpdateMsg(false)
|
238
|
-
|
239
|
-
displayUpdateMsg: (success) =>
|
240
|
-
if success
|
241
|
-
$msg = $("<span class='xray-settings-success xray-settings-update-msg'>Success!</span>")
|
242
|
-
else
|
243
|
-
$msg = $("<span class='xray-settings-error xray-settings-update-msg'>Uh oh, something went wrong!</span>")
|
244
|
-
@$el.append($msg)
|
245
|
-
$msg.delay(2000).fadeOut(500, => $msg.remove(); @toggle())
|
246
|
-
|
247
170
|
|
248
171
|
# Utility methods.
|
249
172
|
util =
|