wunderbar 1.3.3 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -21
- data/lib/wunderbar/asset.rb +5 -5
- data/lib/wunderbar/builder.rb +24 -10
- data/lib/wunderbar/cgi-methods.rb +1 -1
- data/lib/wunderbar/coderay.rb +0 -9
- data/lib/wunderbar/environment.rb +0 -34
- data/lib/wunderbar/html-methods.rb +3 -21
- data/lib/wunderbar/job-control.rb +1 -1
- data/lib/wunderbar/markdown.rb +0 -1
- data/lib/wunderbar/rack.rb +1 -2
- data/lib/wunderbar/react.rb +0 -14
- data/lib/wunderbar/render.rb +5 -7
- data/lib/wunderbar/server.rb +1 -9
- data/lib/wunderbar/sinatra.rb +6 -15
- data/lib/wunderbar/vendor/Markdown.Converter.js +1 -1
- data/lib/wunderbar/version.rb +2 -2
- data/lib/wunderbar/vue.rb +2 -2
- data/wunderbar.gemspec +1 -1
- metadata +5 -6
- data/lib/wunderbar/rails.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1753c6f65653020143af9ed4f73f15e11c7443e8fec1d26a3ae645be0f785191
|
4
|
+
data.tar.gz: 3257c0840a2d8d9aaf5f7368623dc8f487e449d6e8d8046632c1a264bb373e18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364ab25aeab2b20e7b98d98ac0dbf537b68fb11c82046b6206039661b2d0694521d09229cc4c5832aff48eab5fbb8b4fad34cabe65d9c534921b6f015b2c6fab
|
7
|
+
data.tar.gz: '0885f9681bd7955e81de1a2920a77c736b1283c152eab4f20425ec7cebbd75c956da6efd348c388541229822c65644ad20f78f8a6911066fdfcf59616e133840'
|
data/README.md
CHANGED
@@ -226,7 +226,12 @@ convenience methods are defined:
|
|
226
226
|
* `_.submit` -- runs command (or block) as a deamon process
|
227
227
|
* `_.xhtml?` -- output as XHTML?
|
228
228
|
|
229
|
-
|
229
|
+
The `_.system` method takes an optional hash as its last parameter. This can be used to provide settings for the underlying
|
230
|
+
[Process.spawn](https://www.rubydoc.info/stdlib/core/Process.spawn) method.
|
231
|
+
For example: `._system('pwd',{ system_opts: { chdir: dir } , system_env: { 'FOO' => 'BAR' } })`
|
232
|
+
Note that environment variable names must be provided as strings, not symbols.
|
233
|
+
|
234
|
+
Access to all of the builder _defined_ methods (typically these end in an exclamation mark) and all of the Wunderbar module methods can be accessed in this way. Examples:
|
230
235
|
|
231
236
|
* `_.tag! :foo`: insert elements where the name can be dynamic
|
232
237
|
* `_.comment! "text"`: add a comment
|
@@ -368,24 +373,7 @@ Wunderbar will properly escape all HTML and JSON output, eliminating problems
|
|
368
373
|
of HTML or JavaScript injection. This includes calls to `_` to insert text
|
369
374
|
directly. Unless `nokogiri` was previously required (see [optional
|
370
375
|
dependencies](#optional-dependencies) below), calls to insert markup
|
371
|
-
(`_{...}`) will escape the markup
|
372
|
-
marked as `html-safe?` (when using Rails).
|
373
|
-
|
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.
|
383
|
-
|
384
|
-
A special feature that effectively is only available in the Rails environment:
|
385
|
-
if the first argument to call that creates an element is `html_safe?`, then
|
386
|
-
that argument will be treated as a markup instead of as text. This allows one
|
387
|
-
to make calls like `_td link_to...` without placing the call to `link_to` in a
|
388
|
-
block.
|
376
|
+
(`_{...}`) will escape the markup.
|
389
377
|
|
390
378
|
Globals provided
|
391
379
|
---
|
@@ -445,7 +433,6 @@ The following gems are required by extensions of the same name:
|
|
445
433
|
* `coderay` - syntax highlighting
|
446
434
|
* `opal` - ruby to javascript compiler
|
447
435
|
* `rack` - webserver interface
|
448
|
-
* `rails` - web application framework
|
449
436
|
* `sinatra` - DSL for creating web applications
|
450
437
|
|
451
438
|
The following gems, if installed, will produce cleaner and prettier output:
|
@@ -454,7 +441,6 @@ The following gems, if installed, will produce cleaner and prettier output:
|
|
454
441
|
* `nokogumbo` also cleans up HTML fragments inserted via `<<` and `_{}`. If
|
455
442
|
this gem is available, it will be preferred over direct usage of `nokogiri`.
|
456
443
|
* `escape` prettier quoting of `system` commands
|
457
|
-
* `sanitize` will remove unsafe markup from tainted input
|
458
444
|
|
459
445
|
Related efforts
|
460
446
|
---
|
data/lib/wunderbar/asset.rb
CHANGED
@@ -30,14 +30,14 @@ module Wunderbar
|
|
30
30
|
return @path if @path or @contents
|
31
31
|
|
32
32
|
if @options[:name]
|
33
|
-
source =
|
33
|
+
source = @options[:file] || __FILE__
|
34
34
|
@mtime = File.mtime(source)
|
35
35
|
@path = @options[:name]
|
36
36
|
|
37
37
|
# look for asset in site
|
38
38
|
if ENV['DOCUMENT_ROOT']
|
39
|
-
root = File.join(ENV['DOCUMENT_ROOT'], 'assets')
|
40
|
-
dest = File.expand_path(@path, root)
|
39
|
+
root = File.join(ENV['DOCUMENT_ROOT'], 'assets')
|
40
|
+
dest = File.expand_path(@path, root)
|
41
41
|
if File.exist?(dest) and File.size(dest) == File.size(source)
|
42
42
|
@path = "/assets/#{@path}"
|
43
43
|
return @path
|
@@ -45,7 +45,7 @@ module Wunderbar
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# look for asset in app
|
48
|
-
dest = File.expand_path(@path, Asset.root)
|
48
|
+
dest = File.expand_path(@path, Asset.root)
|
49
49
|
if File.exist?(dest) and File.size(dest) == File.size(source)
|
50
50
|
return @path
|
51
51
|
end
|
@@ -103,7 +103,7 @@ module Wunderbar
|
|
103
103
|
@path = '../' * env['PATH_INFO'].to_s.count('/') + 'assets'
|
104
104
|
@root ||= nil
|
105
105
|
@root = File.dirname(env['SCRIPT_FILENAME']) if env['SCRIPT_FILENAME']
|
106
|
-
@root = File.expand_path((@root || Dir.pwd) + "/assets")
|
106
|
+
@root = File.expand_path((@root || Dir.pwd) + "/assets")
|
107
107
|
|
108
108
|
# Options: typically :name plus either :file or :contents
|
109
109
|
# :name => name to be used for the asset
|
data/lib/wunderbar/builder.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'shellwords'
|
2
2
|
require 'open3'
|
3
|
-
require 'thread'
|
4
3
|
|
5
4
|
module Wunderbar
|
6
5
|
@@options = {indent: 2}
|
@@ -51,14 +50,14 @@ module Wunderbar
|
|
51
50
|
secret = command - flat
|
52
51
|
begin
|
53
52
|
# if available, use escape as it does prettier quoting
|
54
|
-
raise LoadError if
|
53
|
+
raise LoadError if not defined? Escape
|
55
54
|
require 'escape'
|
56
55
|
echo = Escape.shell_command(command.compact - secret)
|
57
56
|
rescue LoadError
|
58
57
|
# std-lib function that gets the job done
|
59
58
|
echo = Shellwords.join(command.compact - secret)
|
60
59
|
end
|
61
|
-
command = flat.compact
|
60
|
+
command = flat.compact
|
62
61
|
else
|
63
62
|
echo = command
|
64
63
|
command = [command]
|
@@ -74,7 +73,10 @@ module Wunderbar
|
|
74
73
|
|
75
74
|
semaphore = Mutex.new
|
76
75
|
env = {'LC_CTYPE' => 'en_US.UTF-8'}
|
77
|
-
|
76
|
+
sys_env = opts[:system_env] || {}
|
77
|
+
env.merge! sys_env unless sys_env.empty?
|
78
|
+
sys_opts = opts[:system_opts] || {}
|
79
|
+
Open3.popen3(env, *command, sys_opts) do |pin, pout, perr, wait|
|
78
80
|
[
|
79
81
|
Thread.new do
|
80
82
|
until pout.eof?
|
@@ -357,8 +359,8 @@ module Wunderbar
|
|
357
359
|
end
|
358
360
|
|
359
361
|
# remove leading and trailing space
|
360
|
-
if
|
361
|
-
children.shift
|
362
|
+
if not children.empty?
|
363
|
+
children.shift if children.first.text? and children.first.text.strip.empty?
|
362
364
|
end
|
363
365
|
|
364
366
|
if not children.empty?
|
@@ -461,8 +463,14 @@ module Wunderbar
|
|
461
463
|
output_prefix = opts[:prefix] || {}
|
462
464
|
output_prefix[:stdin] ||= '$ '
|
463
465
|
|
464
|
-
|
465
|
-
|
466
|
+
if Hash === args.last # support original code which needed two hashes
|
467
|
+
super do |kind, line|
|
468
|
+
@_target.puts "#{output_prefix[kind]}#{line}"
|
469
|
+
end
|
470
|
+
else
|
471
|
+
super(*args, opts) do |kind, line|
|
472
|
+
@_target.puts "#{output_prefix[kind]}#{line}"
|
473
|
+
end
|
466
474
|
end
|
467
475
|
end
|
468
476
|
|
@@ -587,8 +595,14 @@ module Wunderbar
|
|
587
595
|
@_target[transcript] = []
|
588
596
|
end
|
589
597
|
|
590
|
-
|
591
|
-
|
598
|
+
if Hash === args.last # support original code which needed two hashes
|
599
|
+
super do |kind, line|
|
600
|
+
@_target[transcript] << "#{output_prefix[kind]}#{line}"
|
601
|
+
end
|
602
|
+
else
|
603
|
+
super(*args, opts) do |kind, line|
|
604
|
+
@_target[transcript] << "#{output_prefix[kind]}#{line}"
|
605
|
+
end
|
592
606
|
end
|
593
607
|
end
|
594
608
|
|
@@ -120,7 +120,7 @@ module Wunderbar
|
|
120
120
|
# asset support for Rack
|
121
121
|
request = (scope.respond_to? :request) ? scope.request : nil
|
122
122
|
if request and request.path =~ %r{/assets/\w[-.\w]+}
|
123
|
-
path =
|
123
|
+
path = '.' + scope.request.path
|
124
124
|
headers = {'type' => 'text/plain'}
|
125
125
|
headers['type'] = 'application/javascript' if path =~ /\.js$/
|
126
126
|
out?(scope, headers) { File.read path if File.exist? path }
|
data/lib/wunderbar/coderay.rb
CHANGED
@@ -2,15 +2,6 @@ require 'wunderbar'
|
|
2
2
|
require 'coderay'
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
|
-
# workaround for https://github.com/rubychan/coderay/pull/159
|
6
|
-
module CodeRay::PluginHost
|
7
|
-
alias_method :old_plugin_path, :plugin_path
|
8
|
-
def plugin_path *args
|
9
|
-
args.first.untaint if args.first == CodeRay::CODERAY_PATH
|
10
|
-
old_plugin_path(*args)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
5
|
module Wunderbar
|
15
6
|
class HtmlMarkup
|
16
7
|
def _coderay(*args)
|
@@ -5,40 +5,6 @@ module Wunderbar
|
|
5
5
|
TEXT = ARGV.delete('--text')
|
6
6
|
end
|
7
7
|
|
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
|
12
|
-
|
13
|
-
def self.unsafe!(mode=true)
|
14
|
-
@@unsafe=mode
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.safe?
|
18
|
-
if $SAFE == 0 and not @@unsafe
|
19
|
-
# some gems (e.g. em-websocket-0.3.6) insert unsafe entries into the
|
20
|
-
# path, and that prevents requires from succeeding. If it looks like
|
21
|
-
# we are about to make a transition to $SAFE=1, clean up that mess
|
22
|
-
# before proceeding.
|
23
|
-
#
|
24
|
-
# the goal of $SAFE is not to protect us against software which was
|
25
|
-
# installed by the owner of the site, but from injection attacks
|
26
|
-
# contained within data provided by users of the site.
|
27
|
-
$:.each_with_index do |path, index|
|
28
|
-
if path.tainted?
|
29
|
-
$:[index] = File.expand_path(path.dup.untaint).untaint
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# avoid: "Insecure PATH - (SecurityError)" when using Bundler
|
34
|
-
if defined? Bundler
|
35
|
-
ENV['PATH'] = ENV['PATH'].dup.untaint
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
not @@unsafe
|
40
|
-
end
|
41
|
-
|
42
8
|
class Scope
|
43
9
|
attr_accessor :env
|
44
10
|
def initialize(env)
|
@@ -133,7 +133,7 @@ module Wunderbar
|
|
133
133
|
# * Proxied Rack server. Document base may be relate to the
|
134
134
|
# HTTP_X_WUNDERBAR_BASE
|
135
135
|
#
|
136
|
-
cwd = File.realpath(Dir.pwd
|
136
|
+
cwd = File.realpath(Dir.pwd)
|
137
137
|
base = @_scope.env['DOCUMENT_ROOT'] if @_scope.env.respond_to? :[]
|
138
138
|
base ||= cwd
|
139
139
|
href = (head.children[1].attrs[:href] || '')
|
@@ -188,15 +188,6 @@ module Wunderbar
|
|
188
188
|
|
189
189
|
name = name.to_s.gsub('_', '-')
|
190
190
|
|
191
|
-
if flag != '!'
|
192
|
-
if String === args.first and args.first.respond_to? :html_safe?
|
193
|
-
if args.first.html_safe? and not block and args.first =~ /[>&]/
|
194
|
-
markup = args.shift
|
195
|
-
block = Proc.new {_ {markup}}
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
191
|
if flag == '!'
|
201
192
|
@_x.compact! { tag! name, *args, &block }
|
202
193
|
elsif flag == '?'
|
@@ -362,11 +353,7 @@ module Wunderbar
|
|
362
353
|
def _(text=nil, &block)
|
363
354
|
unless block
|
364
355
|
if text
|
365
|
-
|
366
|
-
_ {text}
|
367
|
-
else
|
368
|
-
@_x.indented_text! text.to_s
|
369
|
-
end
|
356
|
+
@_x.indented_text! text.to_s
|
370
357
|
end
|
371
358
|
return @_x
|
372
359
|
end
|
@@ -374,11 +361,7 @@ module Wunderbar
|
|
374
361
|
children = instance_eval(&block)
|
375
362
|
|
376
363
|
if String === children
|
377
|
-
|
378
|
-
safe ||= children.html_safe? if children.respond_to? :html_safe?
|
379
|
-
safe &&= defined? Nokogiri
|
380
|
-
ok = safe || defined? Sanitize
|
381
|
-
safe = true
|
364
|
+
ok = defined? Nokogiri
|
382
365
|
|
383
366
|
if ok and (children.include? '<' or children.include? '&')
|
384
367
|
if defined? Nokogiri::HTML5.fragment
|
@@ -387,7 +370,6 @@ module Wunderbar
|
|
387
370
|
doc = Nokogiri::HTML.fragment(children.to_s)
|
388
371
|
end
|
389
372
|
|
390
|
-
Sanitize.new.clean_node! doc.dup.untaint if not safe
|
391
373
|
children = doc.children.to_a
|
392
374
|
|
393
375
|
# ignore leading whitespace
|
@@ -25,7 +25,7 @@ module Wunderbar
|
|
25
25
|
# clear environment of cgi cruft
|
26
26
|
require 'cgi'
|
27
27
|
ENV.keys.select {|key| key =~ /^HTTP_/}.each do |key|
|
28
|
-
ENV.delete key
|
28
|
+
ENV.delete key
|
29
29
|
end
|
30
30
|
::CGI::QueryExtension.public_instance_methods.each do |method|
|
31
31
|
ENV.delete method.to_s.upcase
|
data/lib/wunderbar/markdown.rb
CHANGED
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
|
@@ -16,8 +17,6 @@ module Wunderbar
|
|
16
17
|
Rack::Mime::MIME_TYPES[File.extname(env['PATH_INFO'])]
|
17
18
|
@_response.set_header('Content-Type', mime) if mime
|
18
19
|
@_response.write(file[:content] || file[:source].call)
|
19
|
-
elsif Wunderbar.safe? and $SAFE==0
|
20
|
-
Proc.new { $SAFE=1; Wunderbar::CGI.call(self) }.call
|
21
20
|
else
|
22
21
|
Wunderbar::CGI.call(self)
|
23
22
|
end
|
data/lib/wunderbar/react.rb
CHANGED
@@ -35,17 +35,3 @@ class Wunderbar::Render
|
|
35
35
|
"</pre>"
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
# Monkeypatch to address https://github.com/sstephenson/execjs/pull/180
|
40
|
-
require 'execjs'
|
41
|
-
class ExecJS::ExternalRuntime::Context
|
42
|
-
alias_method :w_write_to_tempfile, :write_to_tempfile
|
43
|
-
def write_to_tempfile(*args)
|
44
|
-
tmpfile = w_write_to_tempfile(*args).path.untaint
|
45
|
-
tmpfile = Struct.new(:path, :to_str).new(tmpfile, tmpfile)
|
46
|
-
def tmpfile.unlink
|
47
|
-
File.unlink path
|
48
|
-
end
|
49
|
-
tmpfile
|
50
|
-
end
|
51
|
-
end
|
data/lib/wunderbar/render.rb
CHANGED
@@ -82,14 +82,12 @@ class Wunderbar::XmlMarkup
|
|
82
82
|
|
83
83
|
src = File.join(base, src) if not base.empty?
|
84
84
|
src = src.sub(/\?.*$/, '') # strip queries (typically mtimes)
|
85
|
-
src.untaint
|
86
85
|
|
87
|
-
name = File.expand_path(src, @_scope.settings.public_folder
|
88
|
-
name.untaint unless src.tainted?
|
86
|
+
name = File.expand_path(src, @_scope.settings.public_folder)
|
89
87
|
if File.exist? name
|
90
88
|
result = File.read(name)
|
91
89
|
else
|
92
|
-
file = File.expand_path(src+'.rb', @_scope.settings.views
|
90
|
+
file = File.expand_path(src+'.rb', @_scope.settings.views)
|
93
91
|
result = Wunderbar::Asset.convert(file)
|
94
92
|
end
|
95
93
|
else
|
@@ -113,11 +111,11 @@ class Wunderbar::XmlMarkup
|
|
113
111
|
scripts.unshift script.contents
|
114
112
|
elsif script.path
|
115
113
|
if script.path.start_with? '/'
|
116
|
-
path =
|
114
|
+
path = ENV['DOCUMENT_ROOT'] + script.path
|
117
115
|
else
|
118
|
-
path = File.expand_path(script.path, Wunderbar::Asset.root)
|
116
|
+
path = File.expand_path(script.path, Wunderbar::Asset.root)
|
119
117
|
end
|
120
|
-
setup << File.read(script.options[:server]
|
118
|
+
setup << File.read(script.options[:server] || path)
|
121
119
|
end
|
122
120
|
end
|
123
121
|
|
data/lib/wunderbar/server.rb
CHANGED
@@ -60,10 +60,6 @@ elsif defined? Sinatra
|
|
60
60
|
|
61
61
|
require 'wunderbar/sinatra'
|
62
62
|
|
63
|
-
elsif defined? ActionView::Template
|
64
|
-
|
65
|
-
require 'wunderbar/rails'
|
66
|
-
|
67
63
|
elsif defined? Rack
|
68
64
|
|
69
65
|
require 'wunderbar/rack'
|
@@ -157,11 +153,7 @@ else
|
|
157
153
|
ENV['REQUEST_METHOD'] ||= 'GET' if ARGV.delete('--get')
|
158
154
|
|
159
155
|
# CGI or command line
|
160
|
-
|
161
|
-
Proc.new { $SAFE=1; Wunderbar::CGI.call(cgi) }.call
|
162
|
-
else
|
163
|
-
Wunderbar::CGI.call(cgi)
|
164
|
-
end
|
156
|
+
Wunderbar::CGI.call(cgi)
|
165
157
|
end
|
166
158
|
end
|
167
159
|
end
|
data/lib/wunderbar/sinatra.rb
CHANGED
@@ -82,22 +82,14 @@ module Wunderbar
|
|
82
82
|
builder.set_variables_from_params(locals)
|
83
83
|
|
84
84
|
if not block
|
85
|
-
builder.instance_eval(data
|
85
|
+
builder.instance_eval(data, eval_file)
|
86
86
|
elsif not data
|
87
87
|
builder.instance_eval(&block)
|
88
88
|
else
|
89
89
|
context = builder.get_binding do
|
90
90
|
builder.instance_eval {_(&block)}
|
91
91
|
end
|
92
|
-
context.eval(data
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def _evaluate_safely(*args, &block)
|
97
|
-
if Wunderbar.safe? and $SAFE==0
|
98
|
-
Proc.new { $SAFE=1; _evaluate(*args, &block) }.call
|
99
|
-
else
|
100
|
-
_evaluate(*args, &block)
|
92
|
+
context.eval(data, eval_file)
|
101
93
|
end
|
102
94
|
end
|
103
95
|
end
|
@@ -108,7 +100,7 @@ module Wunderbar
|
|
108
100
|
def evaluate(scope, locals, &block)
|
109
101
|
builder = HtmlMarkup.new(scope)
|
110
102
|
begin
|
111
|
-
|
103
|
+
_evaluate(builder, scope, locals, &block)
|
112
104
|
rescue Exception => exception
|
113
105
|
scope.response.status = Wunderbar::ServerError.status
|
114
106
|
builder.clear!
|
@@ -132,7 +124,7 @@ module Wunderbar
|
|
132
124
|
def evaluate(scope, locals, &block)
|
133
125
|
builder = JsonBuilder.new(scope)
|
134
126
|
begin
|
135
|
-
result =
|
127
|
+
result = _evaluate(builder, scope, locals, &block)
|
136
128
|
|
137
129
|
# if no output was produced, use the result
|
138
130
|
builder._! result if builder.target? == {} and result
|
@@ -154,7 +146,7 @@ module Wunderbar
|
|
154
146
|
def evaluate(scope, locals, &block)
|
155
147
|
builder = TextBuilder.new(scope)
|
156
148
|
begin
|
157
|
-
result =
|
149
|
+
result = _evaluate(builder, scope, locals, &block)
|
158
150
|
|
159
151
|
# if no output was produced, use the result
|
160
152
|
builder._ result.to_s if builder.target!.empty? and result
|
@@ -240,13 +232,12 @@ Tilt.register 'xhtml.rb', Wunderbar::Template::Xhtml
|
|
240
232
|
helpers Wunderbar::SinatraHelpers
|
241
233
|
|
242
234
|
if Dir.exist? settings.public_folder
|
243
|
-
Wunderbar::Asset.root = File.join(settings.public_folder, 'assets')
|
235
|
+
Wunderbar::Asset.root = File.join(settings.public_folder, 'assets')
|
244
236
|
end
|
245
237
|
|
246
238
|
Wunderbar::Asset.virtual = true
|
247
239
|
|
248
240
|
get "/#{Wunderbar::Asset.path}/:name" do |name|
|
249
|
-
name.untaint if name =~ /^([-\w]\.?)+$/
|
250
241
|
file = "#{Wunderbar::Asset.root}/#{name}"
|
251
242
|
_text do
|
252
243
|
if File.exist? file
|
@@ -695,7 +695,7 @@ else
|
|
695
695
|
|
696
696
|
function attributeEncode(text) {
|
697
697
|
// unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title)
|
698
|
-
// never makes sense to have verbatim HTML in it
|
698
|
+
// never makes sense to have verbatim HTML in it
|
699
699
|
return text.replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
|
700
700
|
}
|
701
701
|
|
data/lib/wunderbar/version.rb
CHANGED
data/lib/wunderbar/vue.rb
CHANGED
@@ -14,7 +14,7 @@ class Wunderbar::Render
|
|
14
14
|
path = `which nodejs`.chomp
|
15
15
|
path = `which node`.chomp if path.empty?
|
16
16
|
raise RuntimeError.new('Unable to locate nodejs') if path.empty?
|
17
|
-
@nodejs = path
|
17
|
+
@nodejs = path
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.server(common)
|
@@ -50,7 +50,7 @@ class Wunderbar::Render
|
|
50
50
|
stdout += "\n<pre>#{CGI.escapeHTML(stderr)}</pre>"
|
51
51
|
end
|
52
52
|
|
53
|
-
stdout
|
53
|
+
stdout
|
54
54
|
rescue => e
|
55
55
|
Wunderbar.error e
|
56
56
|
"<pre>#{CGI.escapeHTML(e.message)}</pre>"
|
data/wunderbar.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.date = "2019-06-07"
|
14
14
|
s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications.'\n".freeze
|
15
15
|
s.email = "rubys@intertwingly.net".freeze
|
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/
|
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/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]
|
17
17
|
s.homepage = "http://github.com/rubys/wunderbar".freeze
|
18
18
|
s.licenses = ["MIT".freeze]
|
19
19
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.3".freeze)
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wunderbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-06-07 00:00:00.000000000 Z
|
@@ -60,7 +60,6 @@ files:
|
|
60
60
|
- lib/wunderbar/pagedown.rb
|
61
61
|
- lib/wunderbar/polymer.rb
|
62
62
|
- lib/wunderbar/rack.rb
|
63
|
-
- lib/wunderbar/rails.rb
|
64
63
|
- lib/wunderbar/react.rb
|
65
64
|
- lib/wunderbar/render.rb
|
66
65
|
- lib/wunderbar/script.rb
|
@@ -90,7 +89,7 @@ homepage: http://github.com/rubys/wunderbar
|
|
90
89
|
licenses:
|
91
90
|
- MIT
|
92
91
|
metadata: {}
|
93
|
-
post_install_message:
|
92
|
+
post_install_message:
|
94
93
|
rdoc_options: []
|
95
94
|
require_paths:
|
96
95
|
- lib
|
@@ -105,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
104
|
- !ruby/object:Gem::Version
|
106
105
|
version: '0'
|
107
106
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
-
signing_key:
|
107
|
+
rubygems_version: 3.1.2
|
108
|
+
signing_key:
|
110
109
|
specification_version: 4
|
111
110
|
summary: HTML Generator and CGI application support
|
112
111
|
test_files: []
|
data/lib/wunderbar/rails.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext'
|
2
|
-
require 'action_view'
|
3
|
-
|
4
|
-
module Wunderbar
|
5
|
-
module Rails
|
6
|
-
class HtmlHandler
|
7
|
-
cattr_accessor :default_format
|
8
|
-
self.default_format = Mime[:html]
|
9
|
-
|
10
|
-
def self.call(template, source=nil)
|
11
|
-
%{
|
12
|
-
compiled = Proc.new {#{template.source}}
|
13
|
-
x = Wunderbar::HtmlMarkup.new(self);
|
14
|
-
instance_variables.each do |var|
|
15
|
-
x.instance_variable_set var, instance_variable_get(var)
|
16
|
-
end
|
17
|
-
x.instance_eval(&compiled)
|
18
|
-
x._.target!
|
19
|
-
}.strip # take care to preserve line numbers in original source
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class JsonHandler
|
24
|
-
cattr_accessor :default_format
|
25
|
-
self.default_format = Mime[:json]
|
26
|
-
|
27
|
-
def self.call(template, source=nil)
|
28
|
-
%{
|
29
|
-
compiled = Proc.new {#{template.source}}
|
30
|
-
x = Wunderbar::JsonBuilder.new(self);
|
31
|
-
instance_variables.each do |var|
|
32
|
-
x.instance_variable_set var, instance_variable_get(var)
|
33
|
-
end
|
34
|
-
x.instance_eval(&compiled)
|
35
|
-
x.target!
|
36
|
-
}.strip # take care to preserve line numbers in original source
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
ActionView::Template.register_template_handler :_html, HtmlHandler
|
41
|
-
ActionView::Template.register_template_handler :_json, JsonHandler
|
42
|
-
end
|
43
|
-
end
|