sproutcore 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +25 -0
- data/Manifest.txt +2 -1
- data/bin/sc-server +4 -1
- data/frameworks/sproutcore/HISTORY +75 -3
- data/frameworks/sproutcore/{Core.js → core.js} +2 -3
- data/frameworks/sproutcore/drag/drag.js +1 -1
- data/frameworks/sproutcore/english.lproj/buttons.css +3 -2
- data/frameworks/sproutcore/english.lproj/detect-browser +44 -0
- data/frameworks/sproutcore/foundation/animator.js +40 -40
- data/frameworks/sproutcore/foundation/application.js +1 -1
- data/frameworks/sproutcore/foundation/benchmark.js +2 -2
- data/frameworks/sproutcore/foundation/error.js +61 -16
- data/frameworks/sproutcore/foundation/input_manager.js +1 -1
- data/frameworks/sproutcore/foundation/mock.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +2 -2
- data/frameworks/sproutcore/foundation/object.js +1 -1
- data/frameworks/sproutcore/foundation/path_module.js +1 -1
- data/frameworks/sproutcore/foundation/responder.js +1 -1
- data/frameworks/sproutcore/foundation/run_loop.js +1 -1
- data/frameworks/sproutcore/foundation/server.js +1 -1
- data/frameworks/sproutcore/foundation/string.js +32 -3
- data/frameworks/sproutcore/foundation/timer.js +1 -1
- data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
- data/frameworks/sproutcore/globals/window.js +1 -1
- data/frameworks/sproutcore/lib/core_views.rb +1 -1
- data/frameworks/sproutcore/lib/index.rhtml +7 -1
- data/frameworks/sproutcore/mixins/observable.js +115 -7
- data/frameworks/sproutcore/models/record.js +1 -1
- data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +101 -99
- data/frameworks/sproutcore/views/collection/grid.js +1 -1
- data/frameworks/sproutcore/views/collection/table.js +1 -1
- data/frameworks/sproutcore/views/list_item.js +1 -1
- data/frameworks/sproutcore/views/progress.js +21 -11
- data/frameworks/sproutcore/views/segmented.js +40 -15
- data/lib/sproutcore/bundle.rb +3 -3
- data/lib/sproutcore/bundle_manifest.rb +7 -7
- data/lib/sproutcore/jsdoc.rb +4 -2
- data/lib/sproutcore/library.rb +112 -43
- data/lib/sproutcore/merb/bundle_controller.rb +77 -4
- data/lib/sproutcore/version.rb +1 -1
- data/sc_generators/client/templates/core.js +1 -4
- metadata +4 -3
data/lib/sproutcore/jsdoc.rb
CHANGED
@@ -33,9 +33,11 @@ module SproutCore
|
|
33
33
|
runjs_path = File.join(jsdoc_root, 'app', 'run.js')
|
34
34
|
template_path = File.join(jsdoc_root, 'templates', 'sproutcore')
|
35
35
|
|
36
|
-
puts
|
36
|
+
puts %(GENERATING: java -Djsdoc.dir="#{jsdoc_root}" -jar "#{jar_path}" "#{runjs_path}" -t="#{template_path}" -d="#{build_path}" "#{ files * '" "' }" -v)
|
37
37
|
|
38
|
-
|
38
|
+
# wrap files in quotes...
|
39
|
+
|
40
|
+
SC.logger.debug `java -Djsdoc.dir="#{jsdoc_root}" -jar "#{jar_path}" "#{runjs_path}" -t="#{template_path}" -d="#{build_path}" "#{ files * '" "' }" -v`
|
39
41
|
|
40
42
|
end
|
41
43
|
end
|
data/lib/sproutcore/library.rb
CHANGED
@@ -64,6 +64,9 @@ module SproutCore
|
|
64
64
|
# The parent library, used for load order dependency
|
65
65
|
attr_accessor :next_library
|
66
66
|
|
67
|
+
# Any proxy info stored for development
|
68
|
+
attr_accessor :proxies
|
69
|
+
|
67
70
|
# The client directories found in this library. This usually maps directly to a
|
68
71
|
# client name but it may not if you have set up some other options.
|
69
72
|
def client_directories
|
@@ -161,7 +164,6 @@ module SproutCore
|
|
161
164
|
# way to get all of your code onto disk in a deployable state
|
162
165
|
def build(*languages)
|
163
166
|
(client_bundles + framework_bundles).each do |bundle|
|
164
|
-
puts "building: #{bundle.bundle_name}"
|
165
167
|
bundle.build(*languages)
|
166
168
|
end
|
167
169
|
end
|
@@ -170,57 +172,75 @@ module SproutCore
|
|
170
172
|
# This will go up the chain of parent libraries, retrieving and merging
|
171
173
|
# any known environment settings. The returned options are suitable for
|
172
174
|
# passing to the ClientBuilder for registration.
|
175
|
+
#
|
176
|
+
# The process here is:
|
177
|
+
#
|
178
|
+
# 1. merge together the :all configs.
|
179
|
+
# 2. Find the deepest config for the bundle specifically and merge that.
|
180
|
+
#
|
173
181
|
def environment_for(bundle_name)
|
174
182
|
|
175
|
-
|
176
|
-
|
177
|
-
|
183
|
+
# Get the bundle location info. This will return nil if the bundle
|
184
|
+
# is not found anywhere. In that case, return nil to indicate bundle
|
185
|
+
# does not exist.
|
186
|
+
bundle_location = bundle_location_for(bundle_name)
|
187
|
+
return nil if bundle_location.nil?
|
188
|
+
|
189
|
+
# A bundle was found, so collect the base environment and any bundle-
|
190
|
+
# specific configs provided by the developer.
|
191
|
+
base_env = base_environment
|
192
|
+
config_env = bundle_environment_for(bundle_name)
|
193
|
+
|
194
|
+
# Now we have the relevant pieces. Join them together. Start with the
|
195
|
+
# base environment and fill in some useful defaults...
|
196
|
+
ret = base_env.dup.merge(config_env).merge(bundle_location)
|
197
|
+
ret[:required] = [:sproutcore] if ret[:required].nil?
|
178
198
|
|
179
|
-
#
|
180
|
-
|
199
|
+
# Add local library so we get proper deployment paths, etc.
|
200
|
+
ret[:library] = self
|
201
|
+
|
202
|
+
# Done! return...
|
203
|
+
return ret
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns a re-written proxy URL for the passed URL or nil if no proxy
|
207
|
+
# is registered. The URL should NOT include a hostname.
|
208
|
+
#
|
209
|
+
# === Returns
|
210
|
+
# the converted proxy_url and the proxy options or nil if no match
|
211
|
+
#
|
212
|
+
def proxy_url_for(url)
|
213
|
+
|
214
|
+
# look for a matching proxy.
|
215
|
+
matched = nil
|
216
|
+
matched_url = nil
|
217
|
+
|
218
|
+
@proxies.each do |proxy_url, opts|
|
219
|
+
matched_url = proxy_url
|
220
|
+
matched = opts if url =~ /^#{proxy_url}/
|
221
|
+
break if matched
|
222
|
+
end
|
223
|
+
|
224
|
+
# If matched, rewrite the URL
|
225
|
+
if matched
|
181
226
|
|
182
|
-
#
|
183
|
-
|
227
|
+
# rewrite the matched_url if needed...
|
228
|
+
if matched[:url]
|
229
|
+
url = url.gsub(/^#{matched_url}/, matched[:url])
|
230
|
+
end
|
184
231
|
|
185
|
-
#
|
186
|
-
|
187
|
-
ret[:bundle_name] = bundle_name.to_sym
|
188
|
-
ret[:bundle_type] = is_local_framework ? :framework : :client
|
189
|
-
ret[:requires] = [:prototype, :sproutcore] if ret[:requires].nil?
|
232
|
+
# prepend the hostname and protocol
|
233
|
+
url = [(matched[:protocol] || 'http'), '://', matched[:to], url].join('')
|
190
234
|
|
191
|
-
|
192
|
-
ret[:source_root] = File.join(root_path, ret[:bundle_type].to_s.pluralize, bundle_name.to_s)
|
193
|
-
|
194
|
-
# CASE 2: Otherwise, if we have a next library, see if the next library has something
|
235
|
+
# otherwise nil
|
195
236
|
else
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
# Final fixup
|
200
|
-
unless ret.nil?
|
201
|
-
# Always url_prefix & index_prefix are always used.
|
202
|
-
all = environment[:all] || {}
|
203
|
-
[:url_prefix, :all_prefix, :preferred_language].each do |key|
|
204
|
-
ret[key] = all[key] if all.include?(key)
|
205
|
-
end
|
206
|
-
|
207
|
-
# Either way, if we have local settings for this specific client, they
|
208
|
-
# override whatever we cooked up just now.
|
209
|
-
local_settings = environment[bundle_name.to_sym]
|
210
|
-
ret = ret.merge(local_settings) unless local_settings.nil?
|
211
|
-
|
212
|
-
# Always replace the library with self so that we get the correct root location for
|
213
|
-
# public paths, etc.
|
214
|
-
ret[:library] = self
|
237
|
+
url = nil
|
215
238
|
end
|
216
239
|
|
240
|
+
return [url, matched]
|
217
241
|
|
218
|
-
# CASE 3: Next library doesn't know about this client. Neither do we. Even if the
|
219
|
-
# user has provided some environmental options, there is no source content, so just
|
220
|
-
# return nil
|
221
|
-
return ret
|
222
242
|
end
|
223
|
-
|
243
|
+
|
224
244
|
protected
|
225
245
|
|
226
246
|
# Load the library at the specified path. Loads the sc-config.rb if it
|
@@ -235,6 +255,7 @@ module SproutCore
|
|
235
255
|
@root_path = rp
|
236
256
|
@next_library = next_lib
|
237
257
|
@load_opts = opts
|
258
|
+
@proxies = {}
|
238
259
|
load_environment!(opts)
|
239
260
|
end
|
240
261
|
|
@@ -269,9 +290,57 @@ module SproutCore
|
|
269
290
|
env.merge!(opts) unless opts.nil?
|
270
291
|
yield(env) if block_given?
|
271
292
|
end
|
293
|
+
|
294
|
+
# Adds a proxy to the local library. This does NOT inherit from parent
|
295
|
+
# libraries.
|
296
|
+
#
|
297
|
+
# ==== Params
|
298
|
+
# url: the root URL to match
|
299
|
+
# opts: options.
|
300
|
+
#
|
301
|
+
# ==== Options
|
302
|
+
# :to: the new hostname
|
303
|
+
# :url: an optional rewriting of the URL path as well.
|
304
|
+
#
|
305
|
+
def proxy(url, opts={})
|
306
|
+
@proxies[url] = opts
|
307
|
+
end
|
308
|
+
|
309
|
+
# ==== Returns
|
310
|
+
# the first :all environment config...
|
311
|
+
def base_environment
|
312
|
+
environment[:all] || (next_library.nil? ? {} : next_library.base_environment)
|
313
|
+
end
|
314
|
+
|
315
|
+
# ==== Returns
|
316
|
+
# the first config found for the specified bundle
|
317
|
+
def bundle_environment_for(bundle_name)
|
318
|
+
bundle_name = bundle_name.to_sym
|
319
|
+
return environment[bundle_name] || (next_library.nil? ? {} : next_library.bundle_environment_for(bundle_name))
|
320
|
+
end
|
321
|
+
|
322
|
+
# ==== Returns
|
323
|
+
# path info for the bundle. Used by bundle object.
|
324
|
+
def bundle_location_for(bundle_name)
|
325
|
+
bundle_name = bundle_name.to_sym
|
326
|
+
is_local_client = client_directories.include?(bundle_name.to_s)
|
327
|
+
is_local_framework = framework_directories.include?(bundle_name.to_s)
|
272
328
|
|
329
|
+
ret = nil
|
330
|
+
if is_local_client || is_local_framework
|
331
|
+
bundle_type = is_local_framework ? :framework : :client
|
332
|
+
ret = {
|
333
|
+
:bundle_name => bundle_name,
|
334
|
+
:bundle_type => bundle_type,
|
335
|
+
:source_root => File.join(root_path, bundle_type.to_s.pluralize, bundle_name.to_s)
|
336
|
+
}
|
337
|
+
else
|
338
|
+
ret = next_library.nil? ? nil : next_library.bundle_location_for(bundle_name)
|
339
|
+
end
|
340
|
+
|
341
|
+
return ret
|
342
|
+
end
|
343
|
+
|
273
344
|
end
|
274
345
|
|
275
346
|
end
|
276
|
-
|
277
|
-
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'sproutcore/jsdoc'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
2
4
|
|
3
5
|
module SproutCore
|
4
6
|
module Merb
|
@@ -32,7 +34,17 @@ module SproutCore
|
|
32
34
|
end
|
33
35
|
|
34
36
|
# Make sure we can service this with a bundle
|
35
|
-
|
37
|
+
# If no bundle is found, try to proxy...
|
38
|
+
if current_bundle.nil?
|
39
|
+
# if proxy url, return proxy...
|
40
|
+
url = request.path
|
41
|
+
proxy_url, proxy_opts = library.proxy_url_for(url)
|
42
|
+
if proxy_url
|
43
|
+
return handle_proxy(url, proxy_url, proxy_opts)
|
44
|
+
else
|
45
|
+
raise(NotFound, "No SproutCore Bundle registered at this location.")
|
46
|
+
end
|
47
|
+
end
|
36
48
|
|
37
49
|
# Check for a few special urls that need to be rewritten
|
38
50
|
url = request.path
|
@@ -71,7 +83,6 @@ module SproutCore
|
|
71
83
|
# Get the entry for the resource.
|
72
84
|
entry = current_bundle.entry_for_url(url, :hidden => :include)
|
73
85
|
raise(NotFound, "No matching entry in #{current_bundle.bundle_name} for #{url}") if entry.nil?
|
74
|
-
|
75
86
|
|
76
87
|
build_path = entry.build_path
|
77
88
|
|
@@ -79,8 +90,17 @@ module SproutCore
|
|
79
90
|
# been built, this will not do much. If this the resource is an
|
80
91
|
# index.html file, force the build.
|
81
92
|
is_index = /\/index\.html$/ =~ url
|
82
|
-
|
83
|
-
|
93
|
+
|
94
|
+
# If we need to serve the source directly, then just set the
|
95
|
+
# build path to the source_path.
|
96
|
+
if entry.use_source_directly?
|
97
|
+
build_path = entry.source_path
|
98
|
+
|
99
|
+
# Otherwise, run the build command on the entry to make sure the
|
100
|
+
# file is up to date.
|
101
|
+
else
|
102
|
+
current_bundle.build_entry(entry, :force => is_index, :hidden => :include)
|
103
|
+
end
|
84
104
|
|
85
105
|
# Move to final build path if necessary
|
86
106
|
if (build_path != entry.build_path) && File.exists?(entry.build_path)
|
@@ -106,6 +126,59 @@ module SproutCore
|
|
106
126
|
return ret
|
107
127
|
end
|
108
128
|
|
129
|
+
# Proxy the request and return the result...
|
130
|
+
def handle_proxy(url, proxy_url, opts ={})
|
131
|
+
|
132
|
+
# collect the method
|
133
|
+
http_method = request.method
|
134
|
+
|
135
|
+
# capture the origin host for cookies. strip away any port.
|
136
|
+
origin_host = request.host.gsub(/:[0-9]+$/,'')
|
137
|
+
|
138
|
+
# collect the headers...
|
139
|
+
headers = {}
|
140
|
+
request.env.each do |key, value|
|
141
|
+
next unless key =~ /^HTTP_/
|
142
|
+
key = key.gsub(/^HTTP_/,'').titleize.gsub(' ','-')
|
143
|
+
headers[key] = value
|
144
|
+
end
|
145
|
+
|
146
|
+
uri = URI.parse(proxy_url)
|
147
|
+
http_host = uri.host
|
148
|
+
http_port = uri.port
|
149
|
+
http_path = [uri.path, uri.query].compact.join('?')
|
150
|
+
http_path = '/' if http_path.nil? || http_path.size <= 0
|
151
|
+
|
152
|
+
# now make the request...
|
153
|
+
response = nil
|
154
|
+
::Net::HTTP.start(http_host, http_port) do |http|
|
155
|
+
response = http.send(http_method, http_path, headers)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Now set the status, headers, and body.
|
159
|
+
@status = response.code
|
160
|
+
|
161
|
+
# Transfer response headers into reponse
|
162
|
+
ignore = ['transfer-encoding', 'keep-alive', 'connection']
|
163
|
+
response.each do | key, value |
|
164
|
+
next if ignore.include?(key.downcase)
|
165
|
+
|
166
|
+
# If this is a cookie, strip out the domain. This technically may
|
167
|
+
# break certain scenarios where services try to set cross-domain
|
168
|
+
# cookies, but those services should not be doing that anyway...
|
169
|
+
if key.downcase == 'set-cookie'
|
170
|
+
value.gsub!(/domain=[^\;]+\;? ?/,'')
|
171
|
+
end
|
172
|
+
|
173
|
+
# Prep key and set header.
|
174
|
+
key = key.split('-').map { |x| x.downcase.capitalize }.join('-')
|
175
|
+
@headers[key] = value
|
176
|
+
end
|
177
|
+
|
178
|
+
# Transfer response body
|
179
|
+
return response.body
|
180
|
+
end
|
181
|
+
|
109
182
|
# Returns JSON containing all of the tests
|
110
183
|
def handle_test(url)
|
111
184
|
test_entries = current_bundle.entries_for(:test, :hidden => :include)
|
data/lib/sproutcore/version.rb
CHANGED
@@ -11,9 +11,6 @@
|
|
11
11
|
// When you are in development mode, this array will be populated with
|
12
12
|
// any fixtures you create for testing and loaded automatically in your
|
13
13
|
// main method. When in production, this will be an empty array.
|
14
|
-
FIXTURES: []
|
15
|
-
|
16
|
-
// Any keys in this array will be instantiated automatically from main.
|
17
|
-
controllers: []
|
14
|
+
FIXTURES: []
|
18
15
|
|
19
16
|
}) ;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sproutcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Jolley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -133,7 +133,7 @@ files:
|
|
133
133
|
- frameworks/sproutcore/controllers/collection.js
|
134
134
|
- frameworks/sproutcore/controllers/controller.js
|
135
135
|
- frameworks/sproutcore/controllers/object.js
|
136
|
-
- frameworks/sproutcore/
|
136
|
+
- frameworks/sproutcore/core.js
|
137
137
|
- frameworks/sproutcore/drag/drag.js
|
138
138
|
- frameworks/sproutcore/drag/drag_data_source.js
|
139
139
|
- frameworks/sproutcore/drag/drag_source.js
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- frameworks/sproutcore/english.lproj/blank.gif
|
142
142
|
- frameworks/sproutcore/english.lproj/buttons.css
|
143
143
|
- frameworks/sproutcore/english.lproj/core.css
|
144
|
+
- frameworks/sproutcore/english.lproj/detect-browser
|
144
145
|
- frameworks/sproutcore/english.lproj/icons.css
|
145
146
|
- frameworks/sproutcore/english.lproj/images/indicator.gif
|
146
147
|
- frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png
|