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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 617d5f1a931e68f19456e55aa4a16ba927ff0d20
4
- data.tar.gz: 109ffc1bd60b4ed88ea6ad386d5fd5f1ab2b1a22
3
+ metadata.gz: 237a90d01c04b4bc90c952c1be16fa97255f170a
4
+ data.tar.gz: d856ac41813bb402d4d3a8f16a3de37be54c6784
5
5
  SHA512:
6
- metadata.gz: 9ac69f5709d0b35d7d90ba5ded4a5ca82a07c7290fc90219c01fffee99f774ef8eb18b9475e23e6d1d3c2f8efe3a24e593da6c1b363e27f0e9df9e2712b7fe00
7
- data.tar.gz: 08babdff7f45fbea834bfc75d126fb91384d298d48ee12ebd7940d2b5c66dff76e41fecd105ec51c4a37f6ea994fafd0b2679886a1947d9070763f749ed61650
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
@@ -1,4 +1,7 @@
1
1
  module BBCode
2
2
  class Railtie < Rails::Railtie
3
+ initializer "bbcode_load_tag" do
4
+ require 'bbcode-rails/tag'
5
+ end
3
6
  end
4
7
  end
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module BBCode
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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!( '&', '&amp;' )
13
+ str.gsub!( '<', '&lt;' )
14
+ str.gsub!( '>', '&gt;' )
15
+ str.gsub!( '"', '&quot;' )
16
+ str.gsub!( "'", '&apos;' )
17
+
11
18
  @@tags.each do |t|
12
- str.gsub!(t.regex) { t.block.call($~) }
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.1.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: