notifications 0.3.0 → 0.4.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
2
  SHA1:
3
- metadata.gz: 19fdfc6600364423b916ac5ceb8f6f392a3f069d
4
- data.tar.gz: b771f33617dab12b562c6b737495f7cfee80fc1a
3
+ metadata.gz: 289be7485587ec007b2383811b0a99daf76d7099
4
+ data.tar.gz: d0197d7f693e1462f7ff802101aa3e94d05ec653
5
5
  SHA512:
6
- metadata.gz: cddce6321db0f1a954ff3e2816b8c3cf858f4893d995788abfd8b3e9a150acc4667440c6c11450b780ff6b302e9357f715b8620cbe869b9b7d0a267149337205
7
- data.tar.gz: f072bd94cd7509e33193bd8dd40953dd9bd4e0fdea9b0b34c933f2bc33be44b66276350275e947ccd03c880323e4302a74277b6d0e118374df2470ba120ebbb1
6
+ metadata.gz: 7ca9ee7e713d576e07603fe543d34c4eeebb22c726f5eaf185c066c1bb7c7bac8a73fdb61547895588f07c6daa387513cd560ce1efdd1a0243fdb21e1525f455
7
+ data.tar.gz: 42d62d628b94b53c6d1504bc8f24c747cd955883b2facedde2aab40ebcc4614c78a0258cd1e09243fe687d751baec0b207b7b73dfb53c5e514c68392c7f57305
@@ -3,10 +3,7 @@ module Notifications
3
3
  def index
4
4
  @notifications = notifications.includes(:actor).order('id desc').page(params[:page])
5
5
 
6
- unread_ids = []
7
- @notifications.each do |n|
8
- unread_ids << n.id unless n.read?
9
- end
6
+ unread_ids = @notifications.reject(&:read?).select(&:id)
10
7
  Notification.read!(unread_ids)
11
8
 
12
9
  @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
@@ -20,6 +17,7 @@ module Notifications
20
17
  private
21
18
 
22
19
  def notifications
20
+ raise "You need reqiure user login for /notifications page." unless current_user
23
21
  Notification.where(user_id: current_user.id)
24
22
  end
25
23
  end
@@ -2,7 +2,5 @@
2
2
  class Notification < ActiveRecord::Base
3
3
  include Notifications::Model
4
4
 
5
- self.per_page = 20
6
-
7
5
  # Write your custom methods...
8
6
  end
@@ -1,7 +1,7 @@
1
1
  <%= cache(['notifications', Notifications::VERSION, notification]) do %>
2
2
  <div id="notification-<%= notification.id %>"
3
3
  data-id="<%= notification.id %>"
4
- class="media notification notification-<%= notification.notify_type %><%= ' unread' if !notification.read? %>">
4
+ class="media notification notification-<%= notification.notify_type %><%= ' unread' unless notification.read? %>">
5
5
  <div class="media-left">
6
6
  <% if notification.actor_profile_url && notification.actor_avatar_url %>
7
7
  <%= link_to image_tag(notification.actor_avatar_url), notification.actor_profile_url, title: notification.actor_name, class: 'user-avatar' %>
@@ -18,5 +18,5 @@
18
18
  <% end %>
19
19
  <% end %>
20
20
  </div>
21
- <%= will_paginate @notifications %>
21
+ <%= paginate @notifications %>
22
22
  </div>
data/lib/notifications.rb CHANGED
@@ -2,15 +2,13 @@ require 'notifications/model'
2
2
  require 'notifications/engine'
3
3
  require 'notifications/configuration'
4
4
  require 'notifications/version'
5
- require 'will_paginate'
6
- require 'will_paginate/active_record'
5
+ require 'kaminari'
7
6
 
8
7
  module Notifications
9
8
  class << self
10
9
  def config
11
10
  return @config if defined?(@config)
12
11
  @config = Configuration.new
13
- @config.per_page = 32
14
12
  @config.user_class = 'User'
15
13
  @config.user_name_method = 'name'
16
14
  @config.user_avatar_url_method = nil
@@ -39,8 +39,5 @@ module Notifications
39
39
 
40
40
  # authenticate_user method in your Controller, default: nil
41
41
  attr_accessor :authenticate_user_method
42
-
43
- # pagination size, default: 32
44
- attr_accessor :per_page
45
42
  end
46
43
  end
@@ -1,3 +1,3 @@
1
1
  module Notifications
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
@@ -31,19 +31,19 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.1'
33
33
  - !ruby/object:Gem::Dependency
34
- name: will_paginate
34
+ name: kaminari
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '3'
39
+ version: '0.15'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '3'
46
+ version: '0.15'
47
47
  description: Rails mountable Notification for any applications.
48
48
  email:
49
49
  - huacnlee@gmail.com