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 +4 -4
- data/README.md +18 -9
- data/lib/bbcode-rails.rb +10 -5
- data/lib/bbcode-rails/version.rb +1 -1
- data/lib/generators/bb_code/templates/b_tag.rb +3 -3
- data/lib/generators/bb_code/templates/i_tag.rb +3 -3
- data/lib/generators/bb_code/templates/img_tag.rb +4 -4
- data/lib/generators/bb_code/templates/quote_tag.rb +4 -4
- data/lib/generators/bb_code/templates/tag.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2d33272d04f3a4dca99ee3945d33c30a8f6e7cf
|
4
|
+
data.tar.gz: a3dd428fe61086e512730366187aef2e2ceb9d5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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!(
|
26
|
-
str.gsub!(
|
27
|
-
str.gsub!(
|
28
|
-
str.gsub!(
|
29
|
-
str.gsub!(
|
25
|
+
str.gsub!('&', '&')
|
26
|
+
str.gsub!('<', '<')
|
27
|
+
str.gsub!('>', '>')
|
28
|
+
str.gsub!('"', '"')
|
29
|
+
str.gsub!("'", ''')
|
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:
|
data/lib/bbcode-rails/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class ImgTag < BBCode::Tag
|
2
|
-
|
2
|
+
block_options :argument
|
3
3
|
|
4
|
-
on_layout do |
|
5
|
-
args[1].gsub!(
|
6
|
-
"<img src='#{
|
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
|
-
|
2
|
+
block_options :argument, :content
|
3
3
|
|
4
|
-
on_layout do |
|
5
|
-
user = User.find_by_id(
|
6
|
-
render(partial: 'bbcode/quote', locals: { user: user, message:
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|