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
|
def text
|
||||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||||
Diaspora::Camo::from_markdown(self[:text])
|
Diaspora::Camo.from_markdown(self[:text])
|
||||||
else
|
else
|
||||||
self[:text]
|
self[:text]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class OpenGraphCache < ActiveRecord::Base
|
||||||
|
|
||||||
def image
|
def image
|
||||||
if AppConfig.privacy.camo.proxy_opengraph_thumbnails?
|
if AppConfig.privacy.camo.proxy_opengraph_thumbnails?
|
||||||
Diaspora::Camo::image_url(self[:image])
|
Diaspora::Camo.image_url(self[:image])
|
||||||
else
|
else
|
||||||
self[:image]
|
self[:image]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class Photo < ActiveRecord::Base
|
||||||
name = name.to_s + '_' if name
|
name = name.to_s + '_' if name
|
||||||
image_url = remote_photo_path + name.to_s + remote_photo_name
|
image_url = remote_photo_path + name.to_s + remote_photo_name
|
||||||
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
||||||
Diaspora::Camo::image_url(image_url)
|
Diaspora::Camo.image_url(image_url)
|
||||||
else
|
else
|
||||||
image_url
|
image_url
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class Profile < ActiveRecord::Base
|
||||||
ActionController::Base.helpers.image_path('user/default.png')
|
ActionController::Base.helpers.image_path('user/default.png')
|
||||||
else
|
else
|
||||||
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
if AppConfig.privacy.camo.proxy_remote_pod_images?
|
||||||
Diaspora::Camo::image_url(result)
|
Diaspora::Camo.image_url(result)
|
||||||
else
|
else
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
@ -144,7 +144,7 @@ class Profile < ActiveRecord::Base
|
||||||
|
|
||||||
def bio
|
def bio
|
||||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||||
Diaspora::Camo::from_markdown(self[:bio])
|
Diaspora::Camo.from_markdown(self[:bio])
|
||||||
else
|
else
|
||||||
self[:bio]
|
self[:bio]
|
||||||
end
|
end
|
||||||
|
|
@ -152,7 +152,7 @@ class Profile < ActiveRecord::Base
|
||||||
|
|
||||||
def location
|
def location
|
||||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
if AppConfig.privacy.camo.proxy_markdown_images?
|
||||||
Diaspora::Camo::from_markdown(self[:location])
|
Diaspora::Camo.from_markdown(self[:location])
|
||||||
else
|
else
|
||||||
self[:location]
|
self[:location]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,15 @@ class PostPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
|
text = if @post.message
|
||||||
|
@post.message.plain_text_for_json
|
||||||
|
else
|
||||||
|
@post.raw_message
|
||||||
|
end
|
||||||
{
|
{
|
||||||
:id => @post.id,
|
:id => @post.id,
|
||||||
:guid => @post.guid,
|
:guid => @post.guid,
|
||||||
:text => @post.message.plain_text_for_json,
|
:text => text,
|
||||||
:public => @post.public,
|
:public => @post.public,
|
||||||
:created_at => @post.created_at,
|
:created_at => @post.created_at,
|
||||||
:interacted_at => @post.interacted_at,
|
:interacted_at => @post.interacted_at,
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ configuration: ## Section
|
||||||
#proxy_remote_pod_images: true
|
#proxy_remote_pod_images: true
|
||||||
|
|
||||||
## Root of your Camo installation
|
## Root of your Camo installation
|
||||||
#root: "https://camo.example.com/"
|
#root: "https://example.com/camo/"
|
||||||
|
|
||||||
## Shared key of your Camo installation
|
## Shared key of your Camo installation
|
||||||
#key: "example123example456example!"
|
#key: "example123example456example!"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ module Diaspora
|
||||||
)
|
)
|
||||||
|
|
||||||
encoded_url = url.to_enum(:each_byte).map {|byte| '%02x' % byte}.join
|
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
|
end
|
||||||
|
|
||||||
def self.url_eligible?(url)
|
def self.url_eligible?(url)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def camo_urls
|
def camo_urls
|
||||||
@message = Diaspora::Camo::from_markdown(@message)
|
@message = Diaspora::Camo.from_markdown(@message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,35 +16,35 @@ describe Diaspora::Camo do
|
||||||
describe '#image_url' do
|
describe '#image_url' do
|
||||||
it 'should not rewrite local URLs' do
|
it 'should not rewrite local URLs' do
|
||||||
local_image = AppConfig.environment.url + 'kitten.jpg'
|
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
|
end
|
||||||
|
|
||||||
it 'should not rewrite relative URLs' do
|
it 'should not rewrite relative URLs' do
|
||||||
relative_image = '/kitten.jpg'
|
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
|
end
|
||||||
|
|
||||||
it 'should not rewrite already camo-fied URLs' do
|
it 'should not rewrite already camo-fied URLs' do
|
||||||
camo_image = AppConfig.privacy.camo.root + '1234/56789abcd'
|
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
|
end
|
||||||
|
|
||||||
it 'should rewrite external URLs' do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#from_markdown' do
|
describe '#from_markdown' do
|
||||||
it 'should rewrite plain markdown images' 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
|
end
|
||||||
|
|
||||||
it 'should rewrite markdown images with alt texts' do
|
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
|
end
|
||||||
|
|
||||||
it 'should rewrite markdown images with title texts' do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue