tomify 0.1.5 → 0.1.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/public/users/edit.coffee +3 -3
- data/app/assets/javascripts/tomify/dynamic/react/components/public/users/new.coffee +1 -1
- data/app/controllers/tomify/api/public/users_controller.rb +26 -16
- data/app/controllers/tomify/concerns/api/helpers.rb +8 -4
- data/app/controllers/tomify/concerns/default/env_helper.rb +1 -1
- data/app/models/tomify/concerns/page.rb +4 -0
- data/app/models/tomify/concerns/user.rb +14 -0
- data/app/models/tomify_record.rb +3 -1
- data/lib/tomify.rb +1 -0
- data/lib/tomify/markdown.rb +14 -0
- data/lib/tomify/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac53de7c87e8d2e4b64ca429b225deea891a650a
|
4
|
+
data.tar.gz: b871e83c8c4af470f0cad696d70ee83935f8a69f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bfbfdf6d25a6cd4738f1239699268dbeabc24b8e190e63016496c2c6cc9d7eede3d82a5b2402aae33ac597b28152ebe328fb295e5b14bc96c053644e3de894c
|
7
|
+
data.tar.gz: 14244aa1726f72017698854f29868554be1100aa4542bf0c752a14f8fe8f70f5ff0777f916db085c185b4a6ad7c47601158b39a724cfa2e18209dce17a81871b
|
@@ -1,7 +1,7 @@
|
|
1
1
|
form = new Form
|
2
|
-
form.add "email", "email"
|
3
2
|
form.add "first_name", "text"
|
4
3
|
form.add "last_name", "text"
|
4
|
+
form.add "email", "email"
|
5
5
|
form.add "password", "password"
|
6
6
|
form.add "password_confirmation", "password"
|
7
7
|
|
@@ -18,7 +18,7 @@ Component.create "Public.Users.Edit",
|
|
18
18
|
@form.setDefaultValues()
|
19
19
|
modelUpdate: (response) ->
|
20
20
|
message type: response.type, text: response.message
|
21
|
-
Store.find("User").merge
|
21
|
+
Store.find("User").merge response.data if response.type == "success"
|
22
22
|
submit: (e) ->
|
23
23
|
e.preventDefault()
|
24
24
|
if @form.changes.empty()
|
@@ -32,7 +32,7 @@ Component.create "Public.Users.Edit",
|
|
32
32
|
destroy: (e) ->
|
33
33
|
e.preventDefault()
|
34
34
|
Model.find("Public.User").destroy().then (response) ->
|
35
|
-
return redirect response.redirect if response.
|
35
|
+
return redirect response.redirect if response.message == "Profile Deleted"
|
36
36
|
message type: response.type, text: response.message
|
37
37
|
false
|
38
38
|
render: ->
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Model.create "Public.User", path: "user"
|
2
2
|
|
3
3
|
form = new Form
|
4
|
-
form.add "email", "email"
|
5
4
|
form.add "first_name", "text"
|
6
5
|
form.add "last_name", "text"
|
6
|
+
form.add "email", "email"
|
7
7
|
form.add "password", "password"
|
8
8
|
form.add "password_confirmation", "password"
|
9
9
|
|
@@ -1,38 +1,48 @@
|
|
1
1
|
class Tomify::Api::Public::UsersController < Tomify.controllers.public_api
|
2
2
|
before_action :require_user!, only: [:show, :update]
|
3
|
-
before_action :set_record, only: [:show, :update, :destroy]
|
4
3
|
before_action :not_found, only: :create, unless: "setting(:allow_signup)"
|
5
4
|
|
6
5
|
def create
|
7
6
|
session[:current_user_id] = Tomify.models.user.create!(record_params).id
|
8
|
-
|
7
|
+
create_activity
|
9
8
|
render json: { type: :success }, success: "Welcome #{current_user.name}!"
|
10
9
|
rescue ActiveRecord::RecordInvalid => e
|
11
10
|
render json: { type: :warning, message: e.record.errors.full_messages.join(", ") }
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
render json: { type: :success, message: "Profile Updated" }
|
18
|
-
rescue ActiveRecord::RecordInvalid => e
|
19
|
-
render json: { type: :warning, message: e.record.errors.full_messages.join(", ") }
|
13
|
+
private
|
14
|
+
def create_activity
|
15
|
+
record.activities.create(action: action_name, controller: controller_name)
|
20
16
|
end
|
21
17
|
|
22
|
-
def
|
18
|
+
def destroy_record
|
23
19
|
flash[:danger] = "Goodbye #{current_user.name}"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
create_activity
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_record
|
25
|
+
@record = current_user
|
26
|
+
end
|
27
|
+
|
28
|
+
def model_name
|
29
|
+
@model_name ||= "Profile"
|
30
|
+
end
|
31
|
+
|
32
|
+
def model_param
|
33
|
+
@model_param ||= "user"
|
28
34
|
end
|
29
35
|
|
30
|
-
private
|
31
36
|
def permitted_attributes
|
32
37
|
[:email, :first_name, :last_name, :password, :password_confirmation]
|
33
38
|
end
|
34
39
|
|
35
|
-
def
|
36
|
-
|
40
|
+
def serializable_options
|
41
|
+
User.env_serializable_options
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_record
|
45
|
+
super
|
46
|
+
create_activity
|
37
47
|
end
|
38
48
|
end
|
@@ -28,16 +28,20 @@ module Tomify::Concerns::Api::Helpers
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def model
|
31
|
-
@model ||=
|
32
|
-
@model ||= "Tomify::#{
|
31
|
+
@model ||= model_class.constantize rescue nil
|
32
|
+
@model ||= "Tomify::#{model_class}".constantize
|
33
|
+
end
|
34
|
+
|
35
|
+
def model_class
|
36
|
+
@model_class ||= controller_name.classify
|
33
37
|
end
|
34
38
|
|
35
39
|
def model_name
|
36
|
-
@model_name ||=
|
40
|
+
@model_name ||= model_class.split("::").first.titleize
|
37
41
|
end
|
38
42
|
|
39
43
|
def model_param
|
40
|
-
@model_param ||=
|
44
|
+
@model_param ||= model_name.underscore
|
41
45
|
end
|
42
46
|
|
43
47
|
def record
|
@@ -69,6 +69,10 @@ module Tomify::Concerns::Page
|
|
69
69
|
as_json(self.class.env_serializable_options)
|
70
70
|
end
|
71
71
|
|
72
|
+
def markdown_options
|
73
|
+
{ replace: as_json(methods: [:cover_image_url, :share_image_url]) }
|
74
|
+
end
|
75
|
+
|
72
76
|
private
|
73
77
|
def parent_valid?
|
74
78
|
errors.add(:parent_id) if parent && parent.id == id
|
@@ -21,6 +21,20 @@ module Tomify::Concerns::User
|
|
21
21
|
scope :admin, -> { where(admin: true) }
|
22
22
|
end
|
23
23
|
|
24
|
+
class_methods do
|
25
|
+
def env_serializable_options
|
26
|
+
{ methods: [:name] }
|
27
|
+
end
|
28
|
+
|
29
|
+
def for_env
|
30
|
+
all.as_json(env_serializable_options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def for_env
|
35
|
+
as_json(self.class.env_serializable_options)
|
36
|
+
end
|
37
|
+
|
24
38
|
def name
|
25
39
|
"#{first_name} #{last_name}"
|
26
40
|
end
|
data/app/models/tomify_record.rb
CHANGED
@@ -5,7 +5,9 @@ class TomifyRecord < ActiveRecord::Base
|
|
5
5
|
attrs.each do |attr|
|
6
6
|
define_method("#{attr}_to_html") do
|
7
7
|
Rails.cache.fetch("#{self.class.name.downcase}-#{id}-#{attr}") do
|
8
|
-
|
8
|
+
options = { autolink: true, tables: true }
|
9
|
+
options.merge!(self.markdown_options) if self.try(:markdown_options)
|
10
|
+
markdown = Redcarpet::Markdown.new(Tomify::Markdown::HTML, options)
|
9
11
|
markdown.render(self[attr] || "").html_safe
|
10
12
|
end
|
11
13
|
end
|
data/lib/tomify.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Tomify
|
2
|
+
module Markdown
|
3
|
+
class HTML < Redcarpet::Render::HTML
|
4
|
+
def preprocess(text)
|
5
|
+
text = find_and_replace(text) if @options[:replace]
|
6
|
+
text
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_and_replace(text)
|
10
|
+
text.gsub!(/!!\w+!!/) { |t| @options[:replace][t[2...-2]] }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
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.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-09-
|
11
|
+
date: 2017-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -435,6 +435,7 @@ files:
|
|
435
435
|
- lib/tomify.rb
|
436
436
|
- lib/tomify/constantly.rb
|
437
437
|
- lib/tomify/engine.rb
|
438
|
+
- lib/tomify/markdown.rb
|
438
439
|
- lib/tomify/version.rb
|
439
440
|
- vendor/tomify/development/react.js
|
440
441
|
- vendor/tomify/production/react.js
|