notable_web 0.0.1 → 0.1.0

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
- SHA1:
3
- metadata.gz: 902f5f6885cfba1cc9ff01f2fe722946f6649cc5
4
- data.tar.gz: d469613856482c398e7667ec2426e4a9256a4838
2
+ SHA256:
3
+ metadata.gz: ad2f229ad7304302d16581c3173f8889b97d834d4c3d53ce097614acbc9c0979
4
+ data.tar.gz: fc90371c287986b808f5795efa88f504fd705a4871d34f4c3d89511d4025b771
5
5
  SHA512:
6
- metadata.gz: 45bb114548b59f29f2c213f1cb388a9074825bba71579d86a77797d39d334973ad0aacce42b0690649fc54c8dfcba0ea52684be87e561b94b2a906eb5f9930cc
7
- data.tar.gz: d0a480918cc03c3af1116753c2bd5f6ae89c1fa498459fa2f1969b3ec63ca0f90d3f98de6d26020d907d281288a77e45634f7e28bcf5392e7819b3e8d39ebf65
6
+ metadata.gz: ed8840e9a6594790892aacc0f52c727bae2012b8a888213cc6da85805edefcce5f43bec64d092d9f0011f8da90e01c229f3280676f350b368979c2aea1104248
7
+ data.tar.gz: 8383fc0ded9a02635378628f88c0b740cb8a8064081aa2c295b6cbad060f7d5b1d63595c6be75776c33a7d1be73325c3513d71d9be1e272ffc63eae495a68222
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.1.0
2
+
3
+ - Fixed errors with Rails 5 and 6
4
+ - Dropped support for Rails < 5
5
+
6
+ ## 0.0.1
7
+
8
+ - First release
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Andrew Kane
1
+ Copyright (c) 2014-2019 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -30,11 +30,23 @@ ENV["NOTABLE_PASSWORD"] = "secret"
30
30
  #### Devise
31
31
 
32
32
  ```ruby
33
- authenticate :user, lambda {|user| user.admin? } do
33
+ authenticate :user, ->(user) { user.admin? } do
34
34
  mount NotableWeb::Engine, at: "notable"
35
35
  end
36
36
  ```
37
37
 
38
+ #### will_paginate
39
+
40
+ If using will_paginate, create an initializer `config/initializers/kaminari.rb` with:
41
+
42
+ ```ruby
43
+ Kaminari.configure do |config|
44
+ config.page_method_name = :per_page_kaminari
45
+ end
46
+ ```
47
+
48
+ to avoid conflicts.
49
+
38
50
  ## Contributing
39
51
 
40
52
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
@@ -0,0 +1,2 @@
1
+ //= require chartkick
2
+ //= require Chart.bundle
@@ -2,13 +2,20 @@ module NotableWeb
2
2
  class HomeController < ActionController::Base
3
3
  layout "notable_web/application"
4
4
 
5
+ protect_from_forgery with: :exception
6
+
5
7
  http_basic_authenticate_with name: ENV["NOTABLE_USERNAME"], password: ENV["NOTABLE_PASSWORD"] if ENV["NOTABLE_PASSWORD"]
6
8
 
7
9
  def index
8
- where = Hash[ params.slice(:status, :note_type, :note, :user_id, :user_type).permit!.map{|k,v| ["notable_requests.#{k}", v] } ]
10
+ @safe_params = params.slice(:status, :note_type, :note, :user_id, :user_type, :action_name, :status, :scope).permit!.to_h
11
+
12
+ where = @safe_params.slice(:status, :note_type, :note, :user_id, :user_type)
13
+ where = {notable_requests: where} if where.any?
14
+
15
+ page_method_name = Kaminari.config.page_method_name
9
16
 
10
17
  # https://github.com/rails/rails/issues/9055
11
- @requests = Notable::Request.order("notable_requests.id DESC").where(where).preload(:user).page(params[:page]).per(100)
18
+ @requests = Notable::Request.order("notable_requests.id DESC").where(where).preload(:user).public_send(page_method_name, params[:page]).per(100)
12
19
 
13
20
  if params[:action_name]
14
21
  @requests = @requests.where(action: params[:action_name])
@@ -44,7 +51,7 @@ module NotableWeb
44
51
  break if user_ids.size >= 20
45
52
  end
46
53
  groups = user_ids.group_by{|v| v[1] }
47
- where = [groups.map{|_, v| "(user_type = ? AND user_id IN (?))" }.join(" OR ")] + groups.flat_map{|v| [v[0], v[1].map{|v1| v1[0] }] }
54
+ where = [groups.map{|_, _v| "(user_type = ? AND user_id IN (?))" }.join(" OR ")] + groups.flat_map{|v| [v[0], v[1].map{|v1| v1[0] }] }
48
55
  @users = requests.includes(:user).where(where).order("created_at DESC").group_by(&:user)
49
56
  end
50
57
 
@@ -64,8 +64,7 @@
64
64
  }
65
65
  </style>
66
66
 
67
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
68
- <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
67
+ <%= javascript_include_tag "notable_web" %>
69
68
  </head>
70
69
  <body>
71
70
  <div class="container">
@@ -94,12 +93,16 @@
94
93
  </div>
95
94
 
96
95
  <script>
97
- $(".stream li").click( function(e) {
98
- if (e.target.tagName != "A") {
99
- e.preventDefault();
100
- $(this).find(".more").slideToggle();
101
- }
102
- });
96
+ var nodes = document.querySelectorAll(".stream li")
97
+ for (var i = 0; i < nodes.length; i++) {
98
+ nodes[i].addEventListener("click", function(e) {
99
+ if (e.target.tagName != "A") {
100
+ var more = e.currentTarget.querySelector(".more")
101
+ var display = more.style.display == "block" ? "none" : "block"
102
+ more.style.display = display
103
+ }
104
+ })
105
+ }
103
106
  </script>
104
107
  </body>
105
108
  </html>
@@ -14,7 +14,7 @@
14
14
  <tr>
15
15
  <td>
16
16
  <%= agg.note %> <span style="color: #999;"><%= agg.action %></span>
17
- <%= link_to "view", params.merge(note: agg.note, action_name: agg.action) %>
17
+ <%= link_to "view", @safe_params.merge(note: agg.note, action_name: agg.action) %>
18
18
  </td>
19
19
  <td style="text-align: right;"><%= agg.count_user %></td>
20
20
  <td style="text-align: right;"><%= agg.count_all %></td>
@@ -31,8 +31,8 @@
31
31
  <%= render partial: "stream", locals: {requests: @requests, show_user: !(params[:user_id] && params[:user_type])} %>
32
32
 
33
33
  <% if @requests.current_page != 1 %>
34
- <%= link_to "Prev", params.merge(page: @requests.current_page - 1), style: "margin-right: 20px;" %>
34
+ <%= link_to "Prev", @safe_params.merge(page: @requests.current_page - 1), style: "margin-right: 20px;" %>
35
35
  <% end %>
36
36
  <% if @requests.size == @requests.limit_value %>
37
- <%= link_to "Next", params.merge(page: @requests.current_page + 1) %>
37
+ <%= link_to "Next", @safe_params.merge(page: @requests.current_page + 1) %>
38
38
  <% end %>
@@ -3,6 +3,9 @@ module NotableWeb
3
3
  isolate_namespace NotableWeb
4
4
 
5
5
  initializer "notable_web" do |app|
6
+ # use a proc instead of a string
7
+ app.config.assets.precompile << proc { |path| path == "notable_web.js" }
8
+
6
9
  NotableWeb.time_zone ||= Time.zone
7
10
  end
8
11
  end
@@ -1,3 +1,3 @@
1
1
  module NotableWeb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notable_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-22 00:00:00.000000000 Z
11
+ date: 2019-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: notable
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: '2'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: kaminari
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -84,42 +98,40 @@ dependencies:
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '1.7'
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '1.7'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '10.0'
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '10.0'
111
- description: A web interface for Notable
112
- email:
113
- - andrew@chartkick.com
124
+ version: '0'
125
+ description:
126
+ email: andrew@chartkick.com
114
127
  executables: []
115
128
  extensions: []
116
129
  extra_rdoc_files: []
117
130
  files:
118
- - ".gitignore"
119
- - Gemfile
131
+ - CHANGELOG.md
120
132
  - LICENSE.txt
121
133
  - README.md
122
- - Rakefile
134
+ - app/assets/javascripts/notable_web.js
123
135
  - app/controllers/notable_web/home_controller.rb
124
136
  - app/views/layouts/notable_web/application.html.erb
125
137
  - app/views/notable_web/home/_stream.html.erb
@@ -131,7 +143,6 @@ files:
131
143
  - lib/notable_web.rb
132
144
  - lib/notable_web/engine.rb
133
145
  - lib/notable_web/version.rb
134
- - notable_web.gemspec
135
146
  homepage: https://github.com/ankane/notable_web
136
147
  licenses:
137
148
  - MIT
@@ -144,15 +155,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
155
  requirements:
145
156
  - - ">="
146
157
  - !ruby/object:Gem::Version
147
- version: '0'
158
+ version: '2.4'
148
159
  required_rubygems_version: !ruby/object:Gem::Requirement
149
160
  requirements:
150
161
  - - ">="
151
162
  - !ruby/object:Gem::Version
152
163
  version: '0'
153
164
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.2.2
165
+ rubygems_version: 3.0.3
156
166
  signing_key:
157
167
  specification_version: 4
158
168
  summary: A web interface for Notable
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in notable_web.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
data/notable_web.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'notable_web/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "notable_web"
8
- spec.version = NotableWeb::VERSION
9
- spec.authors = ["Andrew Kane"]
10
- spec.email = ["andrew@chartkick.com"]
11
- spec.summary = %q{A web interface for Notable}
12
- spec.description = %q{A web interface for Notable}
13
- spec.homepage = "https://github.com/ankane/notable_web"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency "notable"
22
- spec.add_dependency "groupdate"
23
- spec.add_dependency "chartkick"
24
- spec.add_dependency "kaminari"
25
- spec.add_dependency "public_suffix"
26
-
27
- spec.add_development_dependency "bundler", "~> 1.7"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- end