green_shoes 0.189.0 → 0.198.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +4 -0
- data/README.md +4 -0
- data/VERSION +1 -1
- data/lib/ext/hpricot.rb +31 -0
- data/lib/ext/hpricot/blankslate.rb +63 -0
- data/lib/ext/hpricot/builder.rb +216 -0
- data/lib/ext/hpricot/elements.rb +510 -0
- data/lib/ext/hpricot/hpricot_scan.so +0 -0
- data/lib/ext/hpricot/htmlinfo.rb +691 -0
- data/lib/ext/hpricot/inspect.rb +103 -0
- data/lib/ext/hpricot/modules.rb +40 -0
- data/lib/ext/hpricot/parse.rb +38 -0
- data/lib/ext/hpricot/tag.rb +202 -0
- data/lib/ext/hpricot/tags.rb +164 -0
- data/lib/ext/hpricot/traverse.rb +838 -0
- data/lib/ext/hpricot/xchar.rb +94 -0
- data/lib/green_shoes.rb +1 -0
- data/lib/shoes/app.rb +17 -1
- data/lib/shoes/help.rb +168 -13
- data/static/code_highlighter.js +188 -0
- data/static/code_highlighter_ruby.js +26 -0
- data/static/manual-en.txt +133 -61
- data/static/manual.css +177 -0
- metadata +19 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
CodeHighlighter.addStyle("rb",{
|
2
|
+
comment : {
|
3
|
+
exp : /#[^\n]+/
|
4
|
+
},
|
5
|
+
brackets : {
|
6
|
+
exp : /\(|\)|\{|\}/
|
7
|
+
},
|
8
|
+
string : {
|
9
|
+
exp : /'[^']*'|"[^"]*"/
|
10
|
+
},
|
11
|
+
keywords : {
|
12
|
+
exp : /\b(do|end|self|class|def|if|module|yield|then|else|for|until|unless|while|elsif|case|when|break|retry|redo|rescue|raise)\b/
|
13
|
+
},
|
14
|
+
constant : {
|
15
|
+
exp : /\b([A-Z]\w+)\b/
|
16
|
+
},
|
17
|
+
ivar : {
|
18
|
+
exp : /([^@])(@{1,2}\w+)\b/
|
19
|
+
},
|
20
|
+
ns : {
|
21
|
+
exp : /(:{2,})/
|
22
|
+
},
|
23
|
+
symbol : {
|
24
|
+
exp : /(:[A-Za-z0-9_!?]+)/
|
25
|
+
}
|
26
|
+
});
|
data/static/manual-en.txt
CHANGED
@@ -9,7 +9,7 @@ You see, the trivial Shoes program can be just one line:
|
|
9
9
|
|
10
10
|
{{{
|
11
11
|
#!ruby
|
12
|
-
Shoes.app
|
12
|
+
Shoes.app{button("Click me!"){alert("Good job.")}}
|
13
13
|
}}}
|
14
14
|
|
15
15
|
Shoes programs are written in a language called Ruby. When Shoes is handed
|
@@ -354,7 +354,7 @@ can have scrollbars.
|
|
354
354
|
|
355
355
|
{{{
|
356
356
|
Shoes.app do
|
357
|
-
stack :
|
357
|
+
stack width: 200, height: 200, scroll: true do
|
358
358
|
background "#DFA"
|
359
359
|
100.times do |i|
|
360
360
|
para "Paragraph No. #{i}"
|
@@ -488,7 +488,8 @@ UI Gothic'''.
|
|
488
488
|
|
489
489
|
{{{
|
490
490
|
Shoes.app do
|
491
|
-
para "てすと (te-su-to)",
|
491
|
+
para "てすと (te-su-to)",
|
492
|
+
font: case RUBY_PLATFORM
|
492
493
|
when /mingw/; "MS UI Gothic"
|
493
494
|
when /darwin/; "AppleGothic, Arial"
|
494
495
|
else "Arial"
|
@@ -806,7 +807,8 @@ like this: `gradient(green, '#FA3')`
|
|
806
807
|
|
807
808
|
{{{
|
808
809
|
Shoes.app do
|
809
|
-
oval 100, 100, 100,
|
810
|
+
oval 100, 100, 100,
|
811
|
+
fill: gradient(green, '#FA3'), angle: 45
|
810
812
|
end
|
811
813
|
}}}
|
812
814
|
|
@@ -837,7 +839,8 @@ When passing in a whole number, use values from 0 to 255.
|
|
837
839
|
Shoes.app do
|
838
840
|
blueviolet = rgb(138, 43, 226, 0.5)
|
839
841
|
darkgreen = rgb(0, 100, 0, 0.5)
|
840
|
-
oval 100, 100, 100,
|
842
|
+
oval 100, 100, 100,
|
843
|
+
fill: [blueviolet, darkgreen].sample(1)
|
841
844
|
end
|
842
845
|
}}}
|
843
846
|
|
@@ -847,7 +850,8 @@ Or, use a decimal number from 0.0 to 1.0.
|
|
847
850
|
Shoes.app do
|
848
851
|
blueviolet = rgb(0.54, 0.17, 0.89)
|
849
852
|
darkgreen = rgb(0, 0.4, 0)
|
850
|
-
oval 100, 100, 100,
|
853
|
+
oval 100, 100, 100,
|
854
|
+
fill: [blueviolet, darkgreen].sample(1)
|
851
855
|
end
|
852
856
|
}}}
|
853
857
|
|
@@ -873,10 +877,11 @@ describe how big the window is. Perhaps also the name of the app.
|
|
873
877
|
|
874
878
|
{{{
|
875
879
|
#!ruby
|
876
|
-
Shoes.app title: "White Circle",
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
+
Shoes.app title: "White Circle",
|
881
|
+
width: 200, height: 200 do
|
882
|
+
background black
|
883
|
+
fill white
|
884
|
+
oval top: 20, left: 20, radius: 160
|
880
885
|
end
|
881
886
|
}}}
|
882
887
|
|
@@ -918,16 +923,16 @@ entire application, use the built-in method `exit`.
|
|
918
923
|
|
919
924
|
{{{
|
920
925
|
Shoes.app do
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
end
|
926
|
+
para 'hello'
|
927
|
+
button 'spawn' do
|
928
|
+
Shoes.app do
|
929
|
+
para 'hello'
|
930
|
+
button('close: close this window only'){close}
|
931
|
+
button('exit: quit Green Shoes'){exit}
|
928
932
|
end
|
929
|
-
|
930
|
-
|
933
|
+
end
|
934
|
+
button('close: close this window only'){close}
|
935
|
+
button('exit: quit Green Shoes'){exit}
|
931
936
|
end
|
932
937
|
}}}
|
933
938
|
|
@@ -947,8 +952,7 @@ If you attach a block to a download, it'll get called as the `finish` event.
|
|
947
952
|
title "Searching Google", size: 16
|
948
953
|
@status = para "One moment..."
|
949
954
|
|
950
|
-
|
951
|
-
download "http://www.google.com/search?q=shoes" do |goog|
|
955
|
+
download "http://is.gd/bXTVY7" do |goog|
|
952
956
|
@status.text = "Headers: #{goog.meta}"
|
953
957
|
end
|
954
958
|
end
|
@@ -967,7 +971,7 @@ Another simple use of `download` is to save some web data to a file, using the
|
|
967
971
|
title "Downloading Google image", size: 16
|
968
972
|
@status = para "One moment..."
|
969
973
|
|
970
|
-
download "http://
|
974
|
+
download "http://is.gd/GVAGF7",
|
971
975
|
:save => "nasa50th.gif" do
|
972
976
|
@status.text = "Okay, is downloaded."
|
973
977
|
image "nasa50th.gif", top: 100
|
@@ -989,7 +993,7 @@ class.)
|
|
989
993
|
title "GET Google", size: 16
|
990
994
|
@status = para "One moment..."
|
991
995
|
|
992
|
-
download "http://
|
996
|
+
download "http://is.gd/bXTVY7",
|
993
997
|
:method => "GET" do |dump|
|
994
998
|
@status.text = dump.response.body
|
995
999
|
end
|
@@ -1002,6 +1006,26 @@ query google's search engine.
|
|
1002
1006
|
|
1003
1007
|
'''Note:''' Green Shoes doesn't support the `:method`, `:headers` and `:body` styles.
|
1004
1008
|
|
1009
|
+
{{{
|
1010
|
+
include Hpricot
|
1011
|
+
Shoes.app do
|
1012
|
+
status = para "One moment..."
|
1013
|
+
download 'http://is.gd/BatiRt' do |dl|
|
1014
|
+
samples = []
|
1015
|
+
Hpricot(dl).inner_text.each_line do |line|
|
1016
|
+
samples.push($1) if line =~ /(sample.*\.rb)/
|
1017
|
+
end
|
1018
|
+
status.text = samples.join(', ')
|
1019
|
+
flush
|
1020
|
+
end
|
1021
|
+
end
|
1022
|
+
}}}
|
1023
|
+
|
1024
|
+
As you can see from the above example, Green Shoes includes the Hpricot
|
1025
|
+
library for parsing HTML.
|
1026
|
+
|
1027
|
+
'''Note''': Windows platform only so far.
|
1028
|
+
|
1005
1029
|
=== location() » a string ===
|
1006
1030
|
|
1007
1031
|
Gets a string containing the URL of the current app.
|
@@ -1072,9 +1096,12 @@ available on every element and slot.
|
|
1072
1096
|
|
1073
1097
|
{{{
|
1074
1098
|
Shoes.app title: "A Styling Sample" do
|
1075
|
-
choose =
|
1099
|
+
choose =
|
1100
|
+
lambda{[red, blue, green, yellow].sample}
|
1076
1101
|
s = star 100, 50, 30, 200, 180, strokewidth: 5
|
1077
|
-
button
|
1102
|
+
button 'change colors' do
|
1103
|
+
s.style stroke: choose.call, fill: choose.call
|
1104
|
+
end
|
1078
1105
|
end
|
1079
1106
|
}}}
|
1080
1107
|
|
@@ -1086,9 +1113,12 @@ search to find the method.)
|
|
1086
1113
|
{{{
|
1087
1114
|
# Not yet available
|
1088
1115
|
Shoes.app title: "A Styling Sample" do
|
1089
|
-
choose =
|
1116
|
+
choose =
|
1117
|
+
lambda{[red, blue, green, yellow].sample}
|
1090
1118
|
s = star 100, 50, 30, 200, 180, strokewidth: 5
|
1091
|
-
button
|
1119
|
+
button 'change colors' do
|
1120
|
+
s.stroke = choose.call; s.fill = choose.call
|
1121
|
+
end
|
1092
1122
|
end
|
1093
1123
|
}}}
|
1094
1124
|
|
@@ -1761,7 +1791,7 @@ setting `:angle1` to 0 and `:angle2` to `2*Math::PI`.)
|
|
1761
1791
|
a = animate 12 do |i|
|
1762
1792
|
@e.remove if @e
|
1763
1793
|
r = i * (Math::PI * 0.01)
|
1764
|
-
@e = arc 100, 50, 180, 360, 0,
|
1794
|
+
@e = arc 100, 50, 180, 360, 0, r
|
1765
1795
|
a.stop if r >= 2*Math::PI
|
1766
1796
|
end
|
1767
1797
|
end
|
@@ -1771,7 +1801,12 @@ setting `:angle1` to 0 and `:angle2` to `2*Math::PI`.)
|
|
1771
1801
|
|
1772
1802
|
Draws an arrow at coordinates (left, top) with a pixel `width`.
|
1773
1803
|
|
1774
|
-
|
1804
|
+
{{{
|
1805
|
+
Shoes.app do
|
1806
|
+
para 'An arrow shape:', left: 20, top: 10
|
1807
|
+
arrow 30, 40, 70
|
1808
|
+
end
|
1809
|
+
}}}
|
1775
1810
|
|
1776
1811
|
=== cap(:curve or :rect or :project) » self ===
|
1777
1812
|
|
@@ -2103,7 +2138,8 @@ attached here which is called any type the user changes the text in the box.
|
|
2103
2138
|
Shoes.app do
|
2104
2139
|
edit_box
|
2105
2140
|
edit_box text: "HORRAY EDIT ME"
|
2106
|
-
edit_box text: "small one",
|
2141
|
+
edit_box text: "small one",
|
2142
|
+
width: 100, height: 160
|
2107
2143
|
end
|
2108
2144
|
}}}
|
2109
2145
|
|
@@ -2181,13 +2217,13 @@ box becomes selected by the user.
|
|
2181
2217
|
{{{
|
2182
2218
|
#!ruby
|
2183
2219
|
Shoes.app do
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
end
|
2189
|
-
@p = para
|
2220
|
+
stack margin: 10 do
|
2221
|
+
para "Pick a card:"
|
2222
|
+
list_box items: ["Jac", "Ace", "Jok"] do |item|
|
2223
|
+
@p.text = "#{item} was picked!"
|
2190
2224
|
end
|
2225
|
+
@p = para
|
2226
|
+
end
|
2191
2227
|
end
|
2192
2228
|
}}}
|
2193
2229
|
|
@@ -2317,7 +2353,7 @@ away.
|
|
2317
2353
|
background red
|
2318
2354
|
end
|
2319
2355
|
s.hover do
|
2320
|
-
|
2356
|
+
s.clear { background blue }
|
2321
2357
|
end
|
2322
2358
|
s.leave do
|
2323
2359
|
s.clear { background red }
|
@@ -2435,7 +2471,8 @@ Adds elements to the end of a slot.
|
|
2435
2471
|
timer 3 do
|
2436
2472
|
@slot.append do
|
2437
2473
|
title "Breaking News"
|
2438
|
-
tagline "Astronauts
|
2474
|
+
tagline "Astronauts ",
|
2475
|
+
"arrested for space shuttle DUI."
|
2439
2476
|
end
|
2440
2477
|
end
|
2441
2478
|
end
|
@@ -2541,7 +2578,8 @@ This is commonly used to pad elements on the right, like so:
|
|
2541
2578
|
# Not yet available
|
2542
2579
|
Shoes.app do
|
2543
2580
|
stack :margin_right => 20 + gutter do
|
2544
|
-
para "Insert fat and ratified
|
2581
|
+
para "Insert fat and ratified ",
|
2582
|
+
"declaration of independence here..."
|
2545
2583
|
end
|
2546
2584
|
end
|
2547
2585
|
}}}
|
@@ -2740,13 +2778,15 @@ covered as the [[Position.style]] method for slots.)
|
|
2740
2778
|
#!ruby
|
2741
2779
|
Shoes.app do
|
2742
2780
|
stack do
|
2743
|
-
# Background, text and a button:
|
2781
|
+
# Background, text and a button:
|
2782
|
+
# both are elements!
|
2744
2783
|
@back = background green
|
2745
2784
|
@text = banner "A Message for You, Rudy"
|
2746
2785
|
@press = button "Stop your messin about!"
|
2747
2786
|
|
2748
2787
|
# And so, both can be styled.
|
2749
|
-
@text.style size: 12,
|
2788
|
+
@text.style size: 12,
|
2789
|
+
markup: fg(@text.text, red), margin: 10
|
2750
2790
|
@press.style width: 400
|
2751
2791
|
@back.style height: 10
|
2752
2792
|
end
|
@@ -2873,7 +2913,8 @@ original setting (things like "100%" for width or "10px" for top.)
|
|
2873
2913
|
#!ruby
|
2874
2914
|
Shoes.app do
|
2875
2915
|
# A button which take up the whole page
|
2876
|
-
@b = button "All of it",
|
2916
|
+
@b = button "All of it",
|
2917
|
+
width: width, height: height
|
2877
2918
|
|
2878
2919
|
# When clicked, show the styles
|
2879
2920
|
@b.click { alert(@b.style.inspect) }
|
@@ -2911,7 +2952,8 @@ a stack which is 120 pixels wide, you'll get back `120`. And, if you call
|
|
2911
2952
|
stack width: 120 do
|
2912
2953
|
@b = button "Click me", width: 1.0 do
|
2913
2954
|
alert "button.width = #{@b.width}\n" +
|
2914
|
-
"button.style[:width] =
|
2955
|
+
"button.style[:width] = " +
|
2956
|
+
"#{@b.style[:width]}"
|
2915
2957
|
end
|
2916
2958
|
end
|
2917
2959
|
end
|
@@ -3072,9 +3114,9 @@ Just to be pedantic, though, here's another way to write that last example.
|
|
3072
3114
|
#!ruby
|
3073
3115
|
Shoes.app do
|
3074
3116
|
@b1 = button "OK!"
|
3075
|
-
@b1.click
|
3117
|
+
@b1.click{para "Well okay then."}
|
3076
3118
|
@b2 = button "Are you sure?"
|
3077
|
-
@b2.click
|
3119
|
+
@b2.click{para "Your confidence is inspiring."}
|
3078
3120
|
end
|
3079
3121
|
}}}
|
3080
3122
|
|
@@ -3114,9 +3156,16 @@ Here's a sample checklist.
|
|
3114
3156
|
#!ruby
|
3115
3157
|
Shoes.app do
|
3116
3158
|
stack do
|
3117
|
-
flow
|
3118
|
-
|
3119
|
-
|
3159
|
+
flow do
|
3160
|
+
check; para "Frances Johnson", width: 200
|
3161
|
+
end
|
3162
|
+
flow do
|
3163
|
+
check; para "Ignatius J. Reilly", width: 200
|
3164
|
+
end
|
3165
|
+
flow do
|
3166
|
+
check
|
3167
|
+
para "Winston Niles Rumfoord", width: 200
|
3168
|
+
end
|
3120
3169
|
end
|
3121
3170
|
end
|
3122
3171
|
}}}
|
@@ -3140,7 +3189,8 @@ Okay, let's add to the above example.
|
|
3140
3189
|
end
|
3141
3190
|
|
3142
3191
|
button "What's been checked?" do
|
3143
|
-
selected =
|
3192
|
+
selected =
|
3193
|
+
@list.map{|c, n| n if c.checked?}.compact
|
3144
3194
|
alert("You selected: " + selected.join(', '))
|
3145
3195
|
end
|
3146
3196
|
end
|
@@ -3201,7 +3251,8 @@ every time someone types into or deletes from the box.
|
|
3201
3251
|
#!ruby
|
3202
3252
|
Shoes.app do
|
3203
3253
|
edit_box do |e|
|
3204
|
-
@counter.text =
|
3254
|
+
@counter.text =
|
3255
|
+
strong("#{e.text.size}") + " characters"
|
3205
3256
|
end
|
3206
3257
|
@counter = para strong("0"), " characters"
|
3207
3258
|
end
|
@@ -3309,7 +3360,7 @@ You can use web URLs directly as well.
|
|
3309
3360
|
{{{
|
3310
3361
|
#!ruby
|
3311
3362
|
Shoes.app do
|
3312
|
-
image "http://
|
3363
|
+
image "http://is.gd/c0mBtb"
|
3313
3364
|
end
|
3314
3365
|
}}}
|
3315
3366
|
|
@@ -3441,7 +3492,7 @@ A simple progress bar is 150 pixels wide, but you can use the `:width` style
|
|
3441
3492
|
{{{
|
3442
3493
|
Shoes.app do
|
3443
3494
|
title "Progress example"
|
3444
|
-
@p = progress left: 10, top: 100, width: width
|
3495
|
+
@p = progress left: 10, top: 100, width: width-20
|
3445
3496
|
|
3446
3497
|
animate do |i|
|
3447
3498
|
@p.fraction = (i % 100) / 100.0
|
@@ -3476,9 +3527,15 @@ marked.
|
|
3476
3527
|
#!ruby
|
3477
3528
|
Shoes.app do
|
3478
3529
|
para "Among these films, which do you prefer?\n"
|
3479
|
-
radio
|
3480
|
-
|
3481
|
-
|
3530
|
+
radio
|
3531
|
+
para strong("The Taste of Tea"),
|
3532
|
+
" by Katsuhito Ishii\n", width: 570
|
3533
|
+
radio
|
3534
|
+
para strong("Kin-Dza-Dza"),
|
3535
|
+
" by Georgi Danelia\n", width: 570
|
3536
|
+
radio
|
3537
|
+
para strong("Children of Heaven"),
|
3538
|
+
" by Majid Majidi\n", width: 570
|
3482
3539
|
end
|
3483
3540
|
}}}
|
3484
3541
|
|
@@ -3492,9 +3549,21 @@ If we move them each into their own slot, the example breaks.
|
|
3492
3549
|
Shoes.app do
|
3493
3550
|
stack do
|
3494
3551
|
para "Among these films, which do you prefer?"
|
3495
|
-
flow
|
3496
|
-
|
3497
|
-
|
3552
|
+
flow do
|
3553
|
+
radio
|
3554
|
+
para "The Taste of Tea by Katsuhito Ishii",
|
3555
|
+
width: 300
|
3556
|
+
end
|
3557
|
+
flow do
|
3558
|
+
radio
|
3559
|
+
para "Kin-Dza-Dza by Georgi Danelia",
|
3560
|
+
width: 300
|
3561
|
+
end
|
3562
|
+
flow do
|
3563
|
+
radio
|
3564
|
+
para "Children of Heaven by Majid Majidi",
|
3565
|
+
width: 300
|
3566
|
+
end
|
3498
3567
|
end
|
3499
3568
|
end
|
3500
3569
|
}}}
|
@@ -3511,15 +3580,18 @@ Here, let's group all these radios in the `:films` group.
|
|
3511
3580
|
para "Among these films, which do you prefer?"
|
3512
3581
|
flow do
|
3513
3582
|
radio :films
|
3514
|
-
para "The Taste of Tea by Katsuhito Ishii",
|
3583
|
+
para "The Taste of Tea by Katsuhito Ishii",
|
3584
|
+
width: 300
|
3515
3585
|
end
|
3516
3586
|
flow do
|
3517
3587
|
radio :films
|
3518
|
-
para "Kin-Dza-Dza by Georgi Danelia",
|
3588
|
+
para "Kin-Dza-Dza by Georgi Danelia",
|
3589
|
+
width: 300
|
3519
3590
|
end
|
3520
3591
|
flow do
|
3521
3592
|
radio :films
|
3522
|
-
para "Children of Heaven by Majid Majidi",
|
3593
|
+
para "Children of Heaven by Majid Majidi",
|
3594
|
+
width: 300
|
3523
3595
|
end
|
3524
3596
|
end
|
3525
3597
|
end
|