tomify 0.1.2 → 0.1.3
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/global.coffee +4 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/messages.coffee +5 -2
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/public_navbar.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/public/subscription.coffee +23 -14
- data/app/assets/javascripts/tomify/dynamic/react/components/public/users/edit.coffee +3 -1
- data/app/controllers/tomify/api/public/subscriptions_controller.rb +17 -4
- data/app/controllers/tomify/concerns/api/helpers.rb +2 -2
- data/app/controllers/tomify/concerns/api/json.rb +1 -3
- data/app/controllers/tomify/concerns/default/navbar_helper.rb +1 -1
- data/config/routes.rb +2 -1
- data/lib/tomify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34bf7184118f201d83d1ef89b98057bb1d41f53e
|
4
|
+
data.tar.gz: ac949b2ec8b51179601e9ee09ae94902d41c590d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3638b5741f85d2218f22ffcf61b52d4a211c2140e9e0623d3c104af6fcb780b4a4b8f0161678d227b3745bffece49b36c4a9eaf47efb0a9cd48f09fffdc212ea
|
7
|
+
data.tar.gz: c2c8fb0eb2a8dfc5046aa1f74fefa24bf3b2ecfc52027fb9083656c4257fb8f709dfdc1367fe2822f5ce964ed268d0701e117d0d857713fce7ef01fdb9ce5d44
|
@@ -25,7 +25,9 @@ $ ->
|
|
25
25
|
Store.find("Params").set params
|
26
26
|
Store.find("Env").set window.env
|
27
27
|
|
28
|
-
@message = (message)
|
28
|
+
@message = (message) =>
|
29
|
+
message.id ?= @uuid()
|
30
|
+
Store.find("Messages").push message
|
29
31
|
@redirect = (path) -> location.assign path || "/"
|
30
32
|
@setting = (name) ->
|
31
33
|
setting = Store.find("Settings").get().find (setting) -> setting.name == name
|
@@ -35,3 +37,4 @@ $ ->
|
|
35
37
|
page ?= { path: path ? template }
|
36
38
|
if page.root then "/" else "/#{page.path}"
|
37
39
|
@addPlugin = (plugin) -> Store.find("Plugins").push plugin
|
40
|
+
@uuid = -> Math.random().toString(36).substr(2, 9)
|
@@ -2,9 +2,12 @@ Component.create "Layout.Messages",
|
|
2
2
|
followStores: ["messages"]
|
3
3
|
componentWillInitialize: ->
|
4
4
|
@store = Store.create "Messages", window.env.messages
|
5
|
-
@follow @store.on "push",
|
5
|
+
@follow @store.on "push", (message) =>
|
6
|
+
$("body").scrollTop(0)
|
7
|
+
setTimeout @remove.bind(null, message), 5000
|
6
8
|
remove: (i, e) ->
|
7
|
-
e.preventDefault()
|
9
|
+
e && e.preventDefault()
|
10
|
+
i = @store.get().map((m) -> m.id).indexOf(i.id) if i?.id
|
8
11
|
@store.remove(i)
|
9
12
|
false
|
10
13
|
render: ->
|
@@ -31,7 +31,7 @@ Component.create "Layout.PublicNavbar",
|
|
31
31
|
if @state.user.id
|
32
32
|
@link(name: "Profile", url: "/profile")
|
33
33
|
else
|
34
|
-
@link(name: "Login", url: "/session")
|
34
|
+
@link(name: setting("login_text") || "Login", url: "/session")
|
35
35
|
}
|
36
36
|
{for page in @state.pages
|
37
37
|
if page.children[0]
|
@@ -1,29 +1,38 @@
|
|
1
|
-
Model.create "Public.Subscription", path: "subscription"
|
2
|
-
|
3
1
|
Component.create "Public.Subscription",
|
4
|
-
getInitialState: -> { email: Store.find("Params").get("email") }
|
2
|
+
getInitialState: -> { subscription: { active: true, email: Store.find("Params").get("email") }}
|
5
3
|
componentWillInitialize: ->
|
6
|
-
@model = Model.
|
4
|
+
@model = Model.findOrCreate "Public.Subscription"
|
7
5
|
@store = Store.findOrCreate "Public.Subscription"
|
8
|
-
@follow @model.on "
|
9
|
-
|
10
|
-
|
11
|
-
@
|
6
|
+
@follow @model.on "edit", @modelUpdate
|
7
|
+
@follow @model.on "create", @modelUpdate
|
8
|
+
@follow @model.on "destroy", @modelUpdate
|
9
|
+
@model.edit(Store.find("Params").get "email")
|
10
|
+
modelUpdate: (response) ->
|
11
|
+
message type: response.type, text: response.message if response.message
|
12
|
+
@setState subscription: response.data if response.data
|
13
|
+
create: (e) ->
|
14
|
+
e.preventDefault()
|
15
|
+
@model.create email: @state.subscription.email
|
12
16
|
destroy: (e) ->
|
13
17
|
e.preventDefault()
|
14
|
-
@model.destroy
|
18
|
+
@model.destroy email: @state.subscription.email
|
15
19
|
render: ->
|
16
20
|
<div className="row text-center">
|
17
21
|
<div className="dynamic-sm">
|
18
|
-
<h3>
|
19
|
-
{if @state.
|
20
|
-
<
|
22
|
+
<h3>Subscription</h3>
|
23
|
+
{if @state.subscription.active
|
24
|
+
<div>
|
25
|
+
<p>
|
26
|
+
<strong>{@state.subscription.email}</strong> will be no longer recieve the majority of emails from {setting "name"}.
|
27
|
+
</p>
|
28
|
+
<a href="#" onClick={@destroy} className="btn btn-danger" data-confirm="Are you sure?">Unsubscribe</a>
|
29
|
+
</div>
|
21
30
|
else
|
22
31
|
<div>
|
23
32
|
<p>
|
24
|
-
|
33
|
+
<strong>{@state.subscription.email}</strong> will be subscribed to the emails from {setting "name"}.
|
25
34
|
</p>
|
26
|
-
<a href="#" onClick={@
|
35
|
+
<a href="#" onClick={@create} className="btn btn-primary">Subscribe</a>
|
27
36
|
</div>
|
28
37
|
}
|
29
38
|
</div>
|
@@ -48,7 +48,9 @@ Component.create "Public.Users.Edit",
|
|
48
48
|
</div>
|
49
49
|
<div className="form-group">
|
50
50
|
<small>
|
51
|
-
<a href="#
|
51
|
+
<a href="#{path 'subscription'}?email=#{@form.record.get 'email'}">Email Subscription</a>
|
52
|
+
<span> | </span>
|
53
|
+
<a href="#" onClick={@destroy} data-confirm="Are you sure you want to permanently delete your account?">Delete Account</a>
|
52
54
|
</small>
|
53
55
|
</div>
|
54
56
|
</form>
|
@@ -1,11 +1,24 @@
|
|
1
1
|
class Tomify::Api::Public::SubscriptionsController < Tomify.controllers.public_api
|
2
|
+
def create
|
3
|
+
record.activities.create(action: action_name, controller: controller_name)
|
4
|
+
if record.update(active: true)
|
5
|
+
render json: { type: :success, data: data, message: "You have been subscribed to #{setting(:name)}" }
|
6
|
+
else
|
7
|
+
render json: { type: :warning, message: "There was a problem subscribing you to #{setting(:name)}" }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
2
11
|
def destroy
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
render json: { type: :success, message: "You have been unsubscribed from #{setting(:name)}" }
|
12
|
+
record.activities.create(action: action_name, controller: controller_name)
|
13
|
+
if record.update(active: false)
|
14
|
+
render json: { type: :success, data: data, message: "You have been unsubscribed from #{setting(:name)}" }
|
7
15
|
else
|
8
16
|
render json: { type: :warning, message: "There was a problem unsubscribing you from #{setting(:name)}" }
|
9
17
|
end
|
10
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def find_record
|
22
|
+
@record ||= Tomify.models.subscription.find_or_create_by(email: params[:email] || params[:subscription][:email])
|
23
|
+
end
|
11
24
|
end
|
@@ -33,19 +33,17 @@ module Tomify::Concerns::Api::JSON
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def update
|
36
|
-
find_record
|
37
36
|
update_record
|
38
37
|
render json: { type: :success, data: data, message: "#{model_name} Updated" }
|
39
38
|
end
|
40
39
|
|
41
40
|
def destroy
|
42
|
-
find_record
|
43
41
|
destroy_record
|
44
42
|
render json: { type: :danger, message: "#{model_name} Deleted" }
|
45
43
|
end
|
46
44
|
|
47
45
|
private
|
48
46
|
def data
|
49
|
-
@data ||= (record || records).as_json(serializable_options)
|
47
|
+
@data ||= (@record || @records).as_json(serializable_options)
|
50
48
|
end
|
51
49
|
end
|
data/config/routes.rb
CHANGED
@@ -34,7 +34,8 @@ Rails.application.routes.draw do
|
|
34
34
|
resource :user, only: [:create, :show, :update, :destroy]
|
35
35
|
resource :session, only: [:create, :destroy]
|
36
36
|
resource :password, only: :create
|
37
|
-
resource :
|
37
|
+
resource :subscriptions, only: [:create, :destroy]
|
38
|
+
resources :subscriptions, only: :show, param: :email, constraints: { email: /[^\/]+/ }
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
data/lib/tomify/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|