que-web 0.8.0 → 0.9.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.
- checksums.yaml +5 -5
- data/.travis.yml +3 -3
- data/CHANGELOG.md +7 -0
- data/README.md +0 -12
- data/docker/Gemfile.lock +7 -7
- data/examples/rack/Gemfile.lock +14 -14
- data/examples/rack/boot.rb +2 -4
- data/examples/rack/config.ru +1 -3
- data/lib/que/web.rb +9 -2
- data/lib/que/web/viewmodels.rb +2 -0
- data/lib/que/web/viewmodels/job.rb +9 -0
- data/que-web.gemspec +4 -5
- data/spec/pager_spec.rb +12 -12
- data/spec/que/web_spec.rb +63 -0
- data/spec/viewmodels/dashboard_spec.rb +1 -1
- data/spec/viewmodels/job_list_spec.rb +4 -5
- data/spec/viewmodels/job_spec.rb +16 -4
- data/spec/web_spec.rb +6 -6
- data/web/public/styles/foundation.min.css +1 -1
- data/web/public/styles/normalize.min.css +1 -0
- data/web/views/failing.erb +7 -7
- data/web/views/index.erb +1 -1
- data/web/views/layout.erb +7 -7
- data/web/views/running.erb +4 -4
- data/web/views/scheduled.erb +7 -7
- data/web/views/show.erb +6 -6
- metadata +12 -29
- data/web/public/js/foundation.min.js +0 -3651
- data/web/public/js/vendor/fastclick.js +0 -9
- data/web/public/js/vendor/jquery.cookie.js +0 -8
- data/web/public/js/vendor/modernizr.js +0 -8
- data/web/public/js/vendor/placeholder.js +0 -2
- data/web/public/styles/normalize.css +0 -427
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e450eca7ca5dbad2f7fe76dc6bfbf49e9f669fb3
|
4
|
+
data.tar.gz: 9d469004ae8c91444d63689b1b39fafc5be5ab4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 862a3020cd60dde9f89e95d67a4ec4a9ce572c751852a12fd53ed5d87be8d5d3ec2d136d83a673ea8461214ff4ff3d5de89e80ba6edc8f976dbb9949e15e65a0
|
7
|
+
data.tar.gz: 3c70089ccd11c6af4da114257336655528f7dd27913754e6d6a7ce731f8231c342cfdf5f366eadc0433a92751a5fb15126aa3a5b466970952869901bd443612a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -43,18 +43,6 @@ require "que/web"
|
|
43
43
|
mount Que::Web => "/que"
|
44
44
|
```
|
45
45
|
|
46
|
-
#### Rails 5.0
|
47
|
-
|
48
|
-
You must use the master branch of Sinatra for `que-web`.
|
49
|
-
In your gemfile:
|
50
|
-
|
51
|
-
```
|
52
|
-
gem 'que-web'
|
53
|
-
gem 'sinatra', git: 'https://github.com/sinatra/sinatra'
|
54
|
-
```
|
55
|
-
|
56
|
-
See https://github.com/sinatra/sinatra/issues/1071
|
57
|
-
|
58
46
|
### Authentication
|
59
47
|
|
60
48
|
#### Devise
|
data/docker/Gemfile.lock
CHANGED
@@ -2,24 +2,24 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
erubis (2.7.0)
|
5
|
-
mustermann (1.0.
|
5
|
+
mustermann (1.0.3)
|
6
6
|
pg (1.0.0)
|
7
|
-
puma (3.
|
7
|
+
puma (3.12.3)
|
8
8
|
que (0.14.2)
|
9
9
|
que-web (0.7.0)
|
10
10
|
erubis
|
11
11
|
que (~> 0.8)
|
12
12
|
sinatra
|
13
|
-
rack (2.0.
|
14
|
-
rack-protection (2.0.
|
13
|
+
rack (2.0.8)
|
14
|
+
rack-protection (2.0.7)
|
15
15
|
rack
|
16
16
|
sequel (5.5.0)
|
17
|
-
sinatra (2.0.
|
17
|
+
sinatra (2.0.7)
|
18
18
|
mustermann (~> 1.0)
|
19
19
|
rack (~> 2.0)
|
20
|
-
rack-protection (= 2.0.
|
20
|
+
rack-protection (= 2.0.7)
|
21
21
|
tilt (~> 2.0)
|
22
|
-
tilt (2.0.
|
22
|
+
tilt (2.0.10)
|
23
23
|
|
24
24
|
PLATFORMS
|
25
25
|
ruby
|
data/examples/rack/Gemfile.lock
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
que-web (0.
|
5
|
-
|
6
|
-
que (~> 0.8)
|
4
|
+
que-web (0.8.0)
|
5
|
+
que (~> 1.0.0.beta3)
|
7
6
|
sinatra
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
pg (1.
|
15
|
-
que (0.
|
16
|
-
rack (2.
|
17
|
-
rack-protection (2.0.
|
11
|
+
mustermann (1.1.1)
|
12
|
+
ruby2_keywords (~> 0.0.1)
|
13
|
+
pg (1.2.3)
|
14
|
+
que (1.0.0.beta4)
|
15
|
+
rack (2.2.2)
|
16
|
+
rack-protection (2.0.8.1)
|
18
17
|
rack
|
19
|
-
|
20
|
-
|
18
|
+
ruby2_keywords (0.0.2)
|
19
|
+
sequel (5.30.0)
|
20
|
+
sinatra (2.0.8.1)
|
21
21
|
mustermann (~> 1.0)
|
22
22
|
rack (~> 2.0)
|
23
|
-
rack-protection (= 2.0.
|
23
|
+
rack-protection (= 2.0.8.1)
|
24
24
|
tilt (~> 2.0)
|
25
|
-
tilt (2.0.
|
25
|
+
tilt (2.0.10)
|
26
26
|
|
27
27
|
PLATFORMS
|
28
28
|
ruby
|
@@ -33,4 +33,4 @@ DEPENDENCIES
|
|
33
33
|
sequel
|
34
34
|
|
35
35
|
BUNDLED WITH
|
36
|
-
1.
|
36
|
+
2.1.4
|
data/examples/rack/boot.rb
CHANGED
@@ -7,9 +7,8 @@ require 'securerandom'
|
|
7
7
|
|
8
8
|
Que.logger = Logger.new(STDOUT)
|
9
9
|
Que.logger.level = Logger::INFO
|
10
|
-
Que.connection = Sequel.connect
|
11
|
-
Que.migrate!
|
12
|
-
Que.mode = :async
|
10
|
+
Que.connection = Sequel.connect("postgres://localhost/quewebtest", max_connections: 1)
|
11
|
+
Que.migrate!(version: 4)
|
13
12
|
$stdout.sync = true
|
14
13
|
|
15
14
|
class FailJob < Que::Job
|
@@ -31,4 +30,3 @@ class SlowJob < Que::Job
|
|
31
30
|
sleep 15
|
32
31
|
end
|
33
32
|
end
|
34
|
-
|
data/examples/rack/config.ru
CHANGED
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
map '/xss' do
|
24
24
|
run lambda { |env|
|
25
|
-
FailJob.enqueue
|
25
|
+
FailJob.enqueue "<script>alert('xss')</script>", {name: "<script>alert('xss')", age: 20, numbers: [10]*50}
|
26
26
|
[200, {}, ['Failing job queued']]
|
27
27
|
}
|
28
28
|
end
|
@@ -41,7 +41,6 @@ map '/slow' do
|
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
44
|
map '/delayslow' do
|
46
45
|
run lambda { |env|
|
47
46
|
SlowJob.enqueue 'arg1', {name: 'delayslow', age: 20}, run_at: Time.now + 10
|
@@ -52,4 +51,3 @@ end
|
|
52
51
|
run lambda { |env|
|
53
52
|
[200, {}, ['Hello']]
|
54
53
|
}
|
55
|
-
|
data/lib/que/web.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "sinatra/base"
|
2
|
-
require "
|
2
|
+
require "cgi"
|
3
3
|
|
4
4
|
module Que
|
5
5
|
class Web < Sinatra::Base
|
@@ -164,7 +164,7 @@ module Que
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def search_param
|
167
|
-
sanitised = (params['search'] || '').gsub(/[^0-9a-z:]i
|
167
|
+
sanitised = (params['search'] || '').gsub(/[^0-9a-z:]/i, '')
|
168
168
|
return if sanitised.empty?
|
169
169
|
sanitised
|
170
170
|
end
|
@@ -206,6 +206,13 @@ module Que
|
|
206
206
|
hash = session[FLASH_KEY] ||= {}
|
207
207
|
hash[level] = val
|
208
208
|
end
|
209
|
+
|
210
|
+
def html_escape(text)
|
211
|
+
return if text.nil?
|
212
|
+
|
213
|
+
CGI.escape_html(text)
|
214
|
+
end
|
215
|
+
alias h html_escape
|
209
216
|
end
|
210
217
|
helpers Helpers
|
211
218
|
end
|
data/lib/que/web/viewmodels.rb
CHANGED
@@ -13,5 +13,14 @@ module Que::Web::Viewmodels
|
|
13
13
|
def past_due?(relative_to = Time.now)
|
14
14
|
run_at < relative_to
|
15
15
|
end
|
16
|
+
|
17
|
+
def humanized_job_class
|
18
|
+
case job_class
|
19
|
+
when "ActiveJob::QueueAdapters::QueAdapter::JobWrapper"
|
20
|
+
args.first[:job_class]
|
21
|
+
else
|
22
|
+
job_class
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
data/que-web.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "que-web"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.9.0"
|
8
8
|
spec.authors = ["Jason Staten", "Bruno Porto"]
|
9
9
|
spec.email = ["jstaten07@gmail.com", "brunotporto@gmail.com"]
|
10
10
|
spec.summary = %q{A web interface for the que queue}
|
@@ -19,9 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "que", "~> 1.0.0.beta3"
|
21
21
|
spec.add_dependency "sinatra"
|
22
|
-
spec.add_dependency "erubis"
|
23
22
|
|
24
|
-
spec.add_development_dependency "bundler", "
|
25
|
-
spec.add_development_dependency "rake", "
|
26
|
-
spec.add_development_dependency "minitest", "~> 5.
|
23
|
+
spec.add_development_dependency "bundler", ">= 1.6"
|
24
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.6"
|
27
26
|
end
|
data/spec/pager_spec.rb
CHANGED
@@ -5,49 +5,49 @@ describe Que::Web::Pager do
|
|
5
5
|
subject { Que::Web::Pager.new(4, 10, 105) }
|
6
6
|
|
7
7
|
it "provides passed values" do
|
8
|
-
subject.current_page.must_equal 4
|
9
|
-
subject.page_size.must_equal 10
|
10
|
-
subject.total.must_equal 105
|
8
|
+
_(subject.current_page).must_equal 4
|
9
|
+
_(subject.page_size).must_equal 10
|
10
|
+
_(subject.total).must_equal 105
|
11
11
|
end
|
12
12
|
|
13
13
|
it "provides a page count" do
|
14
|
-
subject.page_count.must_equal 11
|
14
|
+
_(subject.page_count).must_equal 11
|
15
15
|
end
|
16
16
|
|
17
17
|
it "defaults to page count of 1 if total is 0" do
|
18
18
|
pager = Que::Web::Pager.new(4, 10, 0)
|
19
|
-
pager.page_count.must_equal 1
|
19
|
+
_(pager.page_count).must_equal 1
|
20
20
|
end
|
21
21
|
|
22
22
|
it "increments next page if it exists" do
|
23
|
-
subject.next_page.must_equal 5
|
23
|
+
_(subject.next_page).must_equal 5
|
24
24
|
end
|
25
25
|
|
26
26
|
it "provides nil next page if on last page" do
|
27
27
|
pager = Que::Web::Pager.new(11, 10, 105)
|
28
|
-
pager.next_page.must_be_nil
|
28
|
+
_(pager.next_page).must_be_nil
|
29
29
|
end
|
30
30
|
|
31
31
|
it "decrements prev page if it exists" do
|
32
|
-
subject.prev_page.must_equal 3
|
32
|
+
_(subject.prev_page).must_equal 3
|
33
33
|
end
|
34
34
|
|
35
35
|
it "provides nil prev page if on first page" do
|
36
36
|
pager = Que::Web::Pager.new(1, 10, 105)
|
37
|
-
pager.prev_page.must_be_nil
|
37
|
+
_(pager.prev_page).must_be_nil
|
38
38
|
end
|
39
39
|
|
40
40
|
it "determines offset" do
|
41
|
-
subject.offset.must_equal 30
|
41
|
+
_(subject.offset).must_equal 30
|
42
42
|
end
|
43
43
|
|
44
44
|
it "sets page_no less than 1 to 1 for current page" do
|
45
45
|
pager = Que::Web::Pager.new(-3, 10, 105)
|
46
|
-
pager.current_page.must_equal 1
|
46
|
+
_(pager.current_page).must_equal 1
|
47
47
|
end
|
48
48
|
|
49
49
|
it "provides range centering current page" do
|
50
50
|
pager = Que::Web::Pager.new(-3, 10, 105)
|
51
|
-
pager.current_page.must_equal 1
|
51
|
+
_(pager.current_page).must_equal 1
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "que/web"
|
3
|
+
|
4
|
+
describe Que::Web::Helpers do
|
5
|
+
subject { Que::Web::Helpers.new(4, 10, 105) }
|
6
|
+
|
7
|
+
def subject_with_attributes(**attributes)
|
8
|
+
Class.new do
|
9
|
+
include Que::Web::Helpers
|
10
|
+
|
11
|
+
attributes.each { |attr, value| define_method(attr) { value } }
|
12
|
+
end.new
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#search' do
|
16
|
+
it 'returns a wildcard search with a search_param' do
|
17
|
+
_(subject_with_attributes(search_param: 'foobar').search).must_equal '%foobar%'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns a wildcard search without a search_param' do
|
21
|
+
_(subject_with_attributes(search_param: nil).search).must_equal '%'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#search_param' do
|
26
|
+
def search_param_for(search)
|
27
|
+
subject_with_attributes(params: { 'search' => search }).search_param
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is nil if the search_param is not present' do
|
31
|
+
assert_nil(search_param_for(nil))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'is nil if the search_param is present but empty' do
|
35
|
+
assert_nil(search_param_for(''))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'is nil if the search_param is empty after sanitisation' do
|
39
|
+
assert_nil(search_param_for('! ?'))
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'preserves a valid Ruby class name' do
|
43
|
+
_(search_param_for("Namespaced::Class")).must_equal 'Namespaced::Class'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'sanitises the passed search' do
|
47
|
+
_(search_param_for("(Foo) / !Bar! --Baz")).must_equal 'FooBarBaz'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'preserves A-Z, a-z, 0-9 and : in the search param' do
|
51
|
+
search = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).join + ':'
|
52
|
+
_(search_param_for(search)).must_equal search
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#escape_html' do
|
57
|
+
it 'prevents XSS' do
|
58
|
+
_(subject_with_attributes.h("<sript>alert('XSS')</script>")).must_equal(
|
59
|
+
"<sript>alert('XSS')</script>"
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -15,16 +15,15 @@ describe Que::Web::Viewmodels::JobList do
|
|
15
15
|
let(:subject) { Que::Web::Viewmodels::JobList.new([job], pager) }
|
16
16
|
|
17
17
|
it "maps jobs" do
|
18
|
-
subject.page_jobs.length.must_equal 1
|
19
|
-
subject.page_jobs.first.queue.must_equal "foo"
|
18
|
+
_(subject.page_jobs.length).must_equal 1
|
19
|
+
_(subject.page_jobs.first.queue).must_equal "foo"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "exposes pager" do
|
23
|
-
subject.pager.must_equal pager
|
23
|
+
_(subject.pager).must_equal pager
|
24
24
|
end
|
25
25
|
|
26
26
|
it "maps total from pager" do
|
27
|
-
subject.total.must_equal pager.total
|
27
|
+
_(subject.total).must_equal pager.total
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
data/spec/viewmodels/job_spec.rb
CHANGED
@@ -14,18 +14,30 @@ describe Que::Web::Viewmodels::Job do
|
|
14
14
|
let(:subject) { Que::Web::Viewmodels::Job.new(source_job) }
|
15
15
|
|
16
16
|
it 'maps fields from source' do
|
17
|
-
subject.priority.must_equal source_job[:priority]
|
18
|
-
subject.queue.must_equal source_job[:queue]
|
17
|
+
_(subject.priority).must_equal source_job[:priority]
|
18
|
+
_(subject.queue).must_equal source_job[:queue]
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'humanized_job_class' do
|
22
|
+
it 'returns job class on unknown wrapper' do
|
23
|
+
_(subject.humanized_job_class).must_equal "SuccessJob"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns wrapped job class for Active Job' do
|
27
|
+
source = source_job.merge(job_class: "ActiveJob::QueueAdapters::QueAdapter::JobWrapper", args: [job_class: "MyJob"])
|
28
|
+
job = Que::Web::Viewmodels::Job.new(source)
|
29
|
+
_(job.humanized_job_class).must_equal "MyJob"
|
30
|
+
end
|
19
31
|
end
|
20
32
|
|
21
33
|
describe 'schedule' do
|
22
34
|
it 'is past due when run_at is behind' do
|
23
|
-
subject.must_be :past_due?
|
35
|
+
_(subject).must_be :past_due?
|
24
36
|
end
|
25
37
|
|
26
38
|
it 'is not past due when run_at is ahead of now' do
|
27
39
|
subject.run_at = Time.now + 3600
|
28
|
-
subject.wont_be :past_due?
|
40
|
+
_(subject).wont_be :past_due?
|
29
41
|
end
|
30
42
|
end
|
31
43
|
end
|