bbcode-rails 0.8.2 → 0.9.0

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: 109c94d320f0111ad525b254f3e99cd37fc7bf0a
4
- data.tar.gz: ac7b790975f2600fb5aca83a3a9d156e141c5e04
3
+ metadata.gz: f2d33272d04f3a4dca99ee3945d33c30a8f6e7cf
4
+ data.tar.gz: a3dd428fe61086e512730366187aef2e2ceb9d5c
5
5
  SHA512:
6
- metadata.gz: 13deaddccdc0de9f4a56b9343be41840e66c1615b2a0077a689c87d3ac4aa9431df3ac8c43e792118ce5dcd7e669326fee72c851fb12055f83fed10084210a90
7
- data.tar.gz: 7cfd4b55921031d91b79c292d77a1fd21d0fbf8a78bbf45bd6e4d5e4ba6aab42c2b30b5ad6d2447da7ad0c9fea2770d4d4cf0527b141a12448afecdf3cc11452
6
+ metadata.gz: 9f1b88ae515b2761320aea8bae8ec1d440520ffb82095e069a264bced7e5cb6257fa58bf62995aecc97c60ab80a3e0803e5e0849be2d940b489950a8e27700f6
7
+ data.tar.gz: 051b5b5df34e0627efb45816b22d502e7887098b903cd7cda41a456b2fddcaacebf60966a420c8b0677455004cccb9097db0a8f084b96e3df3d1f6fab5539037
data/README.md CHANGED
@@ -55,10 +55,16 @@ This will create `app/bbcode/user_tag.rb`.
55
55
  #app/bbcode/user.rb
56
56
 
57
57
  class UserTag < BBCode::Tag
58
- block_name :user
59
- on_layout do |args|
60
- "TODO: Implement user tag"
61
- end
58
+ # If your block uses an argument or can have content add the following line
59
+ # with your needed option
60
+ # block_options :argument, :content
61
+
62
+ # Be sure to put in only the arguments that you need.
63
+ # So if you only take an argument, remove contents, same the other way around.
64
+ # However if you have both, they have to be in the order of `arg, contents`
65
+ on_layout do |arg, contents|
66
+ "TODO: Implement user tag"
67
+ end
62
68
  end
63
69
  ```
64
70
 
@@ -68,11 +74,14 @@ You could now add something like:
68
74
  #app/bbcode/user.rb
69
75
 
70
76
  class UserTag < BBCode::Tag
71
- block_name :user, :argument, :no_closing_tag
72
- on_layout do |args|
73
- user = User.find_by_id(args[1])
74
- render partial: 'shared/userquote', locals: { user: user }
75
- end
77
+ # If your block uses an argument or can have content add the following line
78
+ # with your needed option
79
+ # block_options :argument, :content
80
+ block_options :argument
81
+ on_layout do |arg|
82
+ user = User.find_by_id(arg)
83
+ render partial: 'shared/userquote', locals: { user: user }
84
+ end
76
85
  end
77
86
  ```
78
87
 
data/lib/bbcode-rails.rb CHANGED
@@ -22,11 +22,16 @@ module BBCode
22
22
  def self.parse str, raise_error=false
23
23
  str = str.dup
24
24
 
25
- str.gsub!( '&', '&amp;' )
26
- str.gsub!( '<', '&lt;' )
27
- str.gsub!( '>', '&gt;' )
28
- str.gsub!( '"', '&quot;' )
29
- str.gsub!( "'", '&apos;' )
25
+ str.gsub!('&', '&amp;')
26
+ str.gsub!('<', '&lt;')
27
+ str.gsub!('>', '&gt;')
28
+ str.gsub!('"', '&quot;')
29
+ str.gsub!("'", '&apos;')
30
+
31
+ # Taken from bb-ruby, who took it from Rails Actionpack
32
+ str.gsub!(/\r\n?/, "\n") # \r\n and \r => \n
33
+ str.gsub!(/\n/, '<br>') # 1 newline => br
34
+
30
35
 
31
36
  # Let's iterate over the pieces to build a tree
32
37
  # It works like this:
@@ -1,3 +1,3 @@
1
1
  module BBCode
2
- VERSION = "0.8.2"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -1,8 +1,8 @@
1
1
  class BTag < BBCode::Tag
2
- block_name :b
2
+ block_options :content
3
3
 
4
- on_layout do |args|
5
- "<strong>#{args[1]}</strong>"
4
+ on_layout do |contents|
5
+ "<strong>#{contents}</strong>"
6
6
  end
7
7
  end
8
8
 
@@ -1,8 +1,8 @@
1
1
  class ITag < BBCode::Tag
2
- block_name :i
2
+ block_options :content
3
3
 
4
- on_layout do |args|
5
- "<em>#{args[1]}</em>"
4
+ on_layout do |contents|
5
+ "<em>#{contents}</em>"
6
6
  end
7
7
  end
8
8
 
@@ -1,8 +1,8 @@
1
1
  class ImgTag < BBCode::Tag
2
- block_name :img, :argument, :no_closing_tag
2
+ block_options :argument
3
3
 
4
- on_layout do |args|
5
- args[1].gsub!(/javascript:/, '')
6
- "<img src='#{args[1]}'>"
4
+ on_layout do |arg|
5
+ args[1].gsub!(/^javascript:/, '')
6
+ "<img src='#{arg}'>"
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  class QuoteTag < BBCode::Tag
2
- block_name :quote, :argument
2
+ block_options :argument, :content
3
3
 
4
- on_layout do |args|
5
- user = User.find_by_id(args[1])
6
- render(partial: 'bbcode/quote', locals: { user: user, message: args[2], user_name: args[1] })
4
+ on_layout do |arg, contents|
5
+ user = User.find_by_id(arg)
6
+ render(partial: 'bbcode/quote', locals: { user: user, message: contents, user_name: arg })
7
7
  end
8
8
  end
@@ -1,8 +1,13 @@
1
1
  <% module_namespacing do -%>
2
2
  class <%= name.classify %>Tag < BBCode::Tag
3
- block_name :<%= name %>
3
+ # If your block uses an argument or can have content add the following line
4
+ # with your needed option
5
+ # block_options :argument, :content
4
6
 
5
- on_layout do |args|
7
+ # Be sure to put in only the arguments that you need.
8
+ # So if you only take an argument, remove contents, same the other way around.
9
+ # However if you have both, they have to be in the order of `arg, contents`
10
+ on_layout do |arg, contents|
6
11
  "TODO: Implement <%= name %> tag"
7
12
  end
8
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbcode-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Müller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler