my_forum 0.0.2.1 → 0.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b41182adb8b596c4921371310fbd823932646e8f
4
- data.tar.gz: b1a66385c9b08ce3d4b02ecf581ef348b3b48c6a
3
+ metadata.gz: a40b00dc7a7c405a51552ab8b369c72f3b3db8be
4
+ data.tar.gz: 25bdf7620f52b3343ccdf68300469013c658ff56
5
5
  SHA512:
6
- metadata.gz: e30aebce379a7b413628cc63b46f7974740ca76872a06612d13d3e1b5b1861cb3e86b82e311798b24686261767d992dbf62b7a39f1307de40d0b30706e1345c1
7
- data.tar.gz: 0bac644ed881e21bdbdcb841e737c4b7d626d01cece21c5e618053b73d4dd5449fbd1358f21ec5a5030047956ee2a25779eeaa93697d059909cc34f23ec214fe
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
- post_text.scan(/@\S+/).each do |user_login|
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
@@ -47,6 +47,10 @@ module MyForum
47
47
  password == encrypt(submitted_password)
48
48
  end
49
49
 
50
+ def self.login_exists?(login)
51
+ User.find_by_login(login).present?
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def encrypt_password
@@ -1,3 +1,3 @@
1
1
  module MyForum
2
- VERSION = "0.0.2.1"
2
+ VERSION = "0.0.2.2"
3
3
  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.2.1
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-02 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails