Commit 89c1fd5f authored by Jonne Haß's avatar Jonne Haß

query the set url only through #pod_uri in the app

parent 2a4db54d
......@@ -21,7 +21,7 @@ module ApplicationHelper
end
def raw_bookmarklet( height = 250, width = 620)
"javascript:(function(){f='#{AppConfig.environment.url}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
"javascript:(function(){f='#{AppConfig.pod_uri.to_s}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end
def magic_bookmarklet_link
......
......@@ -99,9 +99,7 @@ class Photo < ActiveRecord::Base
def update_remote_path
unless self.unprocessed_image.url.match(/^https?:\/\//)
pod_url = AppConfig.environment.url.get.dup
pod_url.chop! if pod_url[-1,1] == '/'
remote_path = "#{pod_url}#{self.unprocessed_image.url}"
remote_path = "#{AppConfig.pod_uri.to_s.chomp("/")}#{self.unprocessed_image.url}"
else
remote_path = self.unprocessed_image.url
end
......
......@@ -185,8 +185,6 @@ class Profile < ActiveRecord::Base
end
def absolutify_local_url url
pod_url = AppConfig.environment.url.get
pod_url.chop! if pod_url[-1,1] == '/'
"#{pod_url}#{url}"
"#{AppConfig.pod_uri.to_s.chomp("/")}#{url}"
end
end
......@@ -23,7 +23,7 @@ class Services::Facebook < Service
end
def create_open_graph_params(post)
{:post => "#{AppConfig.environment.url}#{short_post_path(post)}", :access_token => self.access_token}
{:post => "#{AppConfig.pod_uri.to_s}#{short_post_path(post)}", :access_token => self.access_token}
end
def create_post_params(post)
......
......@@ -395,7 +395,7 @@ class User < ActiveRecord::Base
end
def set_person(person)
person.url = AppConfig.environment.url
person.url = AppConfig.pod_uri.to_s
person.diaspora_handle = "#{self.username}#{User.diaspora_id_host}"
self.person = person
end
......
......@@ -15,7 +15,7 @@ class OEmbedPresenter
def as_json(opts={})
{
:provider_name => "Diaspora",
:provider_url => AppConfig.environment.url,
:provider_url => AppConfig.pod_uri.to_s,
:type => 'rich',
:version => '1.0',
:title => post_title,
......
......@@ -28,7 +28,7 @@
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
<tr>
<td style="text-align:center;padding:30px;">
<img src="<%=AppConfig.environment.url %>assets/branding/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
<img src="<%=AppConfig.pod_uri.to_s %>assets/branding/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
</td>
</tr>
</table>
......
......@@ -5,6 +5,6 @@
<Link rel='lrdd'
type='application/xrd+xml'
template='<%= AppConfig.environment.url %>webfinger?q={uri}' />
template='<%= AppConfig.pod_uri.to_s %>webfinger?q={uri}' />
</XRD>
......@@ -74,7 +74,7 @@
= t('aspects.index.donate')
.content
- if AppConfig.settings.paypal_hosted_button_id.present?
= t('aspects.index.keep_pod_running', :pod => URI.parse(AppConfig.environment.url).host)
= t('aspects.index.keep_pod_running', :pod => AppConfig.pod_uri.host)
%br
= render 'shared/donatepod'
- else
......
......@@ -8,7 +8,7 @@ atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
:id => "#{@user.public_url}.atom",
:root_url => "#{@user.public_url}"}) do |feed|
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig.environment.url}"
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig.pod_uri.to_s}"
feed.title "#{@user.name}'s Public Feed"
feed.subtitle "Updates from #{@user.name} on Diaspora"
feed.logo "#{@user.image_url(:thumb_small)}"
......
......@@ -70,7 +70,7 @@ namespace :db do
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
Person.where(:url => 'example.org').all.each{|person|
if person.owner
person.url = AppConfig.environment.url
person.url = AppConfig.pod_uri.to_s
person.diaspora_handle = person.owner.diaspora_handle
person.save
end
......
......@@ -28,7 +28,7 @@ FactoryGirl.define do
factory :person do
sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@example.net" }
sequence(:url) { |n| AppConfig.environment.url.get }
url AppConfig.pod_uri.to_s
serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export
after(:build) do |person|
person.profile = FactoryGirl.build(:profile, :person => person) unless person.profile.first_name.present?
......
......@@ -10,11 +10,36 @@ describe Configuration::Methods do
end
describe "#pod_uri" do
before do
@settings.environment.url = nil
@settings.instance_variable_set(:@pod_uri, nil)
end
it "properly parses the pod url" do
@settings.environment.url = "http://example.org/"
@settings.pod_uri.scheme.should == "http"
@settings.pod_uri.host.should == "example.org"
end
it "adds a trailing slash if there isn't one" do
@settings.environment.url = "http://example.org"
@settings.pod_uri.to_s.should == "http://example.org/"
end
it "does not add an extra trailing slash" do
@settings.environment.url = "http://example.org/"
@settings.pod_uri.to_s.should == "http://example.org/"
end
it "adds http:// on the front if it's missing" do
@settings.environment.url = "example.org/"
@settings.pod_uri.to_s.should == "http://example.org/"
end
it "does not add a prefix if there already is https:// on the front" do
@settings.environment.url = "https://example.org/"
@settings.pod_uri.to_s.should == "https://example.org/"
end
end
describe "#bare_pod_uri" do
......
......@@ -132,11 +132,9 @@ describe Person do
end
it 'does not include www if it is set in app config' do
old_url = AppConfig.environment.url.get
AppConfig.environment.url = 'https://www.foobar.com/'
AppConfig.stub(:pod_uri).and_return(Addressable::URI.parse('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.environment.url = old_url
end
end
......
......@@ -116,7 +116,7 @@ describe Profile do
before do
@profile = FactoryGirl.build(:profile)
@profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
@pod_url = (AppConfig.environment.url.get[-1,1] == '/' ? AppConfig.environment.url.chop : AppConfig.environment.url)
@pod_url = AppConfig.pod_uri.to_s.chomp("/")
end
it 'ignores an empty string' do
......
class User
include Rails.application.routes.url_helpers
def default_url_options
{:host => AppConfig.environment.url}
{:host => AppConfig.pod_uri.host}
end
alias_method :share_with_original, :share_with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment