Method calling convention and doc improvements
... and a stealth-commit of an already introduced bug prevention system. ;)
This commit is contained in:
parent
fd63fca7d5
commit
6808150920
9 changed files with 22 additions and 17 deletions
|
|
@ -85,7 +85,7 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
def text
|
||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||
Diaspora::Camo::from_markdown(self[:text])
|
||||
Diaspora::Camo.from_markdown(self[:text])
|
||||
else
|
||||
self[:text]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class OpenGraphCache < ActiveRecord::Base
|
|||
|
||||
def image
|
||||
if AppConfig.privacy.camo.proxy_opengraph_thumbnails?
|
||||
Diaspora::Camo::image_url(self[:image])
|
||||
Diaspora::Camo.image_url(self[:image])
|
||||
else
|
||||
self[:image]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class Photo < ActiveRecord::Base
|
|||
name = name.to_s + '_' if name
|
||||
image_url = remote_photo_path + name.to_s + remote_photo_name
|
||||
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
||||
Diaspora::Camo::image_url(image_url)
|
||||
Diaspora::Camo.image_url(image_url)
|
||||
else
|
||||
image_url
|
||||
end
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class Profile < ActiveRecord::Base
|
|||
ActionController::Base.helpers.image_path('user/default.png')
|
||||
else
|
||||
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
||||
Diaspora::Camo::image_url(result)
|
||||
Diaspora::Camo.image_url(result)
|
||||
else
|
||||
result
|
||||
end
|
||||
|
|
@ -144,7 +144,7 @@ class Profile < ActiveRecord::Base
|
|||
|
||||
def bio
|
||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||
Diaspora::Camo::from_markdown(self[:bio])
|
||||
Diaspora::Camo.from_markdown(self[:bio])
|
||||
else
|
||||
self[:bio]
|
||||
end
|
||||
|
|
@ -152,7 +152,7 @@ class Profile < ActiveRecord::Base
|
|||
|
||||
def location
|
||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||
Diaspora::Camo::from_markdown(self[:location])
|
||||
Diaspora::Camo.from_markdown(self[:location])
|
||||
else
|
||||
self[:location]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,10 +13,15 @@ class PostPresenter
|
|||
end
|
||||
|
||||
def as_json(options={})
|
||||
text = if @post.message
|
||||
@post.message.plain_text_for_json
|
||||
else
|
||||
@post.raw_message
|
||||
end
|
||||
{
|
||||
:id => @post.id,
|
||||
:guid => @post.guid,
|
||||
:text => @post.message.plain_text_for_json,
|
||||
:text => text,
|
||||
:public => @post.public,
|
||||
:created_at => @post.created_at,
|
||||
:interacted_at => @post.interacted_at,
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ configuration: ## Section
|
|||
#proxy_remote_pod_images: true
|
||||
|
||||
## Root of your Camo installation
|
||||
#root: "https://camo.example.com/"
|
||||
#root: "https://example.com/camo/"
|
||||
|
||||
## Shared key of your Camo installation
|
||||
#key: "example123example456example!"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module Diaspora
|
|||
)
|
||||
|
||||
encoded_url = url.to_enum(:each_byte).map {|byte| '%02x' % byte}.join
|
||||
"#{AppConfig.privacy.camo.root}#{digest}/#{encoded_url}"
|
||||
File.join(AppConfig.privacy.camo.root, digest, encoded_url)
|
||||
end
|
||||
|
||||
def self.url_eligible?(url)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ module Diaspora
|
|||
end
|
||||
|
||||
def camo_urls
|
||||
@message = Diaspora::Camo::from_markdown(@message)
|
||||
@message = Diaspora::Camo.from_markdown(@message)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,35 +16,35 @@ describe Diaspora::Camo do
|
|||
describe '#image_url' do
|
||||
it 'should not rewrite local URLs' do
|
||||
local_image = AppConfig.environment.url + 'kitten.jpg'
|
||||
expect(Diaspora::Camo::image_url(local_image)).to eq(local_image)
|
||||
expect(Diaspora::Camo.image_url(local_image)).to eq(local_image)
|
||||
end
|
||||
|
||||
it 'should not rewrite relative URLs' do
|
||||
relative_image = '/kitten.jpg'
|
||||
expect(Diaspora::Camo::image_url(relative_image)).to eq(relative_image)
|
||||
expect(Diaspora::Camo.image_url(relative_image)).to eq(relative_image)
|
||||
end
|
||||
|
||||
it 'should not rewrite already camo-fied URLs' do
|
||||
camo_image = AppConfig.privacy.camo.root + '1234/56789abcd'
|
||||
expect(Diaspora::Camo::image_url(camo_image)).to eq(camo_image)
|
||||
expect(Diaspora::Camo.image_url(camo_image)).to eq(camo_image)
|
||||
end
|
||||
|
||||
it 'should rewrite external URLs' do
|
||||
expect(Diaspora::Camo::image_url(@raw_image_url)).to eq(@camo_image_url)
|
||||
expect(Diaspora::Camo.image_url(@raw_image_url)).to eq(@camo_image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#from_markdown' do
|
||||
it 'should rewrite plain markdown images' do
|
||||
expect(Diaspora::Camo::from_markdown("")).to include(@camo_image_url)
|
||||
expect(Diaspora::Camo.from_markdown("")).to include(@camo_image_url)
|
||||
end
|
||||
|
||||
it 'should rewrite markdown images with alt texts' do
|
||||
expect(Diaspora::Camo::from_markdown("")).to include(@camo_image_url)
|
||||
expect(Diaspora::Camo.from_markdown("")).to include(@camo_image_url)
|
||||
end
|
||||
|
||||
it 'should rewrite markdown images with title texts' do
|
||||
expect(Diaspora::Camo::from_markdown(" \"title\"")).to include(@camo_image_url)
|
||||
expect(Diaspora::Camo.from_markdown(" \"title\"")).to include(@camo_image_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue