my_forum 0.0.1.beta23 → 0.0.1.beta24
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/my_forum/my_forum.js.coffee +17 -4
- data/app/controllers/my_forum/admin/emoticons_controller.rb +65 -0
- data/app/controllers/my_forum/application_controller.rb +5 -1
- data/app/controllers/my_forum/private_messages_controller.rb +5 -4
- data/app/helpers/my_forum/emoticons_helper.rb +7 -0
- data/app/helpers/my_forum/posts_helper.rb +4 -1
- data/app/mailers/my_forum/user_mailer.rb +5 -0
- data/app/models/my_forum/emoticon.rb +6 -0
- data/app/views/layouts/my_forum/admin_application.haml +1 -0
- data/app/views/my_forum/admin/categories/new.haml +1 -4
- data/app/views/my_forum/admin/emoticons/edit.haml +4 -0
- data/app/views/my_forum/admin/emoticons/index.haml +15 -0
- data/app/views/my_forum/admin/emoticons/new.haml +5 -0
- data/app/views/my_forum/topics/_quick_answer.haml +9 -12
- data/app/views/my_forum/user_mailer/pm_notification.text.erb +6 -0
- data/config/locales/ru.yml +2 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20151220121140_create_my_forum_emoticons.rb +10 -0
- data/lib/my_forum/version.rb +1 -1
- data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +7 -0
- data/spec/models/my_forum/emoticon_spec.rb +7 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d71115243552cf57f8858c49290e6c3cd64f8a
|
4
|
+
data.tar.gz: 6393661615784fdba897347493b2ab44928d4e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9cdb9854415927bd70e9c2fb572bdf78bd074cd2e45296e686f8efb240fc232cacba74286a49cb9d34379614c89eb7bdea75c541e8ee851d7a31d47fad4c073
|
7
|
+
data.tar.gz: 0ef0e527d1adc0b765dc97f83955b8778bb028f963ff58440ca2d88998c812010f2e08295a912ec3528a2f8240af0aec0bc22aa4fd4628f3b61e38d5777b2678
|
@@ -19,15 +19,29 @@ ready = ->
|
|
19
19
|
|
20
20
|
# BBCode editor
|
21
21
|
$('.text-editor-buttons').click (event) ->
|
22
|
-
return false if !$(event.target).is('a') and !$(event.target).is('i')
|
23
|
-
|
24
22
|
event.preventDefault()
|
25
23
|
|
26
24
|
apply_to = $('.text-editor-buttons').data('apply-to')
|
27
25
|
apply_to = $('#' + apply_to)
|
26
|
+
|
27
|
+
# Smiles
|
28
|
+
if $(event.target).attr('class').search('smile') >= 0
|
29
|
+
smile_code = $(event.target).data('code') || $(event.target).find('[data-code]').data('code')
|
30
|
+
|
31
|
+
if smile_code
|
32
|
+
text = apply_to.val()
|
33
|
+
apply_to.val(text + smile_code + ' ')
|
34
|
+
|
35
|
+
return false
|
36
|
+
|
37
|
+
|
38
|
+
# Text formatting
|
39
|
+
return false if !$(event.target).is('a') and !$(event.target).is('i')
|
40
|
+
|
28
41
|
button = if $(event.target).is('a') then $(event.target).find('i') else $(event.target)
|
29
|
-
|
42
|
+
html_class = button.attr('class')
|
30
43
|
|
44
|
+
action = if html_class then html_class.replace('fa fa-', '') else ''
|
31
45
|
text = apply_to.val()
|
32
46
|
|
33
47
|
switch action
|
@@ -41,7 +55,6 @@ ready = ->
|
|
41
55
|
bbcode = '[u] [/u]'
|
42
56
|
when 'link', 'video-camera', 'camera-retro'
|
43
57
|
$('#add_photo').modal()
|
44
|
-
|
45
58
|
else
|
46
59
|
bbcode = ''
|
47
60
|
console.log 'Unknown tag'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
2
|
+
|
3
|
+
module MyForum
|
4
|
+
class Admin::EmoticonsController < ApplicationController
|
5
|
+
before_filter :verify_admin
|
6
|
+
|
7
|
+
layout 'layouts/my_forum/admin_application'
|
8
|
+
|
9
|
+
def index
|
10
|
+
@emoticons = Emoticon.all
|
11
|
+
end
|
12
|
+
|
13
|
+
def new
|
14
|
+
@emoticon = Emoticon.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
#TODO validation add
|
19
|
+
|
20
|
+
# Create dir of not exists
|
21
|
+
FileUtils::mkdir_p Emoticon::UPLOAD_PATH
|
22
|
+
|
23
|
+
uploaded_io = params[:emoticon][:file_name]
|
24
|
+
File.open(File.join(Emoticon::UPLOAD_PATH, uploaded_io.original_filename), 'wb') do |file|
|
25
|
+
file.write(uploaded_io.read)
|
26
|
+
end
|
27
|
+
|
28
|
+
attachment = Emoticon.create(code: params[:emoticon][:code], file_name: uploaded_io.original_filename, is_active: true)
|
29
|
+
|
30
|
+
redirect_to admin_emoticons_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
@emoticon = Emoticon.find(params[:id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
emoticon = Emoticon.find(params[:id])
|
39
|
+
emoticon.update(emoticon_params)
|
40
|
+
|
41
|
+
redirect_to admin_emoticons_path
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
return unless emoticon = Emoticon.find(params[:id])
|
46
|
+
|
47
|
+
begin
|
48
|
+
FileUtils.rm File.join(Emoticon::UPLOAD_PATH, emoticon.file_name)
|
49
|
+
emoticon.destroy
|
50
|
+
rescue
|
51
|
+
Rails.logger.error 'can`t find and delete emoticon file'
|
52
|
+
ensure
|
53
|
+
emoticon.destroy
|
54
|
+
end
|
55
|
+
|
56
|
+
redirect_to admin_emoticons_path
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def emoticon_params
|
62
|
+
params.require(:emoticon).permit(:code)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -3,7 +3,7 @@ module MyForum
|
|
3
3
|
|
4
4
|
before_filter :user_activity
|
5
5
|
|
6
|
-
helper_method :attachment_img_path
|
6
|
+
helper_method :attachment_img_path, :emoticons_list
|
7
7
|
|
8
8
|
def authenticate_user!
|
9
9
|
redirect_to admin_signin_path unless current_user
|
@@ -72,5 +72,9 @@ module MyForum
|
|
72
72
|
attachment = Attachment.find_by_id(attachment_id.to_i)
|
73
73
|
File.join(Attachment::URL, attachment.user_id.to_s, attachment.file_name)
|
74
74
|
end
|
75
|
+
|
76
|
+
def emoticons_list
|
77
|
+
Emoticon.all.inject({}) {|hash, smile| hash.merge!(smile.code => File.join(Emoticon::URL, smile.file_name) ) }
|
78
|
+
end
|
75
79
|
end
|
76
80
|
end
|
@@ -42,12 +42,13 @@ module MyForum
|
|
42
42
|
return
|
43
43
|
end
|
44
44
|
|
45
|
-
@pm.recipient_id
|
45
|
+
@pm.recipient_id = recipient.id
|
46
46
|
@pm.recipient_login = recipient.login
|
47
|
-
@pm.sender_id
|
48
|
-
@pm.sender_login
|
47
|
+
@pm.sender_id = current_user_id
|
48
|
+
@pm.sender_login = current_user.login
|
49
49
|
@pm.assign_attributes(pm_params)
|
50
|
-
|
50
|
+
|
51
|
+
UserMailer.pm_notification(recipient, current_user).deliver_now if @pm.save
|
51
52
|
|
52
53
|
redirect_to action: :index
|
53
54
|
end
|
@@ -43,7 +43,10 @@ module MyForum
|
|
43
43
|
"<div class='bbqoute'> <div class='quote_info'>#{$~[:autor]} #{t('my_forum.bbquote.wrote')}:</div> #{$~[:text]} </div>"
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
# Emoticons (smiles)
|
47
|
+
emoticons_list.each do |code, path|
|
48
|
+
text.gsub!(/#{Regexp.quote(code)}/) { "<img src='#{path}' class='smile' />" }
|
49
|
+
end
|
47
50
|
|
48
51
|
# Link
|
49
52
|
text.gsub!(/\[url=(.*?)\](.*?)\[\/url\]/i) { "<a href='#{$1}'>#{$2}</a>" }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- if @emoticons.blank?
|
2
|
+
=t('.no_emoticons')
|
3
|
+
- else
|
4
|
+
%table.table
|
5
|
+
-@emoticons.each do |smile|
|
6
|
+
%tr
|
7
|
+
%td= smile.code
|
8
|
+
%td
|
9
|
+
%img{ src: emoticon_url_for(smile), class: 'smile' }
|
10
|
+
%td= smile.is_active
|
11
|
+
%td= link_to t('.edit'), edit_admin_emoticon_path(smile)
|
12
|
+
%td= link_to t('.delete'), admin_emoticon_path(smile), method: :delete, data: { confirm: "Are you sure?" }
|
13
|
+
|
14
|
+
|
15
|
+
=link_to t('.add'), new_admin_emoticon_path
|
@@ -25,16 +25,18 @@
|
|
25
25
|
=link_to '#', class: 'btn btn-default btn-sm', data: { toggle: 'modal' } do
|
26
26
|
%i{ class: 'fa fa-camera-retro' }
|
27
27
|
|
28
|
-
=link_to '#', class: 'btn btn-default btn-sm' do
|
29
|
-
|
30
|
-
=link_to '#', class: 'btn btn-default btn-sm' do
|
31
|
-
|
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
32
|
|
33
33
|
%div.btn-group.smiles
|
34
|
-
-
|
35
|
-
- smiles.each do |smile_file|
|
34
|
+
- emoticons_list.each do |code, path|
|
36
35
|
=link_to '#', class: 'btn btn-default btn-sm smile-past' do
|
37
|
-
%img{ src:
|
36
|
+
%img{ src: path, class: 'smile', data: { code: code } }
|
37
|
+
|
38
|
+
|
39
|
+
|
38
40
|
|
39
41
|
= form_for @new_post, url: forum_topic_posts_path(forum, topic), role: 'form' do |form|
|
40
42
|
.form-group= form.text_area :text, class: 'form-control quick-answer', id: 'quick_answer_textarea'
|
@@ -60,11 +62,6 @@
|
|
60
62
|
#loaded-content
|
61
63
|
|
62
64
|
:coffee
|
63
|
-
$('.smile-past').click ->
|
64
|
-
smile_icon_path = $(this).find('img').attr('src')
|
65
|
-
smile_icon_file = smile_icon_path.split('/').pop()
|
66
|
-
$('#quick_answer_textarea').append('::' + smile_icon_file.split('.')[0] + ':: ')
|
67
|
-
|
68
65
|
$('#attachment_file').change ->
|
69
66
|
file_data = $('#attachment_file').prop('files')[0]
|
70
67
|
form_data = new FormData()
|
data/config/locales/ru.yml
CHANGED
data/config/routes.rb
CHANGED
data/lib/my_forum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.beta24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- app/assets/stylesheets/my_forum/welcome.css.scss
|
185
185
|
- app/controllers/my_forum/admin/categories_controller.rb
|
186
186
|
- app/controllers/my_forum/admin/dashboard_controller.rb
|
187
|
+
- app/controllers/my_forum/admin/emoticons_controller.rb
|
187
188
|
- app/controllers/my_forum/admin/forums_controller.rb
|
188
189
|
- app/controllers/my_forum/admin/mail_controller.rb
|
189
190
|
- app/controllers/my_forum/admin/roles_controller.rb
|
@@ -202,6 +203,7 @@ files:
|
|
202
203
|
- app/helpers/my_forum/admin/roles_helper.rb
|
203
204
|
- app/helpers/my_forum/admin/users_helper.rb
|
204
205
|
- app/helpers/my_forum/application_helper.rb
|
206
|
+
- app/helpers/my_forum/emoticons_helper.rb
|
205
207
|
- app/helpers/my_forum/forums_helper.rb
|
206
208
|
- app/helpers/my_forum/posts_helper.rb
|
207
209
|
- app/helpers/my_forum/private_messages_helper.rb
|
@@ -214,6 +216,7 @@ files:
|
|
214
216
|
- app/models/my_forum/avatar.rb
|
215
217
|
- app/models/my_forum/category.rb
|
216
218
|
- app/models/my_forum/category_permission.rb
|
219
|
+
- app/models/my_forum/emoticon.rb
|
217
220
|
- app/models/my_forum/forum.rb
|
218
221
|
- app/models/my_forum/image.rb
|
219
222
|
- app/models/my_forum/log_read_mark.rb
|
@@ -234,6 +237,9 @@ files:
|
|
234
237
|
- app/views/my_forum/admin/categories/edit.haml
|
235
238
|
- app/views/my_forum/admin/categories/new.haml
|
236
239
|
- app/views/my_forum/admin/dashboard/index.haml
|
240
|
+
- app/views/my_forum/admin/emoticons/edit.haml
|
241
|
+
- app/views/my_forum/admin/emoticons/index.haml
|
242
|
+
- app/views/my_forum/admin/emoticons/new.haml
|
237
243
|
- app/views/my_forum/admin/forums/index.haml
|
238
244
|
- app/views/my_forum/admin/forums/new.haml
|
239
245
|
- app/views/my_forum/admin/mail/index.haml
|
@@ -253,6 +259,7 @@ files:
|
|
253
259
|
- app/views/my_forum/topics/new.haml
|
254
260
|
- app/views/my_forum/topics/show.haml
|
255
261
|
- app/views/my_forum/user_mailer/custom_email.text.erb
|
262
|
+
- app/views/my_forum/user_mailer/pm_notification.text.erb
|
256
263
|
- app/views/my_forum/user_mailer/reset_password_email.haml
|
257
264
|
- app/views/my_forum/user_mailer/reset_password_email.text.erb
|
258
265
|
- app/views/my_forum/users/edit.haml
|
@@ -279,10 +286,12 @@ files:
|
|
279
286
|
- db/migrate/20150227210814_create_my_forum_private_messages.rb
|
280
287
|
- db/migrate/20151012095554_create_my_forum_images.rb
|
281
288
|
- db/migrate/20151218135729_add_is_deleted.rb
|
289
|
+
- db/migrate/20151220121140_create_my_forum_emoticons.rb
|
282
290
|
- lib/my_forum.rb
|
283
291
|
- lib/my_forum/engine.rb
|
284
292
|
- lib/my_forum/version.rb
|
285
293
|
- lib/tasks/my_forum_tasks.rake
|
294
|
+
- spec/controllers/my_forum/admin/emoticons_controller_spec.rb
|
286
295
|
- spec/controllers/my_forum/admin/mail_controller_spec.rb
|
287
296
|
- spec/controllers/my_forum/private_messages_controller_spec.rb
|
288
297
|
- spec/controllers/my_forum/users_controller_spec.rb
|
@@ -324,6 +333,7 @@ files:
|
|
324
333
|
- spec/dummy/public/500.html
|
325
334
|
- spec/dummy/public/favicon.ico
|
326
335
|
- spec/helpers/my_forum/private_messages_helper_spec.rb
|
336
|
+
- spec/models/my_forum/emoticon_spec.rb
|
327
337
|
- spec/models/my_forum/private_message_spec.rb
|
328
338
|
- spec/models/my_forum/user_spec.rb
|
329
339
|
- spec/rails_helper.rb
|
@@ -353,6 +363,7 @@ signing_key:
|
|
353
363
|
specification_version: 4
|
354
364
|
summary: Simple Forum
|
355
365
|
test_files:
|
366
|
+
- spec/controllers/my_forum/admin/emoticons_controller_spec.rb
|
356
367
|
- spec/controllers/my_forum/admin/mail_controller_spec.rb
|
357
368
|
- spec/controllers/my_forum/private_messages_controller_spec.rb
|
358
369
|
- spec/controllers/my_forum/users_controller_spec.rb
|
@@ -394,6 +405,7 @@ test_files:
|
|
394
405
|
- spec/dummy/Rakefile
|
395
406
|
- spec/dummy/README.rdoc
|
396
407
|
- spec/helpers/my_forum/private_messages_helper_spec.rb
|
408
|
+
- spec/models/my_forum/emoticon_spec.rb
|
397
409
|
- spec/models/my_forum/private_message_spec.rb
|
398
410
|
- spec/models/my_forum/user_spec.rb
|
399
411
|
- spec/rails_helper.rb
|