Commit dc6c46eff2cf0f0aae3de316fbe03187defe6ab2
- Date: Sat Jan 05 23:35:11 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: dc6c46eff2cf0f0aae3de316fbe03187defe6ab2
- Tree SHA1: 7b33d7296aa14cd512cc918a403809a3d2ae4ce8
added application yaml config file usage
Commit diff
| |   |
| 2 | 2 | # Likewise, all the methods added will be available for all controllers. |
| 3 | 3 | |
| 4 | 4 | class ApplicationController < ActionController::Base |
| 5 | | session :session_key => '_ks1_session_id', |
| 6 | | # TODO: Read from conf file or something |
| 7 | | :secret => "imcerBupbitjahalCauncafiakbyFrecowphoadmodUtNakNipnuepbyRumatmor" |
| 5 | session :session_key => '_ks1_session_id', :secret => GitoriousConfig["cookie_secret"] |
| 8 | 6 | include AuthenticatedSystem |
| 9 | 7 | |
| 10 | 8 | protected |
| toggle raw diff |
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -2,9 +2,7 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
- session :session_key => '_ks1_session_id',
- # TODO: Read from conf file or something
- :secret => "imcerBupbitjahalCauncafiakbyFrecowphoadmodUtNakNipnuepbyRumatmor"
+ session :session_key => '_ks1_session_id', :secret => GitoriousConfig["cookie_secret"]
include AuthenticatedSystem
protected |
| |   |
| 40 | 40 | format.html { redirect_to location } |
| 41 | 41 | format.xml { render :xml => @repository, :status => :created, :location => location } |
| 42 | 42 | else |
| 43 | | format.html { render :action => "copy" } |
| 43 | format.html { render :action => "new" } |
| 44 | 44 | format.xml { render :xml => @repository.errors, :status => :unprocessable_entity } |
| 45 | 45 | end |
| 46 | 46 | end |
| toggle raw diff |
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -40,7 +40,7 @@ class RepositoriesController < ApplicationController
format.html { redirect_to location }
format.xml { render :xml => @repository, :status => :created, :location => location }
else
- format.html { render :action => "copy" }
+ format.html { render :action => "new" }
format.xml { render :xml => @repository.errors, :status => :unprocessable_entity }
end
end |
| |   |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | 26 | BASE_REPOSITORY_URL = "gitorious.org" |
| 27 | | BASE_REPOSITORY_DIR = File.join(RAILS_ROOT, "../repositories") |
| 28 | 27 | |
| 29 | 28 | def gitdir |
| 30 | 29 | File.join(project.slug, "#{name}.git") |
| … | … | |
| 104 | 104 | end |
| 105 | 105 | |
| 106 | 106 | def self.full_path_from_partial_path(path) |
| 107 | | File.expand_path(File.join(BASE_REPOSITORY_DIR, path)) |
| 107 | File.expand_path(File.join(GitoriousConfig["repository_base_path"], path)) |
| 108 | 108 | end |
| 109 | 109 | end |
| toggle raw diff |
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -24,7 +24,6 @@ class Repository < ActiveRecord::Base
end
BASE_REPOSITORY_URL = "gitorious.org"
- BASE_REPOSITORY_DIR = File.join(RAILS_ROOT, "../repositories")
def gitdir
File.join(project.slug, "#{name}.git")
@@ -105,6 +104,6 @@ class Repository < ActiveRecord::Base
end
def self.full_path_from_partial_path(path)
- File.expand_path(File.join(BASE_REPOSITORY_DIR, path))
+ File.expand_path(File.join(GitoriousConfig["repository_base_path"], path))
end
end |
| |   |
| 1 | | database.yml |
| 1 | database.yml |
| 2 | gitorious.yml |
| toggle raw diff |
--- a/config/.gitignore
+++ b/config/.gitignore
@@ -1 +1,2 @@
-database.yml
\ No newline at end of file
+database.yml
+gitorious.yml |
| |   |
| 29 | 29 | |
| 30 | 30 | # Your secret key for verifying cookie session data integrity. |
| 31 | 31 | # If you change this key, all old sessions will become invalid! |
| 32 | | config.action_controller.session = { |
| 33 | | :session_key => '_ks1_session', |
| 34 | | :secret => 'd11c9229c49301cc6c307279b689396b' |
| 35 | | } |
| 32 | # config.action_controller.session = { |
| 33 | # :session_key => '_ks1_session', |
| 34 | # :secret => 'd11c9229c49301cc6c307279b689396b' |
| 35 | # } |
| 36 | 36 | |
| 37 | 37 | # Use the database for sessions instead of the cookie-based default, |
| 38 | 38 | # which shouldn't be used to store highly confidential information |
| toggle raw diff |
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -29,10 +29,10 @@ Rails::Initializer.run do |config|
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
- config.action_controller.session = {
- :session_key => '_ks1_session',
- :secret => 'd11c9229c49301cc6c307279b689396b'
- }
+ # config.action_controller.session = {
+ # :session_key => '_ks1_session',
+ # :secret => 'd11c9229c49301cc6c307279b689396b'
+ # }
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information |
| |   |
| 1 | GitoriousConfig = YAML::load_file(File.join(RAILS_ROOT, "config/gitorious.yml")) |
| toggle raw diff |
--- /dev/null
+++ b/config/initializers/gitorious_config.rb
@@ -0,0 +1 @@
+GitoriousConfig = YAML::load_file(File.join(RAILS_ROOT, "config/gitorious.yml"))
\ No newline at end of file |
| |   |
| 36 | 36 | "#{@strainer.verb} '#{@strainer.full_path}'" |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | | |
| 40 | 39 | protected |
| 41 | 40 | def connection |
| 42 | | port = $DEBUG ? 3000 : 80 |
| 43 | | @connection ||= Net::HTTP.start("localhost", port) |
| 41 | port = GitoriousConfig["gitorious_client_port"] |
| 42 | host = GitoriousConfig["gitorious_client_host"] |
| 43 | @connection ||= Net::HTTP.start(host, port) |
| 44 | 44 | end |
| 45 | 45 | end |
| 46 | 46 | end |
| toggle raw diff |
--- a/lib/gitorious/ssh/client.rb
+++ b/lib/gitorious/ssh/client.rb
@@ -36,11 +36,11 @@ module Gitorious
"#{@strainer.verb} '#{@strainer.full_path}'"
end
-
protected
def connection
- port = $DEBUG ? 3000 : 80
- @connection ||= Net::HTTP.start("localhost", port)
+ port = GitoriousConfig["gitorious_client_port"]
+ host = GitoriousConfig["gitorious_client_host"]
+ @connection ||= Net::HTTP.start(host, port)
end
end
end |
| |   |
| 1 | 1 | #!/usr/bin/env ruby -wKU |
| 2 | 2 | |
| 3 | require "yaml" |
| 3 | 4 | if File.symlink?(__FILE__) |
| 4 | 5 | $:.unshift File.dirname(File.readlink(__FILE__)) + "/../lib/gitorious/ssh" |
| 5 | 6 | else |
| 6 | 7 | $:.unshift File.dirname(__FILE__) + "/../lib/gitorious/ssh" |
| 7 | 8 | end |
| 8 | 9 | |
| 10 | GitoriousConfig = YAML.load_file(File.dirname(__FILE__) + "/../config/gitorious.yml") |
| 11 | |
| 9 | 12 | ENV["PATH"] = "/opt/local/bin:#{ENV["PATH"]}" |
| 10 | 13 | |
| 11 | 14 | require "strainer" |
| toggle raw diff |
--- a/script/gitorious
+++ b/script/gitorious
@@ -1,11 +1,14 @@
#!/usr/bin/env ruby -wKU
+require "yaml"
if File.symlink?(__FILE__)
$:.unshift File.dirname(File.readlink(__FILE__)) + "/../lib/gitorious/ssh"
else
$:.unshift File.dirname(__FILE__) + "/../lib/gitorious/ssh"
end
+GitoriousConfig = YAML.load_file(File.dirname(__FILE__) + "/../config/gitorious.yml")
+
ENV["PATH"] = "/opt/local/bin:#{ENV["PATH"]}"
require "strainer" |
| |   |
| 76 | 76 | end |
| 77 | 77 | |
| 78 | 78 | it "has a full repository_path" do |
| 79 | | expected_dir = File.expand_path(File.join(RAILS_ROOT, "../repositories", projects(:johans).slug, "foo.git")) |
| 79 | expected_dir = File.expand_path(File.join(GitoriousConfig["repository_base_path"], |
| 80 | projects(:johans).slug, "foo.git")) |
| 80 | 81 | @repository.full_repository_path.should == expected_dir |
| 81 | 82 | end |
| 82 | 83 | |
| toggle raw diff |
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -76,7 +76,8 @@ describe Repository do
end
it "has a full repository_path" do
- expected_dir = File.expand_path(File.join(RAILS_ROOT, "../repositories", projects(:johans).slug, "foo.git"))
+ expected_dir = File.expand_path(File.join(GitoriousConfig["repository_base_path"],
+ projects(:johans).slug, "foo.git"))
@repository.full_repository_path.should == expected_dir
end
|
| |   |
| 13 | 13 | config.include KeyserSource::SpecDSL |
| 14 | 14 | |
| 15 | 15 | # config.after(:each) do |
| 16 | | # path = File.join(Repository::BASE_REPOSITORY_DIR, "*") |
| 16 | # path = File.join(GitoriousConfig["repository_base_path"], "*") |
| 17 | 17 | # Dir[path].each do |dir| |
| 18 | 18 | # `rm -rf #{dir}` |
| 19 | 19 | # end |
| toggle raw diff |
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,7 +13,7 @@ Spec::Runner.configure do |config|
config.include KeyserSource::SpecDSL
# config.after(:each) do
- # path = File.join(Repository::BASE_REPOSITORY_DIR, "*")
+ # path = File.join(GitoriousConfig["repository_base_path"], "*")
# Dir[path].each do |dir|
# `rm -rf #{dir}`
# end |