my_forum 0.0.1.beta23 → 0.0.1.beta24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed23ed60a37e201d6c95952c7decff9d690b6452
4
- data.tar.gz: 2867a03850a8e9e8c6e010df6a3138e18c23bbc3
3
+ metadata.gz: 83d71115243552cf57f8858c49290e6c3cd64f8a
4
+ data.tar.gz: 6393661615784fdba897347493b2ab44928d4e68
5
5
  SHA512:
6
- metadata.gz: a7cbd4137c9eced7c7285bb282083cfa7f98f5667bf16613217d97df10adaaa386bca512aba15f0deb9d3bf25d0125de9ecb9284e4de3e27e91934612bfa1c1d
7
- data.tar.gz: c581225b7060f052ef8c7b146234e1d7e433fed63a14144a00c5800d9478b5be827f6d31c95406fe49e5e9f941a4ab896c6c7de8d6ae075bd07e1b5f5490b71c
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
- action = button.attr('class').replace('fa fa-', '');
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 = recipient.id
45
+ @pm.recipient_id = recipient.id
46
46
  @pm.recipient_login = recipient.login
47
- @pm.sender_id = current_user_id
48
- @pm.sender_login = current_user.login
47
+ @pm.sender_id = current_user_id
48
+ @pm.sender_login = current_user.login
49
49
  @pm.assign_attributes(pm_params)
50
- @pm.save
50
+
51
+ UserMailer.pm_notification(recipient, current_user).deliver_now if @pm.save
51
52
 
52
53
  redirect_to action: :index
53
54
  end
@@ -0,0 +1,7 @@
1
+ module MyForum
2
+ module EmoticonsHelper
3
+ def emoticon_url_for(emoticon)
4
+ File.join(Emoticon::URL, emoticon.file_name)
5
+ end
6
+ end
7
+ 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>" }
@@ -15,5 +15,10 @@ module MyForum
15
15
  @message = message
16
16
  mail(to: email, subject: subject)
17
17
  end
18
+
19
+ def pm_notification(user, sender)
20
+ @sender = sender
21
+ mail(to: user.email, subject: I18n.t('my_forum.mailer.new_pm_notification_subject'))
22
+ end
18
23
  end
19
24
  end
@@ -0,0 +1,6 @@
1
+ module MyForum
2
+ class Emoticon < ActiveRecord::Base
3
+ UPLOAD_PATH = File.join(Rails.public_path, 'uploads', 'emoticons')
4
+ URL = File.join('/uploads', 'emoticons')
5
+ end
6
+ end
@@ -21,6 +21,7 @@
21
21
  %li= link_to t('.manage_roles'), admin_roles_path
22
22
  %li= link_to t('.manage_users'), admin_users_path
23
23
  %li= link_to t('.manage_mail'), admin_mail_list_path
24
+ %li= link_to t('.manage_emoticons'), admin_emoticons_path
24
25
 
25
26
  .col-sm-9.col-md-10
26
27
  = yield
@@ -2,7 +2,4 @@
2
2
 
3
3
  = form_for @category, url: admin_categories_path do |f|
4
4
  = f.text_field :name, placeholder: t('.category_name')
5
- = f.submit
6
-
7
-
8
-
5
+ = f.submit
@@ -0,0 +1,4 @@
1
+ .row.col-sm-2
2
+ = form_for @emoticon, url: admin_emoticon_path(@emoticon), multipart: true, role: 'form' do |f|
3
+ .form-group= f.text_field :code, class: 'form-control'
4
+ = f.submit
@@ -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
@@ -0,0 +1,5 @@
1
+ .row.col-sm-2
2
+ = form_for @emoticon, url: admin_emoticons_path, multipart: true, role: 'form' do |f|
3
+ .form-group= f.file_field :file_name, class: 'form-control'
4
+ .form-group= f.text_field :code, class: 'form-control'
5
+ = f.submit
@@ -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
- %i{ class: 'fa fa-video-camera' }
30
- =link_to '#', class: 'btn btn-default btn-sm' do
31
- %i{ class: 'fa fa-link' }
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
- - smiles = %w(acute aggressive beee blum2 blush2 cray dirol download i-m_so_happy ireful2)
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: asset_path("my_forum/smiles/#{smile_file}.gif"), class: 'smile' }
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()
@@ -0,0 +1,6 @@
1
+ Привет!
2
+
3
+ Пользователь <%= @sender.login %> отправил тебе личное сообщение!
4
+
5
+ ----
6
+ http://vaz.od.ua
@@ -1,6 +1,8 @@
1
1
  ru:
2
2
  today: "Сегодня"
3
3
  my_forum:
4
+ mailer:
5
+ new_pm_notification_subject: 'Уведомление о новом личном сообщении'
4
6
  today: "Сегодня в %{hhmm}"
5
7
  yesterday: "Вчера в %{hhmm}"
6
8
  create_new_pm: 'Написать личное сообщение'
data/config/routes.rb CHANGED
@@ -34,6 +34,7 @@ MyForum::Engine.routes.draw do
34
34
  match 'forums', to: 'forums#index', via: [:get]
35
35
  match 'mail_list', to: 'mail#index', via: [:get, :post]
36
36
 
37
+ resources :emoticons
37
38
  resources :users
38
39
  resources :roles
39
40
  resources :categories do
@@ -0,0 +1,10 @@
1
+ class CreateMyForumEmoticons < ActiveRecord::Migration
2
+ def change
3
+ create_table :my_forum_emoticons do |t|
4
+ t.string :file_name
5
+ t.string :code
6
+ t.boolean :is_active, default: true
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module MyForum
2
- VERSION = "0.0.1.beta23"
2
+ VERSION = "0.0.1.beta24"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe Admin::EmoticonsController, type: :controller do
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe Emoticon, type: :model do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
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.beta23
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-18 00:00:00.000000000 Z
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