From 5bebaca4f0179baba0a44cde370ba2be79c6668e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Sun, 1 Sep 2013 19:33:09 +0400 Subject: [PATCH] #291: added friendly_id --- Gemfile | 1 + Gemfile.lock | 3 +++ app/assets/javascripts/angularjs/models/build_list.js.erb | 3 +-- app/models/platform.rb | 3 +++ app/models/repository.rb | 3 +++ config/routes.rb | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 7fee616c9..91b59c30a 100644 --- a/Gemfile +++ b/Gemfile @@ -51,6 +51,7 @@ gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags' gem "haml-rails", '~> 0.3.4' gem 'jquery-rails', '~> 2.0.2' gem 'ruby-haml-js', '~> 0.0.3' +gem 'friendly_id' gem 'rack-throttle' gem 'rest-client', '~> 1.6.6' diff --git a/Gemfile.lock b/Gemfile.lock index 4d08d44a6..2b4b9e77c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,6 +129,8 @@ GEM faraday (0.8.7) multipart-post (~> 1.1) ffi (1.0.11) + friendly_id (4.0.10.1) + activerecord (>= 3.0, < 4.0) fssm (0.2.10) gemoji (1.2.1) github-linguist (2.3.4) @@ -447,6 +449,7 @@ DEPENDENCIES devise (~> 2.2.3) diff-display (~> 0.0.1) factory_girl_rails (~> 4.0.0) + friendly_id gemoji (~> 1.2.1) github-linguist (~> 2.3.4) gollum (~> 2.1.3) diff --git a/app/assets/javascripts/angularjs/models/build_list.js.erb b/app/assets/javascripts/angularjs/models/build_list.js.erb index c1fa09f3b..020ca7ca9 100644 --- a/app/assets/javascripts/angularjs/models/build_list.js.erb +++ b/app/assets/javascripts/angularjs/models/build_list.js.erb @@ -24,6 +24,7 @@ var BuildList = function(atts, dictionary) { if (self.save_to_platform.personal) { self.save_to_repository_name += ' (' + self.build_for_platform.name + ')' } + self.save_to_repository_url = Routes.platform_repository_path(self.save_to_platform.name, self.save_to_repository.name); } if (self.project) { @@ -38,8 +39,6 @@ var BuildList = function(atts, dictionary) { self.project.name_with_owner = self.project.owner + '/' + self.project.name; } - if (self.save_to_platform_id) - self.save_to_repository_url = Routes.platform_repository_path(self.save_to_platform_id, self.save_to_repository_id); if (self.user) self.user.url = Routes.user_path(self.user.uname); self.url = Routes.build_list_path(self.id); diff --git a/app/models/platform.rb b/app/models/platform.rb index ad4660626..6b281b3a1 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,5 +1,8 @@ # -*- encoding : utf-8 -*- class Platform < ActiveRecord::Base + extend FriendlyId + friendly_id :name + include Modules::Models::FileStoreClean include Modules::Models::RegenerationStatus diff --git a/app/models/repository.rb b/app/models/repository.rb index ae2433142..e03452539 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,5 +1,8 @@ # -*- encoding : utf-8 -*- class Repository < ActiveRecord::Base + extend FriendlyId + friendly_id :name + LOCK_FILE_NAMES = {:sync => '.sync.lock', :repo => '.repo.lock'} SORT = {'base' => 1, 'main' => 2, 'contrib' => 3, 'non-free' => 4, 'restricted' => 5} diff --git a/config/routes.rb b/config/routes.rb index 0426da5fe..9efc3be31 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,7 +152,7 @@ Rosa::Application.routes.draw do end scope :module => 'platforms' do - resources :platforms do + resources :platforms, :constraints => {:id => Platform::NAME_PATTERN} do resources :private_users, :except => [:show, :destroy, :update] member do put :regenerate_metadata