my_forum 0.0.1.beta27 → 0.0.1.beta28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/my_forum/users.css.scss +3 -0
- data/app/controllers/my_forum/users_controller.rb +38 -0
- data/app/helpers/my_forum/users_helper.rb +1 -1
- data/app/models/my_forum/attachment.rb +1 -1
- data/app/models/my_forum/avatar.rb +5 -0
- data/app/models/my_forum/user.rb +1 -0
- data/app/views/my_forum/shared/_upload_photo.haml +44 -0
- data/app/views/my_forum/topics/_quick_answer.haml +1 -62
- data/app/views/my_forum/topics/new.haml +28 -2
- data/app/views/my_forum/users/edit.haml +11 -4
- data/config/locales/ru.yml +4 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +5 -0
- data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +5 -0
- data/lib/my_forum/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e9c4dc6e1fd0e4d60d78d975bec3ed7a6a27946
|
4
|
+
data.tar.gz: c45c52e592f918069fa6879d4a391da75a75e0ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 829a37be49a60d7a44676e195ab285cb8004c926d208c003d1cb010cce148ecd6866173c16dc11855afd03ddb63e0c833cca5177fdfc0deed6a22e6ce42e5db8
|
7
|
+
data.tar.gz: d3cad5b3c19c147d2e48d61279a99fcf8120b2e625eb940d605daa21c2328e7f67e47d836263a45f5d51e170c27371a5398e8178cb02a946983da022c3311417
|
@@ -77,8 +77,23 @@ module MyForum
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
def avatar_update
|
81
|
+
if params[:user][:avatar]
|
82
|
+
avatar = upload_avatar(params[:user][:avatar])
|
83
|
+
current_user.update(avatar_url: File.join(Avatar::URL, current_user.id.to_s, avatar.file_name)) if avatar
|
84
|
+
elsif params[:user][:avatar_url]
|
85
|
+
current_user.update_columns(avatar_params)
|
86
|
+
end
|
87
|
+
|
88
|
+
redirect_to edit_user_path(current_user)
|
89
|
+
end
|
90
|
+
|
80
91
|
private
|
81
92
|
|
93
|
+
def avatar_params
|
94
|
+
params.require(:user).permit(:avatar_url)
|
95
|
+
end
|
96
|
+
|
82
97
|
def user_params
|
83
98
|
params.require(:user).permit(:login, :email, :password)
|
84
99
|
end
|
@@ -96,5 +111,28 @@ module MyForum
|
|
96
111
|
current_user.update_attributes(password: new_password)
|
97
112
|
end
|
98
113
|
|
114
|
+
def upload_avatar(avatar_param)
|
115
|
+
return false unless Avatar::ALLOWED_FILE_EXTENSIONS.include? File.extname(avatar_param.original_filename)
|
116
|
+
|
117
|
+
current_avatar = current_user.avatar
|
118
|
+
upload_path = File.join(Avatar::UPLOAD_PATH, current_user.id.to_s)
|
119
|
+
|
120
|
+
# Create dir of not exists
|
121
|
+
FileUtils::mkdir_p upload_path
|
122
|
+
|
123
|
+
File.open(File.join(upload_path, avatar_param.original_filename), 'wb') do |file|
|
124
|
+
file.write(avatar_param.read)
|
125
|
+
end
|
126
|
+
|
127
|
+
new_avatar = Avatar.create(user_id: current_user.id, file_name: avatar_param.original_filename)
|
128
|
+
|
129
|
+
if current_avatar and new_avatar
|
130
|
+
FileUtils.rm File.join(upload_path, current_avatar.file_name) rescue nil
|
131
|
+
current_avatar.destroy
|
132
|
+
end
|
133
|
+
|
134
|
+
new_avatar
|
135
|
+
end
|
136
|
+
|
99
137
|
end
|
100
138
|
end
|
@@ -8,7 +8,7 @@ module MyForum
|
|
8
8
|
|
9
9
|
# Display user avatar
|
10
10
|
def user_avatar(user)
|
11
|
-
return image_tag(user.
|
11
|
+
return image_tag(user.avatar_url, class: 'user-avatar') unless user.avatar_url.blank?
|
12
12
|
|
13
13
|
image_tag('blank_avatar.png', class: 'user-avatar')
|
14
14
|
end
|
data/app/models/my_forum/user.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
#add_photo.modal.fade
|
2
|
+
.modal-dialog
|
3
|
+
.modal-content
|
4
|
+
.modal-header
|
5
|
+
%button.close{ type: 'button', aria_label: 'Close', data: { dismiss: 'modal' } }
|
6
|
+
%span{ aria_hidden: "true" }
|
7
|
+
×
|
8
|
+
%h4.modal-title
|
9
|
+
= t('.add_new_photo')
|
10
|
+
.modal-body
|
11
|
+
%p= t('my_forum.attachments.allowed_extensions', ext: upload_allowed_extensions.join(', '))
|
12
|
+
= form_for MyForum::Attachment.new, url: attachments_path, multipart: true, remote: true do |f|
|
13
|
+
= f.file_field 'file[]', multiple: true, id: 'attachment_files'
|
14
|
+
|
15
|
+
#loaded-content
|
16
|
+
|
17
|
+
.modal-footer
|
18
|
+
%button.btn.btn-default{ type: 'button', aria_label: 'Close', data: { dismiss: 'modal' } }
|
19
|
+
Close
|
20
|
+
|
21
|
+
:coffee
|
22
|
+
$('#attachment_files').change ->
|
23
|
+
form_data = new FormData()
|
24
|
+
|
25
|
+
files_count = $('#attachment_files').prop('files').length
|
26
|
+
form_data.append('files[]', $('#attachment_files').prop('files')[c]) for c in [0...files_count]
|
27
|
+
|
28
|
+
$.ajax({
|
29
|
+
url: "#{attachments_path}"
|
30
|
+
dataType: 'html'
|
31
|
+
cache: false
|
32
|
+
contentType: false
|
33
|
+
processData: false
|
34
|
+
data: form_data
|
35
|
+
type: 'post',
|
36
|
+
success: (data, textStatus, jqXHR) ->
|
37
|
+
response = $.parseJSON(data)
|
38
|
+
bbcode_attachments = ''
|
39
|
+
bbcode_attachments += ('[attachment=' + id + '] \n') for id in response.attachments
|
40
|
+
$('##{textarea}').append(bbcode_attachments)
|
41
|
+
$('#loaded-content').html('#{t('my_forum.successfull_aploaded')}')
|
42
|
+
$('#add_photo').modal('hide')
|
43
|
+
$('#attachment_files').val('')
|
44
|
+
})
|
@@ -11,25 +11,10 @@
|
|
11
11
|
=link_to '#', class: 'btn btn-default btn-sm' do
|
12
12
|
%i{ class: 'fa fa-underline' }
|
13
13
|
|
14
|
-
-# %div.btn-group
|
15
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
16
|
-
-# %i{ class: 'fa fa-align-left' }
|
17
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
18
|
-
-# %i{ class: 'fa fa-align-center' }
|
19
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
20
|
-
-# %i{ class: 'fa fa-align-right' }
|
21
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
22
|
-
-# %i{ class: 'fa fa-align-justify' }
|
23
|
-
|
24
14
|
%div.btn-group
|
25
15
|
=link_to '#', class: 'btn btn-default btn-sm', data: { toggle: 'modal' } do
|
26
16
|
%i{ class: 'fa fa-camera-retro' }
|
27
17
|
|
28
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
29
|
-
-# %i{ class: 'fa fa-video-camera' }
|
30
|
-
-# =link_to '#', class: 'btn btn-default btn-sm' do
|
31
|
-
-# %i{ class: 'fa fa-link' }
|
32
|
-
|
33
18
|
%div.btn-group.smiles
|
34
19
|
- emoticons_list.each do |code, path|
|
35
20
|
=link_to '#', class: 'btn btn-default btn-sm smile-past' do
|
@@ -43,51 +28,5 @@
|
|
43
28
|
|
44
29
|
.pull-right
|
45
30
|
= form.submit t('.quick_answer'), class: 'btn btn-primary'
|
46
|
-
=# link_to t('.advanced_answer'), '#', class: 'btn btn-primary'
|
47
|
-
|
48
|
-
|
49
|
-
#add_photo.modal.fade
|
50
|
-
.modal-dialog
|
51
|
-
.modal-content
|
52
|
-
.modal-header
|
53
|
-
%button.close{ type: 'button', aria_label: 'Close', data: { dismiss: 'modal' } }
|
54
|
-
%span{ aria_hidden: "true" }
|
55
|
-
×
|
56
|
-
%h4.modal-title
|
57
|
-
= t('.add_new_photo')
|
58
|
-
.modal-body
|
59
|
-
%p= t('my_forum.attachments.allowed_extensions', ext: upload_allowed_extensions.join(', '))
|
60
|
-
= form_for MyForum::Attachment.new, url: attachments_path, multipart: true, remote: true do |f|
|
61
|
-
= f.file_field 'file[]', multiple: true, id: 'attachment_files'
|
62
|
-
|
63
|
-
#loaded-content
|
64
|
-
|
65
|
-
:coffee
|
66
|
-
$('#attachment_files').change ->
|
67
|
-
form_data = new FormData()
|
68
|
-
|
69
|
-
files_count = $('#attachment_files').prop('files').length
|
70
|
-
form_data.append('files[]', $('#attachment_files').prop('files')[c]) for c in [0...files_count]
|
71
|
-
|
72
|
-
$.ajax({
|
73
|
-
url: "#{attachments_path}"
|
74
|
-
dataType: 'html'
|
75
|
-
cache: false
|
76
|
-
contentType: false
|
77
|
-
processData: false
|
78
|
-
data: form_data
|
79
|
-
type: 'post',
|
80
|
-
success: (data, textStatus, jqXHR) ->
|
81
|
-
response = $.parseJSON(data)
|
82
|
-
bbcode_attachments = ''
|
83
|
-
bbcode_attachments += ('[attachment=' + id + '] \n') for id in response.attachments
|
84
|
-
$('#quick_answer_textarea').append(bbcode_attachments)
|
85
|
-
$('#loaded-content').html('#{t('my_forum.successfull_aploaded')}')
|
86
|
-
$('#add_photo').modal('hide')
|
87
|
-
$('#attachment_files').val('')
|
88
|
-
})
|
89
|
-
|
90
31
|
|
91
|
-
|
92
|
-
%button.btn.btn-default{ type: 'button', aria_label: 'Close', data: { dismiss: 'modal' } }
|
93
|
-
Close
|
32
|
+
= render partial: 'my_forum/shared/upload_photo', locals: { textarea: 'quick_answer_textarea' }
|
@@ -1,12 +1,38 @@
|
|
1
1
|
%h2= t('.create_new_topic_in', topic_name: @forum.name)
|
2
2
|
|
3
|
+
|
4
|
+
|
3
5
|
= form_for @topic, url: forum_topics_path, role: 'form' do |form|
|
4
6
|
.form-group= form.text_field :name, class: 'name form-control', placeholder: t('.name')
|
5
7
|
.form-group= form.text_field :description, class: 'description form-control', placeholder: t('.description')
|
6
8
|
|
7
9
|
%br
|
8
10
|
|
9
|
-
|
10
|
-
.
|
11
|
+
.row
|
12
|
+
.col-md-12
|
13
|
+
.text-editor-buttons{ data: { apply_to: 'post_text' } }
|
14
|
+
%div.btn-group
|
15
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
16
|
+
%i{ class: 'fa fa-bold' }
|
17
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
18
|
+
%i{ class: 'fa fa-italic' }
|
19
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
20
|
+
%i{ class: 'fa fa-strikethrough' }
|
21
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
22
|
+
%i{ class: 'fa fa-underline' }
|
23
|
+
|
24
|
+
%div.btn-group
|
25
|
+
=link_to '#', class: 'btn btn-default btn-sm', data: { toggle: 'modal' } do
|
26
|
+
%i{ class: 'fa fa-camera-retro' }
|
27
|
+
|
28
|
+
%div.btn-group.smiles
|
29
|
+
- emoticons_list.each do |code, path|
|
30
|
+
=link_to '#', class: 'btn btn-default btn-sm smile-past' do
|
31
|
+
%img{ src: path, class: 'smile', data: { code: code } }
|
32
|
+
|
33
|
+
= fields_for :post do |post_form|
|
34
|
+
.form-group= post_form.text_area :text, placeholder: t('.post_text'), class: 'form-control', rows: 10
|
11
35
|
|
12
36
|
= form.submit class: 'btn '
|
37
|
+
|
38
|
+
= render partial: 'my_forum/shared/upload_photo', locals: { textarea: 'post_text' }
|
@@ -10,11 +10,18 @@
|
|
10
10
|
.form-group= form.password_field :password, value: '', class: 'description form-control', placeholder: t('.current_password')
|
11
11
|
.form-group= form.text_field :new_password, value: '', class: 'description form-control', placeholder: t('.new_password')
|
12
12
|
|
13
|
-
= form.submit class: 'btn btn-primary btn-sm'
|
13
|
+
= form.submit t('.update'), class: 'btn btn-primary btn-sm'
|
14
14
|
|
15
|
-
.col-md-
|
15
|
+
.col-md-5.col-md-offset-1
|
16
16
|
.row.col-sm-4
|
17
17
|
.thumbnail
|
18
18
|
= user_avatar(current_user)
|
19
|
-
.row.col-sm-
|
20
|
-
|
19
|
+
.row.col-sm-7.col-sm-offset-1
|
20
|
+
.row
|
21
|
+
%strong=t('.avatar')
|
22
|
+
= form_for current_user, url: user_avatar_update_path(current_user), role: 'form', multipart: true do |form|
|
23
|
+
.row
|
24
|
+
%p= t('.avatar_upload_description')
|
25
|
+
.row= form.file_field :avatar
|
26
|
+
.row= form.text_field :avatar_url, placeholder: 'http://...'
|
27
|
+
.row= form.submit t('.update_avatar'), class: 'btn btn-primary btn-sm submit_update_avatar'
|
data/config/locales/ru.yml
CHANGED
@@ -103,6 +103,10 @@ ru:
|
|
103
103
|
email: 'Электронная почта'
|
104
104
|
current_password: 'Текущий пароль'
|
105
105
|
new_password: 'Новый пароль'
|
106
|
+
avatar: 'Аватар'
|
107
|
+
avatar_upload_description: 'Загрузите свой аватар или укажите ссылку'
|
108
|
+
update: 'Обновить'
|
109
|
+
update_avatar: 'Обновить аватар'
|
106
110
|
|
107
111
|
|
108
112
|
private_messages:
|
data/config/routes.rb
CHANGED
data/lib/my_forum/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_forum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- app/views/my_forum/private_messages/inbox.haml
|
253
253
|
- app/views/my_forum/private_messages/new.haml
|
254
254
|
- app/views/my_forum/private_messages/show.haml
|
255
|
+
- app/views/my_forum/shared/_upload_photo.haml
|
255
256
|
- app/views/my_forum/topics/_post.haml
|
256
257
|
- app/views/my_forum/topics/_quick_answer.haml
|
257
258
|
- app/views/my_forum/topics/_topic_header.haml
|
@@ -287,6 +288,8 @@ files:
|
|
287
288
|
- db/migrate/20151012095554_create_my_forum_images.rb
|
288
289
|
- db/migrate/20151218135729_add_is_deleted.rb
|
289
290
|
- db/migrate/20151220121140_create_my_forum_emoticons.rb
|
291
|
+
- db/migrate/20151221203243_my_forum_rename_user_avatar.rb
|
292
|
+
- db/migrate/20151221205045_my_forum_change_user_avatar.rb
|
290
293
|
- lib/my_forum.rb
|
291
294
|
- lib/my_forum/engine.rb
|
292
295
|
- lib/my_forum/version.rb
|