wunderbar 1.4.0 → 1.5.0
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 -3
- data/lib/wunderbar/builder.rb +6 -4
- data/lib/wunderbar/html-methods.rb +4 -11
- data/lib/wunderbar/markdown.rb +0 -1
- data/lib/wunderbar/render.rb +6 -1
- data/lib/wunderbar/script.rb +3 -1
- data/lib/wunderbar/server.rb +1 -9
- data/lib/wunderbar/vendor/Markdown.Converter.js +1 -1
- data/lib/wunderbar/version.rb +1 -1
- data/wunderbar.gemspec +1 -1
- metadata +1 -2
- 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: be770934a7f9d0f34e1d506ae7d27f35c5e2ab1a3e5720f56e85fbebf1a02a71
|
4
|
+
data.tar.gz: 63546e1889f0aabaf22cf605d0f415c294368732c018279281be18cb79209500
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23d1a99ad26576668e673da84c73d7cb1eaf376cb9e407084bbcb2d038efba67d01eda47307b82a6c4f50d77539e6378659d2320b0c0efa140644c04f18e712
|
7
|
+
data.tar.gz: 2fca8fbf9bbfd2b765db8d9af73ae6ab16fa99654990bab026c2ca2802aba72fa8a1d63bb679fed65dfd1fbf9da0fa91ad6a2cbed423504343606817eca15363
|
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
|
@@ -366,7 +371,9 @@ Secure by default
|
|
366
371
|
|
367
372
|
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
|
-
directly.
|
374
|
+
directly. Unless `nokogiri` was previously required (see [optional
|
375
|
+
dependencies](#optional-dependencies) below), calls to insert markup
|
376
|
+
(`_{...}`) will escape the markup.
|
370
377
|
|
371
378
|
Globals provided
|
372
379
|
---
|
@@ -426,7 +433,6 @@ The following gems are required by extensions of the same name:
|
|
426
433
|
* `coderay` - syntax highlighting
|
427
434
|
* `opal` - ruby to javascript compiler
|
428
435
|
* `rack` - webserver interface
|
429
|
-
* `rails` - web application framework
|
430
436
|
* `sinatra` - DSL for creating web applications
|
431
437
|
|
432
438
|
The following gems, if installed, will produce cleaner and prettier output:
|
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}
|
@@ -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?
|
@@ -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
|
193
|
-
if 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,7 +353,7 @@ module Wunderbar
|
|
362
353
|
def _(text=nil, &block)
|
363
354
|
unless block
|
364
355
|
if text
|
365
|
-
|
356
|
+
@_x.indented_text! text.to_s
|
366
357
|
end
|
367
358
|
return @_x
|
368
359
|
end
|
@@ -370,7 +361,9 @@ module Wunderbar
|
|
370
361
|
children = instance_eval(&block)
|
371
362
|
|
372
363
|
if String === children
|
373
|
-
|
364
|
+
ok = defined? Nokogiri
|
365
|
+
|
366
|
+
if ok and (children.include? '<' or children.include? '&')
|
374
367
|
if defined? Nokogiri::HTML5.fragment
|
375
368
|
doc = Nokogiri::HTML5.fragment(children.to_s)
|
376
369
|
else
|
data/lib/wunderbar/markdown.rb
CHANGED
data/lib/wunderbar/render.rb
CHANGED
data/lib/wunderbar/script.rb
CHANGED
@@ -13,7 +13,9 @@ module Wunderbar
|
|
13
13
|
if @block and @children.empty? and not @text
|
14
14
|
width = options[:width]
|
15
15
|
width -= indent.to_s.length if width
|
16
|
-
|
16
|
+
opts = {binding: @binding, width: width}
|
17
|
+
opts = {**@attrs.delete(:options), **opts} if @attrs[:options]
|
18
|
+
@text = Ruby2JS.convert(@block, opts).to_s
|
17
19
|
end
|
18
20
|
super
|
19
21
|
end
|
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
|
@@ -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/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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wunderbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
@@ -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
|
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
|