my_forum 0.0.2.1 → 0.0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a40b00dc7a7c405a51552ab8b369c72f3b3db8be
|
4
|
+
data.tar.gz: 25bdf7620f52b3343ccdf68300469013c658ff56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 846bc2b37590460b145f099f66af6368936c68cee9177dea4c9135349b10ab81a153bdc7cc0cc274c03b03e9a7cb8af5a8e3149cc6487bb51a736b53ce126bf9
|
7
|
+
data.tar.gz: b6f75d554ba9cadfd3f6d976923ad515913ff8d4182f37fe9477b23a6a631025b66cf26971bc9d7b589800750d451462ea3d78cf9dba73e12d75d79c24f8ca48
|
@@ -66,8 +66,10 @@ module MyForum
|
|
66
66
|
def ping_user(post_text, page)
|
67
67
|
return unless post_text
|
68
68
|
|
69
|
-
|
69
|
+
# Try to get second word after whitespace if login consist it (ex: @super mario)
|
70
|
+
post_text.scan(/(@\S+)(\s\S+)?/).each do |user_login, additional|
|
70
71
|
user = User.find_by_login(user_login[1..-1]) # strip @
|
72
|
+
user = User.find_by_login(user_login[1..-1] + additional) unless user
|
71
73
|
UserMailer.ping_from_post(user, @topic, page).deliver_later if user
|
72
74
|
end
|
73
75
|
end
|
@@ -61,10 +61,19 @@ module MyForum
|
|
61
61
|
# ActionController::Base.helpers.... - this method uses in controller, which don`t know link_to
|
62
62
|
#text.gsub!(/\[url=(.*?)\](.*?)\[\/url\]/i) { ActionController::Base.helpers.link_to($2, $1, target: '_blank') }
|
63
63
|
#text.gsub!(/(http:\/\/[\S]+|www:\/\/[\S]+)/i) { ActionController::Base.helpers.link_to($1, $1, target: '_blank') }
|
64
|
+
text.gsub!(/\[url=(.*?)\](.*?)\[\/url\]/i) { |match| "#{$1}" }
|
64
65
|
|
65
66
|
# Ping user
|
66
|
-
text.gsub!(/@\S+/) { |match| "<span class='badge'>#{match}</span>" }
|
67
|
-
|
67
|
+
#text.gsub!(/@\S+/) { |match| "<span class='badge'>#{match}</span>" }
|
68
|
+
text.gsub!(/(@\S+)(\s\S+)?/) do |match|
|
69
|
+
user_login = $1[1..-1]
|
70
|
+
|
71
|
+
if User.login_exists?(user_login)
|
72
|
+
"<span class='badge'>#{$1}</span> #{$2}"
|
73
|
+
elsif User.login_exists?(user_login + $2)
|
74
|
+
"<span class='badge'>#{$1}#{$2}</span>"
|
75
|
+
end
|
76
|
+
end
|
68
77
|
|
69
78
|
auto_link(text).html_safe
|
70
79
|
end
|
data/app/models/my_forum/user.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.2.
|
4
|
+
version: 0.0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|