formol-bbcode 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/LICENSE +3 -0
- data/README.md +15 -0
- data/Rakefile +51 -0
- data/formol-bbcode.gemspec +18 -0
- data/lib/formol-bbcode.rb +7 -0
- data/lib/formol/formatters/bbcoder/extensions.rb +38 -0
- data/lib/formol/formatters/bbcoder/formatter.rb +18 -0
- metadata +75 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# BBCode text processor for Formol forum engine
|
2
|
+
|
3
|
+
Just add this gem in your Gemfile, after formol's.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'formol'
|
7
|
+
gem 'formol-bbcode'
|
8
|
+
```
|
9
|
+
|
10
|
+
It adds `Formol::Formatters::BBCoder::Formatter` to Formol.formatters.
|
11
|
+
|
12
|
+
You need then to add in your formol initializer:
|
13
|
+
`config.text_formatter = :bbcode`
|
14
|
+
|
15
|
+
It supports syntax highlighting and quotes. Have fun!
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
require 'rake/testtask'
|
12
|
+
require 'spec/rake/spectask'
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.name = 'formol-bbcode'
|
16
|
+
s.version = '0.0.1'
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
19
|
+
s.summary = 'Your summary here'
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = ''
|
22
|
+
s.email = ''
|
23
|
+
# s.executables = ['your_executable_here']
|
24
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
25
|
+
s.require_path = "lib"
|
26
|
+
s.bindir = "bin"
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |p|
|
30
|
+
p.gem_spec = spec
|
31
|
+
p.need_tar = true
|
32
|
+
p.need_zip = true
|
33
|
+
end
|
34
|
+
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
37
|
+
rdoc.rdoc_files.add(files)
|
38
|
+
rdoc.main = "README" # page to start on
|
39
|
+
rdoc.title = "formol-bbcode Docs"
|
40
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
41
|
+
rdoc.options << '--line-numbers'
|
42
|
+
end
|
43
|
+
|
44
|
+
Rake::TestTask.new do |t|
|
45
|
+
t.test_files = FileList['test/**/*.rb']
|
46
|
+
end
|
47
|
+
|
48
|
+
Spec::Rake::SpecTask.new do |t|
|
49
|
+
t.spec_files = FileList['spec/**/*.rb']
|
50
|
+
t.libs << Dir["lib"]
|
51
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Describe your gem and declare its dependencies:
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "formol-bbcode"
|
6
|
+
s.version = "1.0.0"
|
7
|
+
s.authors = ["Florian DUTEY"]
|
8
|
+
s.email = ["fdutey@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/mulasse/formol-markdown"
|
10
|
+
s.summary = "BBCode formatter for formol forum engine"
|
11
|
+
s.description = "BBCode formatter for formol forum engine"
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.add_dependency 'pygments.rb'
|
17
|
+
s.add_dependency 'bbcoder'
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'bbcoder'
|
2
|
+
|
3
|
+
module Formol
|
4
|
+
module Formatters
|
5
|
+
module BBCoder
|
6
|
+
class Extensions
|
7
|
+
::BBCoder.configure do
|
8
|
+
tag :code do
|
9
|
+
output = ""
|
10
|
+
|
11
|
+
output << Formol::Formatters::BBCoder::Extensions.title_block(meta)
|
12
|
+
output << Pygments.highlight(content, :lexer => meta,
|
13
|
+
:options => {
|
14
|
+
:linenos => 'inline' })
|
15
|
+
|
16
|
+
output
|
17
|
+
end
|
18
|
+
|
19
|
+
tag :quote do
|
20
|
+
wrote = I18n.t('formol.posts.wrote')
|
21
|
+
|
22
|
+
%{<blockquote>\n<p><strong>#{meta} #{wrote}:</strong></p>\n#{content}\n</blockquote>}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def title_block(language)
|
30
|
+
return nil if language.blank?
|
31
|
+
|
32
|
+
%{<div class="highlight_title #{language.downcase}">#{language.downcase.capitalize}</div>}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bbcoder'
|
2
|
+
require 'pygments.rb'
|
3
|
+
|
4
|
+
module Formol
|
5
|
+
module Formatters
|
6
|
+
module BBCoder
|
7
|
+
class Formatter
|
8
|
+
def to_html(text)
|
9
|
+
::BBCoder.new(text).to_html.html_safe
|
10
|
+
end
|
11
|
+
|
12
|
+
def quote(author_name, text)
|
13
|
+
%{[quote=#{author_name}]\n#{text}\n[/quote]}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: formol-bbcode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Florian DUTEY
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-19 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pygments.rb
|
16
|
+
requirement: &78276420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *78276420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bbcoder
|
27
|
+
requirement: &78276060 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *78276060
|
36
|
+
description: BBCode formatter for formol forum engine
|
37
|
+
email:
|
38
|
+
- fdutey@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- formol-bbcode.gemspec
|
48
|
+
- lib/formol-bbcode.rb
|
49
|
+
- lib/formol/formatters/bbcoder/extensions.rb
|
50
|
+
- lib/formol/formatters/bbcoder/formatter.rb
|
51
|
+
homepage: https://github.com/mulasse/formol-markdown
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.10
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: BBCode formatter for formol forum engine
|
75
|
+
test_files: []
|