Commit e8c0d45dd295290c1180cf549a9e16de04249816
1 parent
d9a9294a
Exists in
colab
and in
4 other branches
JS routes are now generated insted of being harcoded
If set, RAILS_RELATIVE_URL_ROOT would break all the AJAX requests.
Showing
11 changed files
with
20 additions
and
7 deletions
Show diff stats
CHANGELOG.rdoc
Gemfile
... | ... | @@ -63,6 +63,9 @@ gem 'google-analytics-rails', '~> 0.0.6' |
63 | 63 | # Browser language detection |
64 | 64 | gem 'http_accept_language' |
65 | 65 | |
66 | +# Routes for JS files | |
67 | +gem 'js-routes', '~> 1.1.0' | |
68 | + | |
66 | 69 | group :test do |
67 | 70 | # Easier test writing |
68 | 71 | gem "shoulda-matchers", '~> 2.8.0' | ... | ... |
Gemfile.lock
... | ... | @@ -154,6 +154,9 @@ GEM |
154 | 154 | thor (>= 0.14, < 2.0) |
155 | 155 | jquery-ui-rails (5.0.5) |
156 | 156 | railties (>= 3.2.16) |
157 | + js-routes (1.1.0) | |
158 | + railties (>= 3.2) | |
159 | + sprockets-rails | |
157 | 160 | json (1.8.3) |
158 | 161 | kalibro_client (1.3.0) |
159 | 162 | activesupport (>= 2.2.1) |
... | ... | @@ -351,6 +354,7 @@ DEPENDENCIES |
351 | 354 | jbuilder (~> 2.0) |
352 | 355 | jquery-rails |
353 | 356 | jquery-ui-rails (~> 5.0.0) |
357 | + js-routes (~> 1.1.0) | |
354 | 358 | kalibro_client (~> 1.3.0) |
355 | 359 | konacha |
356 | 360 | mocha |
... | ... | @@ -375,4 +379,4 @@ DEPENDENCIES |
375 | 379 | web-console (~> 2.0.0) |
376 | 380 | |
377 | 381 | BUNDLED WITH |
378 | - 1.10.5 | |
382 | + 1.10.6 | ... | ... |
app/assets/javascripts/application.js
app/assets/javascripts/module/graphic.js.coffee
app/assets/javascripts/module/tree.js.coffee
app/assets/javascripts/repository/branch.js.coffee
... | ... | @@ -47,7 +47,7 @@ class Repository.Branch |
47 | 47 | scm_type = $("#repository_scm_type").val() |
48 | 48 | |
49 | 49 | context = this |
50 | - @request = $.get '/repository_branches', | |
50 | + @request = $.get Routes.repository_branches_path(), | |
51 | 51 | {'url': address, 'scm_type': scm_type}, |
52 | 52 | (data) -> |
53 | 53 | unless data["errors"] | ... | ... |
app/assets/javascripts/repository/state.js.coffee
... | ... | @@ -2,7 +2,7 @@ class Repository.State |
2 | 2 | constructor: (@repository_id) -> |
3 | 3 | |
4 | 4 | poll_state: (last_state) -> |
5 | - $.get('/repositories/' + @repository_id + '/state', | |
5 | + $.get(Routes.repository_state_path(@repository_id), | |
6 | 6 | last_state: last_state) |
7 | 7 | |
8 | 8 | schedule_poll_state: (last_state) -> | ... | ... |
config/routes.rb
... | ... | @@ -37,8 +37,8 @@ Rails.application.routes.draw do |
37 | 37 | end |
38 | 38 | |
39 | 39 | # Modules |
40 | - post '/modules/:id/metric_history' => 'modules#metric_history' | |
41 | - post '/modules/:id/tree' => 'modules#load_module_tree' | |
40 | + post '/modules/:id/metric_history' => 'modules#metric_history', as: 'module_metric_history' | |
41 | + post '/modules/:id/tree' => 'modules#load_module_tree', as: 'module_tree' | |
42 | 42 | |
43 | 43 | # Tutorials |
44 | 44 | get '/tutorials/:name' => 'tutorials#view', as: 'tutorials' | ... | ... |