geditor 0.0.1

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.
Files changed (47) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +22 -0
  6. data/README.md +33 -0
  7. data/Rakefile +2 -0
  8. data/geditor.gemspec +19 -0
  9. data/lib/.svn/entries +62 -0
  10. data/lib/.svn/prop-base/coderay_string.rb.svn-base +5 -0
  11. data/lib/.svn/text-base/coderay_string.rb.svn-base +9 -0
  12. data/lib/geditor.rb +29 -0
  13. data/lib/geditor/version.rb +3 -0
  14. data/lib/helpers/geditor_helper.rb +19 -0
  15. data/lib/images/geditor/.DS_Store +0 -0
  16. data/lib/images/geditor/.svn/entries +300 -0
  17. data/lib/images/geditor/.svn/prop-base/bold.png.svn-base +9 -0
  18. data/lib/images/geditor/.svn/prop-base/code.png.svn-base +9 -0
  19. data/lib/images/geditor/.svn/prop-base/h1.png.svn-base +9 -0
  20. data/lib/images/geditor/.svn/prop-base/image.png.svn-base +9 -0
  21. data/lib/images/geditor/.svn/prop-base/italic.png.svn-base +9 -0
  22. data/lib/images/geditor/.svn/prop-base/link.png.svn-base +9 -0
  23. data/lib/images/geditor/.svn/prop-base/ordered.png.svn-base +9 -0
  24. data/lib/images/geditor/.svn/prop-base/underline.png.svn-base +9 -0
  25. data/lib/images/geditor/.svn/text-base/bold.png.svn-base +0 -0
  26. data/lib/images/geditor/.svn/text-base/code.png.svn-base +0 -0
  27. data/lib/images/geditor/.svn/text-base/h1.png.svn-base +0 -0
  28. data/lib/images/geditor/.svn/text-base/image.png.svn-base +0 -0
  29. data/lib/images/geditor/.svn/text-base/italic.png.svn-base +0 -0
  30. data/lib/images/geditor/.svn/text-base/link.png.svn-base +0 -0
  31. data/lib/images/geditor/.svn/text-base/ordered.png.svn-base +0 -0
  32. data/lib/images/geditor/.svn/text-base/underline.png.svn-base +0 -0
  33. data/lib/images/geditor/bold.png +0 -0
  34. data/lib/images/geditor/code.png +0 -0
  35. data/lib/images/geditor/h1.png +0 -0
  36. data/lib/images/geditor/image.png +0 -0
  37. data/lib/images/geditor/link.png +0 -0
  38. data/lib/images/geditor/ordered.png +0 -0
  39. data/lib/images/geditor/underline.png +0 -0
  40. data/lib/javascripts/geditor.js +76 -0
  41. data/lib/models/coderay_string.rb +9 -0
  42. data/lib/models/gformat_string.rb +81 -0
  43. data/lib/stylesheets/.svn/entries +62 -0
  44. data/lib/stylesheets/.svn/prop-base/coderay.css.svn-base +5 -0
  45. data/lib/stylesheets/.svn/text-base/coderay.css.svn-base +107 -0
  46. data/lib/stylesheets/geditor.css +108 -0
  47. metadata +124 -0
Binary file
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in geditor.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 zhangzhe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Geditor
2
+ This gem distills from gblog, my old light weight blog. it includes light weight texteditor, textile like syntax and code syntax highlight.
3
+
4
+ # Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'geditor'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install geditor
17
+
18
+ ## Usage
19
+
20
+ in view for generating text:
21
+ <%= use_geditor %>
22
+ <%= f.text_area :content, :id => "geditor", :class => 'text_area' %>
23
+
24
+ in view for display text:
25
+ <%= g_format content %>
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/geditor/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["zhangzhe"]
6
+ gem.email = ["gary.zzhang@gmail.com"]
7
+ gem.description = %q{Distill from gblog, including editor, textile like syntax and code syntax highlight'}
8
+ gem.summary = %q{Write a gem summary}
9
+ gem.homepage = ""
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "geditor"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Geditor::VERSION
16
+
17
+ gem.add_dependency "coderay"
18
+ gem.add_dependency('actionpack')
19
+ end
@@ -0,0 +1,62 @@
1
+ 10
2
+
3
+ dir
4
+ 501
5
+ svn://192.168.5.80/root/svn/gblog/vendor/plugins/coderay/lib
6
+ svn://192.168.5.80
7
+
8
+
9
+
10
+ 2012-01-31T00:36:53.539300Z
11
+ 367
12
+ gary
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ 25b8973a-7b73-4531-a164-de256929bd6b
28
+
29
+ coderay_string.rb
30
+ file
31
+
32
+
33
+
34
+
35
+ 2012-02-01T00:35:45.000000Z
36
+ 502825410ed2f34e845df67da0d33f34
37
+ 2012-01-31T00:36:53.539300Z
38
+ 367
39
+ gary
40
+ has-props
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ 299
62
+
@@ -0,0 +1,5 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ END
@@ -0,0 +1,9 @@
1
+ class CoderayString < String
2
+ def format
3
+ content = self
4
+ content.scan(/(\[code\:([a-z].+?)\](.+?)\[\/code\])/m).each do |match|
5
+ content.gsub!(match[0], CodeRay.scan(match[2].strip, match[1].to_sym).div({:css => :class, :line_numbers => :table}))
6
+ end
7
+ return content
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ require "geditor/version"
2
+ require 'action_view'
3
+ require 'coderay'
4
+ require File.expand_path('../models/coderay_string.rb', __FILE__)
5
+ require File.expand_path('../models/gformat_string.rb', __FILE__)
6
+ require File.expand_path('../helpers/geditor_helper.rb', __FILE__)
7
+
8
+ class GeditorUtils
9
+ def self.copy_files
10
+ require "fileutils"
11
+ dir = "app/assets/stylesheets"
12
+ file = File.expand_path('../stylesheets/geditor.css', __FILE__)
13
+ FileUtils.mkdir_p dir unless File.exists? dir
14
+ FileUtils.cp(file, dir)
15
+
16
+ dir = "app/assets/javascripts"
17
+ file = File.expand_path('../javascripts/geditor.js', __FILE__)
18
+ FileUtils.mkdir_p dir unless File.exists? dir
19
+ FileUtils.cp(file, dir)
20
+
21
+ dir = "app/assets/images"
22
+ folder = File.expand_path('../images/geditor/', __FILE__)
23
+ FileUtils.mkdir_p dir unless File.exists? dir
24
+ FileUtils.cp_r(folder, dir)
25
+ rescue
26
+ end
27
+ end
28
+
29
+ GeditorUtils.copy_files
@@ -0,0 +1,3 @@
1
+ module Geditor
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ module GeditorHelper
2
+ def g_format(text)
3
+ if text
4
+ result = ""
5
+ while text =~ /(\[code\:([a-z].+?)\](.+?)\[\/code\])/m
6
+ result << GformatString.new($`).to_html_format + $&
7
+ text = $'
8
+ end
9
+ result << GformatString.new(text).to_html_format
10
+ return raw CoderayString.new(result).format
11
+ end
12
+ end
13
+
14
+ def use_geditor
15
+ raw %q(<script>gEditor('geditor'); </script>)
16
+ end
17
+ end
18
+
19
+ ActionView::Base.send :include, GeditorHelper
@@ -0,0 +1,300 @@
1
+ 10
2
+
3
+ dir
4
+ 501
5
+ svn://192.168.5.80/root/svn/gblog/app/assets/images/editor_buttons
6
+ svn://192.168.5.80
7
+
8
+
9
+
10
+ 2012-01-17T01:05:53.832233Z
11
+ 311
12
+ gary
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ 25b8973a-7b73-4531-a164-de256929bd6b
28
+
29
+ link.png
30
+ file
31
+
32
+
33
+
34
+
35
+ 2010-01-14T02:02:24.000000Z
36
+ c6fa4bfa9b79bd2e7b4584c620fe7d45
37
+ 2012-01-17T01:05:53.832233Z
38
+ 311
39
+ gary
40
+ has-props
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ 408
62
+
63
+ bold.png
64
+ file
65
+
66
+
67
+
68
+
69
+ 2010-01-14T02:02:24.000000Z
70
+ 3dcb745bc791b6202d1240d9bafe0d31
71
+ 2012-01-17T01:05:53.832233Z
72
+ 311
73
+ gary
74
+ has-props
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ 360
96
+
97
+ image.png
98
+ file
99
+
100
+
101
+
102
+
103
+ 2010-01-14T02:02:24.000000Z
104
+ a019d4705b0dfe0382f9c0ba8ac8dd11
105
+ 2012-01-17T01:05:53.832233Z
106
+ 311
107
+ gary
108
+ has-props
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ 1142
130
+
131
+ ordered.png
132
+ file
133
+
134
+
135
+
136
+
137
+ 2010-01-14T02:02:24.000000Z
138
+ a723a4ac54c0fc3c9adae481e0eb1fc0
139
+ 2012-01-17T01:05:53.832233Z
140
+ 311
141
+ gary
142
+ has-props
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ 365
164
+
165
+ italic.png
166
+ file
167
+
168
+
169
+
170
+
171
+ 2010-01-14T02:02:24.000000Z
172
+ a7fee982e4b09623d07b8a74093dff15
173
+ 2012-01-17T01:05:53.832233Z
174
+ 311
175
+ gary
176
+ has-props
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ 312
198
+
199
+ underline.png
200
+ file
201
+
202
+
203
+
204
+
205
+ 2010-01-14T02:02:24.000000Z
206
+ ca71284ce14f1c438226a59bc9d2ac99
207
+ 2012-01-17T01:05:53.832233Z
208
+ 311
209
+ gary
210
+ has-props
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+ 1055
232
+
233
+ h1.png
234
+ file
235
+
236
+
237
+
238
+
239
+ 2010-01-14T02:02:24.000000Z
240
+ 6c7876f619e37046022766d2de1ee5aa
241
+ 2012-01-17T01:05:53.832233Z
242
+ 311
243
+ gary
244
+ has-props
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ 362
266
+
267
+ code.png
268
+ file
269
+
270
+
271
+
272
+
273
+ 2010-01-14T02:02:24.000000Z
274
+ 661505d2efc05b2347492e4949f564d5
275
+ 2012-01-17T01:05:53.832233Z
276
+ 311
277
+ gary
278
+ has-props
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ 626
300
+
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
@@ -0,0 +1,9 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ K 13
6
+ svn:mime-type
7
+ V 24
8
+ application/octet-stream
9
+ END
Binary file
@@ -0,0 +1,76 @@
1
+ /*****************************************/
2
+ // Name: Javascript Textarea HTML Editor
3
+ // Version: 1.3
4
+ // Author: Balakrishnan
5
+ // Modified by: Gary Zhang
6
+ // Last Modified Date: 13/Sep/2012
7
+ // License: Free
8
+ // URL: http://www.corpocrat.com
9
+ /******************************************/
10
+
11
+ var textarea;
12
+ var content;
13
+ function gEditor(obj) {
14
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/bold.png\" name=\"btnBold\" title=\"Bold\" onClick=\"doAddTags('*','*','" + obj + "')\">");
15
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/underline.png\" name=\"btnUnderline\" title=\"Underline\" onClick=\"doAddTags('+','+','" + obj + "')\">");
16
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/h1.png\" name=\"btnHead\" title=\"Head1\" onClick=\"doAddTags('[h]','[/h]','" + obj + "')\">");
17
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/ordered.png\" name=\"btnList\" title=\"Unordered List\" onClick=\"doList('<ul>','</ul>','" + obj + "')\">");
18
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/code.png\" name=\"btnCode\" title=\"Code\" onClick=\"doAddTags('[code:ruby]','[/code]','" + obj + "')\">");
19
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/link.png\" name=\"btnLink\" title=\"Insert Link\" onClick=\"doAddTags('[link: link_description]','[/link]','" + obj + "')\">");
20
+ document.write("<img class=\"button\" src=\"/assets/editor_buttons/image.png\" name=\"btnPicture\" title=\"Insert Picture\" onClick=\"doAddTags('[img]','[/img]','" + obj + "')\">");
21
+ document.write("<br>"); }
22
+
23
+ function doAddTags(tag1,tag2,obj)
24
+ {
25
+ textarea = document.getElementById(obj);
26
+ if (document.selection) // Code for IE
27
+ {
28
+ textarea.focus();
29
+ var sel = document.selection.createRange();
30
+ sel.text = tag1 + sel.text + tag2;
31
+ }
32
+ else // Code for Mozilla Firefox
33
+ {
34
+ var len = textarea.value.length;
35
+ var start = textarea.selectionStart;
36
+ var end = textarea.selectionEnd;
37
+ var scrollTop = textarea.scrollTop;
38
+ var scrollLeft = textarea.scrollLeft;
39
+ var sel = textarea.value.substring(start, end);
40
+ var rep = tag1 + sel + tag2;
41
+ textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
42
+ textarea.scrollTop = scrollTop;
43
+ textarea.scrollLeft = scrollLeft;
44
+ }
45
+ }
46
+
47
+ function doList(tag1,tag2,obj)
48
+ {
49
+ textarea = document.getElementById(obj);
50
+ if (document.selection) // Code for IE
51
+ {
52
+ textarea.focus();
53
+ var sel = document.selection.createRange();
54
+ var list = sel.text.split('\n');
55
+ for(i=0;i<list.length;i++)
56
+ { list[i] = '* ' + list[i]; }
57
+ sel.text = list.join("\n");
58
+ }
59
+ else // Code for Firefox
60
+ {
61
+ var len = textarea.value.length;
62
+ var start = textarea.selectionStart;
63
+ var end = textarea.selectionEnd;
64
+ var i;
65
+ var scrollTop = textarea.scrollTop;
66
+ var scrollLeft = textarea.scrollLeft;
67
+ var sel = textarea.value.substring(start, end);
68
+ var list = sel.split('\n');
69
+ for(i=0;i<list.length;i++)
70
+ { list[i] = '* ' + list[i]; }
71
+ var rep = list.join("\n");
72
+ textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
73
+ textarea.scrollTop = scrollTop;
74
+ textarea.scrollLeft = scrollLeft;
75
+ }
76
+ }
@@ -0,0 +1,9 @@
1
+ class CoderayString < String
2
+ def format
3
+ content = self
4
+ content.scan(/(\[code\:([a-z].+?)\](.+?)\[\/code\])/m).each do |match|
5
+ content.gsub!(match[0], CodeRay.scan(match[2].strip, match[1].to_sym).div({:css => :class}))
6
+ end
7
+ return content
8
+ end
9
+ end
@@ -0,0 +1,81 @@
1
+ class GformatString < String
2
+ def to_html_format
3
+ content = self
4
+ classes_in_order = self.class.subclasses.map(&:to_s).sort.map(&:constantize)
5
+ classes_in_order.each do |formatable_string|
6
+ content = formatable_string.new(content).format
7
+ end
8
+ return content
9
+ end
10
+ end
11
+
12
+ #importent to put it in first (not good)
13
+ class ListString < GformatString
14
+ def format
15
+ content = self + "\n" # add \n
16
+ content.gsub!(/(^\* [^\n]+\n)+/) {|ul| "<ul>#{ul.gsub!(/\* [^\n]+\n/){|li| "<li>#{li[2..-2]}</li>"} }<\/ul>"}
17
+ return content[0..-2] # remove \n
18
+ end
19
+ end
20
+
21
+ class NString < GformatString
22
+ def format
23
+ return self.gsub("\n", "<br/>\n\r").gsub("\t", "&nbsp;&nbsp;")
24
+ end
25
+ end
26
+
27
+ class FontSizeString < GformatString
28
+ def format
29
+ return self.gsub(/\[h\](.+)\[\/h\]/,'<span style="font-size:27px">\1</span>')
30
+ end
31
+ end
32
+
33
+ class ImageString < GformatString
34
+ def format
35
+ return self.gsub(/\[img(:*.*)\](.+?)\[\/img\]/,'<img style="float\1" src="\2">')
36
+ end
37
+ end
38
+
39
+ class UrlString < GformatString
40
+ def format
41
+ return self.gsub(/\[link:(.+?)\](.+?)\[\/link\]/, '<a target="_blank" style="color:#2894FF" href=\2>\1</a>')
42
+ end
43
+ end
44
+
45
+ class RuleString < GformatString
46
+ RULES = {"*" => "</b>", "#" => "</h>"}
47
+ def format
48
+ @content = self
49
+ unescape_rule = generate_unescape_rule
50
+ escape_rule = generate_escape_rule(unescape_rule)
51
+ escape(escape_rule)
52
+ convert
53
+ escape(unescape_rule)
54
+ return @content
55
+ end
56
+
57
+ private
58
+ def convert
59
+ RULES.each do |key, value|
60
+ while @content =~ /#{"\\"+key}(.+?)#{"\\"+key}/m
61
+ @content = $` + value.delete("/") + $1 + value + $'
62
+ end
63
+ end
64
+ end
65
+
66
+ def generate_unescape_rule
67
+ un_escape_rule = []
68
+ RULES.each_key do |key|
69
+ un_escape_rule << [Kernel.rand.to_s, key]
70
+ end
71
+ un_escape_rule
72
+ end
73
+
74
+ def generate_escape_rule(un_escape_rule)
75
+ return un_escape_rule.map{|rule| ["\\" + rule[1], rule[0]]}
76
+ end
77
+
78
+ def escape(escape_rules)
79
+ escape_rules.each { |escape_rule| @content.gsub!(escape_rule[0], escape_rule[1]) }
80
+ end
81
+ end
@@ -0,0 +1,62 @@
1
+ 10
2
+
3
+ dir
4
+ 501
5
+ svn://192.168.5.80/root/svn/gblog/vendor/plugins/coderay/stylesheets
6
+ svn://192.168.5.80
7
+
8
+
9
+
10
+ 2012-01-17T03:02:16.221898Z
11
+ 322
12
+ gary
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ 25b8973a-7b73-4531-a164-de256929bd6b
28
+
29
+ coderay.css
30
+ file
31
+
32
+
33
+
34
+
35
+ 2012-01-18T07:07:57.000000Z
36
+ 38d0d123d2b0ddf093f0efff19ee9bf9
37
+ 2012-01-17T03:02:16.221898Z
38
+ 322
39
+ gary
40
+ has-props
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ 4077
62
+
@@ -0,0 +1,5 @@
1
+ K 14
2
+ svn:executable
3
+ V 1
4
+ *
5
+ END
@@ -0,0 +1,107 @@
1
+ .CodeRay {
2
+ background-color: hsl(0,0%,95%);
3
+ border: 1px solid silver;
4
+ color: black;
5
+ }
6
+ .CodeRay pre {
7
+ margin: 0px;
8
+ }
9
+
10
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
11
+
12
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
13
+ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
14
+
15
+ .CodeRay .line-numbers {
16
+ background-color: hsl(180,65%,90%);
17
+ color: gray;
18
+ text-align: right;
19
+ -webkit-user-select: none;
20
+ -moz-user-select: none;
21
+ user-select: none;
22
+ }
23
+ .CodeRay .line-numbers a {
24
+ background-color: hsl(180,65%,90%) !important;
25
+ color: gray !important;
26
+ text-decoration: none !important;
27
+ }
28
+ .CodeRay .line-numbers a:target { color: blue !important; }
29
+ .CodeRay .line-numbers .highlighted { color: red !important; }
30
+ .CodeRay .line-numbers .highlighted a { color: red !important; }
31
+ .CodeRay span.line-numbers { padding: 0px 4px; }
32
+ .CodeRay .line { display: block; float: left; width: 100%; }
33
+ .CodeRay .code { width: 100%; }
34
+ .CodeRay .code pre { overflow: auto; }
35
+
36
+ .CodeRay .debug { color: white !important; background: blue !important; }
37
+
38
+ .CodeRay .annotation { color:#007 }
39
+ .CodeRay .attribute-name { color:#b48 }
40
+ .CodeRay .attribute-value { color:#700 }
41
+ .CodeRay .binary { color:#509 }
42
+ .CodeRay .char .content { color:#D20 }
43
+ .CodeRay .char .delimiter { color:#710 }
44
+ .CodeRay .char { color:#D20 }
45
+ .CodeRay .class { color:#B06; font-weight:bold }
46
+ .CodeRay .class-variable { color:#369 }
47
+ .CodeRay .color { color:#0A0 }
48
+ .CodeRay .comment { color:#777 }
49
+ .CodeRay .comment .char { color:#444 }
50
+ .CodeRay .comment .delimiter { color:#444 }
51
+ .CodeRay .complex { color:#A08 }
52
+ .CodeRay .constant { color:#036; font-weight:bold }
53
+ .CodeRay .decorator { color:#B0B }
54
+ .CodeRay .definition { color:#099; font-weight:bold }
55
+ .CodeRay .delimiter { color:black }
56
+ .CodeRay .directive { color:#088; font-weight:bold }
57
+ .CodeRay .doc { color:#970 }
58
+ .CodeRay .doc-string { color:#D42; font-weight:bold }
59
+ .CodeRay .doctype { color:#34b }
60
+ .CodeRay .entity { color:#800; font-weight:bold }
61
+ .CodeRay .error { color:#F00; background-color:#FAA }
62
+ .CodeRay .escape { color:#666 }
63
+ .CodeRay .exception { color:#C00; font-weight:bold }
64
+ .CodeRay .float { color:#60E }
65
+ .CodeRay .function { color:#06B; font-weight:bold }
66
+ .CodeRay .global-variable { color:#d70 }
67
+ .CodeRay .hex { color:#02b }
68
+ .CodeRay .imaginary { color:#f00 }
69
+ .CodeRay .include { color:#B44; font-weight:bold }
70
+ .CodeRay .inline { background-color: hsla(0,0%,0%,0.07); color: black }
71
+ .CodeRay .inline-delimiter { font-weight: bold; color: #666 }
72
+ .CodeRay .instance-variable { color:#33B }
73
+ .CodeRay .integer { color:#00D }
74
+ .CodeRay .key .char { color: #60f }
75
+ .CodeRay .key .delimiter { color: #404 }
76
+ .CodeRay .key { color: #606 }
77
+ .CodeRay .keyword { color:#080; font-weight:bold }
78
+ .CodeRay .label { color:#970; font-weight:bold }
79
+ .CodeRay .local-variable { color:#963 }
80
+ .CodeRay .namespace { color:#707; font-weight:bold }
81
+ .CodeRay .octal { color:#40E }
82
+ .CodeRay .operator { }
83
+ .CodeRay .predefined { color:#369; font-weight:bold }
84
+ .CodeRay .predefined-constant { color:#069 }
85
+ .CodeRay .predefined-type { color:#0a5; font-weight:bold }
86
+ .CodeRay .preprocessor { color:#579 }
87
+ .CodeRay .pseudo-class { color:#00C; font-weight:bold }
88
+ .CodeRay .regexp .content { color:#808 }
89
+ .CodeRay .regexp .delimiter { color:#404 }
90
+ .CodeRay .regexp .modifier { color:#C2C }
91
+ .CodeRay .regexp { background-color:hsla(300,100%,50%,0.06); }
92
+ .CodeRay .reserved { color:#080; font-weight:bold }
93
+ .CodeRay .shell .content { color:#2B2 }
94
+ .CodeRay .shell .delimiter { color:#161 }
95
+ .CodeRay .shell { background-color:hsla(120,100%,50%,0.06); }
96
+ .CodeRay .string .char { color: #b0b }
97
+ .CodeRay .string .content { color: #D20 }
98
+ .CodeRay .string .delimiter { color: #710 }
99
+ .CodeRay .string .modifier { color: #E40 }
100
+ .CodeRay .string { background-color:hsla(0,100%,50%,0.05); }
101
+ .CodeRay .symbol .content { color:#A60 }
102
+ .CodeRay .symbol .delimiter { color:#630 }
103
+ .CodeRay .symbol { color:#A60 }
104
+ .CodeRay .tag { color:#070 }
105
+ .CodeRay .type { color:#339; font-weight:bold }
106
+ .CodeRay .value { color: #088; }
107
+ .CodeRay .variable { color:#037 }
@@ -0,0 +1,108 @@
1
+ .CodeRay {
2
+ background-color: hsl(0,0%,95%);
3
+ border: 1px solid silver;
4
+ color: black;
5
+ }
6
+
7
+ .CodeRay pre {
8
+ margin: 0px;
9
+ font-size:12px;
10
+ }
11
+
12
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
13
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
14
+ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
15
+
16
+ .CodeRay .line-numbers {
17
+ background-color: hsl(180,65%,90%);
18
+ color: gray;
19
+ text-align: right;
20
+ -webkit-user-select: none;
21
+ -moz-user-select: none;
22
+ user-select: none;
23
+ }
24
+
25
+ .CodeRay .line-numbers a {
26
+ background-color: hsl(180,65%,90%) !important;
27
+ color: gray !important;
28
+ text-decoration: none !important;
29
+ }
30
+
31
+ .CodeRay .line-numbers a:target { color: blue !important; }
32
+ .CodeRay .line-numbers .highlighted { color: red !important; }
33
+ .CodeRay .line-numbers .highlighted a { color: red !important; }
34
+ .CodeRay span.line-numbers { padding: 0px 4px; }
35
+ .CodeRay .line { display: block; float: left; width: 100%; }
36
+ .CodeRay .code { width: 100%; }
37
+ .CodeRay .code pre { overflow: auto; font-family: Monaco;}
38
+ .CodeRay .debug { color: white !important; background: blue !important; }
39
+ .CodeRay .annotation { color:#007 }
40
+ .CodeRay .attribute-name { color:#b48 }
41
+ .CodeRay .attribute-value { color:#700 }
42
+ .CodeRay .binary { color:#509 }
43
+ .CodeRay .char .content { color:#D20 }
44
+ .CodeRay .char .delimiter { color:#710 }
45
+ .CodeRay .char { color:#D20 }
46
+ .CodeRay .class { color:#B06; font-weight:bold }
47
+ .CodeRay .class-variable { color:#369 }
48
+ .CodeRay .color { color:#0A0 }
49
+ .CodeRay .comment { color:#777 }
50
+ .CodeRay .comment .char { color:#444 }
51
+ .CodeRay .comment .delimiter { color:#444 }
52
+ .CodeRay .complex { color:#A08 }
53
+ .CodeRay .constant { color:#036; font-weight:bold }
54
+ .CodeRay .decorator { color:#B0B }
55
+ .CodeRay .definition { color:#099; font-weight:bold }
56
+ .CodeRay .delimiter { color:black }
57
+ .CodeRay .directive { color:#088; font-weight:bold }
58
+ .CodeRay .doc { color:#970 }
59
+ .CodeRay .doc-string { color:#D42; font-weight:bold }
60
+ .CodeRay .doctype { color:#34b }
61
+ .CodeRay .entity { color:#800; font-weight:bold }
62
+ .CodeRay .error { color:#F00; background-color:#FAA }
63
+ .CodeRay .escape { color:#666 }
64
+ .CodeRay .exception { color:#C00; font-weight:bold }
65
+ .CodeRay .float { color:#60E }
66
+ .CodeRay .function { color:#06B; font-weight:bold }
67
+ .CodeRay .global-variable { color:#d70 }
68
+ .CodeRay .hex { color:#02b }
69
+ .CodeRay .imaginary { color:#f00 }
70
+ .CodeRay .include { color:#B44; font-weight:bold }
71
+ .CodeRay .inline { background-color: hsla(0,0%,0%,0.07); color: black }
72
+ .CodeRay .inline-delimiter { font-weight: bold; color: #666 }
73
+ .CodeRay .instance-variable { color:#33B }
74
+ .CodeRay .integer { color:#00D }
75
+ .CodeRay .key .char { color: #60f }
76
+ .CodeRay .key .delimiter { color: #404 }
77
+ .CodeRay .key { color: #606 }
78
+ .CodeRay .keyword { color:#080; font-weight:bold }
79
+ .CodeRay .label { color:#970; font-weight:bold }
80
+ .CodeRay .local-variable { color:#963 }
81
+ .CodeRay .namespace { color:#707; font-weight:bold }
82
+ .CodeRay .octal { color:#40E }
83
+ .CodeRay .operator { }
84
+ .CodeRay .predefined { color:#369; font-weight:bold }
85
+ .CodeRay .predefined-constant { color:#069 }
86
+ .CodeRay .predefined-type { color:#0a5; font-weight:bold }
87
+ .CodeRay .preprocessor { color:#579 }
88
+ .CodeRay .pseudo-class { color:#00C; font-weight:bold }
89
+ .CodeRay .regexp .content { color:#808 }
90
+ .CodeRay .regexp .delimiter { color:#404 }
91
+ .CodeRay .regexp .modifier { color:#C2C }
92
+ .CodeRay .regexp { background-color:hsla(300,100%,50%,0.06); }
93
+ .CodeRay .reserved { color:#080; font-weight:bold }
94
+ .CodeRay .shell .content { color:#2B2 }
95
+ .CodeRay .shell .delimiter { color:#161 }
96
+ .CodeRay .shell { background-color:hsla(120,100%,50%,0.06); }
97
+ .CodeRay .string .char { color: #b0b }
98
+ .CodeRay .string .content { color: #D20 }
99
+ .CodeRay .string .delimiter { color: #710 }
100
+ .CodeRay .string .modifier { color: #E40 }
101
+ .CodeRay .string { background-color:hsla(0,100%,50%,0.05); }
102
+ .CodeRay .symbol .content { color:#A60 }
103
+ .CodeRay .symbol .delimiter { color:#630 }
104
+ .CodeRay .symbol { color:#A60 }
105
+ .CodeRay .tag { color:#070 }
106
+ .CodeRay .type { color:#339; font-weight:bold }
107
+ .CodeRay .value { color: #088; }
108
+ .CodeRay .variable { color:#037 }
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geditor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - zhangzhe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: coderay
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: actionpack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Distill from gblog, including editor, textile like syntax and code syntax
47
+ highlight'
48
+ email:
49
+ - gary.zzhang@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .DS_Store
55
+ - .gitignore
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - geditor.gemspec
62
+ - lib/.svn/entries
63
+ - lib/.svn/prop-base/coderay_string.rb.svn-base
64
+ - lib/.svn/text-base/coderay_string.rb.svn-base
65
+ - lib/geditor.rb
66
+ - lib/geditor/version.rb
67
+ - lib/helpers/geditor_helper.rb
68
+ - lib/images/geditor/.DS_Store
69
+ - lib/images/geditor/.svn/entries
70
+ - lib/images/geditor/.svn/prop-base/bold.png.svn-base
71
+ - lib/images/geditor/.svn/prop-base/code.png.svn-base
72
+ - lib/images/geditor/.svn/prop-base/h1.png.svn-base
73
+ - lib/images/geditor/.svn/prop-base/image.png.svn-base
74
+ - lib/images/geditor/.svn/prop-base/italic.png.svn-base
75
+ - lib/images/geditor/.svn/prop-base/link.png.svn-base
76
+ - lib/images/geditor/.svn/prop-base/ordered.png.svn-base
77
+ - lib/images/geditor/.svn/prop-base/underline.png.svn-base
78
+ - lib/images/geditor/.svn/text-base/bold.png.svn-base
79
+ - lib/images/geditor/.svn/text-base/code.png.svn-base
80
+ - lib/images/geditor/.svn/text-base/h1.png.svn-base
81
+ - lib/images/geditor/.svn/text-base/image.png.svn-base
82
+ - lib/images/geditor/.svn/text-base/italic.png.svn-base
83
+ - lib/images/geditor/.svn/text-base/link.png.svn-base
84
+ - lib/images/geditor/.svn/text-base/ordered.png.svn-base
85
+ - lib/images/geditor/.svn/text-base/underline.png.svn-base
86
+ - lib/images/geditor/bold.png
87
+ - lib/images/geditor/code.png
88
+ - lib/images/geditor/h1.png
89
+ - lib/images/geditor/image.png
90
+ - lib/images/geditor/link.png
91
+ - lib/images/geditor/ordered.png
92
+ - lib/images/geditor/underline.png
93
+ - lib/javascripts/geditor.js
94
+ - lib/models/coderay_string.rb
95
+ - lib/models/gformat_string.rb
96
+ - lib/stylesheets/.svn/entries
97
+ - lib/stylesheets/.svn/prop-base/coderay.css.svn-base
98
+ - lib/stylesheets/.svn/text-base/coderay.css.svn-base
99
+ - lib/stylesheets/geditor.css
100
+ homepage: ''
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Write a gem summary
124
+ test_files: []