cbot-bbcodeizer 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +21 -0
  4. data/README +128 -0
  5. data/Rakefile +22 -0
  6. data/bbcodeizer.gemspec +23 -0
  7. data/init.rb +4 -0
  8. data/lib/bbcodeizer.rb +171 -0
  9. data/lib/bbcodeizer/version.rb +3 -0
  10. data/lib/bbcodeizer_helper.rb +8 -0
  11. data/rdoc/BBCodeizeHelper.html +182 -0
  12. data/rdoc/Bbcodeizer.html +146 -0
  13. data/rdoc/README.html +214 -0
  14. data/rdoc/created.rid +5 -0
  15. data/rdoc/images/brick.png +0 -0
  16. data/rdoc/images/brick_link.png +0 -0
  17. data/rdoc/images/bug.png +0 -0
  18. data/rdoc/images/bullet_black.png +0 -0
  19. data/rdoc/images/bullet_toggle_minus.png +0 -0
  20. data/rdoc/images/bullet_toggle_plus.png +0 -0
  21. data/rdoc/images/date.png +0 -0
  22. data/rdoc/images/find.png +0 -0
  23. data/rdoc/images/loadingAnimation.gif +0 -0
  24. data/rdoc/images/macFFBgHack.png +0 -0
  25. data/rdoc/images/package.png +0 -0
  26. data/rdoc/images/page_green.png +0 -0
  27. data/rdoc/images/page_white_text.png +0 -0
  28. data/rdoc/images/page_white_width.png +0 -0
  29. data/rdoc/images/plugin.png +0 -0
  30. data/rdoc/images/ruby.png +0 -0
  31. data/rdoc/images/tag_green.png +0 -0
  32. data/rdoc/images/wrench.png +0 -0
  33. data/rdoc/images/wrench_orange.png +0 -0
  34. data/rdoc/images/zoom.png +0 -0
  35. data/rdoc/index.html +60 -0
  36. data/rdoc/js/darkfish.js +116 -0
  37. data/rdoc/js/jquery.js +32 -0
  38. data/rdoc/js/quicksearch.js +114 -0
  39. data/rdoc/js/thickbox-compressed.js +10 -0
  40. data/rdoc/lib/bbcodeize_helper_rb.html +54 -0
  41. data/rdoc/lib/bbcodeizer/version_rb.html +52 -0
  42. data/rdoc/lib/bbcodeizer_helper_rb.html +54 -0
  43. data/rdoc/lib/bbcodeizer_rb.html +52 -0
  44. data/rdoc/rdoc.css +763 -0
  45. data/test/bbcodeizer_test.rb +145 -0
  46. metadata +125 -0
@@ -0,0 +1,146 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: Bbcodeizer</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="module">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="./index.html">Home</a>
25
+ <a href="./index.html#classes">Classes</a>
26
+ <a href="./index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="./lib/bbcodeizer/version_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/bbcodeizer/version.rb">lib/bbcodeizer/version.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ </div>
58
+
59
+ <div id="project-metadata">
60
+
61
+
62
+ <div id="fileindex-section" class="section project-section">
63
+ <h3 class="section-header">Files</h3>
64
+ <ul>
65
+
66
+ <li class="file"><a href="./README.html">README</a></li>
67
+
68
+ </ul>
69
+ </div>
70
+
71
+
72
+ <div id="classindex-section" class="section project-section">
73
+ <h3 class="section-header">Class/Module Index
74
+ <span class="search-toggle"><img src="./images/find.png"
75
+ height="16" width="16" alt="[+]"
76
+ title="show/hide quicksearch" /></span></h3>
77
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
78
+ <fieldset>
79
+ <legend>Quicksearch</legend>
80
+ <input type="text" name="quicksearch" value=""
81
+ class="quicksearch-field" />
82
+ </fieldset>
83
+ </form>
84
+
85
+ <ul class="link-list">
86
+
87
+ <li><a href="./BBCodeizeHelper.html">BBCodeizeHelper</a></li>
88
+
89
+ <li><a href="./Bbcodeizer.html">Bbcodeizer</a></li>
90
+
91
+ </ul>
92
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
93
+ </div>
94
+
95
+
96
+ </div>
97
+ </div>
98
+
99
+ <div id="documentation">
100
+ <h1 class="module">Bbcodeizer</h1>
101
+
102
+ <div id="description" class="description">
103
+
104
+ </div><!-- description -->
105
+
106
+
107
+
108
+
109
+ <div id="5Buntitled-5D" class="documentation-section">
110
+
111
+
112
+
113
+
114
+
115
+ <!-- Constants -->
116
+ <div id="constants-list" class="section">
117
+ <h3 class="section-header">Constants</h3>
118
+ <dl>
119
+
120
+ <dt><a name="VERSION">VERSION</a></dt>
121
+
122
+ <dd class="description"></dd>
123
+
124
+
125
+ </dl>
126
+ </div>
127
+
128
+
129
+
130
+
131
+ <!-- Methods -->
132
+
133
+ </div><!-- 5Buntitled-5D -->
134
+
135
+
136
+ </div><!-- documentation -->
137
+
138
+ <div id="validator-badges">
139
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
140
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
141
+ Rdoc Generator</a> 2</small>.</p>
142
+ </div>
143
+
144
+ </body>
145
+ </html>
146
+
data/rdoc/README.html ADDED
@@ -0,0 +1,214 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: README [BBCodeizer]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./README.html">README</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+
47
+
48
+ <div id="classindex-section" class="section project-section">
49
+ <h3 class="section-header">Class Index
50
+ <span class="search-toggle"><img src="./images/find.png"
51
+ height="16" width="16" alt="[+]"
52
+ title="show/hide quicksearch" /></span></h3>
53
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
54
+ <fieldset>
55
+ <legend>Quicksearch</legend>
56
+ <input type="text" name="quicksearch" value=""
57
+ class="quicksearch-field" />
58
+ </fieldset>
59
+ </form>
60
+
61
+ <ul class="link-list">
62
+
63
+ <li><a href="./BBCodeizeHelper.html">BBCodeizeHelper</a></li>
64
+
65
+ <li><a href="./Bbcodeizer.html">Bbcodeizer</a></li>
66
+
67
+ </ul>
68
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
69
+ </div>
70
+
71
+
72
+ </div>
73
+ </div>
74
+
75
+ <div id="documentation">
76
+
77
+ <h2>BBCodeizer</h2>
78
+
79
+ <p>BBCodeizer is a gem used to translate BBCode to HTML. The main interface is
80
+ provided through the helper method “bbcodeize.” Use of it is as simple as
81
+ passing a string to bbcodeize:</p>
82
+
83
+ <pre>&lt;%= bbcodeize post.body %&gt;</pre>
84
+
85
+ <p>You can also invoke the BBCodeizer directly without the helper:</p>
86
+
87
+ <pre>render :text =&gt; BBCodeizer.bbcodeize(post.body)</pre>
88
+
89
+ <p>All settings are centralized so you can very quickly deactivate any tag or
90
+ modify the HTML that is generated. You can modify these settings by adding
91
+ lines to the end of your environment.rb. For example:</p>
92
+
93
+ <pre># deactivate [color], [size], and [code] tags
94
+ BBCodeizer.deactivate(:color, :size, :code)
95
+
96
+ # use &lt;b&gt; instead of &lt;strong&gt;
97
+ BBCodeizer.replace_using(:bold, '&lt;b&gt;\1&lt;/b&gt;')</pre>
98
+
99
+ <p>These changes should be considered one-time configuration, e.g. tags cannot
100
+ be deactivated then activated again.</p>
101
+
102
+ <h2>Warning</h2>
103
+
104
+ <p>While BBCodeizer does some validation (see below), you should be aware it
105
+ is possible to create unsafe HTML in the wrong hands (for example, invoking
106
+ Javascript using the [url] tag). It is highly recommended you run the
107
+ resulting HTML through a sanity checker such as WhiteList:</p>
108
+
109
+ <pre>http://svn.techno-weenie.net/projects/plugins/white_list/</pre>
110
+
111
+ <p>Once installed, the following is a helper method that will produce nicely
112
+ formatted, safe HTML:</p>
113
+
114
+ <pre>def format_text(text)
115
+ white_list(simple_format(auto_link(bbcodeize(h(text)))))
116
+ end</pre>
117
+
118
+ <h2>Supported Tags</h2>
119
+
120
+ <p>BBCodeizer currently supports the following tags. The default HTML
121
+ expansion is documented here.</p>
122
+
123
+ <pre>[u]text[/u]
124
+
125
+ &lt;u&gt;text&lt;/u&gt;
126
+
127
+ [b]text[/b]
128
+
129
+ &lt;strong&gt;text&lt;/strong&gt;
130
+
131
+ [i]text[/i]
132
+
133
+ &lt;em&gt;text&lt;/em&gt;
134
+
135
+ [img]http://example.com/image.gif[/img]
136
+
137
+ &lt;img src=&quot;http://example.com/image.gif&quot; /&gt;
138
+
139
+ [email=joe@example.com]Joe Example[/email]
140
+
141
+ &lt;a href=&quot;mailto:joe@example.com&quot;&gt;Joe Example&lt;/a&gt;
142
+
143
+ [email]joe@example.com[/email]
144
+
145
+ &lt;a href=&quot;mailto:joe@example.com&quot;&gt;joe@example.com&lt;/a&gt;
146
+
147
+ [code]bbcodeize(string)[/code]
148
+
149
+ &lt;pre&gt;bbcodeize(string)&lt;/pre&gt;
150
+
151
+ [url=http://www.google.com]Google[/url]
152
+
153
+ &lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;
154
+
155
+ [url]http://www.google.com[/url]
156
+
157
+ &lt;a href=&quot;http://www.google.com&quot;&gt;http://www.google.com&lt;/a&gt;
158
+
159
+ [quote=&quot;Shakespeare&quot;]To be or not to be[/quote]
160
+
161
+ &lt;blockquote&gt;&lt;cite&gt;Shakespeare wrote:&lt;/cite&gt;&lt;br /&gt;To be or not to
162
+ be&lt;/blockquote&gt;
163
+
164
+ [quote]That is the question[/quote]
165
+
166
+ &lt;blockquote&gt;That is the question&lt;/blockquote&gt;
167
+
168
+ [size=32]Big Text[/size]
169
+
170
+ &lt;span style=&quot;font-size: 32px&quot;&gt;Big Text&lt;/span&gt;
171
+
172
+ [color=red]Red Text[/color] [color=#ABCDEF]Alphabet-colored Text[/color]
173
+
174
+ &lt;span style=&quot;color: red&quot;&gt;Red Text&lt;/span&gt;
175
+ &lt;span style=&quot;color: #ABCDEF&quot;&gt;Alphabet Colored Text&lt;/span&gt;</pre>
176
+
177
+ <h2>Validation</h2>
178
+
179
+ <p>BBCodeizer aims to produce HTML that will not break your site - all opening
180
+ tags must have a closing tag or they will not be replaced (unmatched tags
181
+ are left as-is). All [code] and [quote] tags are left entirely untouched if
182
+ there is any mismatch with either of these. All other tags will replace as
183
+ many as possible and leave the remaining unmatched tags as-is.</p>
184
+
185
+ <p>BBCodeizer attempts to produce XHTML-compliant markup, however, misuse of
186
+ nesting tags is not validated or corrected. For example:</p>
187
+
188
+ <pre>[b]bold [u]bold + underline[/b] underline[/u]</pre>
189
+
190
+ <p>Will produce the following HTML:</p>
191
+
192
+ <pre>&lt;strong&gt;bold &lt;u&gt;bold + underline&lt;/strong&gt; underline&lt;/u&gt;</pre>
193
+
194
+ <p>Colors in the [color] tag are not validated - any string can be used.
195
+ Strings containing semicolons are not allowed to prevent users from adding
196
+ additional style rules.</p>
197
+
198
+ <p>Sizes used in the [size] tag are validated - only 1 or 2 digit numbers are
199
+ accepted.</p>
200
+ <hr style="height: 10px">
201
+
202
+ <p>Copyright © 2006 Jonathan Dance / Agora Games Copyright © 2011 Luke Curley
203
+ Distributed under the MIT license</p>
204
+
205
+ </div>
206
+
207
+ <div id="validator-badges">
208
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
209
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
210
+ Rdoc Generator</a> 2</small>.</p>
211
+ </div>
212
+ </body>
213
+ </html>
214
+
data/rdoc/created.rid ADDED
@@ -0,0 +1,5 @@
1
+ Sun, 11 Sep 2011 17:03:49 -0700
2
+ README Sun, 11 Sep 2011 15:37:41 -0700
3
+ lib/bbcodeizer/version.rb Sun, 11 Sep 2011 17:03:43 -0700
4
+ lib/bbcodeizer.rb Sun, 11 Sep 2011 17:02:51 -0700
5
+ lib/bbcodeizer_helper.rb Sun, 11 Sep 2011 17:00:47 -0700
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/rdoc/index.html ADDED
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>BBCodeizer</title>
10
+
11
+ <link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
16
+ <script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
17
+
18
+ </head>
19
+ <body class="indexpage">
20
+
21
+
22
+ <h1>BBCodeizer</h1>
23
+
24
+
25
+ <p>This is the API documentation for 'BBCodeizer'.</p>
26
+
27
+
28
+
29
+
30
+ <h2>Files</h2>
31
+ <ul>
32
+
33
+ <li class="file"><a href="README.html">README</a></li>
34
+
35
+ </ul>
36
+
37
+
38
+ <h2 id="classes">Classes/Modules</h2>
39
+ <ul>
40
+
41
+ <li class="module"><a href="BBCodeizeHelper.html">BBCodeizeHelper</a></li>
42
+
43
+ <li class="module"><a href="Bbcodeizer.html">Bbcodeizer</a></li>
44
+
45
+ </ul>
46
+
47
+ <h2 id="methods">Methods</h2>
48
+ <ul>
49
+
50
+ <li><a href="BBCodeizeHelper.html#method-i-bbcodeize">#bbcodeize &mdash; BBCodeizeHelper</a></li>
51
+
52
+ </ul>
53
+
54
+ <div id="validator-badges">
55
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
56
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
57
+ Rdoc Generator</a> 2</small>.</p>
58
+ </div>
59
+ </body>
60
+ </html>