browse-everything 1.0.0.rc1 → 1.1.0

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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +71 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +4 -0
  5. data/CONTRIBUTING.md +3 -3
  6. data/LICENSE.txt +205 -22
  7. data/README.md +31 -14
  8. data/Rakefile +0 -9
  9. data/app/assets/javascripts/browse_everything/behavior.js +448 -0
  10. data/app/assets/stylesheets/browse_everything.scss +0 -6
  11. data/app/assets/stylesheets/browse_everything/_browse_everything.scss +2 -116
  12. data/app/assets/stylesheets/browse_everything/_browse_everything_bootstrap3.scss +123 -0
  13. data/app/assets/stylesheets/browse_everything/_browse_everything_bootstrap4.scss +117 -0
  14. data/app/views/browse_everything/_files.html.erb +1 -0
  15. data/app/views/browse_everything/_providers.html.erb +2 -1
  16. data/app/views/browse_everything/index.html.erb +3 -2
  17. data/browse-everything.gemspec +7 -9
  18. data/karma.conf.js +71 -0
  19. data/lib/browse-everything.rb +0 -2
  20. data/lib/browse_everything.rb +11 -5
  21. data/lib/browse_everything/driver/box.rb +10 -3
  22. data/lib/browse_everything/driver/dropbox.rb +25 -9
  23. data/lib/browse_everything/driver/file_system.rb +17 -5
  24. data/lib/browse_everything/driver/google_drive.rb +2 -1
  25. data/lib/browse_everything/driver/s3.rb +18 -2
  26. data/lib/browse_everything/retriever.rb +7 -2
  27. data/lib/browse_everything/version.rb +1 -1
  28. data/lib/generators/browse_everything/install_generator.rb +1 -7
  29. data/lib/generators/browse_everything/templates/browse_everything_providers.yml.example +1 -0
  30. data/spec/javascripts/behavior_spec.js +1 -3
  31. data/spec/javascripts/helpers/jquery.js +11008 -0
  32. data/spec/javascripts/karma_spec.rb +16 -0
  33. data/spec/lib/browse_everything/browser_spec.rb +5 -3
  34. data/spec/lib/browse_everything/driver/dropbox_spec.rb +20 -1
  35. data/spec/lib/browse_everything_spec.rb +7 -0
  36. data/spec/spec_helper.rb +8 -1
  37. data/spec/support/capybara.rb +0 -5
  38. data/spec/test_app_templates/Gemfile.extra +7 -0
  39. data/spec/test_app_templates/lib/generators/test_app_generator.rb +7 -1
  40. metadata +69 -82
  41. data/.travis.yml +0 -27
  42. data/app/assets/javascripts/browse_everything/behavior.js.coffee +0 -342
  43. data/app/helpers/font_awesome_version_helper.rb +0 -17
  44. data/lib/generators/browse_everything/assets_generator.rb +0 -13
  45. data/lib/generators/browse_everything/templates/browse_everything.scss +0 -6
  46. data/spec/javascripts/jasmine_spec.rb +0 -21
  47. data/spec/javascripts/support/jasmine.yml +0 -124
  48. data/spec/javascripts/support/jasmine_helper.rb +0 -16
@@ -1,27 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- dist: trusty
4
- sudo: required
5
- addons:
6
- chrome: stable
7
- cache:
8
- bundler: true
9
-
10
- before_install:
11
- - gem update --system # https://docs.travis-ci.com/user/languages/ruby/#Upgrading-RubyGems
12
- - gem install bundler
13
- - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
14
-
15
- rvm:
16
- - 2.5.1
17
- - 2.4.4
18
- - 2.3.7
19
-
20
- env:
21
- global:
22
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
23
- matrix:
24
- - "RAILS_VERSION=5.2.0"
25
- - "RAILS_VERSION=5.1.6"
26
- - "RAILS_VERSION=5.0.7"
27
- - "RAILS_VERSION=4.2.10"
@@ -1,342 +0,0 @@
1
- $ ->
2
- dialog = $('div#browse-everything')
3
-
4
- initialize = (obj,options) ->
5
- if $('div#browse-everything').length == 0
6
- dialog = $('<div tabindex="-1" id="browse-everything" class="ev-browser modal fade" aria-live="polite" role="dialog" aria-labelledby="beModalLabel"></div>').hide().appendTo('body')
7
-
8
- dialog.modal
9
- backdrop: 'static'
10
- show: false
11
- ctx =
12
- opts: $.extend(true, {}, options)
13
- callbacks:
14
- show: $.Callbacks()
15
- done: $.Callbacks()
16
- cancel: $.Callbacks()
17
- fail: $.Callbacks()
18
- ctx.callback_proxy =
19
- show: (func) -> ctx.callbacks.show.add(func) ; return this
20
- done: (func) -> ctx.callbacks.done.add(func) ; return this
21
- cancel: (func) -> ctx.callbacks.cancel.add(func) ; return this
22
- fail: (func) -> ctx.callbacks.fail.add(func) ; return this
23
- $(obj).data('ev-state',ctx)
24
- ctx
25
-
26
- toHiddenFields = (data) ->
27
- fields = $.param(data)
28
- .split('&')
29
- .map (t) -> t.replace(/\+/g,' ').split('=',2)
30
- elements = $(fields).map () ->
31
- $("<input type='hidden'/>")
32
- .attr('name',decodeURIComponent(this[0]))
33
- .val(decodeURIComponent(this[1]))[0].outerHTML
34
- $(elements.toArray().join("\n"))
35
-
36
- indicateSelected = () ->
37
- $('input.ev-url').each () ->
38
- $("*[data-ev-location='#{$(this).val()}']").addClass('ev-selected')
39
-
40
- fileIsSelected = (row) ->
41
- result = false
42
- $('input.ev-url').each () ->
43
- if this.value == $(row).data('ev-location')
44
- result = true
45
- return result
46
-
47
- toggleFileSelect = (row) ->
48
- row.toggleClass('ev-selected')
49
- if row.hasClass('ev-selected')
50
- selectFile(row)
51
- else
52
- unselectFile(row)
53
- updateFileCount()
54
-
55
- selectFile = (row) ->
56
- target_form = $('form.ev-submit-form')
57
- file_location = row.data('ev-location')
58
- hidden_input = $("<input type='hidden' class='ev-url' name='selected_files[]'/>").val(file_location)
59
- target_form.append(hidden_input)
60
- unless $(row).find('.ev-select-file').prop('checked')
61
- $(row).find('.ev-select-file').prop('checked', true)
62
-
63
- unselectFile = (row) ->
64
- target_form = $('form.ev-submit-form')
65
- file_location = row.data('ev-location')
66
- $("form.ev-submit-form input[value='#{file_location}']").remove()
67
- if $(row).find('.ev-select-file').prop('checked')
68
- $(row).find('.ev-select-file').prop('checked', false)
69
-
70
- updateFileCount = () ->
71
- count = $('input.ev-url').length
72
- files = if count == 1 then "file" else "files"
73
- $('.ev-status').html("#{count} #{files} selected")
74
-
75
- toggleBranchSelect = (row) ->
76
- if row.hasClass('collapsed')
77
- node_id = row.find('td.ev-file-name a.ev-link').attr('href')
78
- $('table#file-list').treetable('expandNode',node_id)
79
-
80
- selectAll = (rows) ->
81
- rows.each () ->
82
- if $(this).data('tt-branch')
83
- box = $(this).find('#select_all')[0]
84
- $(box).prop('checked', true)
85
- $(box).prop('value', "1")
86
- toggleBranchSelect($(this))
87
- else
88
- toggleFileSelect($(this)) unless fileIsSelected($(this))
89
-
90
- selectChildRows = (row, action) ->
91
- $('table#file-list tr').each () ->
92
- if $(this).data('tt-parent-id')
93
- re = RegExp($(row).data('tt-id'), 'i')
94
- if $(this).data('tt-parent-id').match(re)
95
- if $(this).data('tt-branch')
96
- box = $(this).find('#select_all')[0]
97
- $(box).prop('value', action)
98
- if action == "1"
99
- $(box).prop("checked", true)
100
- node_id = $(this).find('td.ev-file-name a.ev-link').attr('href')
101
- $('table#file-list').treetable('expandNode',node_id)
102
- else
103
- $(box).prop("checked", false)
104
- else
105
- if action == "1"
106
- $(this).addClass('ev-selected')
107
- selectFile($(this)) unless fileIsSelected($(this))
108
- else
109
- $(this).removeClass('ev-selected')
110
- unselectFile($(this))
111
- updateFileCount()
112
-
113
- tableSetup = (table) ->
114
- table.treetable
115
- expandable: true
116
- onNodeCollapse: ->
117
- node = this;
118
- table.treetable("unloadBranch", node)
119
- onNodeExpand: ->
120
- node = this
121
- startWait()
122
- size = $(node.row).find('td.ev-file-size').text().trim()
123
- start = 1
124
- increment = 1
125
- if (size.indexOf("MB") >-1)
126
- start = 10
127
- increment = 5
128
- if (size.indexOf("KB") >-1)
129
- start = 50
130
- increment = 10
131
- setProgress(start)
132
- progressIntervalID = setInterval (->
133
- start = start + increment
134
- if start > 99
135
- start = 99
136
- setProgress(start)
137
- ), 2000
138
- setTimeout (->
139
- loadFiles(node, table, progressIntervalID)
140
- ), 10
141
- $("#file-list tr:first").focus()
142
- sizeColumns(table)
143
-
144
- sizeColumns = (table) ->
145
- full_width = $('.ev-files').width()
146
- table.width(full_width)
147
- set_size = (selector, pct) ->
148
- $(selector, table).width(full_width * pct).css('width',full_width * pct).css('max-width',full_width * pct)
149
- set_size '.ev-file', 0.4
150
- set_size '.ev-container', 0.4
151
- set_size '.ev-size', 0.1
152
- set_size '.ev-kind', 0.3
153
- set_size '.ev-date', 0.2
154
-
155
- loadFiles = (node, table, progressIntervalID)->
156
- $.ajax
157
- async: true # Must be false, otherwise loadBranch happens after showChildren?
158
- url: $('a.ev-link',node.row).attr('href')
159
- data:
160
- parent: node.row.data('tt-id')
161
- accept: dialog.data('ev-state').opts.accept
162
- context: dialog.data('ev-state').opts.context
163
- .done (html) ->
164
- setProgress('100')
165
- clearInterval progressIntervalID
166
- rows = $('tbody tr',$(html))
167
- table.treetable("loadBranch", node, rows)
168
- $(node).show()
169
- sizeColumns(table)
170
- indicateSelected()
171
- if $(node.row).find('#select_all')[0].checked
172
- selectAll(rows)
173
- .always ->
174
- clearInterval progressIntervalID
175
- stopWait()
176
-
177
- setProgress = (done)->
178
- $('.loading-text').text(done+'% complete')
179
-
180
- refreshFiles = ->
181
- $('.ev-providers select').change()
182
-
183
- startWait = ->
184
- $('.loading-progress').removeClass("hidden")
185
- $('body').css('cursor','wait')
186
- $("html").addClass("wait")
187
- $(".ev-browser").addClass("loading")
188
- $('.ev-submit').attr('disabled', true)
189
-
190
- stopWait = ->
191
- $('.loading-progress').addClass("hidden")
192
- $('body').css('cursor','default')
193
- $("html").removeClass("wait")
194
- $(".ev-browser").removeClass("loading")
195
- $('.ev-submit').attr('disabled', false)
196
-
197
- $(window).on('resize', -> sizeColumns($('table#file-list')))
198
-
199
- $.fn.browseEverything = (options) ->
200
- ctx = $(this).data('ev-state')
201
- options = $(this).data() unless (ctx? or options?)
202
- if options?
203
- ctx = initialize(this[0], options)
204
- $(this).click () ->
205
- dialog.data('ev-state',ctx)
206
- dialog.load ctx.opts.route, () ->
207
- setTimeout refreshFiles, 500
208
- ctx.callbacks.show.fire()
209
- dialog.modal('show')
210
-
211
- if ctx
212
- ctx.callback_proxy
213
- else
214
- {
215
- show: -> this
216
- done: -> this
217
- cancel: -> this
218
- fail: -> this
219
- }
220
-
221
- $.fn.browseEverything.toggleCheckbox = (box) ->
222
- if box.value == "0"
223
- $(box).prop('value', "1")
224
- else
225
- $(box).prop('value', "0")
226
-
227
- $(document).on 'ev.refresh', (event) -> refreshFiles()
228
-
229
- $(document).on 'click', 'button.ev-cancel', (event) ->
230
- event.preventDefault()
231
- dialog.data('ev-state').callbacks.cancel.fire()
232
- $('.ev-browser').modal('hide')
233
-
234
- $(document).on 'click', 'button.ev-submit', (event) ->
235
- event.preventDefault()
236
- $(this).button('loading')
237
- startWait()
238
- main_form = $(this).closest('form')
239
- resolver_url = main_form.data('resolver')
240
- ctx = dialog.data('ev-state')
241
- $(main_form).find('input[name=context]').val(ctx.opts.context)
242
- $.ajax resolver_url,
243
- type: 'POST'
244
- dataType: 'json'
245
- data: main_form.serialize()
246
- .done (data) ->
247
- if ctx.opts.target?
248
- fields = toHiddenFields({selected_files: data})
249
- $(ctx.opts.target).append($(fields))
250
- ctx.callbacks.done.fire(data)
251
- .fail (xhr,status,error) ->
252
- ctx.callbacks.fail.fire(status, error, xhr.responseText)
253
- .always ->
254
- $('body').css('cursor','default')
255
- $('.ev-browser').modal('hide')
256
- $('#browse-btn').focus()
257
-
258
- $(document).on 'click', '.ev-files .ev-container a.ev-link', (event) ->
259
- event.stopPropagation()
260
- event.preventDefault()
261
- row = $(this).closest('tr')
262
- action = if row.hasClass('expanded') then 'collapseNode' else 'expandNode'
263
- node_id = $(this).attr('href')
264
- $('table#file-list').treetable(action,node_id)
265
-
266
- $(document).on 'change', '.ev-providers select', (event) ->
267
- event.preventDefault()
268
- startWait()
269
- $.ajax
270
- url: $(this).val(),
271
- data:
272
- accept: dialog.data('ev-state').opts.accept
273
- context: dialog.data('ev-state').opts.context
274
- .done (data) ->
275
- $('.ev-files').html(data)
276
- indicateSelected();
277
- $('#provider_auth').focus();
278
- tableSetup($('table#file-list'))
279
- .fail (xhr,status,error) ->
280
- if (xhr.responseText.indexOf("Refresh token has expired")>-1)
281
- $('.ev-files').html("Your sessison has expired please clear your cookies.")
282
- else
283
- $('.ev-files').html(xhr.responseText)
284
- .always ->
285
- stopWait()
286
-
287
- $(document).on 'click', '.ev-providers a', (event) ->
288
- $('.ev-providers li').removeClass('ev-selected')
289
- $(this).closest('li').addClass('ev-selected')
290
-
291
- $(document).on 'click', '.ev-file a', (event) ->
292
- event.preventDefault()
293
- target = $(this).closest('*[data-ev-location]')
294
- toggleFileSelect(target)
295
-
296
- $(document).on 'click', '.ev-auth', (event) ->
297
- event.preventDefault()
298
- auth_win = window.open($(this).attr('href'))
299
- check_func = ->
300
- if auth_win.closed
301
- $('.ev-providers .ev-selected a').click()
302
- else
303
- window.setTimeout check_func, 1000
304
- check_func()
305
-
306
- $(document).on 'change', 'input.ev-select-all', (event) ->
307
- event.stopPropagation()
308
- event.preventDefault()
309
- $.fn.browseEverything.toggleCheckbox(this)
310
- action = this.value
311
- row = $(this).closest('tr')
312
- node_id = row.find('td.ev-file-name a.ev-link').attr('href')
313
- if row.hasClass('collapsed')
314
- $('table#file-list').treetable('expandNode',node_id)
315
- else
316
- selectChildRows(row, action)
317
-
318
- $(document).on 'change', 'input.ev-select-file', (event) ->
319
- event.stopPropagation()
320
- event.preventDefault()
321
- toggleFileSelect($(this).closest('tr'))
322
-
323
-
324
- auto_toggle = ->
325
- triggers = $('*[data-toggle=browse-everything]')
326
- if Rails?
327
- $.ajaxSetup({
328
- headers: { 'X-CSRF-TOKEN': (Rails || $.rails).csrfToken() || '' }
329
- });
330
-
331
- triggers.each () ->
332
- ctx = $(this).data('ev-state')
333
- $(this).browseEverything($(this).data()) unless ctx?
334
-
335
- if Turbolinks? && Turbolinks.supported
336
- # Use turbolinks:load for Turbolinks 5, otherwise use the old way
337
- if (Turbolinks.BrowserAdapter)
338
- $(document).on 'turbolinks:load', auto_toggle
339
- else
340
- $(document).on 'page:change', auto_toggle
341
- else
342
- $(document).ready auto_toggle
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FontAwesomeVersionHelper
4
- # Determines if the App uses Font Awesome releases 3.x or 4.x
5
- # @return [TrueClass, FalseClass]
6
- def font_awesome_four?
7
- Bundler.environment.specs['font-awesome-rails'].first.version >= Gem::Version.new('4')
8
- end
9
-
10
- # Selects one of two HTML element classes depending upon the release of Font Awesome used by the App
11
- # @param if3 [String] the Font Awesome 3 HTML class
12
- # @param if4 [String] the Font Awesome 4 HTML class
13
- # @return [String] the Font Awesome HTML class
14
- def fa3or4(if3, if4)
15
- font_awesome_four? ? if4 : if3
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators'
4
-
5
- class BrowseEverything::AssetsGenerator < Rails::Generators::Base
6
- desc 'This generator installs the browse_everything CSS assets into your application'
7
-
8
- source_root File.expand_path('templates', __dir__)
9
-
10
- def inject_css
11
- copy_file 'browse_everything.scss', 'app/assets/stylesheets/browse_everything.scss'
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- @import 'bootstrap-sprockets';
2
- @import 'bootstrap';
3
-
4
- @import "font-awesome";
5
-
6
- @import "browse_everything/browse_everything";
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rake'
4
-
5
- # Run the jasmine tests by running the jasmine:ci rake command and parses the output for failures.
6
- # The spec will fail if any jasmine tests fails.
7
- describe 'Jasmine' do
8
- it 'expects all jasmine tests to pass' do
9
- load_rake_environment ["#{jasmine_path}/lib/jasmine/tasks/jasmine.rake"]
10
- jasmine_out = run_task 'jasmine:ci'
11
- unless jasmine_out.include? '0 failures'
12
- puts 'Some of the Jasmine tests failed'
13
- puts jasmine_out
14
- end
15
- expect(jasmine_out).to include '0 failures'
16
- end
17
- end
18
-
19
- def jasmine_path
20
- Gem.loaded_specs['jasmine'].full_gem_path
21
- end
@@ -1,124 +0,0 @@
1
- # src_files
2
- #
3
- # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
- # Default: []
5
- #
6
- # EXAMPLE:
7
- #
8
- # src_files:
9
- # - lib/source1.js
10
- # - lib/source2.js
11
- # - dist/**/*.js
12
- #
13
- src_files:
14
- - assets/application.js
15
-
16
- # stylesheets
17
- #
18
- # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
19
- # Default: []
20
- #
21
- # EXAMPLE:
22
- #
23
- # stylesheets:
24
- # - css/style.css
25
- # - stylesheets/*.css
26
- #
27
- stylesheets:
28
- - stylesheets/**/*.css
29
-
30
- # helpers
31
- #
32
- # Return an array of filepaths relative to spec_dir to include before jasmine specs.
33
- # Default: ["helpers/**/*.js"]
34
- #
35
- # EXAMPLE:
36
- #
37
- # helpers:
38
- # - helpers/**/*.js
39
- #
40
- helpers:
41
- - 'helpers/**/*.js'
42
-
43
- # spec_files
44
- #
45
- # Return an array of filepaths relative to spec_dir to include.
46
- # Default: ["**/*[sS]pec.js"]
47
- #
48
- # EXAMPLE:
49
- #
50
- # spec_files:
51
- # - **/*[sS]pec.js
52
- #
53
- spec_files:
54
- - '**/*[sS]pec.js*'
55
-
56
- # src_dir
57
- #
58
- # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
59
- # Default: project root
60
- #
61
- # EXAMPLE:
62
- #
63
- # src_dir: public
64
- #
65
- src_dir:
66
-
67
- # spec_dir
68
- #
69
- # Spec directory path. Your spec_files must be returned relative to this path.
70
- # Default: spec/javascripts
71
- #
72
- # EXAMPLE:
73
- #
74
- # spec_dir: spec/javascripts
75
- #
76
- spec_dir:
77
-
78
- # spec_helper
79
- #
80
- # Ruby file that Jasmine server will require before starting.
81
- # Returned relative to your root path
82
- # Default spec/javascripts/support/jasmine_helper.rb
83
- #
84
- # EXAMPLE:
85
- #
86
- # spec_helper: spec/javascripts/support/jasmine_helper.rb
87
- #
88
- spec_helper: spec/javascripts/support/jasmine_helper.rb
89
-
90
- # boot_dir
91
- #
92
- # Boot directory path. Your boot_files must be returned relative to this path.
93
- # Default: Built in boot file
94
- #
95
- # EXAMPLE:
96
- #
97
- # boot_dir: spec/javascripts/support/boot
98
- #
99
- boot_dir:
100
-
101
- # boot_files
102
- #
103
- # Return an array of filepaths relative to boot_dir to include in order to boot Jasmine
104
- # Default: Built in boot file
105
- #
106
- # EXAMPLE
107
- #
108
- # boot_files:
109
- # - '**/*.js'
110
- #
111
- boot_files:
112
-
113
- # rack_options
114
- #
115
- # Extra options to be passed to the rack server
116
- # by default, Port and AccessLog are passed.
117
- #
118
- # This is an advanced options, and left empty by default
119
- #
120
- # EXAMPLE
121
- #
122
- # rack_options:
123
- # server: 'thin'
124
-