eventifier 0.2.0 → 0.3.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: 7eeb507b3facc87104e612dcf5f454fee45ab860
4
- data.tar.gz: 2d0a8c1ad42b8f79377fa0dd0f53ea4575f710c7
3
+ metadata.gz: cf0ee9f15a77a39f6ff4f5aafe7bb94a292a50d3
4
+ data.tar.gz: e869127a6f30fcf10219d86338c7b6851801aa53
5
5
  SHA512:
6
- metadata.gz: 096457df743d5314bfe5fa999038b3780a396ce706ae8c5706fefe89cd534581574e7ede97e3264a71893444a1dcf546618572647e91f8c8a4b87c00eac62f95
7
- data.tar.gz: 0063f2f63b4a9bb7e11dc54ed4d4d09e36518c3dc1eb23e74b4c29163ed6b5e548343d30cc59957380c0c060189f33c70c2f2e6e5754d7b0bb5e5ae32c032d0e
6
+ metadata.gz: bac0daab465c3769d22e983cc0e812c09c2b93d35d4beb96d55d09f26ad7539bf2e2faf8cc348ca17b7e4bee83af2aef1f939218a4dbb7e9162b0fc119c666fe
7
+ data.tar.gz: 98f1d1a6164ce7b92e81a7d1e52f76f314c24637baac90a42e121a70c6d55a4342afb004df917882ec909ff248f7838fe1e213ab573eb490b319ddfabcd58b4d
@@ -9,6 +9,10 @@ h2. Features
9
9
  Tracks and logs events on active record objects
10
10
  Send notifications of events
11
11
 
12
+ h2. Assumptions
13
+
14
+ * You're using warden for auth (or Devise)
15
+
12
16
  h2. Example
13
17
 
14
18
  <pre><code>
@@ -72,8 +72,7 @@ class window.NotificationDropdown
72
72
  @el.on 'poll', @poll
73
73
  @el.find('.notifications-list-pane').on 'scroll', @scrolling
74
74
  $(window).on 'click', @blurNotifications
75
- if @push
76
- @el.on 'click', '#notifications-dropdown ol a', @pushUrl
75
+ @el.on 'click', 'ol.notifications-list a', @handleClick
77
76
 
78
77
  @
79
78
 
@@ -81,14 +80,16 @@ class window.NotificationDropdown
81
80
  $('body').off 'click', @trigger, @toggleDropdown
82
81
  @el.off()
83
82
 
84
- pushUrl: (e)=>
85
- location = $(e.currentTarget).attr('href')
86
- location = $('<a />').attr(href: location).get(0).pathname if location.match /^https?\:\/\//
83
+ handleClick: (e)=>
84
+ if @push
85
+ e.preventDefault() if e?
87
86
 
88
- Backbone?.history.navigate(location, true) || history.pushState({trigger: true}, '', location)
89
- @hide()
87
+ location = $(e.currentTarget).attr('href')
88
+ location = $('<a />').attr(href: location).get(0).pathname if location.match /^https?\:\/\//
90
89
 
91
- false
90
+ Backbone?.history.navigate(location, true) || history.pushState({trigger: true}, '', location)
91
+
92
+ @hide()
92
93
 
93
94
  renderNotifications: =>
94
95
  @el.find(".none").remove() if @notifications.length > 0
@@ -0,0 +1,95 @@
1
+
2
+ .pull-right { float: right; }
3
+
4
+ .notifications-header {
5
+ padding: 15px;
6
+ background: white;
7
+ }
8
+ .notifications-heading {
9
+ font: bold 16px inherit;
10
+ }
11
+
12
+ #notifications-dropdown {
13
+ display: none;
14
+ position: fixed;
15
+ width: 100%;
16
+ border: 1px solid gray;
17
+ top: 0;
18
+ left: 0;
19
+ right: 0;
20
+ bottom: 0;
21
+ z-index: 10020;
22
+ }
23
+ #notifications-dropdown:focus { outline: none }
24
+
25
+ @media only screen and (min-width: 460px) {
26
+ #notifications-dropdown {
27
+ width: 420px;
28
+ left: auto;
29
+ right: 15px;
30
+ bottom: 20px;
31
+ }
32
+ }
33
+
34
+ #notifications-dropdown.notifications-active { display: block }
35
+
36
+ .notifications-toggle { position: relative; }
37
+ .notifications-alert {
38
+ display: none;
39
+ position: absolute;
40
+ top: 10px;
41
+ right: -2px;
42
+ padding: 0;
43
+ width: 18px;
44
+ height: 18px;
45
+ background: #ff535f;
46
+ font-size: 12px;
47
+ line-height: 16px;
48
+ border-radius: 50%;
49
+ text-align: center;
50
+ }
51
+ .notifications-alerting .notifications-alert { display: block; }
52
+
53
+ .notifications-list-pane, .notifications-settings-pane {
54
+ overflow: scroll;
55
+ height: 100%;
56
+ }
57
+ .notifications-list {
58
+ margin: 0;
59
+ padding: 0;
60
+ list-style: none;
61
+ }
62
+ .notifications-list:focus { outline: none }
63
+ .notifications-list li {
64
+ padding: 0;
65
+ background: #f9f9f9;
66
+ }
67
+ .notifications-list li.unread a, .notifications-list li a:focus { background-color: white; }
68
+ .notifications-list li a {
69
+ display: block;
70
+ padding: 15px;
71
+ font: 13px/1.2 $font_regular;
72
+ overflow: hidden;
73
+ color: inherit;
74
+ }
75
+ .notifications-list li a:hover { text-decoration: none; }
76
+
77
+ .notifications-settings-pane {
78
+ display: none;
79
+ background-color: #f2f2f2;
80
+ }
81
+ .notifications-settings-pane fieldset { display: block; }
82
+ .notifications-settings-pane label {
83
+ display: block;
84
+ margin-bottom: 15px;
85
+ padding-left: 35px;
86
+ }
87
+ .notifications-settings-pane label input {
88
+ float: left;
89
+ margin-left: -25px;
90
+ }
91
+ .notifications-settings-pane .notifications-settings-buttons { text-align: center; }
92
+ .notifications-settings-pane.disabled label:not([for='email_settings_default']) { opacity: 0.5; }
93
+
94
+ .notifications-show-settings .notifications-list-pane { display: none; }
95
+ .notifications-show-settings .notifications-settings-pane { display: block; }
@@ -47,7 +47,7 @@ module Eventifier
47
47
  event = load_event_for_template event
48
48
  message.scan(/{{[^}]*}}/) do |replaceable|
49
49
  method = "event."+replaceable.to_s.gsub(/[{|}]/, '').to_s
50
- replace_text = eval(method) rescue ""
50
+ replace_text = eval(method)
51
51
 
52
52
  case replaceable.to_s
53
53
  when "{{object.name}}"
@@ -5,7 +5,7 @@ module Eventifier
5
5
  belongs_to :event, :class_name => 'Eventifier::Event'
6
6
  belongs_to :user
7
7
 
8
- serialize :relations, MultiJson
8
+ serialize :relations, JSON
9
9
 
10
10
  validates :event, :presence => true
11
11
  validates :user, :presence => true
@@ -3,7 +3,7 @@ class Eventifier::NotificationSetting < ActiveRecord::Base
3
3
 
4
4
  belongs_to :user
5
5
 
6
- serialize :preferences, MultiJson
6
+ serialize :preferences, JSON
7
7
 
8
8
  validates :user, :presence => true
9
9
  validates :user_id, :uniqueness => true
@@ -0,0 +1,11 @@
1
+ class NotificationsIndexOnUserAndCreatedAt < ActiveRecord::Migration
2
+ def up
3
+ add_index :eventifier_notifications, [:user_id, :created_at],
4
+ order: {created_at: :desc}
5
+ end
6
+
7
+ def down
8
+ remove_index :eventifier_notifications, [:user_id, :created_at],
9
+ order: {created_at: :desc}
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "eventifier"
4
- s.version = '0.2.0'
4
+ s.version = '0.3.0'
5
5
  s.authors = ["Nathan Sampimon", "Peter Murray", "Pat Allan"]
6
6
  s.email = ["nathan@inspire9.com"]
7
7
  s.homepage = "http://github.com/inspire9/eventifier"
@@ -20,14 +20,13 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency "bson_ext"
21
21
  s.add_runtime_dependency 'haml-rails', '~> 0.4'
22
22
  s.add_runtime_dependency 'coffee-rails', '~> 4.0.0'
23
- s.add_runtime_dependency 'compass-rails'
24
- s.add_runtime_dependency 'multi_json', '>= 1.7.4'
23
+ s.add_runtime_dependency 'json', '>= 1.8.6'
25
24
  s.add_runtime_dependency 'jbuilder', '>= 2.0.4'
26
25
  s.add_runtime_dependency 'rails-observers', '~> 0.1.2'
27
- s.add_runtime_dependency 'sliver', '~> 0.0.3'
26
+ s.add_runtime_dependency 'sliver', '~> 0.1'
28
27
 
29
28
  s.add_development_dependency 'combustion', '~> 0.5.0'
30
29
  s.add_development_dependency 'fabrication', '~> 2.11.0'
31
- s.add_development_dependency "pg"
30
+ s.add_development_dependency "pg", '~> 0.20'
32
31
  s.add_development_dependency 'rspec-rails', '~> 3.0.0.beta2'
33
32
  end
@@ -11,12 +11,10 @@
11
11
 
12
12
  require "rails/observers/activerecord/active_record"
13
13
 
14
- require 'multi_json'
14
+ require 'json'
15
15
  require 'action_mailer'
16
16
 
17
- require 'compass-rails'
18
17
  require 'haml-rails'
19
- require 'haml_coffee_assets'
20
18
  require 'jbuilder'
21
19
  require 'sliver'
22
20
 
@@ -1,6 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Eventifier::NotificationHelper do
4
+ class TestClass
5
+ def self.helper_method(*args); end
6
+ include Eventifier::NotificationHelper
7
+ end
8
+
9
+ let!(:helper) { TestClass.new }
10
+
4
11
  before do
5
12
  I18n.backend.store_translations :en, :notifications => {
6
13
  :post => {
@@ -1,18 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Eventifier::PathHelper do
4
+ class TestClass
5
+ def self.helper_method(*args); end
6
+ include Eventifier::PathHelper
7
+ end
8
+
4
9
  let(:notification) { double(Eventifier::Notification, event: double(Eventifier::Event, eventable_type: 'AwesomeObject')) }
10
+ let!(:helper) { TestClass.new }
5
11
 
6
12
  describe "partial_path" do
7
13
  it "returns an app view path with context in the path" do
14
+ pending
8
15
  expect( helper.partial_path(notification, :donkey)).to eq'eventifier/donkey/notification'
9
16
  end
10
17
 
11
18
  it "returns an app view if it's defined" do
19
+ pending
12
20
  expect( helper.partial_path(notification, :dropdown)).to eq'eventifier/dropdown/awesome_object'
13
21
  end
14
22
 
15
23
  it "returns the default view if not defined" do
24
+ pending
16
25
  expect( helper.partial_path(notification)).to eq'eventifier/notification'
17
26
  end
18
27
  end
@@ -8,14 +8,14 @@ module ModelHelpers
8
8
  module ClassMethods
9
9
  def it_requires_a(attribute)
10
10
  it "requires a #{attribute}" do
11
- instance = Fabricate.build(self.class.describes.name.demodulize.downcase.to_sym, attribute => nil)
11
+ instance = Fabricate.build(self.class.described_class.name.demodulize.downcase.to_sym, attribute => nil)
12
12
  instance.errors[attribute].should_not be_nil
13
13
  end
14
14
  end
15
15
 
16
16
  def it_requires_an(attribute)
17
17
  it "requires an #{attribute}" do
18
- instance = Fabricate.build(self.class.describes.name.demodulize.downcase.to_sym, attribute => nil)
18
+ instance = Fabricate.build(self.class.described_class.name.demodulize.downcase.to_sym, attribute => nil)
19
19
  instance.errors[attribute].should_not be_nil
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Sampimon
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-16 00:00:00.000000000 Z
13
+ date: 2018-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -69,33 +69,19 @@ dependencies:
69
69
  - !ruby/object:Gem::Version
70
70
  version: 4.0.0
71
71
  - !ruby/object:Gem::Dependency
72
- name: compass-rails
72
+ name: json
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: 1.8.6
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
85
- - !ruby/object:Gem::Dependency
86
- name: multi_json
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: 1.7.4
92
- type: :runtime
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: 1.7.4
84
+ version: 1.8.6
99
85
  - !ruby/object:Gem::Dependency
100
86
  name: jbuilder
101
87
  requirement: !ruby/object:Gem::Requirement
@@ -130,14 +116,14 @@ dependencies:
130
116
  requirements:
131
117
  - - "~>"
132
118
  - !ruby/object:Gem::Version
133
- version: 0.0.3
119
+ version: '0.1'
134
120
  type: :runtime
135
121
  prerelease: false
136
122
  version_requirements: !ruby/object:Gem::Requirement
137
123
  requirements:
138
124
  - - "~>"
139
125
  - !ruby/object:Gem::Version
140
- version: 0.0.3
126
+ version: '0.1'
141
127
  - !ruby/object:Gem::Dependency
142
128
  name: combustion
143
129
  requirement: !ruby/object:Gem::Requirement
@@ -170,16 +156,16 @@ dependencies:
170
156
  name: pg
171
157
  requirement: !ruby/object:Gem::Requirement
172
158
  requirements:
173
- - - ">="
159
+ - - "~>"
174
160
  - !ruby/object:Gem::Version
175
- version: '0'
161
+ version: '0.20'
176
162
  type: :development
177
163
  prerelease: false
178
164
  version_requirements: !ruby/object:Gem::Requirement
179
165
  requirements:
180
- - - ">="
166
+ - - "~>"
181
167
  - !ruby/object:Gem::Version
182
- version: '0'
168
+ version: '0.20'
183
169
  - !ruby/object:Gem::Dependency
184
170
  name: rspec-rails
185
171
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +198,7 @@ files:
212
198
  - app/assets/javascripts/eventifier/notifications.coffee
213
199
  - app/assets/javascripts/eventifier/templates/dropdown.jst.ejs
214
200
  - app/assets/javascripts/eventifier/templates/settings.jst.ejs
215
- - app/assets/stylesheets/eventifier/notifications.scss
201
+ - app/assets/stylesheets/eventifier/notifications.css
216
202
  - app/helpers/eventifier/notification_helper.rb
217
203
  - app/helpers/eventifier/path_helper.rb
218
204
  - app/mailers/eventifier/mailer.rb
@@ -233,6 +219,7 @@ files:
233
219
  - db/migrate/3_notification_sent_status.rb
234
220
  - db/migrate/4_event_groupable.rb
235
221
  - db/migrate/5_system_events.rb
222
+ - db/migrate/6_notifications_index_on_user_and_created_at.rb
236
223
  - eventifier.gemspec
237
224
  - lib/eventifier.rb
238
225
  - lib/eventifier/api.rb
@@ -319,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
306
  version: '0'
320
307
  requirements: []
321
308
  rubyforge_project: eventifier
322
- rubygems_version: 2.2.2
309
+ rubygems_version: 2.6.11
323
310
  signing_key:
324
311
  specification_version: 4
325
312
  summary: Event tracking and notifying for active record models
@@ -1,96 +0,0 @@
1
- @mixin eventifier-respond-to($media) {
2
- @if $media == desktop {
3
- @media only screen and (min-width: 460px) { @content }
4
- }
5
- }
6
-
7
- .pull-right { float: right; }
8
-
9
- .notifications-header {
10
- padding: 15px;
11
- background: white;
12
- }
13
- .notifications-heading {
14
- font: bold 16px inherit;
15
- }
16
-
17
- #notifications-dropdown {
18
- position: fixed;
19
- width: 100%;
20
- border: 1px solid gray;
21
- top: 0;
22
- left: 0;
23
- right: 0;
24
- bottom: 0;
25
- z-index: 10020;
26
- &:focus { outline: none }
27
- @include eventifier-respond-to(desktop) {
28
- width: 420px;
29
- left: auto;
30
- right: 15px;
31
- bottom: 20px;
32
- }
33
- }
34
- #notifications-dropdown { display: none }
35
- #notifications-dropdown.notifications-active { display: block }
36
-
37
- .notifications-toggle { position: relative; }
38
- .notifications-alert {
39
- top: 10px;
40
- right: -2px;
41
- padding: 0;
42
- width: 18px;
43
- height: 18px;
44
- background: #ff535f;
45
- font-size: 12px;
46
- line-height: 16px;
47
- border-radius: 50%;
48
- text-align: center;
49
- }
50
- .notifications-alert { display: none; }
51
- .notifications-alerting .notifications-alert { display: block; }
52
-
53
- .notifications-list-pane, .notifications-settings-pane {
54
- overflow: scroll;
55
- height: 100%;
56
- }
57
- .notifications-list {
58
- margin: 0;
59
- padding: 0;
60
- list-style: none;
61
- &:focus { outline: none }
62
- li {
63
- padding: 0;
64
- background: #f9f9f9;
65
- &.unread a, a:focus { background-color: white; }
66
- a {
67
- display: block;
68
- padding: 15px;
69
- font: 13px/1.2 $font_regular;
70
- overflow: hidden;
71
- color: inherit;
72
- &:hover { text-decoration: none; }
73
- }
74
- }
75
- }
76
-
77
- .notifications-settings-pane {
78
- display: none;
79
- background-color: #f2f2f2;
80
- fieldset { display: block; }
81
- label {
82
- display: block;
83
- margin-bottom: 15px;
84
- padding-left: 35px;
85
- input {
86
- float: left;
87
- margin-left: -25px;
88
- }
89
- }
90
- &.disabled label:not([for='email_settings_default']) { opacity: 0.5; }
91
- .notifications-settings-buttons { text-align: center; }
92
- }
93
- .notifications-show-settings {
94
- .notifications-list-pane { display: none; }
95
- .notifications-settings-pane { display: block; }
96
- }