sproutcore 0.9.11 → 0.9.12
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/History.txt +98 -73
- data/Manifest.txt +2 -1
- data/README.txt +1 -1
- data/Rakefile +8 -8
- data/app_generators/sproutcore/USAGE +2 -3
- data/app_generators/sproutcore/sproutcore_generator.rb +12 -12
- data/app_generators/sproutcore/templates/README +26 -23
- data/app_generators/sproutcore/templates/{sc-config.rb → sc-config} +32 -17
- data/bin/sc-build +17 -17
- data/bin/sc-server +1 -1
- data/bin/sproutcore +3 -3
- data/clients/sc_test_runner/english.lproj/no_tests.rhtml +0 -1
- data/config/hoe.rb +9 -9
- data/config/requirements.rb +1 -1
- data/frameworks/sproutcore/HISTORY +14 -0
- data/frameworks/sproutcore/core.js +1 -1
- data/frameworks/sproutcore/english.lproj/theme.css +1 -0
- data/frameworks/sproutcore/foundation/binding.js +2 -2
- data/frameworks/sproutcore/foundation/timer.js +55 -22
- data/frameworks/sproutcore/lib/index.rhtml +2 -3
- data/frameworks/sproutcore/models/record.js +204 -63
- data/frameworks/sproutcore/tests/models/model.rhtml +360 -0
- data/frameworks/sproutcore/views/button/button.js +22 -1
- data/frameworks/sproutcore/views/collection/collection.js +6 -2
- data/frameworks/sproutcore/views/collection/list.js +1 -0
- data/frameworks/sproutcore/views/collection/source_list.js +1 -0
- data/frameworks/sproutcore/views/field/text_field.js +11 -2
- data/frameworks/sproutcore/views/inline_text_field.js +3 -2
- data/frameworks/sproutcore/views/menu_item.js +1 -0
- data/frameworks/sproutcore/views/pagination.js +1 -0
- data/frameworks/sproutcore/views/view.js +4 -1
- data/lib/sproutcore/build_tools/html_builder.rb +36 -36
- data/lib/sproutcore/build_tools/resource_builder.rb +55 -54
- data/lib/sproutcore/build_tools.rb +12 -12
- data/lib/sproutcore/bundle.rb +162 -164
- data/lib/sproutcore/bundle_manifest.rb +154 -107
- data/lib/sproutcore/generator_helper.rb +23 -23
- data/lib/sproutcore/helpers/capture_helper.rb +10 -10
- data/lib/sproutcore/helpers/static_helper.rb +39 -26
- data/lib/sproutcore/helpers/tag_helper.rb +10 -10
- data/lib/sproutcore/helpers/text_helper.rb +36 -36
- data/lib/sproutcore/helpers.rb +1 -1
- data/lib/sproutcore/jsdoc.rb +10 -10
- data/lib/sproutcore/jsmin.rb +14 -14
- data/lib/sproutcore/library.rb +135 -87
- data/lib/sproutcore/merb/bundle_controller.rb +77 -54
- data/lib/sproutcore/merb/router.rb +19 -12
- data/lib/sproutcore/merb.rb +1 -1
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore/view_helpers.rb +121 -121
- data/lib/sproutcore.rb +5 -7
- data/sc-config.rb +6 -0
- data/sc_generators/client/README +1 -1
- data/sc_generators/client/USAGE +1 -2
- data/sc_generators/client/client_generator.rb +6 -6
- data/sc_generators/client/templates/core.js +2 -2
- data/sc_generators/client/templates/english.lproj/body.css +79 -81
- data/sc_generators/client/templates/english.lproj/strings.js +1 -2
- data/sc_generators/client/templates/main.js +6 -8
- data/sc_generators/controller/USAGE +1 -2
- data/sc_generators/controller/controller_generator.rb +7 -7
- data/sc_generators/controller/templates/controller.js +3 -3
- data/sc_generators/controller/templates/test.rhtml +1 -1
- data/sc_generators/framework/README +1 -2
- data/sc_generators/framework/USAGE +2 -3
- data/sc_generators/framework/framework_generator.rb +5 -5
- data/sc_generators/framework/templates/core.js +3 -3
- data/sc_generators/framework/templates/english.lproj/strings.js +1 -2
- data/sc_generators/language/USAGE +1 -2
- data/sc_generators/language/language_generator.rb +6 -6
- data/sc_generators/language/templates/strings.js +1 -2
- data/sc_generators/model/USAGE +1 -2
- data/sc_generators/model/model_generator.rb +7 -7
- data/sc_generators/model/templates/fixture.js +26 -26
- data/sc_generators/model/templates/model.js +5 -5
- data/sc_generators/model/templates/test.rhtml +2 -2
- data/sc_generators/test/USAGE +1 -2
- data/sc_generators/test/templates/test.rhtml +2 -2
- data/sc_generators/test/test_generator.rb +6 -6
- data/sc_generators/view/USAGE +1 -2
- data/sc_generators/view/templates/test.rhtml +2 -2
- data/sc_generators/view/templates/view.js +3 -3
- data/sc_generators/view/view_generator.rb +7 -7
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/sproutcore_spec.rb +3 -3
- data/tasks/deployment.rake +4 -4
- metadata +4 -3
|
@@ -4,62 +4,75 @@
|
|
|
4
4
|
#
|
|
5
5
|
module SproutCore
|
|
6
6
|
module Helpers
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
module StaticHelper
|
|
9
9
|
|
|
10
|
-
# This method will return the HTML to link to all the stylesheets
|
|
11
|
-
# required by the named bundle. If you pass no options, the current
|
|
10
|
+
# This method will return the HTML to link to all the stylesheets
|
|
11
|
+
# required by the named bundle. If you pass no options, the current
|
|
12
12
|
# client will be used.
|
|
13
|
-
#
|
|
14
|
-
# bundle_name = the name of the bundle to render or nil to use the
|
|
15
|
-
# current :language => the language to render. defaults to current
|
|
13
|
+
#
|
|
14
|
+
# bundle_name = the name of the bundle to render or nil to use the
|
|
15
|
+
# current :language => the language to render. defaults to current
|
|
16
16
|
# language
|
|
17
17
|
#
|
|
18
18
|
def stylesheets_for_client(bundle_name = nil, opts = {})
|
|
19
19
|
|
|
20
20
|
opts[:language] ||= language
|
|
21
21
|
|
|
22
|
+
# Set the import method to use the standard <link> tag, if not set
|
|
23
|
+
include_method = opts[:include_method] ||= :link
|
|
24
|
+
|
|
22
25
|
# Get bundle
|
|
23
26
|
cur_bundle = bundle_name.nil? ? bundle : library.bundle_for(bundle_name)
|
|
24
|
-
|
|
27
|
+
|
|
25
28
|
# Convert to a list of required bundles
|
|
26
29
|
all_bundles = cur_bundle.all_required_bundles
|
|
27
|
-
|
|
30
|
+
|
|
28
31
|
# For each bundle, get the ordered list of stylsheet urls
|
|
29
32
|
urls = []
|
|
30
33
|
all_bundles.each do |b|
|
|
31
|
-
urls += b.sorted_stylesheet_entries(opts).map { |x| x.
|
|
34
|
+
urls += b.sorted_stylesheet_entries(opts).map { |x| x.cacheable_url }
|
|
32
35
|
urls += (b.stylesheet_libs || [])
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
# Convert to HTML and return
|
|
36
39
|
urls = urls.map do |url|
|
|
37
|
-
|
|
40
|
+
if include_method == :import
|
|
41
|
+
%( @import url('#{url}');)
|
|
42
|
+
else
|
|
43
|
+
%( <link href="#{url}" rel="stylesheet" type="text/css" />)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# if include style is @import, surround with style tags
|
|
48
|
+
if include_method == :import
|
|
49
|
+
%(<style type="text/css">\n#{urls * "\n"}</style>)
|
|
50
|
+
else
|
|
51
|
+
urls.join("\n")
|
|
38
52
|
end
|
|
39
|
-
urls.join("\n")
|
|
40
53
|
end
|
|
41
|
-
|
|
42
|
-
# This method will return the HTML to link to all the javascripts
|
|
43
|
-
# required by the client. If you pass no options, the current client
|
|
54
|
+
|
|
55
|
+
# This method will return the HTML to link to all the javascripts
|
|
56
|
+
# required by the client. If you pass no options, the current client
|
|
44
57
|
# will be used.
|
|
45
|
-
#
|
|
46
|
-
# client_name = the name of the client to render or nil to use the
|
|
58
|
+
#
|
|
59
|
+
# client_name = the name of the client to render or nil to use the
|
|
47
60
|
# current :language => the language to render. defaults to @language.
|
|
48
61
|
#
|
|
49
62
|
def javascripts_for_client(bundle_name = nil, opts = {})
|
|
50
63
|
|
|
51
64
|
opts[:language] ||= language
|
|
52
|
-
|
|
65
|
+
|
|
53
66
|
# Get bundle
|
|
54
67
|
cur_bundle = bundle_name.nil? ? bundle : library.bundle_for(bundle_name)
|
|
55
|
-
|
|
68
|
+
|
|
56
69
|
# Convert to a list of required bundles
|
|
57
70
|
all_bundles = cur_bundle.all_required_bundles
|
|
58
|
-
|
|
71
|
+
|
|
59
72
|
# For each bundle, get the ordered list of stylsheet urls
|
|
60
73
|
urls = []
|
|
61
74
|
all_bundles.each do |b|
|
|
62
|
-
urls += b.sorted_javascript_entries(opts).map { |x| x.
|
|
75
|
+
urls += b.sorted_javascript_entries(opts).map { |x| x.cacheable_url }
|
|
63
76
|
urls += (b.javascript_libs || [])
|
|
64
77
|
end
|
|
65
78
|
|
|
@@ -67,10 +80,10 @@ module SproutCore
|
|
|
67
80
|
urls = urls.map do |url|
|
|
68
81
|
%( <script type="text/javascript" src="#{url}"></script>)
|
|
69
82
|
end
|
|
70
|
-
|
|
83
|
+
|
|
71
84
|
# Add preferred language definition...
|
|
72
85
|
urls << %(<script type="text/javascript">String.preferredLanguage = "#{language}";</script>)
|
|
73
|
-
|
|
86
|
+
|
|
74
87
|
urls.join("\n")
|
|
75
88
|
end
|
|
76
89
|
|
|
@@ -78,16 +91,16 @@ module SproutCore
|
|
|
78
91
|
def static_url(resource_name, opts = {})
|
|
79
92
|
opts[:language] ||= language
|
|
80
93
|
entry = bundle.find_resource_entry(resource_name, opts)
|
|
81
|
-
entry.nil? ? '' : entry.
|
|
94
|
+
entry.nil? ? '' : entry.cacheable_url
|
|
82
95
|
end
|
|
83
|
-
|
|
96
|
+
|
|
84
97
|
# Localizes the passed string, using the optional passed options.
|
|
85
98
|
def loc(string, opts = {})
|
|
86
99
|
opts[:language] ||= language
|
|
87
100
|
bundle.strings_hash(opts)[string] || string
|
|
88
101
|
end
|
|
89
|
-
|
|
102
|
+
|
|
90
103
|
end
|
|
91
|
-
|
|
104
|
+
|
|
92
105
|
end
|
|
93
106
|
end
|
|
@@ -10,10 +10,10 @@ module SproutCore
|
|
|
10
10
|
module TagHelper
|
|
11
11
|
include ERB::Util
|
|
12
12
|
|
|
13
|
-
# Returns an empty HTML tag of type +name+ which by default is XHTML
|
|
14
|
-
# compliant. Setting +open+ to true will create an open tag compatible
|
|
15
|
-
# with HTML 4.0 and below. Add HTML attributes by passing an attributes
|
|
16
|
-
# hash to +options+. For attributes with no value like (disabled and
|
|
13
|
+
# Returns an empty HTML tag of type +name+ which by default is XHTML
|
|
14
|
+
# compliant. Setting +open+ to true will create an open tag compatible
|
|
15
|
+
# with HTML 4.0 and below. Add HTML attributes by passing an attributes
|
|
16
|
+
# hash to +options+. For attributes with no value like (disabled and
|
|
17
17
|
# readonly), give it a value of true in the +options+ hash. You can use
|
|
18
18
|
# symbols or strings for the attribute names.
|
|
19
19
|
#
|
|
@@ -21,15 +21,15 @@ module SproutCore
|
|
|
21
21
|
# # => <br />
|
|
22
22
|
# tag("br", nil, true)
|
|
23
23
|
# # => <br>
|
|
24
|
-
# tag("input", { :type => 'text', :disabled => true })
|
|
24
|
+
# tag("input", { :type => 'text', :disabled => true })
|
|
25
25
|
# # => <input type="text" disabled="disabled" />
|
|
26
26
|
def tag(name, options = nil, open = false)
|
|
27
27
|
"<#{name}#{tag_options(options) if options}" + (open ? ">" : " />")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# Returns an HTML block tag of type +name+ surrounding the +content+. Add
|
|
31
|
-
# HTML attributes by passing an attributes hash to +options+. For attributes
|
|
32
|
-
# with no value like (disabled and readonly), give it a value of true in
|
|
31
|
+
# HTML attributes by passing an attributes hash to +options+. For attributes
|
|
32
|
+
# with no value like (disabled and readonly), give it a value of true in
|
|
33
33
|
# the +options+ hash. You can use symbols or strings for the attribute names.
|
|
34
34
|
#
|
|
35
35
|
# content_tag(:p, "Hello world!")
|
|
@@ -82,7 +82,7 @@ module SproutCore
|
|
|
82
82
|
tag_options = options ? tag_options(options) : ""
|
|
83
83
|
"<#{name}#{tag_options}>#{content}</#{name}>"
|
|
84
84
|
end
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
def tag_options(options)
|
|
87
87
|
cleaned_options = convert_booleans(options.stringify_keys.reject {|key, value| value.nil?})
|
|
88
88
|
' ' + cleaned_options.map {|key, value| %(#{key}="#{escape_once(value)}")}.sort * ' ' unless cleaned_options.empty?
|
|
@@ -96,12 +96,12 @@ module SproutCore
|
|
|
96
96
|
def boolean_attribute(options, attribute)
|
|
97
97
|
options[attribute] ? options[attribute] = attribute : options.delete(attribute)
|
|
98
98
|
end
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
# Fix double-escaped entities, such as &amp;, &#123;, etc.
|
|
101
101
|
def fix_double_escape(escaped)
|
|
102
102
|
escaped.gsub(/&([a-z]+|(#\d+));/i) { "&#{$1};" }
|
|
103
103
|
end
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
def block_is_within_action_view?(block)
|
|
106
106
|
eval("defined? _erbout", block.binding)
|
|
107
107
|
end
|
|
@@ -5,9 +5,9 @@ require 'sproutcore/helpers/tag_helper'
|
|
|
5
5
|
|
|
6
6
|
module SproutCore
|
|
7
7
|
module Helpers #:nodoc:
|
|
8
|
-
# The TextHelper Module provides a set of methods for filtering, formatting
|
|
9
|
-
# and transforming strings that can reduce the amount of inline Ruby code in
|
|
10
|
-
# your views. These helper methods extend ActionView making them callable
|
|
8
|
+
# The TextHelper Module provides a set of methods for filtering, formatting
|
|
9
|
+
# and transforming strings that can reduce the amount of inline Ruby code in
|
|
10
|
+
# your views. These helper methods extend ActionView making them callable
|
|
11
11
|
# within your template files as shown in the following example which truncates
|
|
12
12
|
# the title of each post to 10 characters.
|
|
13
13
|
#
|
|
@@ -16,10 +16,10 @@ module SproutCore
|
|
|
16
16
|
# Title: <%= truncate(post.title, 10) %>
|
|
17
17
|
# <% end %>
|
|
18
18
|
# => Title: This is my...
|
|
19
|
-
module TextHelper
|
|
20
|
-
# The preferred method of outputting text in your views is to use the
|
|
21
|
-
# <%= "text" %> eRuby syntax. The regular _puts_ and _print_ methods
|
|
22
|
-
# do not operate as expected in an eRuby code block. If you absolutely must
|
|
19
|
+
module TextHelper
|
|
20
|
+
# The preferred method of outputting text in your views is to use the
|
|
21
|
+
# <%= "text" %> eRuby syntax. The regular _puts_ and _print_ methods
|
|
22
|
+
# do not operate as expected in an eRuby code block. If you absolutely must
|
|
23
23
|
# output text within a code block, you can use the concat method.
|
|
24
24
|
#
|
|
25
25
|
# <% concat "hello", binding %>
|
|
@@ -29,10 +29,10 @@ module SproutCore
|
|
|
29
29
|
eval('_buf', binding) << string
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
# If +text+ is longer than +length+, +text+ will be truncated to the length of
|
|
32
|
+
# If +text+ is longer than +length+, +text+ will be truncated to the length of
|
|
33
33
|
# +length+ and the last three characters will be replaced with the +truncate_string+.
|
|
34
34
|
#
|
|
35
|
-
# truncate("Once upon a time in a world far far away", 14)
|
|
35
|
+
# truncate("Once upon a time in a world far far away", 14)
|
|
36
36
|
# => Once upon a...
|
|
37
37
|
def truncate(text, length = 30, truncate_string = "...")
|
|
38
38
|
if text.nil? then return end
|
|
@@ -41,13 +41,13 @@ module SproutCore
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Highlights one or more +phrases+ everywhere in +text+ by inserting it into
|
|
44
|
-
# a +highlighter+ string. The highlighter can be specialized by passing +highlighter+
|
|
44
|
+
# a +highlighter+ string. The highlighter can be specialized by passing +highlighter+
|
|
45
45
|
# as a single-quoted string with \1 where the phrase is to be inserted.
|
|
46
46
|
#
|
|
47
|
-
# highlight('You searched for: rails', 'rails')
|
|
47
|
+
# highlight('You searched for: rails', 'rails')
|
|
48
48
|
# # => You searched for: <strong class="highlight">rails</strong>
|
|
49
49
|
#
|
|
50
|
-
# highlight('You searched for: rails', ['for', 'rails'], '<em>\1</em>')
|
|
50
|
+
# highlight('You searched for: rails', ['for', 'rails'], '<em>\1</em>')
|
|
51
51
|
# # => You searched <em>for</em>: <em>rails</em>
|
|
52
52
|
def highlight(text, phrases, highlighter = '<strong class="highlight">\1</strong>')
|
|
53
53
|
if text.blank? || phrases.blank?
|
|
@@ -58,16 +58,16 @@ module SproutCore
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
# Extracts an excerpt from +text+ that matches the first instance of +phrase+.
|
|
61
|
+
# Extracts an excerpt from +text+ that matches the first instance of +phrase+.
|
|
62
62
|
# The +radius+ expands the excerpt on each side of +phrase+ by the number of characters
|
|
63
63
|
# defined in +radius+. If the excerpt radius overflows the beginning or end of the +text+,
|
|
64
|
-
# then the +excerpt_string+ will be prepended/appended accordingly. If the +phrase+
|
|
64
|
+
# then the +excerpt_string+ will be prepended/appended accordingly. If the +phrase+
|
|
65
65
|
# isn't found, nil is returned.
|
|
66
66
|
#
|
|
67
|
-
# excerpt('This is an example', 'an', 5)
|
|
67
|
+
# excerpt('This is an example', 'an', 5)
|
|
68
68
|
# => "...s is an examp..."
|
|
69
69
|
#
|
|
70
|
-
# excerpt('This is an example', 'is', 5)
|
|
70
|
+
# excerpt('This is an example', 'is', 5)
|
|
71
71
|
# => "This is an..."
|
|
72
72
|
def excerpt(text, phrase, radius = 100, excerpt_string = "...")
|
|
73
73
|
if text.nil? || phrase.nil? then return end
|
|
@@ -87,8 +87,8 @@ module SproutCore
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Attempts to pluralize the +singular+ word unless +count+ is 1. If +plural+
|
|
90
|
-
# is supplied, it will use that when count is > 1, if the ActiveSupport Inflector
|
|
91
|
-
# is loaded, it will use the Inflector to determine the plural form, otherwise
|
|
90
|
+
# is supplied, it will use that when count is > 1, if the ActiveSupport Inflector
|
|
91
|
+
# is loaded, it will use the Inflector to determine the plural form, otherwise
|
|
92
92
|
# it will just add an 's' to the +singular+ word.
|
|
93
93
|
#
|
|
94
94
|
# pluralize(1, 'person') => 1 person
|
|
@@ -131,7 +131,7 @@ module SproutCore
|
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
# Returns the text with all the Textile codes turned into HTML tags,
|
|
134
|
+
# Returns the text with all the Textile codes turned into HTML tags,
|
|
135
135
|
# but without the bounding <p> tag that RedCloth adds.
|
|
136
136
|
# <i>This method is only available if RedCloth[http://whytheluckystiff.net/ruby/redcloth/]
|
|
137
137
|
# is available</i>.
|
|
@@ -157,12 +157,12 @@ module SproutCore
|
|
|
157
157
|
rescue LoadError
|
|
158
158
|
# We can't really help what's not there
|
|
159
159
|
end
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
# Returns +text+ transformed into HTML using simple formatting rules.
|
|
162
|
-
# Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
|
|
162
|
+
# Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
|
|
163
163
|
# paragraph and wrapped in <tt><p></tt> tags. One newline (<tt>\n</tt>) is
|
|
164
164
|
# considered as a linebreak and a <tt><br /></tt> tag is appended. This
|
|
165
|
-
# method does not remove the newlines from the +text+.
|
|
165
|
+
# method does not remove the newlines from the +text+.
|
|
166
166
|
def simple_format(text)
|
|
167
167
|
content_tag 'p', text.to_s.
|
|
168
168
|
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
|
|
@@ -170,9 +170,9 @@ module SproutCore
|
|
|
170
170
|
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
-
# Turns all urls and email addresses into clickable links. The +link+ parameter
|
|
173
|
+
# Turns all urls and email addresses into clickable links. The +link+ parameter
|
|
174
174
|
# will limit what should be linked. You can add html attributes to the links using
|
|
175
|
-
# +href_options+. Options for +link+ are <tt>:all</tt> (default),
|
|
175
|
+
# +href_options+. Options for +link+ are <tt>:all</tt> (default),
|
|
176
176
|
# <tt>:email_addresses</tt>, and <tt>:urls</tt>.
|
|
177
177
|
#
|
|
178
178
|
# auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com") =>
|
|
@@ -201,9 +201,9 @@ module SproutCore
|
|
|
201
201
|
def strip_links(text)
|
|
202
202
|
text.gsub(/<a\b.*?>(.*?)<\/a>/mi, '\1')
|
|
203
203
|
end
|
|
204
|
-
|
|
204
|
+
|
|
205
205
|
# Creates a Cycle object whose _to_s_ method cycles through elements of an
|
|
206
|
-
# array every time it is called. This can be used for example, to alternate
|
|
206
|
+
# array every time it is called. This can be used for example, to alternate
|
|
207
207
|
# classes for table rows:
|
|
208
208
|
#
|
|
209
209
|
# <% @items.each do |item| %>
|
|
@@ -212,9 +212,9 @@ module SproutCore
|
|
|
212
212
|
# </tr>
|
|
213
213
|
# <% end %>
|
|
214
214
|
#
|
|
215
|
-
# You can use named cycles to allow nesting in loops. Passing a Hash as
|
|
215
|
+
# You can use named cycles to allow nesting in loops. Passing a Hash as
|
|
216
216
|
# the last parameter with a <tt>:name</tt> key will create a named cycle.
|
|
217
|
-
# You can manually reset a cycle by calling reset_cycle and passing the
|
|
217
|
+
# You can manually reset a cycle by calling reset_cycle and passing the
|
|
218
218
|
# name of the cycle.
|
|
219
219
|
#
|
|
220
220
|
# <% @items.each do |item| %>
|
|
@@ -244,8 +244,8 @@ module SproutCore
|
|
|
244
244
|
end
|
|
245
245
|
return cycle.to_s
|
|
246
246
|
end
|
|
247
|
-
|
|
248
|
-
# Resets a cycle so that it starts from the first element the next time
|
|
247
|
+
|
|
248
|
+
# Resets a cycle so that it starts from the first element the next time
|
|
249
249
|
# it is called. Pass in +name+ to reset a named cycle.
|
|
250
250
|
def reset_cycle(name = "default")
|
|
251
251
|
cycle = get_cycle(name)
|
|
@@ -254,12 +254,12 @@ module SproutCore
|
|
|
254
254
|
|
|
255
255
|
class Cycle #:nodoc:
|
|
256
256
|
attr_reader :values
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
def initialize(first_value, *values)
|
|
259
259
|
@values = values.unshift(first_value)
|
|
260
260
|
reset
|
|
261
261
|
end
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
def reset
|
|
264
264
|
@index = 0
|
|
265
265
|
end
|
|
@@ -270,7 +270,7 @@ module SproutCore
|
|
|
270
270
|
return value
|
|
271
271
|
end
|
|
272
272
|
end
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
private
|
|
275
275
|
# The cycle helpers need to store the cycles in a place that is
|
|
276
276
|
# guaranteed to be reset every time a page is rendered, so it
|
|
@@ -279,7 +279,7 @@ module SproutCore
|
|
|
279
279
|
@_cycles = Hash.new unless defined?(@_cycles)
|
|
280
280
|
return @_cycles[name]
|
|
281
281
|
end
|
|
282
|
-
|
|
282
|
+
|
|
283
283
|
def set_cycle(name, cycle_object)
|
|
284
284
|
@_cycles = Hash.new unless defined?(@_cycles)
|
|
285
285
|
@_cycles[name] = cycle_object
|
|
@@ -288,13 +288,13 @@ module SproutCore
|
|
|
288
288
|
AUTO_LINK_RE = %r{
|
|
289
289
|
( # leading text
|
|
290
290
|
<\w+.*?>| # leading HTML tag, or
|
|
291
|
-
[^=!:'"/]| # leading punctuation, or
|
|
291
|
+
[^=!:'"/]| # leading punctuation, or
|
|
292
292
|
^ # beginning of line
|
|
293
293
|
)
|
|
294
294
|
(
|
|
295
295
|
(?:https?://)| # protocol spec, or
|
|
296
296
|
(?:www\.) # www.*
|
|
297
|
-
)
|
|
297
|
+
)
|
|
298
298
|
(
|
|
299
299
|
[-\w]+ # subdomain or domain
|
|
300
300
|
(?:\.[-\w]+)* # remaining subdomains or domain
|
data/lib/sproutcore/helpers.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Helpers are mostly borrowed from Rails 2.0.2 with some additional features specifically
|
|
2
2
|
# for building client-side JavaScript.
|
|
3
|
-
Dir.glob(File.join(File.dirname(__FILE__),'helpers','**','*.rb')).each { |x| require x }
|
|
3
|
+
Dir.glob(File.join(File.dirname(__FILE__),'helpers','**','*.rb')).each { |x| require x }
|
data/lib/sproutcore/jsdoc.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# This utility module will use jsdoc to create documentation from a SproutCore
|
|
2
2
|
# client. Note that for this to work you must have Java installed (sudder).
|
|
3
3
|
module SproutCore
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
module JSDoc
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
# Creates the documentation for the specified set of clients, replacing
|
|
8
|
-
# the contents of the output file. Requires some of the following
|
|
8
|
+
# the contents of the output file. Requires some of the following
|
|
9
9
|
# options.
|
|
10
|
-
#
|
|
10
|
+
#
|
|
11
11
|
# :bundle => A Bundle instance - or -
|
|
12
12
|
# :files => Absolute paths to input files
|
|
13
13
|
# :build_path => absolute path to the build root. Uses the bundle if not provided.
|
|
14
|
-
def self.generate(opts = {})
|
|
14
|
+
def self.generate(opts = {})
|
|
15
15
|
bundle = opts[:bundle]
|
|
16
16
|
build_path = opts[:build_path] || File.join(bundle.build_root, '-docs', 'data')
|
|
17
17
|
raise "MISSING OPTION: :bundle => bundle or :build_path => path required for JSDoc" if build_path.nil?
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
# get the list of files to build for.
|
|
20
20
|
files = opts[:files]
|
|
21
|
-
if files.nil?
|
|
21
|
+
if files.nil?
|
|
22
22
|
raise "MISSING OPTION: :bundle => bundle or :files => list of files required for JSDoc" if bundle.nil?
|
|
23
23
|
entries = bundle.entries_for(:javascript, :hidden => :include)
|
|
24
24
|
files = entries.map { |x| x.composite? ? nil : x.source_path }.compact.uniq
|
|
@@ -34,11 +34,11 @@ module SproutCore
|
|
|
34
34
|
template_path = File.join(jsdoc_root, 'templates', 'sproutcore')
|
|
35
35
|
|
|
36
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
|
-
|
|
39
|
+
|
|
40
40
|
SC.logger.debug `java -Djsdoc.dir="#{jsdoc_root}" -jar "#{jar_path}" "#{runjs_path}" -t="#{template_path}" -d="#{build_path}" "#{ files * '" "' }" -v`
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
data/lib/sproutcore/jsmin.rb
CHANGED
|
@@ -36,15 +36,15 @@ module SproutCore
|
|
|
36
36
|
|
|
37
37
|
class JSMin
|
|
38
38
|
EOF = -1
|
|
39
|
-
|
|
40
|
-
# this will minify a single line
|
|
39
|
+
|
|
40
|
+
# this will minify a single line
|
|
41
41
|
def self.run(str)
|
|
42
42
|
minifier = SproutCore::JSMin.new(str)
|
|
43
43
|
minifier.jsmin
|
|
44
44
|
minifier.stdout
|
|
45
45
|
end
|
|
46
|
-
|
|
47
|
-
def initialize(str)
|
|
46
|
+
|
|
47
|
+
def initialize(str)
|
|
48
48
|
@theA = ""
|
|
49
49
|
@theB = ""
|
|
50
50
|
@str = str || ''
|
|
@@ -55,29 +55,29 @@ module SproutCore
|
|
|
55
55
|
def stdin_getc
|
|
56
56
|
ret = @str.nil? || (@loc >= @str.size) ? nil : @str[@loc]
|
|
57
57
|
@loc += 1
|
|
58
|
-
return ret
|
|
58
|
+
return ret
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
def stdin_ungetc(str)
|
|
62
62
|
@loc -= 1
|
|
63
63
|
@loc = 0 if @loc < 0
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
def stdout_write(chr)
|
|
67
67
|
@stdout << chr
|
|
68
68
|
end
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
def stdout
|
|
71
71
|
return @stdout
|
|
72
72
|
end
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
#### JSMIN
|
|
75
75
|
## To update, replace the text below with the latest jsmin.rb. Then replace:
|
|
76
|
-
## $theA => @theA, $theB => @theB,
|
|
77
|
-
## $stdin.getc => stdin_getc, $stdin.ungetc => stding_ungetc,
|
|
76
|
+
## $theA => @theA, $theB => @theB,
|
|
77
|
+
## $stdin.getc => stdin_getc, $stdin.ungetc => stding_ungetc,
|
|
78
78
|
## $stdout.write => stdout_write
|
|
79
79
|
|
|
80
|
-
# isAlphanum -- return true if the character is a letter, digit,
|
|
80
|
+
# isAlphanum -- return true if the character is a letter, digit,
|
|
81
81
|
# underscore, dollar sign, or non-ASCII character
|
|
82
82
|
def isAlphanum(c)
|
|
83
83
|
return false if !c || c == EOF
|
|
@@ -86,8 +86,8 @@ module SproutCore
|
|
|
86
86
|
c == '\\' || c[0] > 126)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
# get -- return the next character from stdin. Watch out for lookahead.
|
|
90
|
-
# If the character is a control character, translate it to a space or
|
|
89
|
+
# get -- return the next character from stdin. Watch out for lookahead.
|
|
90
|
+
# If the character is a control character, translate it to a space or
|
|
91
91
|
# linefeed.
|
|
92
92
|
def get()
|
|
93
93
|
c = stdin_getc
|