gossiper 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/application.js +13 -0
- data/app/assets/javascripts/bootstrap.js +4 -0
- data/app/assets/javascripts/gossiper/application.js +2 -0
- data/app/assets/javascripts/gossiper/notifications.js +2 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +30 -0
- data/app/assets/stylesheets/gossiper/application.css +1 -0
- data/app/assets/stylesheets/gossiper/notifications.css +4 -0
- data/app/controllers/gossiper/application_controller.rb +18 -0
- data/app/controllers/gossiper/notifications_controller.rb +28 -0
- data/app/helpers/gossiper/notifications_helper.rb +4 -0
- data/app/views/gossiper/notifications/dummy_notification_notification.html.erb +0 -0
- data/app/views/gossiper/notifications/index.html.erb +40 -0
- data/app/views/gossiper/notifications/show.html.erb +31 -0
- data/app/views/kaminari/_first_page.html.erb +3 -0
- data/app/views/kaminari/_gap.html.erb +3 -0
- data/app/views/kaminari/_last_page.html.erb +3 -0
- data/app/views/kaminari/_next_page.html.erb +3 -0
- data/app/views/kaminari/_page.html.erb +3 -0
- data/app/views/kaminari/_paginator.html.erb +17 -0
- data/app/views/kaminari/_prev_page.html.erb +3 -0
- data/app/views/kaminari/gossiper/_first_page.html.erb +3 -0
- data/app/views/kaminari/gossiper/_gap.html.erb +3 -0
- data/app/views/kaminari/gossiper/_last_page.html.erb +3 -0
- data/app/views/kaminari/gossiper/_next_page.html.erb +3 -0
- data/app/views/kaminari/gossiper/_page.html.erb +3 -0
- data/app/views/kaminari/gossiper/_paginator.html.erb +17 -0
- data/app/views/kaminari/gossiper/_prev_page.html.erb +3 -0
- data/app/views/layouts/gossiper/application.html.erb +36 -12
- data/config/locales/en.bootstrap.yml +18 -0
- data/config/routes.rb +7 -0
- data/lib/generators/gossiper/install/install_generator.rb +2 -2
- data/lib/generators/gossiper/install/templates/initializer.rb +24 -6
- data/lib/generators/gossiper/install/templates/locale.en.yml +11 -0
- data/lib/generators/gossiper/notification_type/USAGE +3 -1
- data/lib/generators/gossiper/notification_type/notification_type_generator.rb +9 -0
- data/lib/generators/gossiper/notification_type/templates/notification_type_template.rb +18 -0
- data/lib/gossiper/configuration.rb +6 -2
- data/lib/gossiper/email_config.rb +11 -8
- data/lib/gossiper/mailer.rb +6 -1
- data/lib/gossiper/notification_decorator.rb +70 -0
- data/lib/gossiper/version.rb +1 -1
- data/lib/gossiper.rb +2 -1
- metadata +80 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3716407ac00419742e5e27b7ca519d8c917db74
|
4
|
+
data.tar.gz: aef5ae17de79516eb899b82e511b3f2968638dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8a47020bd298bc4c7839b8697d73165d393084a4c948378a21f2d2139584484b53899372acbaacbb1c359eca762bf4a2f6a322ab7186d54f78f0f00ab735b0
|
7
|
+
data.tar.gz: 194baa36496e0d7cd375ba98f687c3410a413654de0ff1b78507c52a6796225819a52aa5b126f6588d2e946dda43d5c08acbe275f5c13eabbe496094a215728c
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,30 @@
|
|
1
|
+
@import "twitter/bootstrap/bootstrap";
|
2
|
+
@import "twitter/bootstrap/responsive";
|
3
|
+
|
4
|
+
// Set the correct sprite paths
|
5
|
+
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
|
6
|
+
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");
|
7
|
+
|
8
|
+
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
9
|
+
@fontAwesomeEotPath: asset-url("fontawesome-webfont.eot");
|
10
|
+
@fontAwesomeEotPath_iefix: asset-url("fontawesome-webfont.eot?#iefix");
|
11
|
+
@fontAwesomeWoffPath: asset-url("fontawesome-webfont.woff");
|
12
|
+
@fontAwesomeTtfPath: asset-url("fontawesome-webfont.ttf");
|
13
|
+
@fontAwesomeSvgPath: asset-url("fontawesome-webfont.svg#fontawesomeregular");
|
14
|
+
|
15
|
+
// Font Awesome
|
16
|
+
@import "fontawesome/font-awesome";
|
17
|
+
|
18
|
+
// Glyphicons
|
19
|
+
//@import "twitter/bootstrap/sprites.less";
|
20
|
+
|
21
|
+
// Your custom LESS stylesheets goes here
|
22
|
+
//
|
23
|
+
// Since bootstrap was imported above you have access to its mixins which
|
24
|
+
// you may use and inherit here
|
25
|
+
//
|
26
|
+
// If you'd like to override bootstrap's own variables, you can do so here as well
|
27
|
+
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
|
28
|
+
//
|
29
|
+
// Example:
|
30
|
+
// @linkColor: #ff0000;
|
@@ -1,4 +1,22 @@
|
|
1
1
|
module Gossiper
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
if respond_to?(:before_action)
|
5
|
+
before_action :gossiper_authorization
|
6
|
+
else
|
7
|
+
before_filter :gossiper_authorization
|
8
|
+
end
|
9
|
+
|
10
|
+
def gossiper_authorization
|
11
|
+
instance_eval(&Gossiper.configuration.authorize_with)
|
12
|
+
end
|
13
|
+
|
14
|
+
def page
|
15
|
+
params[:page].presence || 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def per_page
|
19
|
+
params[:per_page].presence || 25
|
20
|
+
end
|
3
21
|
end
|
4
22
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_dependency "gossiper/application_controller"
|
2
|
+
|
3
|
+
module Gossiper
|
4
|
+
class NotificationsController < ApplicationController
|
5
|
+
respond_to :html
|
6
|
+
|
7
|
+
def index
|
8
|
+
@notifications = Notification.order('id desc').page(page).per(per_page)
|
9
|
+
respond_with(@notifications)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
respond_with(notification)
|
14
|
+
end
|
15
|
+
|
16
|
+
def deliver
|
17
|
+
notification.deliver!
|
18
|
+
respond_with(notification) do |format|
|
19
|
+
format.html { redirect_to :notifications, notice: t('.delivered') }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def notification
|
25
|
+
@notification ||= Notification.find(params[:id])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<h1><%= Gossiper::Notification.model_name.human.pluralize %></h1>
|
2
|
+
|
3
|
+
<% if notice.present? %>
|
4
|
+
<div class="alert alert-success"><%= notice %></div>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<table class="table table-striped table-bordered">
|
8
|
+
<tr>
|
9
|
+
<th><%= t('.kind') %></th>
|
10
|
+
<th><%= t('.email') %></th>
|
11
|
+
<th><%= t('.delivered_at') %></th>
|
12
|
+
<th><%= t('.status') %></th>
|
13
|
+
<th><%= t('.read') %></th>
|
14
|
+
<th><%= t('.actions') %></th>
|
15
|
+
</tr>
|
16
|
+
<% @notifications.each do |notification| %>
|
17
|
+
<% decorator = Gossiper::NotificationDecorator.new(notification) %>
|
18
|
+
<tr>
|
19
|
+
<td><%= decorator.kind %></td>
|
20
|
+
<td><%= decorator.user.email %></td>
|
21
|
+
<td><%= decorator.delivered_at %></td>
|
22
|
+
<td><%= decorator.status %></td>
|
23
|
+
<td><%= decorator.read? %></td>
|
24
|
+
<td class="actions">
|
25
|
+
<%= link_to(
|
26
|
+
t('.deliver', default: 'Deliver'),
|
27
|
+
deliver_notification_path(notification),
|
28
|
+
data: {
|
29
|
+
confirm: t('.confirm_delivery', default: t('gossiper.notifications.confirm_delivery')),
|
30
|
+
method: :post,
|
31
|
+
},
|
32
|
+
class: 'btn pull-right'
|
33
|
+
) %>
|
34
|
+
<%= link_to(t('.show', default: t('gossiper.notifications.show')), notification, class: 'btn pull-right') %>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</table>
|
39
|
+
|
40
|
+
<%= paginate(@notifications, theme: :gossiper) %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% decorator = Gossiper::NotificationDecorator.new(@notification) %>
|
2
|
+
|
3
|
+
<h1><%= Gossiper::Notification.model_name.human.pluralize %></h1>
|
4
|
+
|
5
|
+
<table class="table table-striped table-bordered">
|
6
|
+
<% %w(kind subject to user_class user_id delivered_at status read created_at updated_at).each do |attribute| %>
|
7
|
+
<tr>
|
8
|
+
<th class="title"><%= Gossiper::Notification.human_attribute_name(attribute) rescue t(".#{attribute}") %></th>
|
9
|
+
<td><%= decorator.send(attribute) %></td>
|
10
|
+
</tr>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<tr>
|
14
|
+
<th class="title"><%= Gossiper::Notification.human_attribute_name('email_body') rescue t("email_body") %></th>
|
15
|
+
<td><pre><%= decorator.email_object %></pre></td>
|
16
|
+
</tr>
|
17
|
+
|
18
|
+
</table>
|
19
|
+
|
20
|
+
<div class="form-actions">
|
21
|
+
<%= link_to(
|
22
|
+
t('.deliver', default: 'Deliver'),
|
23
|
+
deliver_notification_path(@notification),
|
24
|
+
data: {
|
25
|
+
confirm: t('.confirm_delivery', default: t('gossiper.notifications.confirm_delivery')),
|
26
|
+
method: :post,
|
27
|
+
},
|
28
|
+
class: 'btn pull-right'
|
29
|
+
) %>
|
30
|
+
<%= link_to(t('.back', default: t('gossiper.notifications.back')), :notifications, class: "btn pull-right") %>
|
31
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= paginator.render do -%>
|
2
|
+
<div class="pagination">
|
3
|
+
<ul>
|
4
|
+
<%= first_page_tag unless current_page.first? %>
|
5
|
+
<%= prev_page_tag unless current_page.first? %>
|
6
|
+
<% each_page do |page| -%>
|
7
|
+
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
|
8
|
+
<%= page_tag page %>
|
9
|
+
<% elsif !page.was_truncated? -%>
|
10
|
+
<%= gap_tag %>
|
11
|
+
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
<%= next_page_tag unless current_page.last? %>
|
14
|
+
<%= last_page_tag unless current_page.last? %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= paginator.render do -%>
|
2
|
+
<div class="pagination">
|
3
|
+
<ul>
|
4
|
+
<%= first_page_tag unless current_page.first? %>
|
5
|
+
<%= prev_page_tag unless current_page.first? %>
|
6
|
+
<% each_page do |page| -%>
|
7
|
+
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
|
8
|
+
<%= page_tag page %>
|
9
|
+
<% elsif !page.was_truncated? -%>
|
10
|
+
<%= gap_tag %>
|
11
|
+
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
<%= next_page_tag unless current_page.last? %>
|
14
|
+
<%= last_page_tag unless current_page.last? %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<% end -%>
|
@@ -1,14 +1,38 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<title><%= content_for?(:title) ? yield(:title) : "Gossiper" %></title>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
|
10
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
11
|
+
<!--[if lt IE 9]>
|
12
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
|
13
|
+
<![endif]-->
|
14
|
+
|
15
|
+
<%= stylesheet_link_tag "gossiper/application", :media => "all" %>
|
16
|
+
|
17
|
+
<%= javascript_include_tag "gossiper/application" %>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
|
21
|
+
<div class="container-fluid">
|
22
|
+
<div class="row-fluid">
|
23
|
+
<div class="span12">
|
24
|
+
<%# <%= bootstrap_flash %>
|
25
|
+
<%= yield %>
|
26
|
+
</div>
|
27
|
+
</div><!--/row-->
|
28
|
+
|
29
|
+
<footer class="footer">
|
30
|
+
<div class="pull-right">
|
31
|
+
Powered by <a href="https://github.com/mjacobus/gossiper">Gossiper <%= Gossiper::VERSION %></a>
|
32
|
+
</div>
|
33
|
+
</footer>
|
34
|
+
|
35
|
+
</div> <!-- /container -->
|
36
|
+
|
37
|
+
</body>
|
14
38
|
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
+
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
|
+
|
4
|
+
en:
|
5
|
+
helpers:
|
6
|
+
actions: "Actions"
|
7
|
+
links:
|
8
|
+
back: "Back"
|
9
|
+
cancel: "Cancel"
|
10
|
+
confirm: "Are you sure?"
|
11
|
+
destroy: "Delete"
|
12
|
+
new: "New"
|
13
|
+
edit: "Edit"
|
14
|
+
titles:
|
15
|
+
edit: "Edit %{model}"
|
16
|
+
save: "Save %{model}"
|
17
|
+
new: "New %{model}"
|
18
|
+
delete: "Delete %{model}"
|
data/config/routes.rb
CHANGED
@@ -2,10 +2,10 @@ class Gossiper::InstallGenerator < Rails::Generators::Base
|
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
|
4
4
|
def copy_initializer
|
5
|
-
template "initializer.rb", "config/
|
5
|
+
template "initializer.rb", "config/initializers/gossiper.rb"
|
6
6
|
end
|
7
7
|
|
8
8
|
def copy_locale
|
9
|
-
template "locale.en.yml", "config/
|
9
|
+
template "locale.en.yml", "config/locales/gossiper.en.yml"
|
10
10
|
end
|
11
11
|
end
|
@@ -1,22 +1,40 @@
|
|
1
1
|
<%- test_folder = defined?(RSpec) ? 'rspec' : 'test' -%>
|
2
2
|
Gossiper.configure do |config|
|
3
3
|
# Change the default user class
|
4
|
-
|
4
|
+
config.default_notification_user_class = 'User'
|
5
5
|
|
6
6
|
# change the default class of the configurations
|
7
|
-
config.
|
7
|
+
config.default_notification_config_class = 'Gossiper::EmailConfig'
|
8
|
+
|
9
|
+
# email the email sender
|
10
|
+
config.default_from = 'from@example.com'
|
11
|
+
|
12
|
+
# The list of emails to send copies to
|
13
|
+
# config.default_cc = ['user@example.com']
|
14
|
+
|
15
|
+
# The list of emails to send hidden copies to
|
16
|
+
# config.default_bcc = ['user@example.com']
|
8
17
|
|
9
18
|
# change the path where the notifications should be placed
|
10
|
-
config.
|
19
|
+
config.notifications_root_folder = Rails.root.join('app/models')
|
20
|
+
|
21
|
+
# the notifications templates
|
22
|
+
config.notifications_template_folder = Rails.root.join("app/views")
|
11
23
|
|
12
24
|
# the notifications test folder
|
13
|
-
config.
|
25
|
+
config.notifications_test_folder = Rails.root.join("<%= test_folder %>", "models")
|
14
26
|
|
15
|
-
|
27
|
+
# The process to be run before a controller action is executed
|
28
|
+
# Can also implemented in the application controller
|
29
|
+
# by ovewriting the ApplicationController::gossiper_authorization
|
30
|
+
#
|
31
|
+
# See: Gossiper::ApplicationController#gossiper_authorization
|
32
|
+
#
|
33
|
+
config.authorize_with do
|
16
34
|
# Example:
|
17
35
|
|
18
36
|
# unless current_user.is_admin?
|
19
|
-
# redirect_to root_path, notice: 'Get
|
37
|
+
# redirect_to root_path, notice: 'Get outta here!'
|
20
38
|
# end
|
21
39
|
end
|
22
40
|
end
|
@@ -1,6 +1,17 @@
|
|
1
1
|
en:
|
2
|
+
"true": Yes
|
3
|
+
"false": No
|
2
4
|
gossiper:
|
3
5
|
notifications:
|
6
|
+
status:
|
7
|
+
delivered: Delivered
|
8
|
+
pending: Pending
|
9
|
+
deliver:
|
10
|
+
delivered: Your message has successfully been sent
|
11
|
+
show: View
|
12
|
+
back: Back
|
13
|
+
confirm_delivery: Are you sure you want to deliver this notification?
|
4
14
|
# Example
|
5
15
|
user_welcome:
|
6
16
|
subject: Welcome!
|
17
|
+
title: User Registration
|
@@ -5,4 +5,6 @@ Example:
|
|
5
5
|
rails generate notification_type user_welcome
|
6
6
|
|
7
7
|
This will create:
|
8
|
-
app/models/notifications/user_welcome_notification
|
8
|
+
app/models/notifications/user_welcome_notification.rb
|
9
|
+
app/views/notifications/user_welcome_notification.html.erb
|
10
|
+
spec/models/notifications/user_welcome_notification_spec.rb
|
@@ -20,4 +20,13 @@ class Gossiper::NotificationTypeGenerator < Rails::Generators::NamedBase
|
|
20
20
|
"#{singular_name}_notification_#{test_sufix}.rb"
|
21
21
|
)
|
22
22
|
end
|
23
|
+
|
24
|
+
def create_template
|
25
|
+
template 'notification_type_template.rb', File.join(
|
26
|
+
Gossiper.configuration.notifications_template_folder.to_s,
|
27
|
+
'notifications',
|
28
|
+
class_path,
|
29
|
+
"#{singular_name}_notification.html.erb"
|
30
|
+
)
|
31
|
+
end
|
23
32
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!--
|
2
|
+
# @notification.class #=> Gossiper::NotificationDecorator
|
3
|
+
# @notification.subject
|
4
|
+
# @notification.email
|
5
|
+
# @notification.read?
|
6
|
+
# @notification.delivered_at?
|
7
|
+
|
8
|
+
|
9
|
+
# Also, if you want to assign other vars here, just edit the
|
10
|
+
# <%= File.join(Gossiper.configuration.notifications_root_folder.to_s, 'notifications', class_path, "#{singular_name}_notification.rb") %>
|
11
|
+
# and override the
|
12
|
+
# def instance_variables
|
13
|
+
# { some_var: 'some_value' }
|
14
|
+
# end
|
15
|
+
|
16
|
+
# and the value will be assign to the @some_var instance variable
|
17
|
+
-->
|
18
|
+
<p>Write your email here</p>
|
@@ -13,10 +13,14 @@ module Gossiper
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
attribute :default_notification_user_class
|
17
|
-
attribute :default_notification_config_class
|
18
16
|
attribute :notifications_root_folder
|
19
17
|
attribute :notifications_test_folder
|
18
|
+
attribute :notifications_template_folder
|
19
|
+
attribute :default_notification_user_class
|
20
|
+
attribute :default_notification_config_class
|
21
|
+
attribute :default_from
|
22
|
+
attribute :default_cc
|
23
|
+
attribute :default_bcc
|
20
24
|
|
21
25
|
def authorize_with(&block)
|
22
26
|
if block_given?
|
@@ -7,6 +7,10 @@ module Gossiper
|
|
7
7
|
@user = notification.user
|
8
8
|
end
|
9
9
|
|
10
|
+
def from
|
11
|
+
config.default_from
|
12
|
+
end
|
13
|
+
|
10
14
|
def to
|
11
15
|
if user.respond_to?(:name)
|
12
16
|
["#{user.name} <#{user.email}>"]
|
@@ -15,18 +19,12 @@ module Gossiper
|
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
# TODO: Make configuration for default bcc
|
19
22
|
def bcc
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
# TODO: Make configuration for default from
|
24
|
-
def from
|
23
|
+
config.default_bcc
|
25
24
|
end
|
26
25
|
|
27
|
-
# TODO: Make configuration for default cc
|
28
26
|
def cc
|
29
|
-
|
27
|
+
config.default_cc
|
30
28
|
end
|
31
29
|
|
32
30
|
def template_name
|
@@ -48,5 +46,10 @@ module Gossiper
|
|
48
46
|
def instance_variables
|
49
47
|
{}
|
50
48
|
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def config
|
52
|
+
Gossiper.configuration
|
53
|
+
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/gossiper/mailer.rb
CHANGED
@@ -8,11 +8,14 @@ module Gossiper
|
|
8
8
|
attachments[filename] = file
|
9
9
|
end
|
10
10
|
|
11
|
+
@notification = NotificationDecorator.new(notification)
|
12
|
+
|
11
13
|
config.instance_variables.each do |name, value|
|
12
14
|
instance_variable_set("@#{name}", value)
|
13
15
|
end
|
14
16
|
|
15
17
|
mail(
|
18
|
+
from: config.from,
|
16
19
|
to: config.to,
|
17
20
|
cc: config.cc,
|
18
21
|
bcc: config.bcc,
|
@@ -27,8 +30,10 @@ module Gossiper
|
|
27
30
|
klass = "Notifications::#{notification.kind.classify}Notification"
|
28
31
|
klass.constantize.new(notification)
|
29
32
|
rescue NameError
|
30
|
-
Gossiper
|
33
|
+
klass = Gossiper.configuration.default_notification_config_class
|
34
|
+
klass.constantize.new(notification)
|
31
35
|
end
|
36
|
+
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Gossiper
|
2
|
+
class NotificationDecorator
|
3
|
+
|
4
|
+
attr_reader :notification
|
5
|
+
|
6
|
+
def initialize(notification)
|
7
|
+
@notification = notification
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method, *args, &block)
|
11
|
+
notification.send(method, *args, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to?(method)
|
15
|
+
notification.respond_to?(method)
|
16
|
+
end
|
17
|
+
|
18
|
+
def kind
|
19
|
+
t("gossiper.notifications.#{notification.kind}.title",
|
20
|
+
default: notification.kind.titleize
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def subject
|
25
|
+
t("gossiper.notifications.#{notification.kind}.subject",
|
26
|
+
default: kind
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def status
|
31
|
+
t("gossiper.notifications.status.#{notification.status}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def read?
|
35
|
+
t(notification.read?.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
def email
|
39
|
+
notification.user.email
|
40
|
+
end
|
41
|
+
alias_method :to, :email
|
42
|
+
|
43
|
+
def delivered_at
|
44
|
+
decorate_date(notification.delivered_at)
|
45
|
+
end
|
46
|
+
|
47
|
+
def created_at
|
48
|
+
decorate_date(notification.created_at)
|
49
|
+
end
|
50
|
+
|
51
|
+
def updated_at
|
52
|
+
decorate_date(notification.updated_at)
|
53
|
+
end
|
54
|
+
|
55
|
+
def email_object
|
56
|
+
@email_object ||= Mailer.mail_for(notification)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def t(*args)
|
62
|
+
I18n.t(*args)
|
63
|
+
end
|
64
|
+
|
65
|
+
def decorate_date(date)
|
66
|
+
I18n.l(date, format: :short) if date
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
data/lib/gossiper/version.rb
CHANGED
data/lib/gossiper.rb
CHANGED
@@ -2,6 +2,7 @@ require "gossiper/engine"
|
|
2
2
|
require "gossiper/email_config"
|
3
3
|
require "gossiper/mailer"
|
4
4
|
require "gossiper/configuration"
|
5
|
+
require "gossiper/notification_decorator"
|
5
6
|
|
6
7
|
module Gossiper
|
7
8
|
|
@@ -10,7 +11,7 @@ module Gossiper
|
|
10
11
|
@@_config ||= Configuration.new
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def configure
|
14
15
|
yield configuration
|
15
16
|
end
|
16
17
|
end
|
metadata
CHANGED
@@ -1,37 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gossiper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sqlite3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
21
25
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
23
|
-
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shoulda-matchers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
24
35
|
prerelease: false
|
25
36
|
version_requirements: !ruby/object:Gem::Requirement
|
26
37
|
requirements:
|
27
38
|
- - '>='
|
28
39
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
31
53
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
54
|
+
version: '0'
|
33
55
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
56
|
+
name: simplecov
|
35
57
|
requirement: !ruby/object:Gem::Requirement
|
36
58
|
requirements:
|
37
59
|
- - '>='
|
@@ -45,7 +67,7 @@ dependencies:
|
|
45
67
|
- !ruby/object:Gem::Version
|
46
68
|
version: '0'
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
70
|
+
name: coveralls
|
49
71
|
requirement: !ruby/object:Gem::Requirement
|
50
72
|
requirements:
|
51
73
|
- - '>='
|
@@ -59,7 +81,7 @@ dependencies:
|
|
59
81
|
- !ruby/object:Gem::Version
|
60
82
|
version: '0'
|
61
83
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
84
|
+
name: faker
|
63
85
|
requirement: !ruby/object:Gem::Requirement
|
64
86
|
requirements:
|
65
87
|
- - '>='
|
@@ -73,7 +95,7 @@ dependencies:
|
|
73
95
|
- !ruby/object:Gem::Version
|
74
96
|
version: '0'
|
75
97
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
98
|
+
name: interactive_editor
|
77
99
|
requirement: !ruby/object:Gem::Requirement
|
78
100
|
requirements:
|
79
101
|
- - '>='
|
@@ -93,30 +115,58 @@ executables: []
|
|
93
115
|
extensions: []
|
94
116
|
extra_rdoc_files: []
|
95
117
|
files:
|
118
|
+
- app/views/layouts/gossiper/application.html.erb
|
119
|
+
- app/views/gossiper/notifications/dummy_notification_notification.html.erb
|
120
|
+
- app/views/gossiper/notifications/index.html.erb
|
121
|
+
- app/views/gossiper/notifications/show.html.erb
|
122
|
+
- app/views/kaminari/_first_page.html.erb
|
123
|
+
- app/views/kaminari/_prev_page.html.erb
|
124
|
+
- app/views/kaminari/gossiper/_first_page.html.erb
|
125
|
+
- app/views/kaminari/gossiper/_prev_page.html.erb
|
126
|
+
- app/views/kaminari/gossiper/_last_page.html.erb
|
127
|
+
- app/views/kaminari/gossiper/_next_page.html.erb
|
128
|
+
- app/views/kaminari/gossiper/_page.html.erb
|
129
|
+
- app/views/kaminari/gossiper/_gap.html.erb
|
130
|
+
- app/views/kaminari/gossiper/_paginator.html.erb
|
131
|
+
- app/views/kaminari/_last_page.html.erb
|
132
|
+
- app/views/kaminari/_next_page.html.erb
|
133
|
+
- app/views/kaminari/_page.html.erb
|
134
|
+
- app/views/kaminari/_gap.html.erb
|
135
|
+
- app/views/kaminari/_paginator.html.erb
|
136
|
+
- app/helpers/gossiper/notifications_helper.rb
|
137
|
+
- app/helpers/gossiper/application_helper.rb
|
138
|
+
- app/assets/javascripts/application.js
|
96
139
|
- app/assets/javascripts/gossiper/application.js
|
140
|
+
- app/assets/javascripts/gossiper/notifications.js
|
141
|
+
- app/assets/javascripts/bootstrap.js
|
142
|
+
- app/assets/stylesheets/application.css
|
143
|
+
- app/assets/stylesheets/gossiper/notifications.css
|
97
144
|
- app/assets/stylesheets/gossiper/application.css
|
98
|
-
- app/
|
145
|
+
- app/assets/stylesheets/bootstrap_and_overrides.css.less
|
99
146
|
- app/models/gossiper/notification.rb
|
100
|
-
- app/views/layouts/gossiper/application.html.erb
|
101
147
|
- app/controllers/gossiper/application_controller.rb
|
148
|
+
- app/controllers/gossiper/notifications_controller.rb
|
149
|
+
- config/locales/en.bootstrap.yml
|
102
150
|
- config/routes.rb
|
103
151
|
- db/migrate/20131206162038_create_gossiper_notifications.rb
|
104
|
-
- lib/generators/gossiper/notification_type/USAGE
|
105
|
-
- lib/generators/gossiper/notification_type/notification_type_generator.rb
|
106
|
-
- lib/generators/gossiper/notification_type/templates/notification_type_spec.rb
|
107
|
-
- lib/generators/gossiper/notification_type/templates/notification_type_test.rb
|
108
|
-
- lib/generators/gossiper/notification_type/templates/notification_type.rb
|
109
|
-
- lib/generators/gossiper/install/USAGE
|
110
|
-
- lib/generators/gossiper/install/install_generator.rb
|
111
|
-
- lib/generators/gossiper/install/templates/initializer.rb
|
112
|
-
- lib/generators/gossiper/install/templates/locale.en.yml
|
113
152
|
- lib/gossiper.rb
|
114
|
-
- lib/tasks/gossiper_tasks.rake
|
115
|
-
- lib/gossiper/email_config.rb
|
116
|
-
- lib/gossiper/engine.rb
|
117
|
-
- lib/gossiper/mailer.rb
|
118
153
|
- lib/gossiper/configuration.rb
|
154
|
+
- lib/gossiper/engine.rb
|
155
|
+
- lib/gossiper/email_config.rb
|
119
156
|
- lib/gossiper/version.rb
|
157
|
+
- lib/gossiper/mailer.rb
|
158
|
+
- lib/gossiper/notification_decorator.rb
|
159
|
+
- lib/tasks/gossiper_tasks.rake
|
160
|
+
- lib/generators/gossiper/install/templates/locale.en.yml
|
161
|
+
- lib/generators/gossiper/install/templates/initializer.rb
|
162
|
+
- lib/generators/gossiper/install/install_generator.rb
|
163
|
+
- lib/generators/gossiper/install/USAGE
|
164
|
+
- lib/generators/gossiper/notification_type/notification_type_generator.rb
|
165
|
+
- lib/generators/gossiper/notification_type/templates/notification_type.rb
|
166
|
+
- lib/generators/gossiper/notification_type/templates/notification_type_test.rb
|
167
|
+
- lib/generators/gossiper/notification_type/templates/notification_type_template.rb
|
168
|
+
- lib/generators/gossiper/notification_type/templates/notification_type_spec.rb
|
169
|
+
- lib/generators/gossiper/notification_type/USAGE
|
120
170
|
- MIT-LICENSE
|
121
171
|
- Rakefile
|
122
172
|
homepage: https://github.com/mjacobus/gossiper
|
@@ -139,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
189
|
version: '0'
|
140
190
|
requirements: []
|
141
191
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
192
|
+
rubygems_version: 2.1.11
|
143
193
|
signing_key:
|
144
194
|
specification_version: 4
|
145
195
|
summary: It eases the creation of messages for the users
|