browser_gui 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +84 -1
- data/examples/simple_erector.rb +40 -0
- data/examples/simple_haml.rb +33 -0
- data/lib/browser_gui/version.rb +1 -1
- metadata +4 -2
data/README.md
CHANGED
@@ -39,7 +39,7 @@ post "/action" do
|
|
39
39
|
end
|
40
40
|
```
|
41
41
|
|
42
|
-
### A simple Markdown example
|
42
|
+
### A simple [Markdown](http://daringfireball.net/projects/markdown) example
|
43
43
|
|
44
44
|
```
|
45
45
|
#!/usr/bin/env ruby
|
@@ -62,6 +62,89 @@ get "/action/:id" do
|
|
62
62
|
end
|
63
63
|
```
|
64
64
|
|
65
|
+
### A simple [Erector](http://erector.rubyforge.org) example
|
66
|
+
|
67
|
+
```
|
68
|
+
#! /usr/bin/env ruby
|
69
|
+
|
70
|
+
require "sinatra"
|
71
|
+
require "browser_gui"
|
72
|
+
require "erector"
|
73
|
+
|
74
|
+
class Hello < Erector::Widget
|
75
|
+
def content
|
76
|
+
html {
|
77
|
+
head { title "Erector example" }
|
78
|
+
body {
|
79
|
+
h1 "Hello from Erector."
|
80
|
+
form(:action => "/action", :method => "post") {
|
81
|
+
text "Name:"
|
82
|
+
input :type => "text", :name => "text", :size => 30
|
83
|
+
br
|
84
|
+
input :type => "submit"
|
85
|
+
}
|
86
|
+
ul {
|
87
|
+
(1..3).each do |index|
|
88
|
+
click_text = (index == 1) ? "Click me!" : "No, click me!"
|
89
|
+
li { a(:href => "/link/#{index}") { text click_text } }
|
90
|
+
end
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
get "/" do
|
98
|
+
Hello.new().to_html
|
99
|
+
end
|
100
|
+
|
101
|
+
post "/action" do
|
102
|
+
params.inspect
|
103
|
+
end
|
104
|
+
|
105
|
+
get "/link/:id" do
|
106
|
+
"You clicked link #{params[:id]}"
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
### A simple [Haml](http://haml.info/) example
|
111
|
+
|
112
|
+
```
|
113
|
+
#!/usr/bin/env ruby
|
114
|
+
|
115
|
+
require "sinatra"
|
116
|
+
require "browser_gui"
|
117
|
+
require "haml"
|
118
|
+
|
119
|
+
HAML =<<EOF
|
120
|
+
%h1 Hello from Haml
|
121
|
+
%form{ :action => "/action", :method => "post" }
|
122
|
+
Name:
|
123
|
+
%input{ :type => "text", :name => "text", :size => 30 }
|
124
|
+
%br/
|
125
|
+
%input{ :type => "submit" }
|
126
|
+
%ul
|
127
|
+
- (1..3).each do |i|
|
128
|
+
- href = "/link/" + i.to_s
|
129
|
+
%li
|
130
|
+
%a{ :href => href }
|
131
|
+
= (i == 1) ? "Click me!" : "No, click me!"
|
132
|
+
%br/
|
133
|
+
EOF
|
134
|
+
|
135
|
+
get "/" do
|
136
|
+
haml HAML
|
137
|
+
end
|
138
|
+
|
139
|
+
post "/action" do
|
140
|
+
params.inspect
|
141
|
+
end
|
142
|
+
|
143
|
+
get "/link/:id" do
|
144
|
+
"You clicked link #{params[:id]}"
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
65
148
|
## Using command-line options
|
66
149
|
|
67
150
|
```
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require "sinatra"
|
4
|
+
require "browser_gui"
|
5
|
+
require "erector"
|
6
|
+
|
7
|
+
class Hello < Erector::Widget
|
8
|
+
def content
|
9
|
+
html {
|
10
|
+
head { title "Erector example" }
|
11
|
+
body {
|
12
|
+
h1 "Hello from Erector."
|
13
|
+
form(:action => "/action", :method => "post") {
|
14
|
+
text "Name:"
|
15
|
+
input :type => "text", :name => "text", :size => 30
|
16
|
+
br
|
17
|
+
input :type => "submit"
|
18
|
+
}
|
19
|
+
ul {
|
20
|
+
(1..3).each do |index|
|
21
|
+
click_text = (index == 1) ? "Click me!" : "No, click me!"
|
22
|
+
li { a(:href => "/link/#{index}") { text click_text } }
|
23
|
+
end
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
get "/" do
|
31
|
+
Hello.new().to_html
|
32
|
+
end
|
33
|
+
|
34
|
+
post "/action" do
|
35
|
+
params.inspect
|
36
|
+
end
|
37
|
+
|
38
|
+
get "/link/:id" do
|
39
|
+
"You clicked link #{params[:id]}"
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "sinatra"
|
4
|
+
require "browser_gui"
|
5
|
+
require "haml"
|
6
|
+
|
7
|
+
HAML =<<EOF
|
8
|
+
%h1 Hello from Haml
|
9
|
+
%form{ :action => "/action", :method => "post" }
|
10
|
+
Name:
|
11
|
+
%input{ :type => "text", :name => "text", :size => 30 }
|
12
|
+
%br/
|
13
|
+
%input{ :type => "submit" }
|
14
|
+
%ul
|
15
|
+
- (1..3).each do |i|
|
16
|
+
- href = "/link/" + i.to_s
|
17
|
+
%li
|
18
|
+
%a{ :href => href }
|
19
|
+
= (i == 1) ? "Click me!" : "No, click me!"
|
20
|
+
%br/
|
21
|
+
EOF
|
22
|
+
|
23
|
+
get "/" do
|
24
|
+
haml HAML
|
25
|
+
end
|
26
|
+
|
27
|
+
post "/action" do
|
28
|
+
params.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
get "/link/:id" do
|
32
|
+
"You clicked link #{params[:id]}"
|
33
|
+
end
|
data/lib/browser_gui/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browser_gui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Use with Sinatra to create command-line scripts that open the browser
|
15
15
|
as a GUI.
|
@@ -27,7 +27,9 @@ files:
|
|
27
27
|
- browser_gui.gemspec
|
28
28
|
- examples/browser_url.rb
|
29
29
|
- examples/gui_optional.rb
|
30
|
+
- examples/simple_erector.rb
|
30
31
|
- examples/simple_form.rb
|
32
|
+
- examples/simple_haml.rb
|
31
33
|
- examples/simple_markdown.rb
|
32
34
|
- lib/browser_gui.rb
|
33
35
|
- lib/browser_gui/version.rb
|