introduce base_pod_uri, so we can support domains that use www and [bare] with webfinger
This commit is contained in:
parent
30947778f9
commit
b09e76a0ce
11 changed files with 36 additions and 8 deletions
|
|
@ -32,6 +32,10 @@ module ApplicationHelper
|
||||||
without_close_html + link_to(image_tag('deletelabel.png'), "#", :class => 'close')
|
without_close_html + link_to(image_tag('deletelabel.png'), "#", :class => 'close')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def diaspora_id_host
|
||||||
|
User.diaspora_id_host
|
||||||
|
end
|
||||||
|
|
||||||
def jquery_include_tag
|
def jquery_include_tag
|
||||||
javascript_include_tag('//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js') +
|
javascript_include_tag('//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js') +
|
||||||
content_tag(:script) do
|
content_tag(:script) do
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,10 @@ HELP
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.bare_pod_uri
|
||||||
|
self[:pod_uri].authority.gsub('www.', '')
|
||||||
|
end
|
||||||
|
|
||||||
def self.normalize_admins
|
def self.normalize_admins
|
||||||
self[:admins] ||= []
|
self[:admins] ||= []
|
||||||
self[:admins].collect! { |username| username.downcase }
|
self[:admins].collect! { |username| username.downcase }
|
||||||
|
|
|
||||||
|
|
@ -377,10 +377,14 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def set_person(person)
|
def set_person(person)
|
||||||
person.url = AppConfig[:pod_url]
|
person.url = AppConfig[:pod_url]
|
||||||
person.diaspora_handle = "#{self.username}@#{AppConfig[:pod_uri].authority}"
|
person.diaspora_handle = "#{self.username}#{User.diaspora_id_host}"
|
||||||
self.person = person
|
self.person = person
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.diaspora_id_host
|
||||||
|
"@#{AppConfig.bare_pod_uri}"
|
||||||
|
end
|
||||||
|
|
||||||
def seed_aspects
|
def seed_aspects
|
||||||
self.aspects.create(:name => I18n.t('aspects.seed.family'))
|
self.aspects.create(:name => I18n.t('aspects.seed.family'))
|
||||||
self.aspects.create(:name => I18n.t('aspects.seed.friends'))
|
self.aspects.create(:name => I18n.t('aspects.seed.friends'))
|
||||||
|
|
@ -476,7 +480,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_person_with_same_username
|
def no_person_with_same_username
|
||||||
diaspora_id = "#{self.username}@#{AppConfig[:pod_uri].host}"
|
diaspora_id = "#{self.username}#{User.diaspora_id_host}"
|
||||||
if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
|
if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
|
||||||
errors[:base] << 'That username has already been taken'
|
errors[:base] << 'That username has already been taken'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
= t('username')
|
= t('username')
|
||||||
= f.text_field :username, :title => t('registrations.new.enter_username')
|
= f.text_field :username, :title => t('registrations.new.enter_username')
|
||||||
%span.host_uri
|
%span.host_uri
|
||||||
= "@#{AppConfig[:pod_uri].host}"
|
= diaspora_id_host
|
||||||
.clearfix
|
.clearfix
|
||||||
%b
|
%b
|
||||||
= t('email')
|
= t('email')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||||
<hm:Host><%= AppConfig[:pod_uri].authority %></hm:Host>
|
<hm:Host><%= AppConfig[:pod_bare_domain] %></hm:Host>
|
||||||
<Link rel='lrdd'
|
<Link rel='lrdd'
|
||||||
template='<%= AppConfig[:pod_url] %>webfinger?q={uri}'>
|
template='<%= AppConfig[:pod_url] %>webfinger?q={uri}'>
|
||||||
<Title>Resource Descriptor</Title>
|
<Title>Resource Descriptor</Title>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
= t('username')
|
= t('username')
|
||||||
= f.text_field :username, :title => t('registrations.new.enter_username')
|
= f.text_field :username, :title => t('registrations.new.enter_username')
|
||||||
%span.host_uri
|
%span.host_uri
|
||||||
= "@#{AppConfig[:pod_uri].host}"
|
= diaspora_id_host
|
||||||
.clearfix
|
.clearfix
|
||||||
%b
|
%b
|
||||||
= t('email')
|
= t('email')
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
.centered
|
.centered
|
||||||
= f.text_field :username
|
= f.text_field :username
|
||||||
%span.host_uri
|
%span.host_uri
|
||||||
= "@#{AppConfig[:pod_uri].host}"
|
= diaspora_id_host
|
||||||
.row
|
.row
|
||||||
.row
|
.row
|
||||||
= f.label :email, t('email')
|
= f.label :email, t('email')
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ Factory.define :user do |u|
|
||||||
user.person = Factory.build(:person, :profile => Factory.build(:profile),
|
user.person = Factory.build(:person, :profile => Factory.build(:profile),
|
||||||
:owner_id => user.id,
|
:owner_id => user.id,
|
||||||
:serialized_public_key => user.encryption_key.public_key.export,
|
:serialized_public_key => user.encryption_key.public_key.export,
|
||||||
:diaspora_handle => "#{user.username}@#{AppConfig[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
|
:diaspora_handle => "#{user.username}#{User.diaspora_id_host}")
|
||||||
end
|
end
|
||||||
u.after_create do |user|
|
u.after_create do |user|
|
||||||
user.person.save
|
user.person.save
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,14 @@ describe AppConfig do
|
||||||
AppConfig.normalize_pod_url
|
AppConfig.normalize_pod_url
|
||||||
AppConfig[:pod_url].should == "https://example.org/"
|
AppConfig[:pod_url].should == "https://example.org/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.bare_pod_uri' do
|
||||||
|
it 'is AppConfig[:pod_uri].authority stripping www.' do
|
||||||
|
AppConfig[:pod_url] = "https://www.example.org/"
|
||||||
|
AppConfig.bare_pod_uri.should == 'example.org'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".pod_uri" do
|
describe ".pod_uri" do
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,14 @@ describe Person do
|
||||||
new_person = User.build(:username => "foo123", :email => "foo123@example.com", :password => "password", :password_confirmation => "password").person
|
new_person = User.build(:username => "foo123", :email => "foo123@example.com", :password => "password", :password_confirmation => "password").person
|
||||||
new_person.diaspora_handle.should == "foo123@#{AppConfig[:pod_uri].authority}"
|
new_person.diaspora_handle.should == "foo123@#{AppConfig[:pod_uri].authority}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not include www if it is set in app config' do
|
||||||
|
old_url = AppConfig[:pod_url]
|
||||||
|
AppConfig[:pod_url] = 'https://www.foobar.com/'
|
||||||
|
new_person = User.build(:username => "foo123", :email => "foo123@example.com", :password => "password", :password_confirmation => "password").person
|
||||||
|
new_person.diaspora_handle.should == "foo123@foobar.com"
|
||||||
|
AppConfig[:pod_url] = old_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'remote people' do
|
context 'remote people' do
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'requires uniqueness also amount Person objects with diaspora handle' do
|
it 'requires uniqueness also amount Person objects with diaspora handle' do
|
||||||
p = Factory(:person, :diaspora_handle => "jimmy@#{AppConfig[:pod_uri].host}")
|
p = Factory(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}")
|
||||||
alice.username = 'jimmy'
|
alice.username = 'jimmy'
|
||||||
alice.should_not be_valid
|
alice.should_not be_valid
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue