Commit dc6c46eff2cf0f0aae3de316fbe03187defe6ab2

added application yaml config file usage

Commit diff

app/controllers/application.rb

 
22# Likewise, all the methods added will be available for all controllers.
33
44class 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"]
86 include AuthenticatedSystem
97
108 protected
toggle raw diff

app/controllers/repositories_controller.rb

 
4040 format.html { redirect_to location }
4141 format.xml { render :xml => @repository, :status => :created, :location => location }
4242 else
43 format.html { render :action => "copy" }
43 format.html { render :action => "new" }
4444 format.xml { render :xml => @repository.errors, :status => :unprocessable_entity }
4545 end
4646 end
toggle raw diff

app/models/repository.rb

 
2424 end
2525
2626 BASE_REPOSITORY_URL = "gitorious.org"
27 BASE_REPOSITORY_DIR = File.join(RAILS_ROOT, "../repositories")
2827
2928 def gitdir
3029 File.join(project.slug, "#{name}.git")
104104 end
105105
106106 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))
108108 end
109109end
toggle raw diff

config/.gitignore

 
1database.yml
1database.yml
2gitorious.yml
toggle raw diff

config/environment.rb

 
2929
3030 # Your secret key for verifying cookie session data integrity.
3131 # 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 # }
3636
3737 # Use the database for sessions instead of the cookie-based default,
3838 # which shouldn't be used to store highly confidential information
toggle raw diff

config/initializers/gitorious_config.rb

 
1GitoriousConfig = YAML::load_file(File.join(RAILS_ROOT, "config/gitorious.yml"))
toggle raw diff

lib/gitorious/ssh/client.rb

 
3636 "#{@strainer.verb} '#{@strainer.full_path}'"
3737 end
3838
39
4039 protected
4140 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)
4444 end
4545 end
4646 end
toggle raw diff

script/gitorious

 
11#!/usr/bin/env ruby -wKU
22
3require "yaml"
34if File.symlink?(__FILE__)
45 $:.unshift File.dirname(File.readlink(__FILE__)) + "/../lib/gitorious/ssh"
56else
67 $:.unshift File.dirname(__FILE__) + "/../lib/gitorious/ssh"
78end
89
10GitoriousConfig = YAML.load_file(File.dirname(__FILE__) + "/../config/gitorious.yml")
11
912ENV["PATH"] = "/opt/local/bin:#{ENV["PATH"]}"
1013
1114require "strainer"
toggle raw diff

spec/models/repository_spec.rb

 
7676 end
7777
7878 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"))
8081 @repository.full_repository_path.should == expected_dir
8182 end
8283
toggle raw diff

spec/spec_helper.rb

 
1313 config.include KeyserSource::SpecDSL
1414
1515 # config.after(:each) do
16 # path = File.join(Repository::BASE_REPOSITORY_DIR, "*")
16 # path = File.join(GitoriousConfig["repository_base_path"], "*")
1717 # Dir[path].each do |dir|
1818 # `rm -rf #{dir}`
1919 # end
toggle raw diff