wunderbar 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -3
- data/lib/wunderbar/html-methods.rb +21 -13
- data/lib/wunderbar/rails.rb +11 -28
- data/lib/wunderbar/sinatra.rb +1 -1
- data/lib/wunderbar/version.rb +2 -2
- data/wunderbar.gemspec +3 -3
- metadata +56 -69
data/README.md
CHANGED
@@ -80,9 +80,13 @@ Element with optional (omitted) attributes:
|
|
80
80
|
|
81
81
|
_tr class: nil
|
82
82
|
|
83
|
-
Text:
|
83
|
+
Text (may contain markup):
|
84
84
|
|
85
|
-
_ "hello"
|
85
|
+
_ "<em>hello</em>!!!"
|
86
|
+
|
87
|
+
Text (markup is escaped):
|
88
|
+
|
89
|
+
_? "<3"
|
86
90
|
|
87
91
|
Mixed content (autospaced):
|
88
92
|
|
@@ -183,6 +187,7 @@ The "`_`" method serves a number of purposes. Calling it with a single argument
|
|
183
187
|
produces text nodes. Inserting markup verbatim is done by "`_ << text`". A
|
184
188
|
number of other convenience methods are defined:
|
185
189
|
|
190
|
+
* `_?`: insert markup with indentation matching the current output
|
186
191
|
* `_.post?` -- was this invoked via HTTP POST?
|
187
192
|
* `_.system` -- invokes a shell command, captures stdin, stdout, and stderr
|
188
193
|
* `_.submit` -- runs command (or block) as a deamon process
|
@@ -192,7 +197,6 @@ Access to all of the builder _defined_ methods (typically these end in an esclam
|
|
192
197
|
|
193
198
|
* `_.tag! :foo`: insert elements where the name can be dynamic
|
194
199
|
* `_.error 'Log message'`: write a message to the server log
|
195
|
-
* `_import!`: insert markup with indentation matching the current output
|
196
200
|
|
197
201
|
XHTML differs from HTML in the escaping of inline style and script elements.
|
198
202
|
XHTML will also fall back to HTML output unless the user agent indicates it
|
@@ -101,6 +101,7 @@ class HtmlMarkup < Wunderbar::BuilderBase
|
|
101
101
|
|
102
102
|
if name.sub!(/_$/,'')
|
103
103
|
@x.margin!
|
104
|
+
return __send__ "_#{name}", *args, &block if respond_to? "_#{name}"
|
104
105
|
end
|
105
106
|
|
106
107
|
if flag != '!'
|
@@ -218,14 +219,12 @@ class HtmlMarkup < Wunderbar::BuilderBase
|
|
218
219
|
@x.tag! :math, *args, &block
|
219
220
|
end
|
220
221
|
|
221
|
-
def _(text
|
222
|
-
@x.indented_text! text
|
223
|
-
@x
|
222
|
+
def _?(text)
|
223
|
+
@x.indented_text! text
|
224
224
|
end
|
225
225
|
|
226
|
-
def _!(text
|
227
|
-
@x.text! text
|
228
|
-
@x
|
226
|
+
def _!(text)
|
227
|
+
@x.text! text
|
229
228
|
end
|
230
229
|
|
231
230
|
def _coffeescript(text)
|
@@ -257,10 +256,16 @@ class HtmlMarkup < Wunderbar::BuilderBase
|
|
257
256
|
flatten
|
258
257
|
end
|
259
258
|
|
260
|
-
def
|
259
|
+
def _(children=nil)
|
260
|
+
return @x if children == nil
|
261
|
+
|
261
262
|
if String === children
|
262
|
-
|
263
|
-
|
263
|
+
if children.include? '<' or children.include? '&'
|
264
|
+
require 'nokogiri'
|
265
|
+
children = Nokogiri::HTML::fragment(children.to_s).children
|
266
|
+
else
|
267
|
+
return @x.indented_text! children
|
268
|
+
end
|
264
269
|
end
|
265
270
|
|
266
271
|
# remove leading and trailing space
|
@@ -295,10 +300,10 @@ class HtmlMarkup < Wunderbar::BuilderBase
|
|
295
300
|
while not children.empty?
|
296
301
|
stop = children.index(&block_element)
|
297
302
|
if stop == 0
|
298
|
-
|
303
|
+
_ [children.shift]
|
299
304
|
else
|
300
305
|
@x.disable_indentation! do
|
301
|
-
|
306
|
+
_ children.shift(stop || children.length)
|
302
307
|
end
|
303
308
|
end
|
304
309
|
end
|
@@ -306,15 +311,18 @@ class HtmlMarkup < Wunderbar::BuilderBase
|
|
306
311
|
else
|
307
312
|
# disable indentation on the entire element
|
308
313
|
@x.disable_indentation! do
|
309
|
-
@x.tag!(child.name, child.attributes) {
|
314
|
+
@x.tag!(child.name, child.attributes) {_ child.children}
|
310
315
|
end
|
311
316
|
end
|
312
317
|
elsif child.children.empty?
|
313
318
|
@x.tag!(child.name, child.attributes)
|
314
319
|
elsif child.children.all? {|gchild| gchild.text?}
|
315
320
|
@x.tag!(child.name, child.text.strip, child.attributes)
|
321
|
+
elsif child.children.any? {|gchild| gchild.cdata?} and
|
322
|
+
(child.text.include? '<' or child.text.include? '&')
|
323
|
+
@x << child
|
316
324
|
else
|
317
|
-
@x.tag!(child.name, child.attributes) {
|
325
|
+
@x.tag!(child.name, child.attributes) {_ child.children}
|
318
326
|
end
|
319
327
|
end
|
320
328
|
end
|
data/lib/wunderbar/rails.rb
CHANGED
@@ -2,35 +2,20 @@ require 'active_support/core_ext'
|
|
2
2
|
|
3
3
|
module Wunderbar
|
4
4
|
module Rails
|
5
|
-
class HelperProxy < HtmlMarkup
|
6
|
-
def method_missing(symbol, *args, &block)
|
7
|
-
if @_scope.respond_to? symbol
|
8
|
-
if @_scope.method(symbol).owner.parents.include? ActionView::Helpers
|
9
|
-
return _import! @_scope.__send__(symbol, *args, &block)
|
10
|
-
end
|
11
|
-
elsif @_scope.helpers.instance_methods.include? symbol
|
12
|
-
return _import! @_scope.__send__(symbol, *args, &block)
|
13
|
-
end
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
5
|
class HtmlHandler
|
19
6
|
cattr_accessor :default_format
|
20
7
|
self.default_format = Mime::HTML
|
21
8
|
|
22
9
|
def self.call(template)
|
23
|
-
|
24
|
-
|
10
|
+
%{
|
11
|
+
compiled = Proc.new {#{template.source}}
|
12
|
+
x = HtmlMarkup.new(self);
|
25
13
|
instance_variables.each do |var|
|
26
14
|
x.instance_variable_set var, instance_variable_get(var)
|
27
15
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# take care to preserve line numbers in original source
|
33
|
-
"#{pre}; x.instance_eval { #{template.source} }; #{post}"
|
16
|
+
x.instance_eval &compiled
|
17
|
+
x._.target!.join
|
18
|
+
}.strip # take care to preserve line numbers in original source
|
34
19
|
end
|
35
20
|
end
|
36
21
|
|
@@ -39,17 +24,15 @@ module Wunderbar
|
|
39
24
|
self.default_format = Mime::JSON
|
40
25
|
|
41
26
|
def self.call(template)
|
42
|
-
|
27
|
+
%{
|
28
|
+
compiled = Proc.new {#{template.source}}
|
43
29
|
x = Wunderbar::JsonBuilder.new(self);
|
44
30
|
instance_variables.each do |var|
|
45
31
|
x.instance_variable_set var, instance_variable_get(var)
|
46
32
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# take care to preserve line numbers in original source
|
52
|
-
"#{pre}; x.instance_eval { #{template.source} }; #{post}"
|
33
|
+
x.instance_eval &compiled
|
34
|
+
x.target!
|
35
|
+
}.strip # take care to preserve line numbers in original source
|
53
36
|
end
|
54
37
|
end
|
55
38
|
|
data/lib/wunderbar/sinatra.rb
CHANGED
data/lib/wunderbar/version.rb
CHANGED
data/wunderbar.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "wunderbar"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.12.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sam Ruby"]
|
9
9
|
s.date = "2012-04-24"
|
10
10
|
s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications. This includes\n output that conforms to the Polyglot specification and the emerging\n results from the XML Error Recovery Community Group.\n"
|
11
11
|
s.email = "rubys@intertwingly.net"
|
12
|
-
s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/
|
12
|
+
s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/version.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/server.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/cgi-methods.rb"]
|
13
13
|
s.homepage = "http://github.com/rubys/wunderbar"
|
14
14
|
s.require_paths = ["lib"]
|
15
|
-
s.rubygems_version = "1.8.
|
15
|
+
s.rubygems_version = "1.8.23"
|
16
16
|
s.summary = "HTML Generator and CGI application support"
|
17
17
|
|
18
18
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,109 +1,96 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wunderbar
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.12.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 11
|
9
|
-
- 1
|
10
|
-
version: 0.11.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Sam Ruby
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: builder
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
version: "3.0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: json
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :runtime
|
48
|
-
|
49
|
-
|
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: ! " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML,
|
47
|
+
Unicode\n (utf-8), consistently indented, readable applications. This includes\n
|
48
|
+
\ output that conforms to the Polyglot specification and the emerging\n results
|
49
|
+
from the XML Error Recovery Community Group.\n"
|
50
50
|
email: rubys@intertwingly.net
|
51
51
|
executables: []
|
52
|
-
|
53
52
|
extensions: []
|
54
|
-
|
55
53
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
54
|
+
files:
|
58
55
|
- wunderbar.gemspec
|
59
56
|
- README.md
|
60
57
|
- COPYING
|
61
58
|
- lib/wunderbar.rb
|
59
|
+
- lib/wunderbar/version.rb
|
62
60
|
- lib/wunderbar/installation.rb
|
63
|
-
- lib/wunderbar/
|
64
|
-
- lib/wunderbar/job-control.rb
|
65
|
-
- lib/wunderbar/server.rb
|
66
|
-
- lib/wunderbar/logger.rb
|
61
|
+
- lib/wunderbar/cssproxy.rb
|
67
62
|
- lib/wunderbar/rack.rb
|
63
|
+
- lib/wunderbar/logger.rb
|
68
64
|
- lib/wunderbar/builder.rb
|
69
65
|
- lib/wunderbar/sinatra.rb
|
70
|
-
- lib/wunderbar/environment.rb
|
71
66
|
- lib/wunderbar/rails.rb
|
67
|
+
- lib/wunderbar/server.rb
|
68
|
+
- lib/wunderbar/html-methods.rb
|
69
|
+
- lib/wunderbar/job-control.rb
|
70
|
+
- lib/wunderbar/environment.rb
|
72
71
|
- lib/wunderbar/cgi-methods.rb
|
73
|
-
- lib/wunderbar/cssproxy.rb
|
74
|
-
- lib/wunderbar/version.rb
|
75
72
|
homepage: http://github.com/rubys/wunderbar
|
76
73
|
licenses: []
|
77
|
-
|
78
74
|
post_install_message:
|
79
75
|
rdoc_options: []
|
80
|
-
|
81
|
-
require_paths:
|
76
|
+
require_paths:
|
82
77
|
- lib
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
79
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
90
|
-
- 0
|
91
|
-
version: "0"
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
85
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
101
90
|
requirements: []
|
102
|
-
|
103
91
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.23
|
105
93
|
signing_key:
|
106
94
|
specification_version: 3
|
107
95
|
summary: HTML Generator and CGI application support
|
108
96
|
test_files: []
|
109
|
-
|