www_app 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/www_app.rb +3 -1
- data/lib/www_app/HTML.rb +9 -5
- data/lib/www_app/TO.rb +20 -11
- data/specs/lib/helpers.rb +1 -1
- data/specs/server-side/0021-link.rb +18 -6
- data/specs/server-side/0060-text.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae67823b91ac54d165890af512d9c2b8b97fb7ea
|
4
|
+
data.tar.gz: abac21553d1cc1f37d9bc0793866075e00ffbef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e5008e96ce87034649f61e66f21b7f61d06b24e8fbd980a90461694139ba86f82b1bf38d0a7107ea7100e8a176feb208f206adaf3d45d3147a2503b1defc30e
|
7
|
+
data.tar.gz: 804359ff34f1287b952f6f30587774a208fe9cd4bf955267727c9bb27d02c806093435d201f75a3be5d5c732d4c0bc647bd433bd5bd77275acae9867c547ac50
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.3
|
data/lib/www_app.rb
CHANGED
data/lib/www_app/HTML.rb
CHANGED
@@ -58,8 +58,8 @@ class WWW_App
|
|
58
58
|
|
59
59
|
TAGS.each { |name|
|
60
60
|
eval <<-EOF, nil, __FILE__, __LINE__ + 1
|
61
|
-
def #{name}
|
62
|
-
create(:#{name})
|
61
|
+
def #{name} str = :none
|
62
|
+
create(:#{name}, str)
|
63
63
|
block_given? ?
|
64
64
|
close { yield } :
|
65
65
|
self
|
@@ -87,10 +87,14 @@ class WWW_App
|
|
87
87
|
create(:meta, *args)
|
88
88
|
end
|
89
89
|
|
90
|
-
def title
|
90
|
+
def title str = :none
|
91
91
|
fail ":title not allowed here" if parent
|
92
|
-
|
93
|
-
|
92
|
+
if !block_given? && str != :none
|
93
|
+
create { text str }
|
94
|
+
else
|
95
|
+
create :title do
|
96
|
+
yield
|
97
|
+
end
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
data/lib/www_app/TO.rb
CHANGED
@@ -203,6 +203,9 @@ class WWW_App
|
|
203
203
|
when t_name == :style
|
204
204
|
style_tags[:children] << t
|
205
205
|
|
206
|
+
when t_name == :link
|
207
|
+
head[:children] << t
|
208
|
+
|
206
209
|
when t_name == :_ && !parent
|
207
210
|
body[:css] = (body[:css] || {}).merge(t[:css]) if t[:css]
|
208
211
|
body[:class] = (body[:class] || []).concat(t[:class]) if t[:class]
|
@@ -382,6 +385,10 @@ class WWW_App
|
|
382
385
|
Clean.html(tag[:value])
|
383
386
|
)
|
384
387
|
|
388
|
+
when t_name == :link
|
389
|
+
final << (
|
390
|
+
%^#{SPACES(indent)}<link type="text/css" rel="stylesheet" href="#{::Escape_Escape_Escape.relative_href tag[:href]}" />^
|
391
|
+
)
|
385
392
|
|
386
393
|
when t_name == :meta
|
387
394
|
case
|
@@ -394,7 +401,7 @@ class WWW_App
|
|
394
401
|
end
|
395
402
|
|
396
403
|
final << (
|
397
|
-
%^#{SPACES(indent)}<meta #{key_name}="#{key_content}" content="#{content}"
|
404
|
+
%^#{SPACES(indent)}<meta #{key_name}="#{key_content}" content="#{content}" />\n^
|
398
405
|
)
|
399
406
|
|
400
407
|
when t_name == :html # === :html tag ================
|
@@ -476,17 +483,19 @@ class WWW_App
|
|
476
483
|
]
|
477
484
|
}
|
478
485
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
486
|
+
if !stacks[:js].empty?
|
487
|
+
clean_vals = stacks[:js].map { |raw_x| stacks[:clean_text].call(raw_x) }
|
488
|
+
content = <<-EOF
|
489
|
+
\n#{SPACES(indent)}WWW_App.run( #{::Escape_Escape_Escape.json_encode(code: clean_vals)} );
|
490
|
+
EOF
|
483
491
|
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
492
|
+
new_todo.concat [
|
493
|
+
:clean_attrs, {:type=>'application/javascript'}, script_tag,
|
494
|
+
:open, :script,
|
495
|
+
{:tag_name=>:text, :skip_escape=>true, :value=> content },
|
496
|
+
:close, :script
|
497
|
+
]
|
498
|
+
end
|
490
499
|
|
491
500
|
todo = new_todo.concat(todo)
|
492
501
|
|
data/specs/lib/helpers.rb
CHANGED
@@ -10,17 +10,29 @@ describe :link do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "escapes slashes in :href" do
|
13
|
-
target %^<link href="/css/css/styles.css" />^
|
14
|
-
|
13
|
+
target = %^<link type="text/css" rel="stylesheet" href="/css/css/styles.css" />^
|
14
|
+
WWW_App.new {
|
15
15
|
link.href('/css/css/styles.css')./
|
16
|
-
}
|
16
|
+
}.to_html.scan(target).should == [target]
|
17
17
|
end
|
18
18
|
|
19
|
+
it "gets rendered in :head" do
|
20
|
+
html = get_content(:head, WWW_App.new {
|
21
|
+
link.type('text/css').rel('stylesheet').href("/file.css")./
|
22
|
+
}.to_html)
|
23
|
+
|
24
|
+
html.
|
25
|
+
scan(%r!<link [^>]+>!).
|
26
|
+
should == [<<-EOF.strip]
|
27
|
+
<link type="text/css" rel="stylesheet" href="/file.css" />
|
28
|
+
EOF
|
29
|
+
end # === it gets rendered in :head
|
30
|
+
|
19
31
|
it "allows a relative :href" do
|
20
|
-
target %^<link href="/css.css" />^
|
21
|
-
|
32
|
+
target = %^<link type="text/css" rel="stylesheet" href="/css.css" />^
|
33
|
+
WWW_App.new {
|
22
34
|
link.href('/css.css')./
|
23
|
-
}
|
35
|
+
}.to_html.scan(target).should == [target]
|
24
36
|
end
|
25
37
|
|
26
38
|
end # === describe :link
|
@@ -10,6 +10,13 @@ describe :text do
|
|
10
10
|
end
|
11
11
|
end # === it prints a string if value is a hash: {:type=>:string, ...}
|
12
12
|
|
13
|
+
it "prints a string passed to it as a single argument" do
|
14
|
+
target :body, %^<p>string string</p>^
|
15
|
+
actual do
|
16
|
+
p "string string"
|
17
|
+
end
|
18
|
+
end # === it prints a string passed to it as a single argument
|
19
|
+
|
13
20
|
end # === describe "string content"
|
14
21
|
|
15
22
|
describe :raw_text do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: www_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- da99
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|