sinatra-s3 0.98 → 0.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README +36 -18
  2. data/bin/sinatra-s3 +47 -15
  3. data/examples/wiki.rb +13 -13
  4. data/lib/sinatra-s3/admin.rb +1 -1
  5. data/lib/sinatra-s3/base.rb +1 -5
  6. data/lib/sinatra-s3/models/bit.rb +2 -2
  7. data/lib/sinatra-s3/s3.rb +11 -4
  8. data/public/js/wiki.js +35 -0
  9. data/s3.yml.example +6 -3
  10. metadata +63 -67
  11. data/examples/README +0 -9
  12. data/examples/wikicloth/MIT-LICENSE +0 -20
  13. data/examples/wikicloth/README +0 -81
  14. data/examples/wikicloth/Rakefile +0 -23
  15. data/examples/wikicloth/init.rb +0 -1
  16. data/examples/wikicloth/install.rb +0 -0
  17. data/examples/wikicloth/lib/core_ext.rb +0 -43
  18. data/examples/wikicloth/lib/wiki_buffer.rb +0 -279
  19. data/examples/wikicloth/lib/wiki_buffer/html_element.rb +0 -237
  20. data/examples/wikicloth/lib/wiki_buffer/link.rb +0 -70
  21. data/examples/wikicloth/lib/wiki_buffer/table.rb +0 -159
  22. data/examples/wikicloth/lib/wiki_buffer/var.rb +0 -77
  23. data/examples/wikicloth/lib/wiki_cloth.rb +0 -61
  24. data/examples/wikicloth/lib/wiki_link_handler.rb +0 -138
  25. data/examples/wikicloth/lib/wikicloth.rb +0 -5
  26. data/examples/wikicloth/run_tests.rb +0 -48
  27. data/examples/wikicloth/sample_documents/air_force_one.wiki +0 -170
  28. data/examples/wikicloth/sample_documents/cheatsheet.wiki +0 -205
  29. data/examples/wikicloth/sample_documents/default.css +0 -34
  30. data/examples/wikicloth/sample_documents/elements.wiki +0 -7
  31. data/examples/wikicloth/sample_documents/george_washington.wiki +0 -526
  32. data/examples/wikicloth/sample_documents/images.wiki +0 -15
  33. data/examples/wikicloth/sample_documents/lists.wiki +0 -421
  34. data/examples/wikicloth/sample_documents/pipe_trick.wiki +0 -68
  35. data/examples/wikicloth/sample_documents/random.wiki +0 -55
  36. data/examples/wikicloth/sample_documents/tv.wiki +0 -312
  37. data/examples/wikicloth/sample_documents/wiki.png +0 -0
  38. data/examples/wikicloth/sample_documents/wiki_tables.wiki +0 -410
  39. data/examples/wikicloth/tasks/wikicloth_tasks.rake +0 -0
  40. data/examples/wikicloth/test/test_helper.rb +0 -3
  41. data/examples/wikicloth/test/wiki_cloth_test.rb +0 -8
  42. data/examples/wikicloth/uninstall.rb +0 -0
  43. data/examples/wikicloth/wikicloth-0.1.3.gem +0 -0
  44. data/examples/wikicloth/wikicloth.gemspec +0 -69
  45. data/public/test.html +0 -8
data/examples/README DELETED
@@ -1,9 +0,0 @@
1
- To use the example wiki application insure you first have the wikicloth and ruby-git
2
- gems installed, and you have followed all the Sinatra-S3 install instructions. Once
3
- you have Sinatra-S3 running correctly run the following commands in the Sinatra-S3
4
- root directory.
5
-
6
- rake setup:wiki
7
- rackup examples/wiki.ru -p 6060
8
-
9
- Access your Wiki at http://localhost:6060/ and admin at http://localhost:6060/control/
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,81 +0,0 @@
1
- Ruby implementation of the MediaWiki markup language.
2
-
3
- Supports
4
- ---------------------------------------------------
5
-
6
- * Variables, Templates {{ ... }}
7
- * Links
8
- o External Links [ ... ]
9
- o Internal Links, Images [[ ... ]]
10
- + (see also pipe trick)
11
- * Wikimedia Markup
12
- o == Headings ==
13
- o Lists (*#;:)
14
- o bold ('''), italic ('') or both (''''')
15
- o Horizontal rule (----)
16
- o Tables
17
- * <code>,<nowiki>,<pre> (disable wiki markup)
18
- o space at the beginning of a line (<pre>)
19
- * <ref> and <references/> support
20
- * html sanitization
21
-
22
- Install
23
- ---------------------------------------------------
24
-
25
- git clone git://github.com/nricciar/wikicloth.git
26
- cd wikicloth/
27
- gem build wikicloth.gemspec
28
- sudo gem install wikicloth-0.1.3.gem
29
-
30
- Usage
31
- ---------------------------------------------------
32
-
33
- include WikiCloth
34
-
35
- @wiki = WikiCloth.new({
36
- :data => "<nowiki>{{test}}</nowiki> ''Hello {{test}}!''\n",
37
- :params => { "test" => "World" } })
38
- @wiki.to_html => "<p>&#123;&#123;test&#125;&#125; <i>Hello World!</i></p>"
39
-
40
-
41
- Wiki Links and Variable/Template Handling
42
- ---------------------------------------------------
43
-
44
- Use the url_for and link_attributes_for methods to override the default URL for
45
- an [[internal link]]. If you need even more control, the link_for can also be
46
- used to return raw html.
47
-
48
- class CustomLinkHandler < WikiCloth::WikiLinkHandler
49
-
50
- def url_for(page)
51
- "javascript:alert('You clicked on: #{page}');"
52
- end
53
-
54
- def link_attributes_for(page)
55
- { :href => url_for(page) }
56
- end
57
-
58
- def include_resource(resource,options=[])
59
- case resource
60
- when "date"
61
- Time.now.to_s
62
- else
63
- # default behavior
64
- super(resource,options)
65
- end
66
- end
67
-
68
- end
69
-
70
-
71
- @wiki = WikiCloth::WikiCloth.new({
72
- :params => { "PAGENAME" => "Testing123" },
73
- :link_handler => CustomLinkHandler.new,
74
- :data => "Hello World From {{ PAGENAME }} on {{ date }}\n"
75
- })
76
-
77
- @wiki.to_html =>
78
- <p>
79
- <a href="javascript:alert('You clicked on: Hello World');">Hello World</a> From Testing123 on Wed Jul 08 22:23:44 -0400 2009
80
- </p>
81
-
@@ -1,23 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- desc 'Default: run unit tests.'
6
- task :default => :test
7
-
8
- desc 'Test the wikicloth plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
14
- end
15
-
16
- desc 'Generate documentation for the wikicloth plugin.'
17
- Rake::RDocTask.new(:rdoc) do |rdoc|
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = 'WikiCloth'
20
- rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
23
- end
@@ -1 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), "lib", "wikicloth")
File without changes
@@ -1,43 +0,0 @@
1
- module ExtendedString
2
-
3
- def blank?
4
- respond_to?(:empty?) ? empty? : !self
5
- end
6
-
7
- def to_slug
8
- self.gsub(/\W+/, '-').gsub(/^-+/,'').gsub(/-+$/,'').downcase
9
- end
10
-
11
- def auto_link
12
- url_check = Regexp.new( '(^|[\n ])([\w]+?://[\w]+[^ \"\r\n\t<]*)', Regexp::MULTILINE | Regexp::IGNORECASE )
13
- www_check = Regexp.new( '(^|[\n ])((www)\.[^ \"\t\n\r<]*)', Regexp::MULTILINE | Regexp::IGNORECASE )
14
- self.gsub!(url_check, '\1<a href="\2">\2</a>')
15
- self.gsub!(www_check, '\1<a href="http://\2">\2</a>')
16
- to_s
17
- end
18
-
19
- def dump()
20
- ret = to_s
21
- delete!(to_s)
22
- ret
23
- end
24
-
25
- def smart_split(char)
26
- ret = []
27
- tmp = ""
28
- inside = 0
29
- to_s.each_char do |x|
30
- if x == char && inside == 0
31
- ret << tmp
32
- tmp = ""
33
- else
34
- inside += 1 if x == "[" || x == "{" || x == "<"
35
- inside -= 1 if x == "]" || x == "}" || x == ">"
36
- tmp += x
37
- end
38
- end
39
- ret << tmp unless tmp.empty?
40
- ret
41
- end
42
-
43
- end
@@ -1,279 +0,0 @@
1
- module WikiCloth
2
- class WikiBuffer
3
-
4
- def initialize(data="",options={})
5
- @options = options
6
- self.data = data
7
- self.buffer_type = nil
8
- @section_count = 0
9
- @buffers ||= [ ]
10
- @buffers << self
11
- @list_data = []
12
- end
13
-
14
- def run_globals?
15
- true
16
- end
17
-
18
- def skip_html?
19
- false
20
- end
21
-
22
- def data
23
- @data ||= ""
24
- end
25
-
26
- def params
27
- @params ||= [ "" ]
28
- end
29
-
30
- def buffer_type
31
- @buffer_type
32
- end
33
-
34
- def to_s
35
- "<p>" + self.params.join("\n") + "</p>"
36
- end
37
-
38
- def check_globals()
39
- return false if self.class != WikiBuffer
40
-
41
- if previous_char == "\n"
42
- if @indent == @buffers[-1].object_id && current_char != " " && current_char != "\n"
43
- # close pre tag
44
- cc_temp = current_char
45
- "</pre>\n".each_char { |c| self.add_char(c) }
46
- # get the parser back on the right track
47
- "\n#{cc_temp}".each_char { |c| @buffers[-1].add_char(c) }
48
- @indent = nil
49
- return true
50
- end
51
- if current_char == " " && @indent.nil? && @buffers[-1].class != WikiBuffer::HTMLElement
52
- "\n<pre> ".each_char { |c| @buffers[-1].add_char(c) }
53
- @indent = @buffers[-1].object_id
54
- return true
55
- end
56
- end
57
-
58
- if @buffers[-1].run_globals?
59
- # new html tag
60
- if @check_new_tag == true && current_char =~ /([a-z])/ && !@buffers[-1].skip_html?
61
- @buffers[-1].data.chop!
62
- parent = @buffers[-1].element_name if @buffers[-1].class == WikiBuffer::HTMLElement
63
- @buffers << WikiBuffer::HTMLElement.new("",@options,parent)
64
- end
65
- @check_new_tag = current_char == '<' ? true : false
66
-
67
- # global
68
- case
69
- # start variable
70
- when previous_char == '{' && current_char == '{'
71
- @buffers[-1].data.chop!
72
- @buffers << WikiBuffer::Var.new("",@options)
73
- return true
74
-
75
- # start link
76
- when current_char == '[' && previous_char != '['
77
- @buffers << WikiBuffer::Link.new("",@options)
78
- return true
79
-
80
- # start table
81
- when previous_char == '{' && current_char == "|"
82
- @buffers[-1].data.chop!
83
- @buffers << WikiBuffer::Table.new("",@options)
84
- return true
85
-
86
- end
87
- end
88
-
89
- return false
90
- end
91
-
92
- def add_char(c)
93
- self.previous_char = self.current_char
94
- self.current_char = c
95
-
96
- if self.check_globals() == false
97
- case
98
- when @buffers.size == 1
99
- return self.new_char()
100
- when @buffers[-1].add_char(c) == false && self.class == WikiBuffer
101
- tmp = @buffers.pop
102
- @buffers[-1].data += tmp.to_s
103
- # any data left in the buffer we feed into the parent
104
- unless tmp.data.blank?
105
- tmp.data.each_char { |c| self.add_char(c) }
106
- end
107
- end
108
- end
109
- end
110
-
111
- protected
112
- # only executed in the default state
113
- def new_char()
114
- case
115
- when current_char == "\n"
116
- if @options[:extended_markup] == true
117
- self.data.gsub!(/---([^-]+)---/,"<strike>\\1</strike>")
118
- self.data.gsub!(/_([^_]+)_/,"<u>\\1</u>")
119
- end
120
- self.data.gsub!(/__([a-zA-Z0-9]+)__/) { |r|
121
- case $1
122
- when "NOEDITSECTION"
123
- @noeditsection = true
124
- end
125
- ""
126
- }
127
- self.data.gsub!(/^([-]{4,})/) { |r| "<hr />" }
128
- self.data.gsub!(/^([=]{1,6})\s*(.*?)\s*(\1)/) { |r|
129
- @section_count += 1
130
- "<h#{$1.length}>" + (@noeditsection == true ? "" :
131
- "<span class=\"editsection\">[<a href=\"" + @options[:link_handler].section_link(@section_count) +
132
- "\" title=\"Edit section: #{$2}\">edit</a>]</span>") +
133
- " <span class=\"mw-headline\">#{$2}</span></h#{$1.length}>"
134
- }
135
- self.data.gsub!(/([\']{2,5})(.*?)(\1)/) { |r|
136
- tmp = "<i>#{$2}</i>" if $1.length == 2
137
- tmp = "<b>#{$2}</b>" if $1.length == 3
138
- tmp = "<b>'#{$2}'</b>" if $1.length == 4
139
- tmp = "<b><i>#{$2}</i></b>" if $1.length == 5
140
- tmp
141
- }
142
- lines = self.data.split("\n")
143
- self.data = ""
144
- for line in lines
145
- if !@list_data.empty? && (line.blank? || line =~ /^([^#\*:;]+)/)
146
- tmp = ""
147
- @list_data.reverse!
148
- @list_data.each { |x| tmp += "</" + list_inner_tag_for(x) + "></#{list_tag_for(x)}>" }
149
- line = "#{tmp} #{line}"
150
- @list_data = []
151
- end
152
- line.gsub!(/^([#\*:;]+)(.*)$/) { |r|
153
- cdata = []
154
- tmp = ""
155
- $1.each_char { |c| cdata << c }
156
- if @list_data.empty?
157
- tmp += "<#{list_tag_for(cdata[0])}>"
158
- cdata[1..-1].each { |x| tmp += "<" + list_inner_tag_for(cdata[0]) + "><#{list_tag_for(x)}>" } if cdata.size > 1
159
- else
160
- case
161
- when cdata.size > @list_data.size
162
- i = cdata.size-@list_data.size
163
- cdata[-i,i].each { |x| tmp += "<#{list_tag_for(x)}>" }
164
- when cdata.size < @list_data.size
165
- i = @list_data.size-cdata.size
166
- nlist = @list_data[-i,i].reverse
167
- nlist.each { |x| tmp += "</" + list_inner_tag_for(x) + "></#{list_tag_for(x)}>" }
168
- tmp += "</#{list_inner_tag_for(cdata.last)}>"
169
- else
170
- if cdata != @list_data
171
- # FIXME: this will only work if the change depth is one level
172
- unless (@list_data.last == ';' || @list_data.last == ':') && (cdata.last == ';' || cdata.last == ':')
173
- tmp += "</#{list_tag_for(@list_data.pop)}>"
174
- tmp += "<#{list_tag_for(cdata.last)}>"
175
- end
176
- else
177
- tmp += "</" + list_inner_tag_for(@list_data.last) + ">"
178
- end
179
- end
180
- end
181
- # FIXME: still probably does not detect the : properly
182
- peices = cdata.last == ";" ? $2.smart_split(":") : [ $2 ]
183
- if peices.size > 1
184
- tmp += "<#{list_inner_tag_for(cdata.last)}>#{peices[0]}</#{list_inner_tag_for(cdata.last)}>"
185
- tmp += "<dd>#{peices[1..-1].join(":")}</dd>"
186
- cdata[-1] = ":"
187
- else
188
- tmp += "<#{list_inner_tag_for(cdata.last)}>#{peices[0]}"
189
- end
190
- @list_data = cdata
191
- tmp
192
- }
193
- self.data += line + "\n"
194
- end
195
-
196
- self.data = "</p><p>" if self.data.blank?
197
-
198
- self.params << self.data.auto_link
199
- self.data = ""
200
- else
201
- self.data += current_char
202
- end
203
- return true
204
- end
205
-
206
- def name_current_param()
207
- params[-1] = { :value => "", :name => params[-1] } unless params[-1].kind_of?(Hash) || params[-1].nil?
208
- end
209
-
210
- def current_param=(val)
211
- unless self.params[-1].nil? || self.params[-1].kind_of?(String)
212
- self.params[-1][:value] = val
213
- else
214
- self.params[-1] = val
215
- end
216
- end
217
-
218
- def params=(val)
219
- @params = val
220
- end
221
-
222
- def buffer_type=(val)
223
- @buffer_type = val
224
- end
225
-
226
- def data=(val)
227
- @data = val
228
- end
229
-
230
- def current_char=(val)
231
- @current_char = val
232
- end
233
-
234
- def current_char
235
- @current_char ||= ""
236
- end
237
-
238
- def previous_char=(val)
239
- @previous_char = val
240
- end
241
-
242
- def previous_char
243
- @previous_char
244
- end
245
-
246
- def current_line=(val)
247
- @current_line = val
248
- end
249
-
250
- def current_line
251
- @current_line ||= ""
252
- end
253
-
254
- def list_tag_for(tag)
255
- case tag
256
- when "#" then "ol"
257
- when "*" then "ul"
258
- when ";" then "dl"
259
- when ":" then "dl"
260
- end
261
- end
262
-
263
- def list_inner_tag_for(tag)
264
- case tag
265
- when "#" then "li"
266
- when "*" then "li"
267
- when ";" then "dt"
268
- when ":" then "dd"
269
- end
270
- end
271
-
272
- end
273
-
274
- end
275
-
276
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_buffer", "html_element")
277
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_buffer", "table")
278
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_buffer", "var")
279
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_buffer", "link")