From e19fb6d0f885afaaaa48708da2f29f60ecfc2bed Mon Sep 17 00:00:00 2001 From: Raphael Sofaer <raphael@joindiaspora.com> Date: Wed, 20 Jul 2011 02:20:23 -0700 Subject: [PATCH] Use authority instead of host in order to get the port as well. --- app/models/app_config.rb | 2 +- app/models/user.rb | 2 +- app/views/publics/host_meta.erb | 2 +- app/views/publics/host_meta.html.erb | 2 +- config/initializers/mailer_config.rb | 2 +- spec/support/server.rb | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/app_config.rb b/app/models/app_config.rb index e3aea84cb8..3380360024 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index b93c093ace..a37445555c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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] diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index faaa0e0a22..5bb6786c56 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -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> diff --git a/app/views/publics/host_meta.html.erb b/app/views/publics/host_meta.html.erb index 8b0ad3aa83..fa8cd98797 100644 --- a/app/views/publics/host_meta.html.erb +++ b/app/views/publics/host_meta.html.erb @@ -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> diff --git a/config/initializers/mailer_config.rb b/config/initializers/mailer_config.rb index 0f154d3e95..a42f539c31 100644 --- a/config/initializers/mailer_config.rb +++ b/config/initializers/mailer_config.rb @@ -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 diff --git a/spec/support/server.rb b/spec/support/server.rb index eb31db5e6a..27df791f7e 100644 --- a/spec/support/server.rb +++ b/spec/support/server.rb @@ -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 -- GitLab