bowline 0.5.3 → 0.5.4
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.
- data/.gitignore +1 -0
- data/README.txt +62 -62
- data/Rakefile +10 -0
- data/TODO +3 -1
- data/VERSION +1 -1
- data/assets/bowline.js +118 -3
- data/bowline.gemspec +6 -6
- data/examples/example.js +2 -15
- data/examples/tweet.rb +35 -0
- data/examples/tweets_binder.rb +6 -0
- data/examples/twitter.html +6 -8
- data/examples/users.rb +8 -14
- data/lib/bowline/binders.rb +130 -42
- data/lib/bowline/dependencies/lib/dependencies.rb +2 -1
- data/lib/bowline/dependencies/lib/ext/rubygems.rb +4 -4
- data/lib/bowline/desktop.rb +11 -2
- data/lib/bowline/desktop/app.rb +7 -3
- data/lib/bowline/desktop/bridge.rb +8 -9
- data/lib/bowline/desktop/clipboard.rb +11 -2
- data/lib/bowline/desktop/dialog.rb +19 -0
- data/lib/bowline/desktop/dock.rb +14 -3
- data/lib/bowline/desktop/host.rb +13 -4
- data/lib/bowline/desktop/js.rb +2 -2
- data/lib/bowline/desktop/misc.rb +7 -3
- data/lib/bowline/desktop/network.rb +1 -1
- data/lib/bowline/desktop/proxy.rb +28 -30
- data/lib/bowline/desktop/sound.rb +3 -2
- data/lib/bowline/desktop/window.rb +147 -21
- data/lib/bowline/desktop/window_manager.rb +53 -5
- data/lib/bowline/desktop/window_methods.rb +2 -2
- data/lib/bowline/ext/object.rb +1 -1
- data/lib/bowline/generators.rb +1 -1
- data/lib/bowline/generators/binder.rb +1 -1
- data/lib/bowline/helpers.rb +1 -1
- data/lib/bowline/initializer.rb +37 -4
- data/lib/bowline/library.rb +11 -0
- data/lib/bowline/local_model.rb +45 -19
- data/lib/bowline/logging.rb +1 -1
- data/lib/bowline/platform.rb +8 -6
- data/lib/bowline/tasks/app.rake +4 -3
- data/lib/bowline/version.rb +1 -1
- data/lib/bowline/watcher.rb +18 -8
- data/templates/binder.rb +1 -1
- data/vendor/pathname.rb +0 -4
- metadata +6 -6
- data/examples/account.rb +0 -31
- data/examples/tweets.rb +0 -28
data/.gitignore
CHANGED
data/README.txt
CHANGED
@@ -4,7 +4,7 @@ http://github.com/maccman/bowline
|
|
4
4
|
|
5
5
|
= DESCRIPTION
|
6
6
|
|
7
|
-
Ruby desktop application framework
|
7
|
+
Ruby, HTML and JS desktop application framework.
|
8
8
|
|
9
9
|
= FEATURES
|
10
10
|
|
@@ -12,7 +12,7 @@ Ruby desktop application framework
|
|
12
12
|
* Uses Webkit
|
13
13
|
* View in HTML/JavaScript
|
14
14
|
* Binding between HTML & Ruby
|
15
|
-
* Cross platform (only osx atm)
|
15
|
+
* Cross platform (only osx atm ;)
|
16
16
|
|
17
17
|
= INTRODUCTION
|
18
18
|
|
@@ -39,13 +39,22 @@ info@eribium.org
|
|
39
39
|
http://eribium.org
|
40
40
|
http://twitter.com/maccman
|
41
41
|
|
42
|
-
=
|
42
|
+
= COMMUNITY
|
43
|
+
|
44
|
+
http://groups.google.com/group/bowline-dev
|
45
|
+
|
46
|
+
= REQUIREMENTS
|
43
47
|
|
44
|
-
|
45
|
-
|
48
|
+
- Mac OSX (both Leopard & Snow Leopard)
|
49
|
+
- Ruby 1.9 (Ruby 1.8.6 is supported, but we recommend you use 1.9 since that's the version your application will be using when it's run).
|
50
|
+
- Bowline gem
|
51
|
+
|
52
|
+
The other required libraries, such as bowline-desktop, are downloaded later by Bowline - you don't need to worry about these.
|
53
|
+
|
54
|
+
= INSTALLATION
|
46
55
|
|
47
56
|
Install the gem:
|
48
|
-
>> sudo gem install
|
57
|
+
>> sudo gem install bowline
|
49
58
|
|
50
59
|
= USAGE
|
51
60
|
|
@@ -56,11 +65,12 @@ or browse the completed version here:
|
|
56
65
|
= GENERATING
|
57
66
|
|
58
67
|
Using the bowline-gen binary (installed with Bowline) you can generate the following things:
|
59
|
-
app
|
60
|
-
binder
|
61
|
-
helper
|
62
|
-
migration
|
63
|
-
model
|
68
|
+
app
|
69
|
+
binder
|
70
|
+
helper
|
71
|
+
migration
|
72
|
+
model
|
73
|
+
window
|
64
74
|
|
65
75
|
Run 'bowline-gen --help' for more information.
|
66
76
|
|
@@ -72,30 +82,24 @@ App console:
|
|
72
82
|
Run application:
|
73
83
|
>> script/run
|
74
84
|
|
75
|
-
|
76
|
-
|
77
|
-
Binders are the core of Bowline, they're classes that you can bind HTML to.
|
78
|
-
Binders contain data. If you modify the binder's data the HTML automatically updates.
|
79
|
-
It's a one way relationship though.
|
85
|
+
Build package for distribution:
|
86
|
+
>> script/build
|
80
87
|
|
81
|
-
|
88
|
+
= BINDERS
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
And it goes without saying that collection binders are for an array of data.
|
90
|
+
Binders are the core of Bowline. They're a model abstraction for the view which you can bind HTML to.
|
91
|
+
Binders in turn are associated with a Model. When the model gets changed, the binder makes sure that the HTML stays in sync.
|
86
92
|
|
87
|
-
You can create a
|
88
|
-
>> bowline-gen binder users
|
93
|
+
You can create a binder like this:
|
94
|
+
>> bowline-gen binder users
|
89
95
|
|
90
96
|
Which will generate code a bit like this:
|
91
|
-
|
92
|
-
class Users < Bowline::Collection
|
93
|
-
end
|
97
|
+
class UsersBinder < Bowline::Binders::Base
|
94
98
|
end
|
95
99
|
|
96
100
|
Now, in the view you can bind HTML to this collection, by
|
97
101
|
using the following javascript:
|
98
|
-
$('#users').
|
102
|
+
$('#users').bindto('users');
|
99
103
|
|
100
104
|
You should probably become familiar with Chain.js (which bowline uses for binding): http://wiki.github.com/raid-ox/chain.js/
|
101
105
|
|
@@ -111,7 +115,7 @@ Suffice to say, the HTML looks a bit like this:
|
|
111
115
|
Now, were you to have a user object, you could do something like
|
112
116
|
this to update the HTML.
|
113
117
|
|
114
|
-
|
118
|
+
# TODO
|
115
119
|
|
116
120
|
= METHODS IN BINDERS
|
117
121
|
|
@@ -124,7 +128,7 @@ $('#users').invoke('admins')
|
|
124
128
|
It's the same syntax for invoking instance methods, just called
|
125
129
|
on one of the individual users:
|
126
130
|
|
127
|
-
$('#users div:first').invoke('
|
131
|
+
$('#users div:first').invoke('instance_meth', 'arg1')
|
128
132
|
|
129
133
|
= HELPERS
|
130
134
|
|
@@ -136,55 +140,53 @@ $.bowline.helper('name', 'arg1', ['arg2'])
|
|
136
140
|
|
137
141
|
= MODELS
|
138
142
|
|
139
|
-
Bowline supports ActiveRecord and the Sqlite3 database.
|
140
|
-
The packaging for databases is still in development though.
|
143
|
+
Bowline supports ActiveRecord and the Sqlite3 database.
|
144
|
+
The packaging for distributing databases is still in development though.
|
145
|
+
Bowline also has a LocalModel class for models held in memory.
|
141
146
|
|
142
|
-
=
|
147
|
+
= WINDOWS
|
143
148
|
|
144
|
-
|
145
|
-
|
146
|
-
|
149
|
+
Bowline lets you control your application's windows. The API is under Bowline::Desktop::Window.
|
150
|
+
There's a generator for creating new windows; they live under app/windows.
|
151
|
+
Every window lives under the MainWindow class. If the MainWindow is closed, the app exits.
|
147
152
|
|
148
|
-
=
|
153
|
+
= BOWLINE-DESKTOP
|
149
154
|
|
150
|
-
Bowline is
|
151
|
-
You can use any of the Titanium api methods in Ruby and JavaScript, like this:
|
152
|
-
Titanium.UI.currentWindow.close
|
155
|
+
Bowline-desktop is an abstraction upon wxWidgets for Bowline. It gives your app access to numerous APIs & system features, such as the Clipboard, Dock, Speakers and Windows.
|
153
156
|
|
154
|
-
|
155
|
-
|
157
|
+
The binary is built in C++, and statically linked with Ruby 1.9 and wxWidgets so it has no local dependencies. Compiling it isn't a requirement to use Bowline, but if you want to extend or contribute to Bowline-desktop, you can find it here:
|
158
|
+
http://github.com/maccman/bowline-desktop
|
156
159
|
|
157
|
-
=
|
160
|
+
= DISTRIBUTING
|
158
161
|
|
159
|
-
Once your app is
|
160
|
-
to make sure all the gems required (including Bowline) have been vendorised:
|
162
|
+
Once your app is ready for a release, you should run the following command to make sure all the gems required have been vendorised:
|
161
163
|
rake gems:sync
|
162
164
|
|
163
165
|
Then, run:
|
164
|
-
|
166
|
+
./script/build
|
165
167
|
|
166
|
-
You can only build distributions for your local platform, but
|
167
|
-
|
168
|
+
You can only build distributions for your local platform at the moment, but we're planning to extend this.
|
169
|
+
|
170
|
+
= THEMES
|
171
|
+
|
172
|
+
The Cappuccino Aristo theme has been specially customized for Bowline, you can see
|
173
|
+
examples of it in the Twitter client, and find it here:
|
174
|
+
http://github.com/maccman/aristo
|
168
175
|
|
169
176
|
= EXAMPLES
|
170
177
|
|
171
178
|
Usage for a collection (of users):
|
172
179
|
|
173
|
-
|
174
|
-
|
180
|
+
class Users < Bowline::Binders::Base
|
181
|
+
bind User
|
175
182
|
# These are class methods
|
176
183
|
# i.e. methods that appear on
|
177
184
|
# users, rather an user
|
178
185
|
class << self
|
179
|
-
def index
|
180
|
-
# self.items is a magic variable -
|
181
|
-
# it'll update the html binders
|
182
|
-
self.items = User.all
|
183
|
-
end
|
184
|
-
|
185
186
|
def admins
|
186
187
|
# This just replaces all the listed
|
187
188
|
# users with just admins
|
189
|
+
# TODO
|
188
190
|
self.items = User.admins.all
|
189
191
|
end
|
190
192
|
end
|
@@ -201,7 +203,7 @@ Usage for a collection (of users):
|
|
201
203
|
# an ActiveRecord instance
|
202
204
|
#
|
203
205
|
# self.page gives you access to the dom, e.g:
|
204
|
-
# self.page.alert('hello world')
|
206
|
+
# self.page.alert('hello world').call
|
205
207
|
|
206
208
|
def destroy
|
207
209
|
self.item.destroy
|
@@ -220,7 +222,7 @@ Usage for a collection (of users):
|
|
220
222
|
jQuery(function($){
|
221
223
|
$.bowline.ready(function(){
|
222
224
|
// Bind the element users to UserBinder
|
223
|
-
var users = $('#users').
|
225
|
+
var users = $('#users').bindto('users', function(){
|
224
226
|
var self = $(this);
|
225
227
|
self.find('.destroy').click(function(){
|
226
228
|
self.invoke('destroy');
|
@@ -257,19 +259,17 @@ Usage for a collection (of users):
|
|
257
259
|
|
258
260
|
= Building a basic Twitter client
|
259
261
|
|
260
|
-
Install the Titanium SDK:
|
261
|
-
http://www.appcelerator.com/products/download-titanium/download/
|
262
|
-
|
263
262
|
Install the gem:
|
264
|
-
>> sudo gem install
|
263
|
+
>> sudo gem install bowline
|
265
264
|
|
266
265
|
Run the app/binder generators:
|
267
266
|
>> bowline-gen app bowline_twitter
|
268
267
|
>> cd bowline_twitter
|
269
268
|
>> bowline-gen binder tweets
|
270
269
|
|
271
|
-
Copy
|
272
|
-
|
270
|
+
Copy tweets_binder.rb from examples to app/binders/tweets_binder.rb
|
271
|
+
Copy tweet.rb from examples to app/models/tweet.rb
|
272
|
+
Add your Twitter credentials to config/application.yml - in this simple example they're not dynamic.
|
273
273
|
|
274
274
|
Copy twitter.html from examples to public/index.html
|
275
275
|
|
data/Rakefile
CHANGED
@@ -18,4 +18,14 @@ end
|
|
18
18
|
task :write_version do
|
19
19
|
require File.join(File.dirname(__FILE__), *%w[lib bowline])
|
20
20
|
File.open('VERSION', 'w') {|f| f.write Bowline::Version::STRING }
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/rdoctask'
|
24
|
+
desc "Generate documentation for Bowline."
|
25
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
26
|
+
rdoc.rdoc_dir = "rdoc"
|
27
|
+
rdoc.title = "Bowline"
|
28
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
29
|
+
rdoc.rdoc_files.include("README.txt")
|
30
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
21
31
|
end
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/assets/bowline.js
CHANGED
@@ -1,3 +1,118 @@
|
|
1
|
+
/*
|
2
|
+
Bowline JavaScript API
|
3
|
+
|
4
|
+
This library lets you call Ruby methods, and bind up elements.
|
5
|
+
It requires jQuery, Chain.js and json2:
|
6
|
+
http://jquery.com
|
7
|
+
http://github.com/raid-ox/chain.js
|
8
|
+
http://www.JSON.org/json2.js
|
9
|
+
|
10
|
+
= Functions
|
11
|
+
|
12
|
+
invoke(klass, method, *args)
|
13
|
+
Invoke a class method on a particular class. Usually
|
14
|
+
used to invoke methods on a binder. The class needs to
|
15
|
+
be exposed to JS (using the Bowline::Desktop::Bridge#js_expose).
|
16
|
+
Usage:
|
17
|
+
Bowline.invoke('MyClass', 'my_method');
|
18
|
+
|
19
|
+
instanceInvoke(klass, id, method, *args)
|
20
|
+
Invoke an instance method an a binder.
|
21
|
+
Usually called via the jQuery helper functions.
|
22
|
+
Usage:
|
23
|
+
Bowline.instanceInvoke('UsersBinder', 1, 'charge!');
|
24
|
+
|
25
|
+
windowInvoke(method, *args)
|
26
|
+
Invoke class method on this window's class.
|
27
|
+
Usage:
|
28
|
+
Bowline.windowInvoke('close');
|
29
|
+
|
30
|
+
helper(method, *args)
|
31
|
+
Invoke a method defined in any helper.
|
32
|
+
|
33
|
+
bindto(element, klass, options = {})
|
34
|
+
Bind a element to a Bowline binder.
|
35
|
+
Usually called via the jQuery helper functions.
|
36
|
+
Usage:
|
37
|
+
Bowline.bindto('#users', 'UsersBinder');
|
38
|
+
|
39
|
+
The options can either be a template hash:
|
40
|
+
{
|
41
|
+
'.name .first': {
|
42
|
+
style: 'color: blue;',
|
43
|
+
content: 'First Name: {first}'
|
44
|
+
},
|
45
|
+
'.name .last': 'Family Name: {last}',
|
46
|
+
'.address': function(data, el){
|
47
|
+
if(!data.address)
|
48
|
+
el.hide();
|
49
|
+
return data.address;
|
50
|
+
},
|
51
|
+
builder: function(){
|
52
|
+
var data = this.item();
|
53
|
+
this.find('.name').click(function(){alert(data.name)});
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
Or the options can be a builder function:
|
58
|
+
(function(){
|
59
|
+
this.bind('click', function(){
|
60
|
+
var data = this.item();
|
61
|
+
alert(data);
|
62
|
+
})
|
63
|
+
|
64
|
+
For more documentation, look at the Chain.js library:
|
65
|
+
http://wiki.github.com/raid-ox/chain.js/elementchain
|
66
|
+
|
67
|
+
= Filtering items
|
68
|
+
|
69
|
+
$('#users').items('filter', 'value');
|
70
|
+
|
71
|
+
= Sorting items
|
72
|
+
|
73
|
+
$('#users').items('sort', 'first_name');
|
74
|
+
|
75
|
+
= Update events
|
76
|
+
|
77
|
+
$('#users').update(function(){
|
78
|
+
//...
|
79
|
+
});
|
80
|
+
|
81
|
+
= JQuery functions
|
82
|
+
|
83
|
+
These are how you usually bind elements, or invoke a binders class/instance methods.
|
84
|
+
|
85
|
+
$.fn.bindto(klass, options)
|
86
|
+
Associate an an element with a Bowline binder.
|
87
|
+
Example:
|
88
|
+
$("#users").bindto('UsersBinder');
|
89
|
+
|
90
|
+
$.fn.invoke(method, *args)
|
91
|
+
Invoke a class/instance method on a Bowline binder.
|
92
|
+
|
93
|
+
If called on the bound element, in this example the #users div, then a class method
|
94
|
+
will be called on the binder.
|
95
|
+
Example:
|
96
|
+
$("#users").invoke("my_class_method", "arg1");
|
97
|
+
|
98
|
+
If called on a item inside a bound element, an instance method will be called.
|
99
|
+
Example:
|
100
|
+
$("#users").items(10).invoke("my_instance_method");
|
101
|
+
|
102
|
+
= Debugging
|
103
|
+
|
104
|
+
Turn on Bowline.trace to show debugging information:
|
105
|
+
Bowline.trace = true
|
106
|
+
|
107
|
+
= Using other libraries (e.g. Prototype)
|
108
|
+
|
109
|
+
Although this library requires jQuery, its API is not jQuery
|
110
|
+
specific. It's perfectly feasible to rewrite to use Prototype instead.
|
111
|
+
Additionally, jQuery plays nicely with other libraries using it's noConflict() method.
|
112
|
+
So you're still free to use other JavaScript libraries without fear of conflicts.
|
113
|
+
|
114
|
+
*/
|
115
|
+
|
1
116
|
var Bowline = {
|
2
117
|
msgs: [],
|
3
118
|
callbacks: {},
|
@@ -54,7 +169,7 @@ var Bowline = {
|
|
54
169
|
Bowline.invoke(args);
|
55
170
|
},
|
56
171
|
|
57
|
-
|
172
|
+
bindto: function(el, klass, options){
|
58
173
|
el = jQuery(el);
|
59
174
|
el.chain(options);
|
60
175
|
el.data('bowline', klass);
|
@@ -182,10 +297,10 @@ var Bowline = {
|
|
182
297
|
}
|
183
298
|
};
|
184
299
|
|
185
|
-
$.fn.
|
300
|
+
$.fn.bindto = function(){
|
186
301
|
var args = $.makeArray(arguments);
|
187
302
|
args.unshift(this);
|
188
|
-
Bowline.
|
303
|
+
Bowline.bindto.apply(this, args);
|
189
304
|
};
|
190
305
|
})(jQuery);
|
191
306
|
|
data/bowline.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bowline}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex MacCaw"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-22}
|
13
13
|
s.default_executable = %q{bowline-gen}
|
14
14
|
s.description = %q{Ruby/JS GUI framework}
|
15
15
|
s.email = %q{alex@leadthinking.com}
|
@@ -35,9 +35,9 @@ Gem::Specification.new do |s|
|
|
35
35
|
"assets/osx/makeicns",
|
36
36
|
"bin/bowline-gen",
|
37
37
|
"bowline.gemspec",
|
38
|
-
"examples/account.rb",
|
39
38
|
"examples/example.js",
|
40
|
-
"examples/
|
39
|
+
"examples/tweet.rb",
|
40
|
+
"examples/tweets_binder.rb",
|
41
41
|
"examples/twitter.html",
|
42
42
|
"examples/users.rb",
|
43
43
|
"lib/bowline.rb",
|
@@ -125,8 +125,8 @@ Gem::Specification.new do |s|
|
|
125
125
|
s.rubygems_version = %q{1.3.5}
|
126
126
|
s.summary = %q{Bowline GUI framework}
|
127
127
|
s.test_files = [
|
128
|
-
"examples/
|
129
|
-
"examples/
|
128
|
+
"examples/tweet.rb",
|
129
|
+
"examples/tweets_binder.rb",
|
130
130
|
"examples/users.rb"
|
131
131
|
]
|
132
132
|
|
data/examples/example.js
CHANGED
@@ -1,11 +1,4 @@
|
|
1
|
-
$('#users').
|
2
|
-
|
3
|
-
var user = $('#users').items(10);
|
4
|
-
user.update({name: 'Alex'}); // will automatiinvokey
|
5
|
-
user.item().errors //=> []
|
6
|
-
|
7
|
-
// Deletes item from DOM too
|
8
|
-
item.destroy()
|
1
|
+
$('#users').bindto('UsersBinder');
|
9
2
|
|
10
3
|
// invoke collection method
|
11
4
|
// This will invoke UserBinder.admins and fill #users with admins
|
@@ -15,10 +8,4 @@ $('#users').invoke('admins');
|
|
15
8
|
$('#users').items(10).invoke('charge!');
|
16
9
|
|
17
10
|
// invoke charge! on every user
|
18
|
-
$('#users').items().invoke('charge!')
|
19
|
-
|
20
|
-
// // For binding over a http connection - an async invoke
|
21
|
-
// // last argument is a function
|
22
|
-
// $('#users').items(10).invoke('charge!', function(){
|
23
|
-
//
|
24
|
-
// })
|
11
|
+
$('#users').items().invoke('charge!')
|