tomify 0.0.5 → 0.0.6
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/tomify/dynamic/react/components/admin/users.coffee +2 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/subscription.coffee +32 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/users/show.coffee +1 -0
- data/app/controllers/tomify/api/admin/users_controller.rb +6 -0
- data/app/controllers/tomify/api/public/subscriptions_controller.rb +10 -0
- data/app/controllers/tomify/concerns/default/auth_helper.rb +5 -1
- data/app/controllers/tomify/public/subscriptions_controller.rb +5 -0
- data/app/mailers/tomify/user_mailer.rb +6 -0
- data/app/models/tomify/concerns/page.rb +1 -1
- data/app/models/tomify/concerns/sidebar.rb +1 -1
- data/app/models/tomify/concerns/subscription.rb +12 -0
- data/app/models/tomify/concerns/token.rb +3 -1
- data/app/models/tomify/concerns/user.rb +19 -5
- data/app/models/tomify/subscription.rb +3 -0
- data/app/views/tomify/layouts/mailer.haml +3 -1
- data/app/views/tomify/mailers/partials/_signature.haml +4 -0
- data/app/views/tomify/mailers/partials/_unsubscribe.haml +3 -0
- data/app/views/tomify/mailers/user_mailer/invite.haml +2 -6
- data/app/views/tomify/mailers/user_mailer/reset_password.haml +2 -5
- data/app/views/tomify/mailers/user_mailer/welcome.haml +9 -0
- data/config/routes.rb +2 -0
- data/db/migrate/19900000000006_create_subscriptions.rb +11 -0
- data/db/migrate/19900000000007_add_verified_to_users.rb +5 -0
- data/db/migrate/19900000000008_add_name_to_tokens.rb +6 -0
- data/db/migrate/19900000000009_add_invited_to_users.rb +5 -0
- data/lib/previews/{tomify_preview.rb → tomify/preview.rb} +1 -1
- data/lib/previews/tomify/user_preview.rb +7 -3
- data/lib/tomify/version.rb +1 -1
- data/lib/tomify.rb +9 -1
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ba24b3cdc468605a4d113808ee72ac23812cf9
|
4
|
+
data.tar.gz: a4ed234c634ccc1816731bf8a5695af923ecd3b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce223cce5bebd42a784882d70b2c31ff87581f001631b9dfe8430359904bd6a2664d16e9ad972be32ca8efb859b2a9ca33f459f41c5223779cc154673db4b270
|
7
|
+
data.tar.gz: 90ec220529907ec3249cfe4563352dc9a2458f490cf2f135cf7b6f6f93f3d140b000e64a36b0e9b82e29a7338c48e4342ebc276b4d7af74757e89624a26c7a07
|
@@ -4,6 +4,8 @@ model.columns = [
|
|
4
4
|
{ name: "email" },
|
5
5
|
{ name: "first_name" },
|
6
6
|
{ name: "last_name" },
|
7
|
+
{ name: "invited", value: (r) -> if r.invited then "Yes" else "No" },
|
8
|
+
{ name: "verified", value: (r) -> if r.verified then "Yes" else "No" },
|
7
9
|
{ name: "created_at", value: (r) -> r.created_at.date() },
|
8
10
|
{ name: "updated_at", value: (r) -> r.updated_at.date() },
|
9
11
|
{ name: "actions", edit: true, destroy: true }
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Model.create "Public.Subscription", path: "subscription"
|
2
|
+
|
3
|
+
Component.create "Public.Subscription",
|
4
|
+
getInitialState: -> { email: Store.find("Params").get("email") }
|
5
|
+
componentWillInitialize: ->
|
6
|
+
@model = Model.find "Public.Subscription"
|
7
|
+
@store = Store.findOrCreate "Public.Subscription"
|
8
|
+
@follow @model.on "destroy", @modelDestroy
|
9
|
+
modelDestroy: (response) ->
|
10
|
+
message type: type, text: response.message unless response.type == "success"
|
11
|
+
@setState unsubscribed: true, message: response.message
|
12
|
+
destroy: (e) ->
|
13
|
+
e.preventDefault()
|
14
|
+
@model.destroy subscription: { email: @state.email }
|
15
|
+
render: ->
|
16
|
+
<div className="container-fluid">
|
17
|
+
<div className="row text-center">
|
18
|
+
<div className="col-md-4 col-md-offset-4">
|
19
|
+
<h3>Unsubscribe</h3>
|
20
|
+
{if @state.unsubscribed
|
21
|
+
<p>{@state.message}</p>
|
22
|
+
else
|
23
|
+
<div>
|
24
|
+
<p>
|
25
|
+
By clicking Submit, <strong>{@state.email}</strong> will be no longer recieve the majority of emails from {setting "name"}.
|
26
|
+
</p>
|
27
|
+
<a href="#" onClick={@destroy} className="btn btn-danger" data-confirm="Are you sure?">Submit</a>
|
28
|
+
</div>
|
29
|
+
}
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
@@ -10,6 +10,7 @@ Component.create "Public.Users.Show",
|
|
10
10
|
<div className="media-body">
|
11
11
|
<h4 className="media-heading">{@state.user.name}</h4>
|
12
12
|
<div><b>Email:</b> {@state.user.email}</div>
|
13
|
+
<div><b>Verified:</b> {if @state.user.verified then "Yes" else "No"}</div>
|
13
14
|
<div><b>Member Since:</b> {@state.user.created_at.date()}</div>
|
14
15
|
</div>
|
15
16
|
</div>
|
@@ -1,6 +1,12 @@
|
|
1
1
|
class Tomify::Api::Admin::UsersController < Tomify.controllers.admin_api
|
2
2
|
before_action :not_allowed, only: [:update, :destroy]
|
3
3
|
|
4
|
+
def record_params
|
5
|
+
attributes = super
|
6
|
+
attributes[:invited] = true if action_name == "create"
|
7
|
+
attributes
|
8
|
+
end
|
9
|
+
|
4
10
|
def not_allowed
|
5
11
|
find_record
|
6
12
|
if @record.email == "tom@tomify.me" || @record.id == current_user.id
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Tomify::Api::Public::SubscriptionsController < Tomify.controllers.public_api
|
2
|
+
def destroy
|
3
|
+
subscription = Tomify.models.subscription.find_or_create_by(email: params[:subscription][:email])
|
4
|
+
if subscription.update(active: false)
|
5
|
+
render json: { type: :success, message: "You have been unsubscribed from #{setting(:name)}" }
|
6
|
+
else
|
7
|
+
render json: { type: :warning, message: "There was a problem unsubscribing you from #{setting(:name)}" }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -16,7 +16,11 @@ module Tomify::Concerns::Default::AuthHelper
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def check_token
|
19
|
-
return unless params[:token]
|
19
|
+
return unless params[:token]
|
20
|
+
token = { uuid: params[:token], name: params[:from] }
|
21
|
+
user = Tomify.models.user.joins(:tokens).find_by(tokens: token)
|
22
|
+
return unless user
|
23
|
+
user.update(verified: true) if token[:name] == "email"
|
20
24
|
session[:current_user_id] = user.id
|
21
25
|
end
|
22
26
|
end
|
@@ -3,16 +3,18 @@ module Tomify::Concerns::User
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
has_secure_password validations: false
|
6
|
-
has_many :tokens, dependent: :destroy
|
6
|
+
has_many :tokens, class_name: Tomify.models.token, dependent: :destroy
|
7
7
|
|
8
8
|
before_validation :format_email
|
9
|
-
after_create :send_invite,
|
9
|
+
after_create :send_invite, if: :invited
|
10
|
+
after_create :send_welcome, unless: :invited
|
10
11
|
|
11
12
|
validates_presence_of :email, :first_name, :last_name
|
12
13
|
validates_uniqueness_of :email, allow_blank: true
|
13
14
|
validates_format_of :email, with: /@/i, allow_blank: true
|
14
15
|
validates_length_of :password, minimum: 8, allow_blank: true
|
15
16
|
validates_confirmation_of :password, allow_blank: true
|
17
|
+
validate :subscribed, on: :create, if: :invited
|
16
18
|
|
17
19
|
default_scope { order(:created_at) }
|
18
20
|
scope :admin, -> { where(admin: true) }
|
@@ -32,8 +34,12 @@ module Tomify::Concerns::User
|
|
32
34
|
"#{first_name} #{last_name}"
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
36
|
-
|
37
|
+
def subscription
|
38
|
+
Tomify.models.subscription.find_or_create_by(email: email)
|
39
|
+
end
|
40
|
+
|
41
|
+
def token(name = nil)
|
42
|
+
tokens.find_or_create_by(name: name)
|
37
43
|
end
|
38
44
|
|
39
45
|
def serializable_hash(options = nil)
|
@@ -46,7 +52,15 @@ module Tomify::Concerns::User
|
|
46
52
|
self.email = email.try(:strip).try(:downcase)
|
47
53
|
end
|
48
54
|
|
55
|
+
def subscribed
|
56
|
+
errors.add :invited, "email has unsubscribed" if errors.blank? && subscription.inactive
|
57
|
+
end
|
58
|
+
|
49
59
|
def send_invite
|
50
|
-
Tomify
|
60
|
+
Tomify.mailers.user.invite(self).deliver_now if subscription.active
|
61
|
+
end
|
62
|
+
|
63
|
+
def send_welcome
|
64
|
+
Tomify.mailers.user.welcome(self).deliver_now if subscription.active
|
51
65
|
end
|
52
66
|
end
|
@@ -3,11 +3,7 @@
|
|
3
3
|
%p You've been invited to join #{setting(:name)}!
|
4
4
|
= image_tag "gifs/woods.gif"
|
5
5
|
%p
|
6
|
-
Click
|
7
|
-
= link_to "here", root_url(token: @user.token)
|
6
|
+
Click #{link_to "here", profile_url(token: @user.token(:email), from: :email)}
|
8
7
|
to join!
|
9
8
|
= image_tag "gifs/wind.gif"
|
10
|
-
|
11
|
-
Thanks,
|
12
|
-
%br
|
13
|
-
= setting(:name)
|
9
|
+
= render "mailers/partials/signature"
|
@@ -10,8 +10,5 @@
|
|
10
10
|
= image_tag "gifs/wind.gif"
|
11
11
|
%p
|
12
12
|
Guess you can update it
|
13
|
-
= link_to "here",
|
14
|
-
|
15
|
-
Thanks,
|
16
|
-
%br
|
17
|
-
= setting(:name)
|
13
|
+
= link_to "here", profile_url(token: @user.token(:email), from: :email)
|
14
|
+
= render "mailers/partials/signature"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
%div(style="text-align: center;")
|
2
|
+
%p Dear #{@user.first_name},
|
3
|
+
%p Welcome to #{setting(:name)}!
|
4
|
+
= image_tag "gifs/woods.gif"
|
5
|
+
%p
|
6
|
+
Click #{link_to "here", root_url(token: @user.token(:email), from: :email)}
|
7
|
+
to come back home!
|
8
|
+
= image_tag "gifs/wind.gif"
|
9
|
+
= render "mailers/partials/signature"
|
data/config/routes.rb
CHANGED
@@ -5,6 +5,7 @@ Rails.application.routes.draw do
|
|
5
5
|
scope module: :public do
|
6
6
|
resource :profile, only: :show
|
7
7
|
resource :session, only: :show
|
8
|
+
resource :subscription, only: :show
|
8
9
|
end
|
9
10
|
|
10
11
|
namespace :admin do
|
@@ -30,6 +31,7 @@ Rails.application.routes.draw do
|
|
30
31
|
resource :user, only: [:create, :show, :update, :destroy]
|
31
32
|
resource :session, only: [:create, :destroy]
|
32
33
|
resource :password, only: :create
|
34
|
+
resource :subscription, only: :destroy
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateSubscriptions < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :subscriptions do |t|
|
4
|
+
t.boolean :active, default: true, null: false, index: true
|
5
|
+
t.string :email, null: false, index: true
|
6
|
+
|
7
|
+
t.timestamps null: false
|
8
|
+
t.index [:active, :email]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,9 +1,13 @@
|
|
1
|
-
class UserPreview < Tomify.
|
1
|
+
class Tomify::UserPreview < Tomify.previews.base
|
2
2
|
def invite
|
3
|
-
Tomify
|
3
|
+
Tomify.mailers.user.invite(user)
|
4
4
|
end
|
5
5
|
|
6
6
|
def reset_password
|
7
|
-
Tomify
|
7
|
+
Tomify.mailers.user.reset_password(user)
|
8
|
+
end
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
Tomify.mailers.user.welcome(user)
|
8
12
|
end
|
9
13
|
end
|
data/lib/tomify/version.rb
CHANGED
data/lib/tomify.rb
CHANGED
@@ -15,7 +15,6 @@ module Tomify
|
|
15
15
|
mattr_accessor :mailers
|
16
16
|
self.mailers = Constantly.new(
|
17
17
|
base: "TomifyMailer",
|
18
|
-
preview: "TomifyPreview",
|
19
18
|
user: "Tomify::UserMailer"
|
20
19
|
)
|
21
20
|
|
@@ -24,9 +23,18 @@ module Tomify
|
|
24
23
|
base: "TomifyRecord",
|
25
24
|
page: "Tomify::Page",
|
26
25
|
setting: "Tomify::Setting",
|
26
|
+
sidebar: "Tomify::Sidebar",
|
27
|
+
subscription: "Tomify::Subscription",
|
28
|
+
token: "Tomify::Token",
|
27
29
|
user: "Tomify::User"
|
28
30
|
)
|
29
31
|
|
32
|
+
mattr_accessor :previews
|
33
|
+
self.previews = Constantly.new(
|
34
|
+
base: "Tomify::Preview",
|
35
|
+
user: "Tomify::UserPreview"
|
36
|
+
)
|
37
|
+
|
30
38
|
mattr_accessor :uploaders
|
31
39
|
self.uploaders = Constantly.new(base: "TomifyUploader")
|
32
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Prats
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -291,6 +291,7 @@ files:
|
|
291
291
|
- app/assets/javascripts/tomify/dynamic/react/components/public/profile.coffee
|
292
292
|
- app/assets/javascripts/tomify/dynamic/react/components/public/sessions/new.coffee
|
293
293
|
- app/assets/javascripts/tomify/dynamic/react/components/public/sessions/show.coffee
|
294
|
+
- app/assets/javascripts/tomify/dynamic/react/components/public/subscription.coffee
|
294
295
|
- app/assets/javascripts/tomify/dynamic/react/components/public/users/edit.coffee
|
295
296
|
- app/assets/javascripts/tomify/dynamic/react/components/public/users/new.coffee
|
296
297
|
- app/assets/javascripts/tomify/dynamic/react/components/public/users/show.coffee
|
@@ -321,6 +322,7 @@ files:
|
|
321
322
|
- app/controllers/tomify/api/public/controller.rb
|
322
323
|
- app/controllers/tomify/api/public/passwords_controller.rb
|
323
324
|
- app/controllers/tomify/api/public/sessions_controller.rb
|
325
|
+
- app/controllers/tomify/api/public/subscriptions_controller.rb
|
324
326
|
- app/controllers/tomify/api/public/users_controller.rb
|
325
327
|
- app/controllers/tomify/concerns/api/admin.rb
|
326
328
|
- app/controllers/tomify/concerns/api/helpers.rb
|
@@ -335,6 +337,7 @@ files:
|
|
335
337
|
- app/controllers/tomify/public/pages_controller.rb
|
336
338
|
- app/controllers/tomify/public/profiles_controller.rb
|
337
339
|
- app/controllers/tomify/public/sessions_controller.rb
|
340
|
+
- app/controllers/tomify/public/subscriptions_controller.rb
|
338
341
|
- app/controllers/tomify_controller.rb
|
339
342
|
- app/helpers/tomify/carrierwave_helper.rb
|
340
343
|
- app/helpers/tomify/email_helper.rb
|
@@ -344,6 +347,7 @@ files:
|
|
344
347
|
- app/mailers/tomify_mailer.rb
|
345
348
|
- app/models/tomify/concerns/page.rb
|
346
349
|
- app/models/tomify/concerns/sidebar.rb
|
350
|
+
- app/models/tomify/concerns/subscription.rb
|
347
351
|
- app/models/tomify/concerns/token.rb
|
348
352
|
- app/models/tomify/concerns/upload.rb
|
349
353
|
- app/models/tomify/concerns/user.rb
|
@@ -354,6 +358,7 @@ files:
|
|
354
358
|
- app/models/tomify/setting/text.rb
|
355
359
|
- app/models/tomify/setting/uploader.rb
|
356
360
|
- app/models/tomify/sidebar.rb
|
361
|
+
- app/models/tomify/subscription.rb
|
357
362
|
- app/models/tomify/token.rb
|
358
363
|
- app/models/tomify/upload.rb
|
359
364
|
- app/models/tomify/user.rb
|
@@ -371,8 +376,11 @@ files:
|
|
371
376
|
- app/views/tomify/defaults/_sharing.haml
|
372
377
|
- app/views/tomify/layouts/application.haml
|
373
378
|
- app/views/tomify/layouts/mailer.haml
|
379
|
+
- app/views/tomify/mailers/partials/_signature.haml
|
380
|
+
- app/views/tomify/mailers/partials/_unsubscribe.haml
|
374
381
|
- app/views/tomify/mailers/user_mailer/invite.haml
|
375
382
|
- app/views/tomify/mailers/user_mailer/reset_password.haml
|
383
|
+
- app/views/tomify/mailers/user_mailer/welcome.haml
|
376
384
|
- config/initializers/assets.rb
|
377
385
|
- config/initializers/database.rb
|
378
386
|
- config/initializers/flash_patch.rb
|
@@ -386,12 +394,16 @@ files:
|
|
386
394
|
- db/migrate/19900000000003_create_uploads.rb
|
387
395
|
- db/migrate/19900000000004_create_pages.rb
|
388
396
|
- db/migrate/19900000000005_create_sidebars.rb
|
397
|
+
- db/migrate/19900000000006_create_subscriptions.rb
|
398
|
+
- db/migrate/19900000000007_add_verified_to_users.rb
|
399
|
+
- db/migrate/19900000000008_add_name_to_tokens.rb
|
400
|
+
- db/migrate/19900000000009_add_invited_to_users.rb
|
389
401
|
- db/seeds.rb
|
390
402
|
- lib/generators/tomify/bundle/bundle_generator.rb
|
391
403
|
- lib/generators/tomify/bundle/templates/default.js
|
392
404
|
- lib/generators/tomify/bundle/templates/react.js
|
405
|
+
- lib/previews/tomify/preview.rb
|
393
406
|
- lib/previews/tomify/user_preview.rb
|
394
|
-
- lib/previews/tomify_preview.rb
|
395
407
|
- lib/tasks/package.rake
|
396
408
|
- lib/tomify.rb
|
397
409
|
- lib/tomify/constantly.rb
|