my_forum 0.0.1.beta21 → 0.0.1.beta22
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 +4 -4
- data/app/assets/javascripts/my_forum/my_forum.js.coffee +18 -0
- data/app/controllers/my_forum/posts_controller.rb +21 -6
- data/app/helpers/my_forum/posts_helper.rb +12 -6
- data/app/models/my_forum/post.rb +2 -0
- data/app/views/my_forum/topics/_post.haml +6 -1
- data/config/locales/ru.yml +2 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20151218135729_add_is_deleted.rb +6 -0
- data/lib/my_forum/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6687212d40454b3bd545b5c820d5376fda03eb06
|
4
|
+
data.tar.gz: 296495aa0ecbac42795cc0160fc015831e484e03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 124b015faae0d8d258efa32adcfbc1a939ef9d6d6aa6fa62a3522c6587fcb25cec81dd498e504f330af85601f306e35422bf6174bcb45a7be78a3b1f074e013b
|
7
|
+
data.tar.gz: 63f95b1ff1ec240aaf7abf64472ed6d24cbc0e0fba47196de6c8192452327a79df0adcd1afb74688320a282b481be65feef494b4b53f910b735f52d15368a649
|
@@ -1,4 +1,22 @@
|
|
1
1
|
ready = ->
|
2
|
+
# Quote button
|
3
|
+
$('.quote-post').click (event) ->
|
4
|
+
quoute_post_id = $(event.target).data('post-id')
|
5
|
+
|
6
|
+
$.ajax
|
7
|
+
url: '/post/' + quoute_post_id
|
8
|
+
type: "GET"
|
9
|
+
dataType: "json"
|
10
|
+
success: (response) ->
|
11
|
+
quote = $('#quick_answer_textarea').val()
|
12
|
+
quote += '\n[quote author=' + response.author+ ']'
|
13
|
+
quote += response.text
|
14
|
+
quote += '[/quote]\n\n'
|
15
|
+
|
16
|
+
$('#quick_answer_textarea').val(quote)
|
17
|
+
$('body').scrollTo($('#quick_answer_textarea'))
|
18
|
+
|
19
|
+
|
2
20
|
# BBCode editor
|
3
21
|
$('.text-editor-buttons').click (event) ->
|
4
22
|
return false if !$(event.target).is('a') and !$(event.target).is('i')
|
@@ -2,21 +2,36 @@ require_dependency "my_forum/application_controller"
|
|
2
2
|
|
3
3
|
module MyForum
|
4
4
|
class PostsController < ApplicationController
|
5
|
-
before_filter :find_topic
|
6
|
-
before_filter :find_forum
|
5
|
+
before_filter :find_topic, except: [:show]
|
6
|
+
before_filter :find_forum, except: [:show]
|
7
7
|
|
8
8
|
def create
|
9
|
-
post
|
10
|
-
|
11
|
-
|
9
|
+
unless params[:post].fetch(:text).blank?
|
10
|
+
post = @topic.posts.build(post_params)
|
11
|
+
post.user = current_user
|
12
|
+
post.save
|
12
13
|
|
13
|
-
|
14
|
+
process_attachments(post)
|
15
|
+
end
|
14
16
|
|
15
17
|
last_page = @topic.posts.count / Post::PER_PAGE
|
16
18
|
last_page = 1 if last_page == 0
|
17
19
|
redirect_to forum_topic_path(@forum, @topic, page: last_page)
|
18
20
|
end
|
19
21
|
|
22
|
+
def destroy
|
23
|
+
post = Post.find(params[:id])
|
24
|
+
post.update(is_deleted: true)
|
25
|
+
redirect_to forum_topic_path(post.topic.forum, post.topic)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show
|
29
|
+
post = Post.find(params[:id])
|
30
|
+
respond_to do |format|
|
31
|
+
format.js { render json: { text: post.text, author: post.user.login }.as_json, status: :ok }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
20
35
|
private
|
21
36
|
|
22
37
|
def process_attachments(post)
|
@@ -20,13 +20,13 @@ module MyForum
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Bold text
|
23
|
-
text.gsub!(/(\[b\]
|
23
|
+
text.gsub!(/(\[b\](?<bold_text>.+?)\[\/b\])/i) { |match| "<strong>#{$1}</strong>" }
|
24
24
|
|
25
25
|
# Italic
|
26
|
-
text.gsub!(/(\[i\])(?<italic_text
|
26
|
+
text.gsub!(/(\[i\])(?<italic_text>.*?)(\[\/i\])/i) { |match| "<i>#{$1}</i>" }
|
27
27
|
|
28
28
|
# Cut
|
29
|
-
text.gsub!(/(\[cut\])(?<cut_text
|
29
|
+
text.gsub!(/(\[cut\])(?<cut_text>.*?)(\[\/cut\])/i) { |match| "<pre>#{$1}</pre>" }
|
30
30
|
|
31
31
|
# Color
|
32
32
|
text.gsub!(/\[color=(.*?)\](.*?)\[\/color\]/i) { "<span style='color: #{$1}'>#{$2}</span>" }
|
@@ -35,9 +35,15 @@ module MyForum
|
|
35
35
|
text.gsub!(/\[size=(.*?)\](.*?)\[\/size\]/i) { "<span style='font-size: #{$1}'>#{$2}</span>" }
|
36
36
|
|
37
37
|
# Quote
|
38
|
-
text.gsub!(/\[quote author=(.*?) link=(.*?) date=(.*?)\]/i) { bbquote(author: $1, date: $3) }
|
39
|
-
text.gsub!(/\[\/quote\]/i, '</div>')
|
40
|
-
text.gsub!(/\[quote(.*)\]/i, "<div class='bbqoute'>")
|
38
|
+
#text.gsub!(/\[quote author=(.*?) link=(.*?) date=(.*?)\]/i) { bbquote(author: $1, date: $3) }
|
39
|
+
#text.gsub!(/\[\/quote\]/i, '</div>')
|
40
|
+
#text.gsub!(/\[quote(.*)\]/i, "<div class='bbqoute'>")
|
41
|
+
text.gsub!(/(?<open>\[quote author=(?<autor>(.*?)) (.+)\](?<text>(.+))(?<close>\[\/quote\]))/i) do |match|
|
42
|
+
# "<div class='bbqoute'> <div class='quote_info'>#{$~[:autor]} #{t('my_forum.bbquote.wrote')} #{Time.now}:</div> #{$~[:text]} </div>"
|
43
|
+
"<div class='bbqoute'> <div class='quote_info'>#{$~[:autor]} #{t('my_forum.bbquote.wrote')}:</div> #{$~[:text]} </div>"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
41
47
|
|
42
48
|
# Link
|
43
49
|
text.gsub!(/\[url=(.*?)\](.*?)\[\/url\]/i) { "<a href='#{$1}'>#{$2}</a>" }
|
data/app/models/my_forum/post.rb
CHANGED
@@ -5,7 +5,12 @@
|
|
5
5
|
- user_login = post.user.try(:login)
|
6
6
|
= online_user_marker(user_login)
|
7
7
|
= user_login
|
8
|
-
.col-md-
|
8
|
+
.col-md-2.post_number.text-right
|
9
|
+
- # TODO optimize condition!
|
10
|
+
- if current_user and current_user.is_admin? and post.topic.posts.first != post
|
11
|
+
=link_to t('.delete'), forum_topic_post_path(@forum, post.topic, post), class: 'btn btn-xs btn-danger', method: :delete, data: { confirm: "Are you sure?" }
|
12
|
+
%button.btn.btn-xs.btn-warning.quote-post{ data: { post_id: post.id } }
|
13
|
+
=t('.quote')
|
9
14
|
=link_to t('.number', post_number: post_counter), forum_topic_path(@forum, post.topic, show_post: post_counter)
|
10
15
|
.row
|
11
16
|
.col-md-2
|
data/config/locales/ru.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -8,6 +8,8 @@ MyForum::Engine.routes.draw do
|
|
8
8
|
match 'unread_topics', to: 'forums#unread_topics', via: [:get], as: :unread_topics
|
9
9
|
match 'mark_all_as_read', to: 'forums#mark_all_as_read', via: [:get], as: :mark_all_as_read
|
10
10
|
|
11
|
+
match 'post/:id', to: 'posts#show', via: [:get], as: :post_content
|
12
|
+
|
11
13
|
resources :images
|
12
14
|
resources :avatars
|
13
15
|
resources :attachments
|
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.beta22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- db/migrate/20150215212443_create_my_forum_category_permissions.rb
|
279
279
|
- db/migrate/20150227210814_create_my_forum_private_messages.rb
|
280
280
|
- db/migrate/20151012095554_create_my_forum_images.rb
|
281
|
+
- db/migrate/20151218135729_add_is_deleted.rb
|
281
282
|
- lib/my_forum.rb
|
282
283
|
- lib/my_forum/engine.rb
|
283
284
|
- lib/my_forum/version.rb
|