Use authority instead of host in order to get the port as well.

This commit is contained in:
Raphael Sofaer 2011-07-20 02:20:23 -07:00
parent 537766d0d7
commit e19fb6d0f8
6 changed files with 9 additions and 9 deletions

View file

@ -125,7 +125,7 @@ HELP
def self.pod_uri
if @@pod_uri.nil?
begin
@@pod_uri = URI.parse(self.pod_url)
@@pod_uri = Addressable::URI.parse(self.pod_url)
rescue
puts "WARNING: pod url " + self.pod_url + " is not a legal URI"
end

View file

@ -340,7 +340,7 @@ class User < ActiveRecord::Base
end
self.person = Person.new(opts[:person])
self.person.diaspora_handle = "#{opts[:username]}@#{AppConfig[:pod_uri].host}"
self.person.diaspora_handle = "#{opts[:username]}@#{AppConfig[:pod_uri].authority}"
self.person.url = AppConfig[:pod_url]

View file

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/xrd/1.0'>
<hm:Host><%= AppConfig[:pod_uri].host %></hm:Host>
<hm:Host><%= AppConfig[:pod_uri].authority %></hm:Host>
<Link rel='lrdd'
template='<%= AppConfig[:pod_url].chomp("/") %>/webfinger?q={uri}'>
<Title>Resource Descriptor</Title>

View file

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/xrd/1.0'>
<hm:Host><%= AppConfig[:pod_uri].host %></hm:Host>
<hm:Host><%= AppConfig[:pod_uri].authority %></hm:Host>
<Link rel='lrdd'
template='<%= AppConfig[:pod_url] %>webfinger?q={uri}'>
<Title>Resource Descriptor</Title>

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file.
Diaspora::Application.configure do
config.action_mailer.default_url_options = {:host => AppConfig[:pod_uri].host}
config.action_mailer.default_url_options = {:host => AppConfig[:pod_uri].authority }
unless Rails.env == 'test' || AppConfig[:mailer_on] != true
if AppConfig[:mailer_method] == "sendmail"
config.action_mailer.delivery_method = :sendmail

View file

@ -9,7 +9,7 @@ class Server
attr_reader :port, :env
def initialize(env)
@db_config = ActiveRecord::Base.configurations[env]
@app_config = (YAML.load_file AppConfig.source)[env]
@app_config = (YAML.load_file AppConfig.source)[env]
@port = URI::parse(@app_config["pod_url"]).port
@env = env
ensure_database_setup
@ -18,7 +18,7 @@ class Server
def ensure_database_setup
`cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:create`
tables_exist = self.db do
ActiveRecord::Base.connection.tables.include?("users")
ActiveRecord::Base.connection.tables.include?("users")
end
if tables_exist
truncate_database
@ -49,7 +49,7 @@ class Server
processes.first.split(" ").first
}.call
end
def running?
begin
RestClient.get("localhost:#{@port}/users/sign_in")
@ -79,7 +79,7 @@ class Server
def in_scope
pod_url = "http://localhost:#{@port}/"
AppConfig.stub!(:pod_url).and_return(pod_url)
AppConfig.stub!(:pod_uri).and_return(URI.parse(pod_url))
AppConfig.stub!(:pod_uri).and_return(Addressable::URI.parse(pod_url))
begin
result = db do
yield