bbcode-rails 0.1.0 → 0.2.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 +2 -0
- data/bbcode-rails-0.1.0.gem +0 -0
- data/lib/bbcode-rails/railtie.rb +3 -0
- data/lib/bbcode-rails/tag.rb +38 -0
- data/lib/bbcode-rails/version.rb +1 -1
- data/lib/bbcode-rails.rb +8 -29
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237a90d01c04b4bc90c952c1be16fa97255f170a
|
4
|
+
data.tar.gz: d856ac41813bb402d4d3a8f16a3de37be54c6784
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ae86f9691c2473b8369790aa85699647ab51ebc46a2bf660033c74dee4241f88e8fdb8c461d0a711655e071cb0ad29938ab8769b9e913123c5de2fb608c32a
|
7
|
+
data.tar.gz: 5acec4533f51a1ece1d31cd28ea092796c9c608c657205f932d7fa7778a4e52f9753eb59693ac6cf8f7b0dbbce18efbed36fdee59a80c1034cac96a9e2ce6576
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# BBCode for Rails
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bbcode-rails.svg)](http://badge.fury.io/rb/bbcode-rails)
|
4
|
+
|
3
5
|
`bbcode-rails` is a gem for simple integration of BBCode into your application.
|
4
6
|
It does not assume your feature scope and thus does not include every tag out
|
5
7
|
there. However, for ease of developement several BBCode tags are included,
|
Binary file
|
data/lib/bbcode-rails/railtie.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
class BBCode::Tag < AbstractController::Base
|
2
|
+
include AbstractController::Rendering
|
3
|
+
include AbstractController::Helpers
|
4
|
+
include AbstractController::Translation
|
5
|
+
include AbstractController::AssetPaths
|
6
|
+
include ActionView::Rendering
|
7
|
+
include Rails.application.routes.url_helpers
|
8
|
+
self.view_paths = "app/views"
|
9
|
+
|
10
|
+
|
11
|
+
def self.inherited subclass
|
12
|
+
BBCode.tags << subclass
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.block_name n, *args
|
16
|
+
if args.include? :argument
|
17
|
+
arg = "=(.+?)"
|
18
|
+
end
|
19
|
+
if args.include? :no_closing_tag
|
20
|
+
@regex = /\[#{n.to_s}#{arg}\]/mi
|
21
|
+
else
|
22
|
+
@regex = /\[#{n.to_s}#{arg}\](.+?)\[\/#{n.to_s}\]/mi
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.on_layout &b
|
27
|
+
@block = b
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.regex
|
31
|
+
@regex
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.block
|
35
|
+
@block
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/bbcode-rails/version.rb
CHANGED
data/lib/bbcode-rails.rb
CHANGED
@@ -8,40 +8,19 @@ module BBCode
|
|
8
8
|
|
9
9
|
def self.parse str
|
10
10
|
str = str.dup
|
11
|
+
|
12
|
+
str.gsub!( '&', '&' )
|
13
|
+
str.gsub!( '<', '<' )
|
14
|
+
str.gsub!( '>', '>' )
|
15
|
+
str.gsub!( '"', '"' )
|
16
|
+
str.gsub!( "'", ''' )
|
17
|
+
|
11
18
|
@@tags.each do |t|
|
12
|
-
str.gsub!(t.regex) { t.
|
19
|
+
str.gsub!(t.regex) { t.new.instance_exec($~, &t.block) }
|
13
20
|
end
|
14
21
|
str
|
15
22
|
end
|
16
23
|
|
17
|
-
class Tag
|
18
|
-
def self.inherited subclass
|
19
|
-
BBCode.tags << subclass
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.name n, *args
|
23
|
-
if args.include? :argument
|
24
|
-
arg = "=(.+?)"
|
25
|
-
end
|
26
|
-
if args.include? :no_closing_tag
|
27
|
-
@regex = /\[#{n.to_s}#{arg}\]/mi
|
28
|
-
else
|
29
|
-
@regex = /\[#{n.to_s}#{arg}\](.+?)\[\/#{n.to_s}\]/mi
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.on_layout &b
|
34
|
-
@block = b
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.regex
|
38
|
-
@regex
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.block
|
42
|
-
@block
|
43
|
-
end
|
44
|
-
end
|
45
24
|
end
|
46
25
|
|
47
26
|
class String
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbcode-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcel Müller
|
@@ -52,10 +52,12 @@ files:
|
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
|
+
- bbcode-rails-0.1.0.gem
|
55
56
|
- bbcode-rails.gemspec
|
56
57
|
- bin/console
|
57
58
|
- lib/bbcode-rails.rb
|
58
59
|
- lib/bbcode-rails/railtie.rb
|
60
|
+
- lib/bbcode-rails/tag.rb
|
59
61
|
- lib/bbcode-rails/version.rb
|
60
62
|
homepage: https://github.com/TheNeikos/bbcode-rails
|
61
63
|
licenses:
|