wunderbar 1.2.10 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/wunderbar/builder.rb +16 -4
- data/lib/wunderbar/environment.rb +15 -2
- data/lib/wunderbar/rack.rb +15 -1
- data/lib/wunderbar/rails.rb +2 -2
- data/lib/wunderbar/react.rb +6 -0
- data/lib/wunderbar/render.rb +1 -1
- data/lib/wunderbar/version.rb +2 -2
- data/lib/wunderbar/vue.rb +15 -2
- data/wunderbar.gemspec +6 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faf3ed56159ea9aae14376907dd0c17efabb7560f08b886b1f4f781be5b630af
|
4
|
+
data.tar.gz: f0a40ec22da2f77faf6b97c6a156198430a4afe12d96baacd37c8c489bcc037b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba3b4c3676b35938fc132792a5fb8d73ea949fe3d76b9a4a05a2b83a2d24e3b933ce993b45e36717dc9877c8a2a429af80dceab4313dfaa3ef8eb63cdba4380
|
7
|
+
data.tar.gz: f9d3f47d1f81627649f98ebfeda570f84dadb9f33e9839a06584f31c52da587b98ca9be027f411a805f82c09979bb96e92882be0a8907dd743193fbf4c51f8ee
|
data/README.md
CHANGED
@@ -371,13 +371,15 @@ dependencies](#optional-dependencies) below), calls to insert markup
|
|
371
371
|
(`_{...}`) will escape the markup if the input is `tainted` and not explicitly
|
372
372
|
marked as `html-safe?` (when using Rails).
|
373
373
|
|
374
|
-
For
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
[`
|
379
|
-
|
380
|
-
|
374
|
+
For Ruby version < 2.6.0:
|
375
|
+
|
376
|
+
> For all environments other than Rails, unless you call `Wunderbar.unsafe!` at
|
377
|
+
> the top of your script, Wunderbar will also set
|
378
|
+
> [`$SAFE=1`](http://www.ruby-doc.org/docs/ProgrammingRuby/html/taint.html)
|
379
|
+
> before processing requests. This means that you will need to
|
380
|
+
> [`untaint`](ruby-doc.org/core/Object.html#method-i-untaint) all inputs
|
381
|
+
> received from external sources before you make system calls or access the file
|
382
|
+
> system.
|
381
383
|
|
382
384
|
A special feature that effectively is only available in the Rails environment:
|
383
385
|
if the first argument to call that creates an element is `html_safe?`, then
|
data/lib/wunderbar/builder.rb
CHANGED
@@ -461,8 +461,14 @@ module Wunderbar
|
|
461
461
|
output_prefix = opts[:prefix] || {}
|
462
462
|
output_prefix[:stdin] ||= '$ '
|
463
463
|
|
464
|
-
|
465
|
-
|
464
|
+
if Hash === args.last # support original code which needed two hashes
|
465
|
+
super do |kind, line|
|
466
|
+
@_target.puts "#{output_prefix[kind]}#{line}"
|
467
|
+
end
|
468
|
+
else
|
469
|
+
super(*args, opts) do |kind, line|
|
470
|
+
@_target.puts "#{output_prefix[kind]}#{line}"
|
471
|
+
end
|
466
472
|
end
|
467
473
|
end
|
468
474
|
|
@@ -587,8 +593,14 @@ module Wunderbar
|
|
587
593
|
@_target[transcript] = []
|
588
594
|
end
|
589
595
|
|
590
|
-
|
591
|
-
|
596
|
+
if Hash === args.last # support original code which needed two hashes
|
597
|
+
super do |kind, line|
|
598
|
+
@_target[transcript] << "#{output_prefix[kind]}#{line}"
|
599
|
+
end
|
600
|
+
else
|
601
|
+
super(*args, opts) do |kind, line|
|
602
|
+
@_target[transcript] << "#{output_prefix[kind]}#{line}"
|
603
|
+
end
|
592
604
|
end
|
593
605
|
end
|
594
606
|
|
@@ -5,14 +5,17 @@ module Wunderbar
|
|
5
5
|
TEXT = ARGV.delete('--text')
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
# Ruby 2.6.0 gets rid of $SAFE > 1; unfortunately in the process it
|
9
|
+
# treats $SAFE = 1 as a higher level; @FAFE = 1 no longer is limited
|
10
|
+
# to taintness checks, it not treats all File operations as unsafe
|
11
|
+
@@unsafe = (RUBY_VERSION.split('.').map(&:to_i) <=> [2, 6, 0]) == 1
|
9
12
|
|
10
13
|
def self.unsafe!(mode=true)
|
11
14
|
@@unsafe=mode
|
12
15
|
end
|
13
16
|
|
14
17
|
def self.safe?
|
15
|
-
if $SAFE == 0
|
18
|
+
if not @@unsafe and $SAFE == 0
|
16
19
|
# some gems (e.g. em-websocket-0.3.6) insert unsafe entries into the
|
17
20
|
# path, and that prevents requires from succeeding. If it looks like
|
18
21
|
# we are about to make a transition to $SAFE=1, clean up that mess
|
@@ -44,11 +47,16 @@ module Wunderbar
|
|
44
47
|
end
|
45
48
|
|
46
49
|
@@templates = {}
|
50
|
+
@@files = {}
|
47
51
|
|
48
52
|
def self.templates
|
49
53
|
@@templates
|
50
54
|
end
|
51
55
|
|
56
|
+
def self.files
|
57
|
+
@@files
|
58
|
+
end
|
59
|
+
|
52
60
|
module API
|
53
61
|
def _html(*args, &block)
|
54
62
|
Wunderbar.html(*args, &block)
|
@@ -74,6 +82,11 @@ module Wunderbar
|
|
74
82
|
def _template(name, &block)
|
75
83
|
Wunderbar.templates[name.to_s.gsub('_','-')] = block
|
76
84
|
end
|
85
|
+
|
86
|
+
def _file(name, options={}, &block)
|
87
|
+
options[:source] = block if block
|
88
|
+
Wunderbar.files[name] = options
|
89
|
+
end
|
77
90
|
end
|
78
91
|
|
79
92
|
#
|
data/lib/wunderbar/rack.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'wunderbar'
|
2
2
|
require 'rack'
|
3
|
+
require 'rack/media_type'
|
3
4
|
|
4
5
|
module Wunderbar
|
5
6
|
class RackApp
|
@@ -9,7 +10,14 @@ module Wunderbar
|
|
9
10
|
@_request = Rack::Request.new(env)
|
10
11
|
@_response = Rack::Response.new
|
11
12
|
Wunderbar.logger = @_request.logger
|
12
|
-
|
13
|
+
file = Wunderbar.files[env['PATH_INFO']]
|
14
|
+
|
15
|
+
if file
|
16
|
+
mime = file[:mime] ||
|
17
|
+
Rack::Mime::MIME_TYPES[File.extname(env['PATH_INFO'])]
|
18
|
+
@_response.set_header('Content-Type', mime) if mime
|
19
|
+
@_response.write(file[:content] || file[:source].call)
|
20
|
+
elsif Wunderbar.safe? and $SAFE==0
|
13
21
|
Proc.new { $SAFE=1; Wunderbar::CGI.call(self) }.call
|
14
22
|
else
|
15
23
|
Wunderbar::CGI.call(self)
|
@@ -43,6 +51,12 @@ module Wunderbar
|
|
43
51
|
def response
|
44
52
|
@_response
|
45
53
|
end
|
54
|
+
|
55
|
+
%w(delete get head options post put trace).each do |http_method|
|
56
|
+
define_method "#{http_method}?" do
|
57
|
+
@_env['REQUEST_METHOD'].to_s.downcase == http_method
|
58
|
+
end
|
59
|
+
end
|
46
60
|
end
|
47
61
|
end
|
48
62
|
|
data/lib/wunderbar/rails.rb
CHANGED
@@ -7,7 +7,7 @@ module Wunderbar
|
|
7
7
|
cattr_accessor :default_format
|
8
8
|
self.default_format = Mime[:html]
|
9
9
|
|
10
|
-
def self.call(template)
|
10
|
+
def self.call(template, source=nil)
|
11
11
|
%{
|
12
12
|
compiled = Proc.new {#{template.source}}
|
13
13
|
x = Wunderbar::HtmlMarkup.new(self);
|
@@ -24,7 +24,7 @@ module Wunderbar
|
|
24
24
|
cattr_accessor :default_format
|
25
25
|
self.default_format = Mime[:json]
|
26
26
|
|
27
|
-
def self.call(template)
|
27
|
+
def self.call(template, source=nil)
|
28
28
|
%{
|
29
29
|
compiled = Proc.new {#{template.source}}
|
30
30
|
x = Wunderbar::JsonBuilder.new(self);
|
data/lib/wunderbar/react.rb
CHANGED
@@ -16,6 +16,12 @@ class Wunderbar::Render
|
|
16
16
|
"ReactDOMServer.renderToString(#{common})"
|
17
17
|
end
|
18
18
|
|
19
|
+
# return all nodes on server rendering, as there is no wrapper element
|
20
|
+
# like there is for vue
|
21
|
+
def self.extract(nodes)
|
22
|
+
nodes
|
23
|
+
end
|
24
|
+
|
19
25
|
def self.client(common, element, target)
|
20
26
|
"ReactDOM.render(#{common}, #{element})"
|
21
27
|
end
|
data/lib/wunderbar/render.rb
CHANGED
data/lib/wunderbar/version.rb
CHANGED
data/lib/wunderbar/vue.rb
CHANGED
@@ -18,13 +18,26 @@ class Wunderbar::Render
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.server(common)
|
21
|
-
"VueServer.renderToString(new Vue({render: function($h) {
|
21
|
+
"VueServer.renderToString(new Vue({render: function($h) {
|
22
|
+
return $h('div', #{common})}}))"
|
23
|
+
end
|
24
|
+
|
25
|
+
# unwrap children from div wrapper inserted by self.server
|
26
|
+
def self.extract(nodes)
|
27
|
+
if
|
28
|
+
nodes.length == 1 and nodes.first.name == 'div' and
|
29
|
+
nodes.first.attrs['data-server-rendered'].to_s == 'true'
|
30
|
+
then
|
31
|
+
nodes.first.children
|
32
|
+
else
|
33
|
+
nodes
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
37
|
def self.client(common, element, target)
|
25
38
|
wrap = "$h(#{target.name.inspect}, " +
|
26
39
|
"{attrs: {#{target.attrs.map {|name, value|
|
27
|
-
"#{name}: #{value.inspect}"}.join(', ')}}},
|
40
|
+
"#{name}: #{value.inspect}"}.join(', ')}}}, #{common})"
|
28
41
|
"new Vue({el: #{element}, render: function($h) {return #{wrap}}})"
|
29
42
|
end
|
30
43
|
|
data/wunderbar.gemspec
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
require 'wunderbar/version'
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
7
|
s.name = "wunderbar".freeze
|
6
|
-
s.version =
|
8
|
+
s.version = Wunderbar::VERSION::STRING
|
7
9
|
|
8
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
11
|
s.require_paths = ["lib".freeze]
|
10
12
|
s.authors = ["Sam Ruby".freeze]
|
11
|
-
s.date = "
|
13
|
+
s.date = "2019-06-07"
|
12
14
|
s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications.'\n".freeze
|
13
15
|
s.email = "rubys@intertwingly.net".freeze
|
14
16
|
s.files = ["COPYING".freeze, "README.md".freeze, "lib/wunderbar".freeze, "lib/wunderbar.rb".freeze, "lib/wunderbar/asset.rb".freeze, "lib/wunderbar/backtick.rb".freeze, "lib/wunderbar/bootstrap".freeze, "lib/wunderbar/bootstrap.rb".freeze, "lib/wunderbar/bootstrap/theme.rb".freeze, "lib/wunderbar/builder.rb".freeze, "lib/wunderbar/cgi-methods.rb".freeze, "lib/wunderbar/coderay.rb".freeze, "lib/wunderbar/coffeescript.rb".freeze, "lib/wunderbar/cssproxy.rb".freeze, "lib/wunderbar/environment.rb".freeze, "lib/wunderbar/eventsource.rb".freeze, "lib/wunderbar/html-methods.rb".freeze, "lib/wunderbar/installation.rb".freeze, "lib/wunderbar/job-control.rb".freeze, "lib/wunderbar/jquery".freeze, "lib/wunderbar/jquery.rb".freeze, "lib/wunderbar/jquery/filter.rb".freeze, "lib/wunderbar/jquery/stupidtable.rb".freeze, "lib/wunderbar/listen.rb".freeze, "lib/wunderbar/logger.rb".freeze, "lib/wunderbar/markdown.rb".freeze, "lib/wunderbar/marked.rb".freeze, "lib/wunderbar/node.rb".freeze, "lib/wunderbar/pagedown.rb".freeze, "lib/wunderbar/polymer.rb".freeze, "lib/wunderbar/rack.rb".freeze, "lib/wunderbar/rails.rb".freeze, "lib/wunderbar/react.rb".freeze, "lib/wunderbar/render.rb".freeze, "lib/wunderbar/script.rb".freeze, "lib/wunderbar/server.rb".freeze, "lib/wunderbar/sinatra.rb".freeze, "lib/wunderbar/underscore.rb".freeze, "lib/wunderbar/vendor".freeze, "lib/wunderbar/vendor/Markdown.Converter.js".freeze, "lib/wunderbar/vendor/bootstrap-theme.min.css".freeze, "lib/wunderbar/vendor/bootstrap.min.css".freeze, "lib/wunderbar/vendor/bootstrap.min.js".freeze, "lib/wunderbar/vendor/eventsource.min.js".freeze, "lib/wunderbar/vendor/jquery-3.2.1.min.js".freeze, "lib/wunderbar/vendor/marked.min.js".freeze, "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js".freeze, "lib/wunderbar/vendor/react-dom-server.min.js".freeze, "lib/wunderbar/vendor/react-dom.min.js".freeze, "lib/wunderbar/vendor/react-with-addons.min.js".freeze, "lib/wunderbar/vendor/stupidtable.min.js".freeze, "lib/wunderbar/vendor/underscore-min.js".freeze, "lib/wunderbar/vendor/vue-server.min.js".freeze, "lib/wunderbar/vendor/vue.min.js".freeze, "lib/wunderbar/version.rb".freeze, "lib/wunderbar/vue.rb".freeze, "lib/wunderbar/websocket.rb".freeze, "wunderbar.gemspec".freeze]
|
15
17
|
s.homepage = "http://github.com/rubys/wunderbar".freeze
|
16
18
|
s.licenses = ["MIT".freeze]
|
17
19
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.3".freeze)
|
18
|
-
s.rubygems_version = "
|
20
|
+
s.rubygems_version = "3.0.6".freeze
|
19
21
|
s.summary = "HTML Generator and CGI application support".freeze
|
20
22
|
|
21
23
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wunderbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.7.4
|
108
|
+
rubygems_version: 3.1.2
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: HTML Generator and CGI application support
|