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,6 +63,9 @@ gem 'google-analytics-rails', '~> 0.0.6' | ||
63 | # Browser language detection | 63 | # Browser language detection |
64 | gem 'http_accept_language' | 64 | gem 'http_accept_language' |
65 | 65 | ||
66 | +# Routes for JS files | ||
67 | +gem 'js-routes', '~> 1.1.0' | ||
68 | + | ||
66 | group :test do | 69 | group :test do |
67 | # Easier test writing | 70 | # Easier test writing |
68 | gem "shoulda-matchers", '~> 2.8.0' | 71 | gem "shoulda-matchers", '~> 2.8.0' |
Gemfile.lock
@@ -154,6 +154,9 @@ GEM | @@ -154,6 +154,9 @@ GEM | ||
154 | thor (>= 0.14, < 2.0) | 154 | thor (>= 0.14, < 2.0) |
155 | jquery-ui-rails (5.0.5) | 155 | jquery-ui-rails (5.0.5) |
156 | railties (>= 3.2.16) | 156 | railties (>= 3.2.16) |
157 | + js-routes (1.1.0) | ||
158 | + railties (>= 3.2) | ||
159 | + sprockets-rails | ||
157 | json (1.8.3) | 160 | json (1.8.3) |
158 | kalibro_client (1.3.0) | 161 | kalibro_client (1.3.0) |
159 | activesupport (>= 2.2.1) | 162 | activesupport (>= 2.2.1) |
@@ -351,6 +354,7 @@ DEPENDENCIES | @@ -351,6 +354,7 @@ DEPENDENCIES | ||
351 | jbuilder (~> 2.0) | 354 | jbuilder (~> 2.0) |
352 | jquery-rails | 355 | jquery-rails |
353 | jquery-ui-rails (~> 5.0.0) | 356 | jquery-ui-rails (~> 5.0.0) |
357 | + js-routes (~> 1.1.0) | ||
354 | kalibro_client (~> 1.3.0) | 358 | kalibro_client (~> 1.3.0) |
355 | konacha | 359 | konacha |
356 | mocha | 360 | mocha |
@@ -375,4 +379,4 @@ DEPENDENCIES | @@ -375,4 +379,4 @@ DEPENDENCIES | ||
375 | web-console (~> 2.0.0) | 379 | web-console (~> 2.0.0) |
376 | 380 | ||
377 | BUNDLED WITH | 381 | BUNDLED WITH |
378 | - 1.10.5 | 382 | + 1.10.6 |
app/assets/javascripts/application.js
app/assets/javascripts/module/graphic.js.coffee
@@ -8,7 +8,7 @@ class Module.Graphic | @@ -8,7 +8,7 @@ class Module.Graphic | ||
8 | drawer.slideUp('slow') | 8 | drawer.slideUp('slow') |
9 | 9 | ||
10 | load: -> | 10 | load: -> |
11 | - $.post '/modules/' + @module_id + '/metric_history', | 11 | + $.post Routes.module_metric_history_path(@module_id), |
12 | { | 12 | { |
13 | metric_name: @metric_name, | 13 | metric_name: @metric_name, |
14 | container: @container | 14 | container: @container |
app/assets/javascripts/module/tree.js.coffee
@@ -2,4 +2,4 @@ class Module.Tree | @@ -2,4 +2,4 @@ class Module.Tree | ||
2 | @load: (loading_html, module_id) -> | 2 | @load: (loading_html, module_id) -> |
3 | $('div#module_tree').html(loading_html) | 3 | $('div#module_tree').html(loading_html) |
4 | $('div#metric_results').html(loading_html) | 4 | $('div#metric_results').html(loading_html) |
5 | - $.post '/modules/'+module_id+'/tree' | ||
6 | \ No newline at end of file | 5 | \ No newline at end of file |
6 | + $.post Routes.module_tree_path(module_id) |
app/assets/javascripts/repository/branch.js.coffee
@@ -47,7 +47,7 @@ class Repository.Branch | @@ -47,7 +47,7 @@ class Repository.Branch | ||
47 | scm_type = $("#repository_scm_type").val() | 47 | scm_type = $("#repository_scm_type").val() |
48 | 48 | ||
49 | context = this | 49 | context = this |
50 | - @request = $.get '/repository_branches', | 50 | + @request = $.get Routes.repository_branches_path(), |
51 | {'url': address, 'scm_type': scm_type}, | 51 | {'url': address, 'scm_type': scm_type}, |
52 | (data) -> | 52 | (data) -> |
53 | unless data["errors"] | 53 | unless data["errors"] |
app/assets/javascripts/repository/state.js.coffee
@@ -2,7 +2,7 @@ class Repository.State | @@ -2,7 +2,7 @@ class Repository.State | ||
2 | constructor: (@repository_id) -> | 2 | constructor: (@repository_id) -> |
3 | 3 | ||
4 | poll_state: (last_state) -> | 4 | poll_state: (last_state) -> |
5 | - $.get('/repositories/' + @repository_id + '/state', | 5 | + $.get(Routes.repository_state_path(@repository_id), |
6 | last_state: last_state) | 6 | last_state: last_state) |
7 | 7 | ||
8 | schedule_poll_state: (last_state) -> | 8 | schedule_poll_state: (last_state) -> |
config/routes.rb
@@ -37,8 +37,8 @@ Rails.application.routes.draw do | @@ -37,8 +37,8 @@ Rails.application.routes.draw do | ||
37 | end | 37 | end |
38 | 38 | ||
39 | # Modules | 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 | # Tutorials | 43 | # Tutorials |
44 | get '/tutorials/:name' => 'tutorials#view', as: 'tutorials' | 44 | get '/tutorials/:name' => 'tutorials#view', as: 'tutorials' |
spec/javascripts/spec_helper.js.coffee