bbcode-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 617d5f1a931e68f19456e55aa4a16ba927ff0d20
4
+ data.tar.gz: 109ffc1bd60b4ed88ea6ad386d5fd5f1ab2b1a22
5
+ SHA512:
6
+ metadata.gz: 9ac69f5709d0b35d7d90ba5ded4a5ca82a07c7290fc90219c01fffee99f774ef8eb18b9475e23e6d1d3c2f8efe3a24e593da6c1b363e27f0e9df9e2712b7fe00
7
+ data.tar.gz: 08babdff7f45fbea834bfc75d126fb91384d298d48ee12ebd7940d2b5c66dff76e41fecd105ec51c4a37f6ea994fafd0b2679886a1947d9070763f749ed61650
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bbcode-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Marcel Müller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # BBCode for Rails
2
+
3
+ `bbcode-rails` is a gem for simple integration of BBCode into your application.
4
+ It does not assume your feature scope and thus does not include every tag out
5
+ there. However, for ease of developement several BBCode tags are included,
6
+ namely:
7
+
8
+ - Italics `[i] Italics [/i]`
9
+ - Bold `[b] Bold [/b]`
10
+ - Quote `[quote=ID-Name] You can Quote me[/quote]`
11
+ - Image `[img=https://i.imgur.com/V8G8dKg.gif]` or `[img]https://i.imgur.com/V8G8dKg.gif[/img]`
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'bbcode-rails'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install bbcode-rails
29
+
30
+ ## Usage
31
+
32
+ To keep developement simple and easy to understand all tag definitions are found
33
+ in `app/bbcode/`. While it is usually better to have one file per tag, usually
34
+ tags are not big enough to warrant this, so one can also group them. For example
35
+ `styling.rb` could have the simplest tags in it.
36
+
37
+ ### Creating a new tag
38
+
39
+ You can use the bbcode generator to quickly setup a new tag, simple run
40
+
41
+ $ rails generate bbcode tagname
42
+
43
+ For example if we want to create a bbcode tag to easily link to a user
44
+
45
+ $ rails generate bbcode user
46
+
47
+ This will create `app/bbcode/user_tag.rb`.
48
+
49
+ ```ruby
50
+ #app/bbcode/user.rb
51
+
52
+ class UserTag < BBCode::Tag
53
+ name :user
54
+ on_layout do |args|
55
+ "TODO: Implement user tag"
56
+ end
57
+ end
58
+ ```
59
+
60
+ You could now add something like:
61
+
62
+ ```ruby
63
+ #app/bbcode/user.rb
64
+
65
+ class UserTag < BBCode::Tag
66
+ name :user, :argument, :no_closing_tag
67
+ on_layout do |args|
68
+ user = User.find_by_id(args[1])
69
+ render partial: 'shared/userquote', locals: user
70
+ end
71
+ end
72
+ ```
73
+
74
+ Of course, the limitations are your knowledge in ruby and rails :)
75
+
76
+
77
+ ## Contributing
78
+
79
+ 1. Fork it ( https://github.com/TheNeikos/bbcode-rails/fork )
80
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
81
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
82
+ 4. Push to the branch (`git push origin my-new-feature`)
83
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bbcode-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bbcode-rails"
8
+ spec.version = BBCode::VERSION
9
+ spec.authors = ["Marcel Müller"]
10
+ spec.email = ["neikos@neikos.email"]
11
+
12
+ spec.summary = %q{A simple BBCode gem for Rails}
13
+ spec.description = %q{A simple and efficient way of managing BBCode in a rails application.}
14
+ spec.homepage = "https://github.com/TheNeikos/bbcode-rails"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bbcode-rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,4 @@
1
+ module BBCode
2
+ class Railtie < Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module BBCode
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,53 @@
1
+ require "bbcode-rails/version"
2
+
3
+ module BBCode
4
+ @@tags = []
5
+ def self.tags
6
+ @@tags
7
+ end
8
+
9
+ def self.parse str
10
+ str = str.dup
11
+ @@tags.each do |t|
12
+ str.gsub!(t.regex) { t.block.call($~) }
13
+ end
14
+ str
15
+ end
16
+
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
+ end
46
+
47
+ class String
48
+ def to_bbcode
49
+ BBCode.parse(self)
50
+ end
51
+ end
52
+
53
+ require 'bbcode-rails/railtie' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbcode-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcel Müller
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A simple and efficient way of managing BBCode in a rails application.
42
+ email:
43
+ - neikos@neikos.email
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bbcode-rails.gemspec
56
+ - bin/console
57
+ - lib/bbcode-rails.rb
58
+ - lib/bbcode-rails/railtie.rb
59
+ - lib/bbcode-rails/version.rb
60
+ homepage: https://github.com/TheNeikos/bbcode-rails
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.5
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: A simple BBCode gem for Rails
84
+ test_files: []