#251: added js-routes gem, updated JS

This commit is contained in:
Vokhmin Alexey V 2013-08-05 21:38:48 +04:00
parent 894d61908b
commit a91bfe95c9
7 changed files with 19 additions and 14 deletions

View File

@ -75,6 +75,7 @@ group :assets do
gem 'therubyracer', '~> 0.10.2', :platforms => [:mri, :rbx] gem 'therubyracer', '~> 0.10.2', :platforms => [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
gem 'turbo-sprockets-rails3' gem 'turbo-sprockets-rails3'
gem 'js-routes'
end end
group :production do group :production do

View File

@ -170,6 +170,8 @@ GEM
jquery-rails (2.0.3) jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0) railties (>= 3.1.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
js-routes (0.9.3)
rails (>= 3.2)
json (1.8.0) json (1.8.0)
jwt (0.1.8) jwt (0.1.8)
multi_json (>= 1.5) multi_json (>= 1.5)
@ -458,6 +460,7 @@ DEPENDENCIES
hirb hirb
jbuilder (~> 1.4.2) jbuilder (~> 1.4.2)
jquery-rails (~> 2.0.2) jquery-rails (~> 2.0.2)
js-routes
mailcatcher mailcatcher
meta-tags (~> 1.2.5) meta-tags (~> 1.2.5)
meta_request meta_request

View File

@ -14,7 +14,8 @@ RosaABF.controller('BuildListsController', ['$scope', '$http', '$location', '$ti
// Disable 'Search' button // Disable 'Search' button
$scope.isRequest = true; $scope.isRequest = true;
$http.get('/build_lists.json', {params: $location.search()}).success(function(results) {
$http.get(Routes.build_lists_path({format: 'json'}), {params: $location.search()}).success(function(results) {
// Render Server status // Render Server status
$scope.server_status = results.server_status; $scope.server_status = results.server_status;

View File

@ -25,23 +25,21 @@ var BuildList = function(atts, dictionary) {
} }
if (self.project) { if (self.project) {
self.version_link_url = '/' + self.project.name_with_owner;
if (self.last_published_commit_hash) { if (self.last_published_commit_hash) {
self.version_link_text = self.last_published_commit_hash + '...' + self.commit_hash; self.version_link_text = self.last_published_commit_hash + '...' + self.commit_hash;
self.version_link_url += '/diff/'; self.version_link_url = Routes.diff_path(self.project.owner, self.project.name, self.version_link_text);
} else { } else {
self.version_link_text = self.commit_hash || self.project_version; self.version_link_text = self.commit_hash || self.project_version;
self.version_link_url += '/commit/'; self.version_link_url = Routes.commit_path(self.project.owner, self.project.name, self.version_link_text);
}
self.project.url = Routes.project_path(self.project.owner, self.project.name);
self.project.name_with_owner = self.project.owner + '/' + self.project.name;
} }
self.version_link_url += self.version_link_text; self.save_to_repository_url = Routes.platform_repository_path(self.save_to_platform_id, self.save_to_repository_id);
self.project.url = '/' + self.project.name_with_owner; self.user.url = Routes.user_path(self.user.uname);
}
self.save_to_repository_url = '/platforms/' + self.save_to_platform_id + '/repositories/' + self.save_to_repository_id;
self.user.url = '/' + self.user.uname;
self.human_status = 'build_list.status.' + self.status; self.human_status = 'build_list.status.' + self.status;
self.url = '/build_lists/' + self.id; self.url = Routes.build_list_path(self.id);
switch (self.status) { // See: app/helpers/build_lists_helper.rb switch (self.status) { // See: app/helpers/build_lists_helper.rb
case <%=BuildList::BUILD_PUBLISHED%>: self.status_color = 'success'; break case <%=BuildList::BUILD_PUBLISHED%>: self.status_color = 'success'; break

View File

@ -14,15 +14,15 @@ var ProjectRef = function(atts) {
self.ui_container = false; self.ui_container = false;
self.path = function(project) { self.path = function(project) {
return '/' + project.fullname + '/tree/' + self.ref; return Routes.tree_path(project.owner.uname, project.name, self.ref);
} }
self.diff_path = function(project, current_ref) { self.diff_path = function(project, current_ref) {
return '/' + project.fullname + '/diff/' + current_ref + '...' + self.ref; return Routes.diff_path(project.owner.uname, project.name, current_ref + '...' + self.ref);
} }
self.archive_path = function(project, type) { self.archive_path = function(project, type) {
return '/' + project.fullname + '/archive/' + project.name + '-' + self.ref + '.' + type; return Routes.archive_path(project.owner.uname, project.name, project.name + '-' + self.ref, {format: type});
} }
//return the scope-safe instance //return the scope-safe instance

View File

@ -14,6 +14,7 @@
//= require backbone_datalink //= require backbone_datalink
//= require backbone/rosa //= require backbone/rosa
//= require js-routes
// require angular // require angular
//= require unstable/angular //= require unstable/angular
// require angular-resource // require angular-resource

View File

@ -18,7 +18,8 @@ json.dictionary do
json.(user, :id, :uname, :fullname) json.(user, :id, :uname, :fullname)
end end
json.projects @build_lists.map(&:project).uniq.compact do |project| json.projects @build_lists.map(&:project).uniq.compact do |project|
json.(project, :id, :name_with_owner) json.(project, :id, :name)
json.owner project.name_with_owner.gsub(/\/.*/, '')
end end
json.platforms (@build_lists.map(&:build_for_platform) | @build_lists.map(&:save_to_platform)).uniq do |platform| json.platforms (@build_lists.map(&:build_for_platform) | @build_lists.map(&:save_to_platform)).uniq do |platform|
json.(platform, :id, :name) json.(platform, :id, :name)