Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Doctor Ripples committed Jan 10, 2013
2 parents 884ce02 + 6cc90a5 commit 8fcca11
Show file tree
Hide file tree
Showing 10 changed files with 19,088 additions and 19,047 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Marked Style: GitHub
-->
# v0.9.1

- Updated to to require.js \ r.js 2.1.2, and almond 0.2.2
- Updated to to require.js \ r.js 2.1.2, and almond 0.2.3

# v0.9.0

Expand Down
98 changes: 49 additions & 49 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
PATH
remote: .
specs:
requirejs-rails (0.9.0)
requirejs-rails (0.9.1)
railties (>= 3.1.1, < 3.3)

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.0)
builder (3.0.0)
arel (3.0.2)
builder (3.0.4)
erubis (2.7.0)
execjs (1.3.0)
execjs (1.4.0)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.1)
jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.6.5)
mail (2.4.1)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
mime-types (1.19)
multi_json (1.3.7)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.1)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
tzinfo (0.3.35)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Integrates [RequireJS](http://requirejs.org/) into the Rails 3 Asset Pipeline.
6. When ready, build your assets for production deployment as usual.
`requirejs-rails` defaults to a single-file build of `application.js`.
Additional modules and r.js layered builds may be specified via
`config\requirejs.yml`; see the Configuration section below.
`config/requirejs.yml`; see the Configuration section below.
```rake assets:precompile```
Expand Down
14 changes: 13 additions & 1 deletion app/helpers/requirejs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ def _requirejs_data(name, &block)
{}.tap do |data|
if name
name += ".js" unless name =~ /\.js$/
data['main'] = _javascript_path(name).sub(/\.js$/,'')
data['main'] = _javascript_path(name).
sub(/\.js$/,'').
sub(baseUrl(name), '').
sub(/\A\//, '')
end

data.merge!(yield controller) if block_given?
Expand Down Expand Up @@ -57,6 +60,8 @@ def requirejs_include_tag(name=nil, &block)
# and in the build_config.
run_config['paths'] = paths
end

run_config['baseUrl'] = baseUrl(name)
html.concat <<-HTML
<script>var require = #{run_config.to_json};</script>
HTML
Expand Down Expand Up @@ -92,4 +97,11 @@ def _javascript_path(name)
"/assets/#{name}"
end
end

def baseUrl(js_asset)
js_asset_path = javascript_path(js_asset)
uri = URI.parse(js_asset_path)
asset_host = uri.host && js_asset_path.sub(uri.request_uri, '')
[asset_host, Rails.application.config.assets.prefix].join
end
end
Loading

0 comments on commit 8fcca11

Please sign in to comment.