notifications 0.1.0 → 0.2.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: 1f3c5ecc3a58f354cdc58b715503f4584906f380
4
- data.tar.gz: 9655dcd0146b82449f1f5b6c5c80f8219d74af09
3
+ metadata.gz: 4db6d361624d9bc1d23d47a7ccc2972a72c2b7db
4
+ data.tar.gz: 9997b74887d08320e258d170c726e20a5f7b5196
5
5
  SHA512:
6
- metadata.gz: 9dc6d63668741397b9b9c0c3444896e4c052f907854dc1a8bfe15090015c1c93a19cb114f1838136adab7530ffe20c2a23e1d5ac8ee5efaec337b37f8b35e33e
7
- data.tar.gz: 677bce37a175c88e48dea6f58c02e2feb2c3db036113780a4365ccbae5310540a269a807e43016f5faf4048df76bea7ffa07897671dca39dfd54bb52b809250d
6
+ metadata.gz: 3c0c36018c209e2b50b02b856880f4170b2ce33df7322a3a766c27c1b0461cc98c6b4670b25ad9d143d4d29df1441e48499d898b4bed929270ab1a88fb0fec9c
7
+ data.tar.gz: ec47e9eb45a4bfa1e158f478191dc3b5fb78bc327f25c7205c32aca71df454418ae4fd3a17c01f279c372ead7ed3ff55ab8040a649c52f8e134440bfe4baa32e
data/README.md CHANGED
@@ -103,6 +103,10 @@ We suggest use [second_level_cached](https://github.com/hooopo/second_level_cach
103
103
 
104
104
  Contribution directions go here.
105
105
 
106
+ ## Site Used
107
+
108
+ - [Ruby China](https://ruby-china.org)
109
+
106
110
  ## License
107
111
 
108
112
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -10,10 +10,21 @@
10
10
  margin-bottom: 10px;
11
11
  }
12
12
 
13
- .notification {
14
- margin-bottom: 10px;
13
+
14
+ .notification-group {
15
15
  padding: 10px;
16
- border-bottom: 1px solid #eee;
16
+ margin-bottom: 20px;
17
+
18
+ .group-title {
19
+ padding: 5px 0;
20
+ color: #999;
21
+ border-bottom: 1px solid #eee;
22
+ }
23
+ }
24
+
25
+ .notification {
26
+ margin: 0;
27
+ padding: 10px 0px;
17
28
  color: #999;
18
29
 
19
30
  a { color: #555; }
@@ -31,7 +42,7 @@
31
42
 
32
43
 
33
44
  .media-content {
34
- p:last-chind {
45
+ p:last-child {
35
46
  margin-bottom: 0;
36
47
  }
37
48
  }
@@ -8,6 +8,8 @@ module Notifications
8
8
  unread_ids << n.id unless n.read?
9
9
  end
10
10
  Notification.read!(unread_ids)
11
+
12
+ @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
11
13
  end
12
14
 
13
15
  def clean
@@ -10,7 +10,12 @@
10
10
  <% if @notifications.blank? %>
11
11
  <div class="no-records"><%= t('notifications.no_records') %></div>
12
12
  <% else %>
13
- <%= render @notifications %>
13
+ <% @notification_groups.each do |group, notifications| %>
14
+ <div class="notification-group">
15
+ <div class="group-title"><%= group %></div>
16
+ <%= render notifications %>
17
+ </div>
18
+ <% end %>
14
19
  <% end %>
15
20
  </div>
16
21
  <%= will_paginate @notifications %>
@@ -1,15 +1,14 @@
1
- # coding: utf-8
2
1
  require 'rails/generators'
3
2
  module Notifications
4
3
  module Generators
5
4
  class ControllersGenerator < Rails::Generators::Base #:nodoc:
6
- source_root File.expand_path("../../../../app/controllers", __FILE__)
5
+ source_root File.expand_path('../../../../app/controllers', __FILE__)
7
6
  desc "Used to copy Notifications's controllers to your application's controllers."
8
7
 
9
8
  def copy_controllers
10
9
  %w(notifications).each do |fname|
11
10
  path = "#{Rails.root}/app/controllers/notifications/#{fname}_controller.rb"
12
- if File.exists?(path)
11
+ if File.exist?(path)
13
12
  puts "Skipping notifications/#{fname}_controller.rb creation, as file already exists!"
14
13
  else
15
14
  puts "Adding controller (notifications/#{fname}_controller.rb)..."
@@ -3,12 +3,12 @@ module Notifications
3
3
  module Generators
4
4
  class I18nGenerator < Rails::Generators::Base
5
5
  desc "Create Notifications's default I18n files"
6
- source_root File.expand_path("../../../../", __FILE__)
6
+ source_root File.expand_path('../../../../', __FILE__)
7
7
 
8
8
  def add_locales
9
9
  %w(en.yml zh-CN.yml).each do |fname|
10
10
  path = "#{Rails.root}/config/locales/notifications.#{fname}"
11
- if File.exists?(path)
11
+ if File.exist?(path)
12
12
  puts "Skipping config/locales/notifications.#{fname} creation, as file already exists!"
13
13
  else
14
14
  puts "Adding locale (config/locales/notifications.#{fname})..."
@@ -16,7 +16,6 @@ module Notifications
16
16
  end
17
17
  end
18
18
  end
19
-
20
19
  end
21
20
  end
22
21
  end
@@ -3,25 +3,25 @@ module Notifications
3
3
  module Generators
4
4
  class InstallGenerator < Rails::Generators::Base
5
5
  desc "Create Notifications's base files"
6
- source_root File.expand_path("../../../../", __FILE__)
6
+ source_root File.expand_path('../../../../', __FILE__)
7
7
 
8
8
  def add_initializer
9
9
  path = "#{Rails.root}/config/initializers/notifications.rb"
10
- if File.exists?(path)
11
- puts "Skipping config/initializers/notifications.rb creation, as file already exists!"
10
+ if File.exist?(path)
11
+ puts 'Skipping config/initializers/notifications.rb creation, as file already exists!'
12
12
  else
13
- puts "Adding Homeland initializer (config/initializers/notifications.rb)..."
14
- template "config/initializers/notifications.rb", path
13
+ puts 'Adding Homeland initializer (config/initializers/notifications.rb)...'
14
+ template 'config/initializers/notifications.rb', path
15
15
  end
16
16
  end
17
17
 
18
18
  def add_models
19
19
  path = "#{Rails.root}/app/models/notification.rb"
20
- if File.exists?(path)
21
- puts "Skipping notification.rb creation, as file already exists!"
20
+ if File.exist?(path)
21
+ puts 'Skipping notification.rb creation, as file already exists!'
22
22
  else
23
- puts "Adding model (notification.rb)..."
24
- template "app/models/notification.rb", path
23
+ puts 'Adding model (notification.rb)...'
24
+ template 'app/models/notification.rb', path
25
25
  end
26
26
  end
27
27
 
@@ -30,7 +30,7 @@ module Notifications
30
30
  end
31
31
 
32
32
  def add_migrations
33
- `rake notifications:install:migrations`
33
+ exec('rake notifications:install:migrations')
34
34
  end
35
35
  end
36
36
  end
@@ -1,13 +1,12 @@
1
- # coding: utf-8
2
1
  require 'rails/generators'
3
2
  module Notifications
4
3
  module Generators
5
4
  class ViewsGenerator < Rails::Generators::Base #:nodoc:
6
- source_root File.expand_path("../../../../", __FILE__)
5
+ source_root File.expand_path('../../../../', __FILE__)
7
6
  desc "Used to copy Notifications's views to your application's views."
8
7
 
9
8
  def copy_views
10
- directory 'app/views/notifications', "app/views/notifications"
9
+ directory 'app/views/notifications', 'app/views/notifications'
11
10
  template 'app/assets/stylesheets/notifications.scss', 'app/assets/stylesheets/notifications.scss'
12
11
  end
13
12
  end
data/lib/notifications.rb CHANGED
@@ -1,7 +1,7 @@
1
- require "notifications/model"
2
- require "notifications/engine"
3
- require "notifications/configuration"
4
- require "notifications/version"
1
+ require 'notifications/model'
2
+ require 'notifications/engine'
3
+ require 'notifications/configuration'
4
+ require 'notifications/version'
5
5
  require 'will_paginate'
6
6
  require 'will_paginate/active_record'
7
7
 
@@ -10,13 +10,13 @@ module Notifications
10
10
  def config
11
11
  return @config if defined?(@config)
12
12
  @config = Configuration.new
13
- @config.per_page = 32
14
- @config.user_class = 'User'
15
- @config.user_name_method = 'name'
16
- @config.user_avatar_url_method = nil
17
- @config.user_profile_url_method = 'profile_url'
13
+ @config.per_page = 32
14
+ @config.user_class = 'User'
15
+ @config.user_name_method = 'name'
16
+ @config.user_avatar_url_method = nil
17
+ @config.user_profile_url_method = 'profile_url'
18
18
  @config.authenticate_user_method = 'authenticate_user!'
19
- @config.current_user_method = 'current_user'
19
+ @config.current_user_method = 'current_user'
20
20
  @config
21
21
  end
22
22
 
@@ -20,7 +20,7 @@ module Notifications
20
20
  end
21
21
 
22
22
  def actor_name
23
- return "" if self.actor.blank?
23
+ return '' if self.actor.blank?
24
24
  self.actor.send(Notifications.config.user_name_method)
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module Notifications
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2016-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.5.1
98
+ rubygems_version: 2.4.8
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Rails mountable Notification for any applications.