wunderbar 0.22.1 → 0.22.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -394,8 +394,7 @@ Also, the following environment variables are set if they aren't already:
394
394
  * `LANG`
395
395
  * `REMOTE_USER`
396
396
 
397
- Finally, the (Ruby 1.9.x) default external and internal encodings are set to
398
- UTF-8. For Ruby 1.8, `$KCODE` is set to `U`
397
+ Finally, the default external and internal encodings are set to UTF-8.
399
398
 
400
399
  Logging:
401
400
  ---
@@ -77,12 +77,8 @@ $SERVER = ENV['HTTP_HOST'] || Socket::gethostname
77
77
 
78
78
  # set encoding to UTF-8
79
79
  ENV['LANG'] ||= "en_US.UTF-8"
80
- if defined? Encoding
81
- Encoding.default_external = Encoding::UTF_8
82
- Encoding.default_internal = Encoding::UTF_8
83
- else
84
- $KCODE = 'U'
85
- end
80
+ Encoding.default_external = Encoding::UTF_8
81
+ Encoding.default_internal = Encoding::UTF_8
86
82
 
87
83
  # Add methods to the 'main' object
88
84
  if self.to_s == 'main'
@@ -50,11 +50,7 @@ module Wunderbar
50
50
  @_x.width = args.first.delete(:_width).to_i if args.first[:_width]
51
51
  end
52
52
 
53
- if ''.respond_to? :encoding
54
- bom = "\ufeff"
55
- else
56
- bom = "\xEF\xBB\xBF"
57
- end
53
+ bom = "\ufeff"
58
54
 
59
55
  title = args.shift if String === args.first
60
56
  @_x.declare! :DOCTYPE, :html
@@ -295,6 +291,12 @@ module Wunderbar
295
291
  end
296
292
  end
297
293
 
294
+ def _textarea(*args, &block)
295
+ @_x.compact! do
296
+ proxiable_tag! :textarea, PreformattedNode, *args, &block
297
+ end
298
+ end
299
+
298
300
  def _ul(*args, &block)
299
301
  iterable = args.first.respond_to? :each
300
302
  if iterable and (args.length > 1 or not args.first.respond_to? :to_hash)
@@ -13,6 +13,7 @@ module Wunderbar
13
13
  '"' => '"',
14
14
  '<' => '&lt;',
15
15
  '>' => '&gt;',
16
+ "\u00A0" => '&#xA0;',
16
17
  }
17
18
 
18
19
  def initialize(name, *args)
@@ -73,7 +74,7 @@ module Wunderbar
73
74
  next unless value
74
75
  name = name.to_s.gsub('_','-') if Symbol === name
75
76
  value=name if value==true
76
- line += " #{name}=\"#{value.to_s.gsub(/[&\"<>]/,ESCAPE)}\""
77
+ line += " #{name}=\"#{value.to_s.gsub(/[&\"<>\u00A0]/,ESCAPE)}\""
77
78
  end
78
79
 
79
80
  if children.empty?
@@ -83,7 +84,7 @@ module Wunderbar
83
84
  width = options[:width] unless preserve_spaces?
84
85
 
85
86
  if text
86
- line += ">#{text.to_s.gsub(/[&<>]/,ESCAPE)}</#{name}>"
87
+ line += ">#{text.to_s.gsub(/[&<>\u00A0]/,ESCAPE)}</#{name}>"
87
88
  elsif VOID.include? name.to_s
88
89
  line += "/>"
89
90
  else
@@ -215,9 +216,9 @@ module Wunderbar
215
216
 
216
217
  def serialize(options, result, indent)
217
218
  if options[:space] == :preserve
218
- result << @text.to_s.gsub(/[&<>]/,ESCAPE)
219
+ result << @text.to_s.gsub(/[&<>\u00A0]/,ESCAPE)
219
220
  else
220
- result << @text.to_s.gsub(/[&<>]/,ESCAPE).gsub(/\s+/, ' ')
221
+ result << @text.to_s.gsub(/[&<>\u00A0]/,ESCAPE).gsub(/\s+/, ' ')
221
222
  end
222
223
  end
223
224
  end
@@ -247,7 +248,7 @@ module Wunderbar
247
248
  end
248
249
 
249
250
  result.push *IndentedTextNode.reflow(indent,
250
- text.to_s.gsub(/[&<>]/,ESCAPE), options[:width])
251
+ text.to_s.gsub(/[&<>\u00A0]/,ESCAPE), options[:width])
251
252
  end
252
253
  end
253
254
 
@@ -76,7 +76,7 @@ module Wunderbar
76
76
 
77
77
  module Template
78
78
  module Js
79
- def self.ext; :_js; end
79
+ def self.ext; ['js.rb', :_js]; end
80
80
  def self.mime; 'application/javascript'; end
81
81
 
82
82
  def evaluate(scope, locals, &block)
@@ -14,11 +14,11 @@ module Wunderbar
14
14
  Wunderbar::Template.locals(self, args)
15
15
 
16
16
  if block
17
- Wunderbar::Template::Html.evaluate('_html', self) do
17
+ Wunderbar::Template::Html.evaluate('html.rb', self) do
18
18
  _html(*args) { instance_eval &block }
19
19
  end
20
20
  else
21
- Wunderbar::Template::Html.evaluate('_html', self, *args)
21
+ Wunderbar::Template::Html.evaluate('html.rb', self, *args)
22
22
  end
23
23
  end
24
24
 
@@ -27,12 +27,14 @@ module Wunderbar
27
27
  return _html(*args, &block)
28
28
  end
29
29
 
30
+ Wunderbar::Template.locals(self, args)
31
+
30
32
  if block
31
- Wunderbar::Template::Xhtml.evaluate('_xhtml', self) do
33
+ Wunderbar::Template::Xhtml.evaluate('xhtml.rb', self) do
32
34
  _xhtml(*args) { instance_eval &block }
33
35
  end
34
36
  else
35
- Wunderbar::Template::Xhtml.evaluate('_xhtml', self, *args)
37
+ Wunderbar::Template::Xhtml.evaluate('xhtml.rb', self, *args)
36
38
  end
37
39
  end
38
40
  end
@@ -124,7 +126,7 @@ module Wunderbar
124
126
  end
125
127
 
126
128
  module Json
127
- def self.ext; :_json; end
129
+ def self.ext; ['json.rb', :_json]; end
128
130
  def self.mime; 'application/json'; end
129
131
 
130
132
  def evaluate(scope, locals, &block)
@@ -142,7 +144,7 @@ module Wunderbar
142
144
  end
143
145
 
144
146
  module Text
145
- def self.ext; :_text; end
147
+ def self.ext; ['text.rb', :_text]; end
146
148
  def self.mime; 'text/plain'; end
147
149
 
148
150
  def evaluate(scope, locals, &block)
@@ -184,24 +186,26 @@ module Wunderbar
184
186
  include language
185
187
  end
186
188
 
187
- SinatraHelpers.send :define_method, language.ext do |*args, &block|
188
- # parse json
189
- if env['CONTENT_TYPE'] =~ /^\w+\/json/
190
- json = JSON.parse(env['rack.input'].read)
191
- @params.merge! json if Hash === json
192
- end
189
+ Array(language.ext).each do |ext|
190
+ SinatraHelpers.send :define_method, ext do |*args, &block|
191
+ # parse json
192
+ if env['CONTENT_TYPE'] =~ /^\w+\/json/
193
+ json = JSON.parse(env['rack.input'].read)
194
+ @params.merge! json if Hash === json
195
+ end
193
196
 
194
- Wunderbar::Template.locals(self, args)
195
- if Hash === args.last and args.last[:locals]
196
- @params.each do |name, value|
197
- args.last[:locals]["@#{name}".to_sym] = value
197
+ Wunderbar::Template.locals(self, args)
198
+ if Hash === args.last and args.last[:locals]
199
+ @params.each do |name, value|
200
+ args.last[:locals]["@#{name}".to_sym] = value
201
+ end
198
202
  end
203
+
204
+ template.evaluate(ext, self, *args, &block)
199
205
  end
200
206
 
201
- template.evaluate(language.ext, self, *args, &block)
207
+ Tilt.register ext.to_s, template
202
208
  end
203
-
204
- Tilt.register language.ext.to_s, template
205
209
  end
206
210
 
207
211
  constants.each do |language|
@@ -212,7 +216,9 @@ module Wunderbar
212
216
  end
213
217
 
214
218
  Tilt.register '_html', Wunderbar::Template::Html
219
+ Tilt.register 'html.rb', Wunderbar::Template::Html
215
220
  Tilt.register '_xhtml', Wunderbar::Template::Xhtml
221
+ Tilt.register 'xhtml.rb', Wunderbar::Template::Xhtml
216
222
 
217
223
  helpers Wunderbar::SinatraHelpers
218
224
 
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 22
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,17 +2,18 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.22.1"
5
+ s.version = "0.22.2"
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
- s.date = "2015-01-02"
9
+ s.date = "2015-01-08"
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
12
  s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/script.rb", "lib/wunderbar/jquery.rb", "lib/wunderbar/underscore.rb", "lib/wunderbar/polymer.rb", "lib/wunderbar/jquery", "lib/wunderbar/jquery/filter.rb", "lib/wunderbar/jquery/stupidtable.rb", "lib/wunderbar/vendor", "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js", "lib/wunderbar/vendor/stupidtable.min.js", "lib/wunderbar/vendor/bootstrap.min.js", "lib/wunderbar/vendor/Markdown.Converter.js", "lib/wunderbar/vendor/angular.min.js", "lib/wunderbar/vendor/bootstrap-theme.min.css", "lib/wunderbar/vendor/jquery-1.11.0.min.js", "lib/wunderbar/vendor/angular-resource.min.js", "lib/wunderbar/vendor/bootstrap.min.css", "lib/wunderbar/vendor/underscore-min.js", "lib/wunderbar/vendor/angular-route.min.js", "lib/wunderbar/websocket.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/pagedown.rb", "lib/wunderbar/version.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/server.rb", "lib/wunderbar/angularjs.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/backtick.rb", "lib/wunderbar/opal", "lib/wunderbar/opal/browser.rb", "lib/wunderbar/opal/jquery.rb", "lib/wunderbar/coffeescript.rb", "lib/wunderbar/markdown.rb", "lib/wunderbar/opal.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/bootstrap.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/angularjs", "lib/wunderbar/angularjs/resource.rb", "lib/wunderbar/angularjs/route.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/coderay.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/bootstrap", "lib/wunderbar/bootstrap/theme.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/node.rb"]
13
13
  s.homepage = "http://github.com/rubys/wunderbar"
14
14
  s.licenses = ["MIT"]
15
15
  s.require_paths = ["lib"]
16
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
16
17
  s.rubygems_version = "1.8.23"
17
18
  s.summary = "HTML Generator and CGI application support"
18
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.22.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-02 00:00:00.000000000 Z
12
+ date: 2015-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
101
+ version: 1.9.3
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements: