Skip to content
Extraits de code Groupes Projets
Valider eacee548 rédigé par Alec Leamas's avatar Alec Leamas Validation de Alec Leamas
Parcourir les fichiers

Replace APP_CONFIG[:terse_pod_url] with uri object.

Adds a new APP_CONFIG[:pod_uri] item, an uri object parsed from
pod_url. Replace all occurrences of APP_CONFIG[:terse_pod_url] with
APP_CONFIG[:pod_uri].host. Closes http://bugs.joindiaspora.com/issues/684,
using the well-defined semantics of the uri object.

The pod_url is normalized using module URI's functions, always with a
trailing /.

The diaspora-handle will always reflect the pod_url with this patch
i. e., a pod_url like www.dpod.se will give the handle xx@www.dpod.se;
previous code stripped the www. prefix. If this is a problem, it
should be addressed by another setting, since one cannot presume that
www.domain.tld resolves to the same address as domain.tld.
parent 416a36ea
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class Notifier < ActionMailer::Base
default :from => APP_CONFIG[:smtp_sender_address]
ATTACHMENT = File.read("#{Rails.root}/public/images/diaspora_white_on_grey.png")
def self.admin(string, recipients, opts = {})
......@@ -18,7 +18,7 @@ class Notifier < ActionMailer::Base
@string = string.html_safe
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
mail(:to => @recipient.email,
:subject => I18n.t('notifier.single_admin.subject'), :host => APP_CONFIG[:terse_pod_url])
:subject => I18n.t('notifier.single_admin.subject'), :host => APP_CONFIG[:pod_uri].host)
end
def new_request(recipient_id, sender_id)
......@@ -30,7 +30,7 @@ class Notifier < ActionMailer::Base
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
:subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => APP_CONFIG[:terse_pod_url])
:subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => APP_CONFIG[:pod_uri].host)
end
def request_accepted(recipient_id, sender_id, aspect_id)
......@@ -40,10 +40,10 @@ class Notifier < ActionMailer::Base
log_mail(recipient_id, sender_id, 'request_accepted')
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => APP_CONFIG[:terse_pod_url])
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => APP_CONFIG[:pod_uri].host)
end
private
......
......@@ -357,13 +357,13 @@ class User
opts[:person][:profile] ||= Profile.new
self.person = Person.new(opts[:person])
self.person.diaspora_handle = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
self.person.diaspora_handle = "#{opts[:username]}@#{APP_CONFIG[:pod_uri].host}"
self.person.url = APP_CONFIG[:pod_url]
self.serialized_private_key ||= User.generate_key
self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key
self
end
......
......@@ -4,7 +4,7 @@
.span-10.append-1.last
.floating
%h3
%h3
= t('.login')
= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
#user
......@@ -12,7 +12,7 @@
= f.label :username , t('username')
= f.text_field :username
%p.user_network
="@#{APP_CONFIG[:terse_pod_url]}"
="@#{APP_CONFIG[:pod_uri].host}/"
%p
= f.label :password , t('password')
......@@ -22,7 +22,7 @@
/ = f.check_box :remember_me
/ = f.label :remember_me , t('.remember_me')
= f.submit t('.sign_in')
%p
= render :partial => "devise/shared/links"
%p
......@@ -39,5 +39,5 @@
%span.brandon DIASPORA*
= t('.modern_browsers')
= image_tag('modern_browsers.png')
......@@ -11,7 +11,7 @@
= f.label :username , t('username')
= f.text_field :username
%p.user_network
="@#{APP_CONFIG[:terse_pod_url]}"
="@#{APP_CONFIG[:pod_uri].host}/"
%p
= f.label :password , t('password')
......@@ -26,4 +26,4 @@
= t('.alpha_software')
%h3
= t('.bugs_and_feedback_mobile')
\ No newline at end of file
= t('.bugs_and_feedback_mobile')
<?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><%= APP_CONFIG[:terse_pod_url] %></hm:Host>
<hm:Host><%= APP_CONFIG[:pod_uri].host %></hm:Host>
<Link rel='lrdd'
template='<%= APP_CONFIG[:pod_url] %>webfinger?q={uri}'>
template='<%= APP_CONFIG[:pod_uri].host %>/webfinger?q={uri}'>
<Title>Resource Descriptor</Title>
</Link>
</XRD>
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
# Sets up APP_CONFIG. Unless stated below, each entry is a the string in
# the file app_config.yml, as applicable for current environment.
#
# Specific items
# * pod_url: As in app_config.yml, normalized with a trailing /.
# * pod_uri: An uri object derived from pod_url.
require 'uri'
def load_config_yaml filename
YAML.load(File.read(filename))
......@@ -20,10 +29,14 @@ else
APP_CONFIG = all_envs['default'].symbolize_keys
end
APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '')
APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/'
begin
APP_CONFIG[:pod_uri] = URI.parse( APP_CONFIG[:pod_url])
rescue
puts "WARNING: pod url " + APP_CONFIG[:pod_url] + " is not a legal URI"
end
APP_CONFIG[:pod_url].chop! if APP_CONFIG[:pod_url][-1, 1] == '/'
APP_CONFIG[:pod_url] = APP_CONFIG[:pod_url] + '/'
APP_CONFIG[:pod_url] = APP_CONFIG[:pod_uri].normalize.to_s
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != "test"
if APP_CONFIG[:pod_uri].host == "example.org" && Rails.env != "test"
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!"
end
......@@ -3,7 +3,7 @@
# the COPYRIGHT file.
Diaspora::Application.configure do
config.action_mailer.default_url_options = {:host => APP_CONFIG[:terse_pod_url]}
config.action_mailer.default_url_options = {:host => APP_CONFIG[:pod_uri].host}
unless Rails.env == 'test' || APP_CONFIG[:mailer_on] != true
config.action_mailer.delivery_method = :smtp
if APP_CONFIG[:smtp_authentication] == "none"
......
......@@ -12,6 +12,6 @@ describe 'making sure the config is parsed as should' do
describe 'terse_pod_url'
it 'should be correctly parsed' do
APP_CONFIG[:terse_pod_url].should == 'example.org'
APP_CONFIG[:pod_uri].host.should == 'example.org'
end
end
......@@ -38,13 +38,13 @@ describe Person do
context 'local people' do
it 'uses the pod config url to set the diaspora_handle' do
new_user = Factory.create(:user)
new_user.person.diaspora_handle.should == new_user.username + "@" + APP_CONFIG[:terse_pod_url]
new_user.person.diaspora_handle.should == new_user.username + "@" + APP_CONFIG[:pod_uri].host
end
end
context 'remote people' do
it 'stores the diaspora_handle in the database' do
@person.diaspora_handle.include?(APP_CONFIG[:terse_pod_url]).should be false
@person.diaspora_handle.include?(APP_CONFIG[:pod_uri].host).should be false
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter