remove template picker functionality
This commit is contained in:
parent
cfc247db75
commit
6c8c4fc99e
5 changed files with 0 additions and 121 deletions
|
|
@ -49,10 +49,6 @@ class Reshare < Post
|
||||||
self.root ? root.photos : []
|
self.root ? root.photos : []
|
||||||
end
|
end
|
||||||
|
|
||||||
def frame_name
|
|
||||||
self.root ? root.frame_name : nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def receive(recipient, sender)
|
def receive(recipient, sender)
|
||||||
local_reshare = Reshare.where(:guid => self.guid).first
|
local_reshare = Reshare.where(:guid => self.guid).first
|
||||||
if local_reshare && local_reshare.root.author_id == recipient.person.id
|
if local_reshare && local_reshare.root.author_id == recipient.person.id
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class PostPresenter
|
||||||
:open_graph_cache => @post.open_graph_cache.try(:as_api_response, :backbone),
|
:open_graph_cache => @post.open_graph_cache.try(:as_api_response, :backbone),
|
||||||
:mentioned_people => @post.mentioned_people.as_api_response(:backbone),
|
:mentioned_people => @post.mentioned_people.as_api_response(:backbone),
|
||||||
:photos => @post.photos.map {|p| p.as_api_response(:backbone)},
|
:photos => @post.photos.map {|p| p.as_api_response(:backbone)},
|
||||||
:frame_name => @post.frame_name || template_name,
|
|
||||||
:root => root,
|
:root => root,
|
||||||
:title => title,
|
:title => title,
|
||||||
:address => @post.address,
|
:address => @post.address,
|
||||||
|
|
@ -51,10 +50,6 @@ class PostPresenter
|
||||||
@post.text.present? ? post_page_title(@post) : I18n.translate('posts.presenter.title', :name => @post.author_name)
|
@post.text.present? ? post_page_title(@post) : I18n.translate('posts.presenter.title', :name => @post.author_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_name #kill me, lol, I should be client side
|
|
||||||
@template_name ||= TemplatePicker.new(@post).template_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def root
|
def root
|
||||||
PostPresenter.new(@post.absolute_root, current_user).as_json if @post.respond_to?(:absolute_root) && @post.absolute_root.present?
|
PostPresenter.new(@post.absolute_root, current_user).as_json if @post.respond_to?(:absolute_root) && @post.absolute_root.present?
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,5 @@ require 'pubsubhubbub'
|
||||||
require 'salmon'
|
require 'salmon'
|
||||||
require 'statistics'
|
require 'statistics'
|
||||||
require 'stream'
|
require 'stream'
|
||||||
require 'template_picker'
|
|
||||||
require 'webfinger'
|
require 'webfinger'
|
||||||
require 'webfinger_profile'
|
require 'webfinger_profile'
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
class TemplatePicker
|
|
||||||
attr_accessor :post
|
|
||||||
|
|
||||||
TEMPLATES = %w{ status_with_photo_backdrop
|
|
||||||
note
|
|
||||||
photo_backdrop
|
|
||||||
status
|
|
||||||
}
|
|
||||||
|
|
||||||
def initialize(post)
|
|
||||||
self.post = post
|
|
||||||
end
|
|
||||||
|
|
||||||
def template_name
|
|
||||||
TEMPLATES.each do |template|
|
|
||||||
return TemplatePicker.jsonify_name(template) if self.send("#{template}?".to_sym)
|
|
||||||
end
|
|
||||||
|
|
||||||
'status' #default
|
|
||||||
end
|
|
||||||
|
|
||||||
def status_with_photo_backdrop?
|
|
||||||
status? && photo_backdrop?
|
|
||||||
end
|
|
||||||
|
|
||||||
def note?
|
|
||||||
self.status? && post.text(:plain_text => true).length > 200
|
|
||||||
end
|
|
||||||
|
|
||||||
def photo_backdrop?
|
|
||||||
false # No backdrop, ever.
|
|
||||||
end
|
|
||||||
|
|
||||||
def status?
|
|
||||||
post.text?
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.jsonified_templates
|
|
||||||
TEMPLATES.map{|x| jsonify_name(x)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.jsonify_name(name)
|
|
||||||
name.gsub('_', '-')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe TemplatePicker do
|
|
||||||
before do
|
|
||||||
@post_stubs = {:type => 'StatusMessage', :photos => stub(:size => 2),
|
|
||||||
:o_embed_cache => stub(:present? => true),
|
|
||||||
:text? => true, :text => stub(:length => 400)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:post) {
|
|
||||||
stub(@post_stubs)
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'has a post' do
|
|
||||||
t = TemplatePicker.new(post)
|
|
||||||
t.post.should_not be_nil
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#template_name' do
|
|
||||||
it 'returns the coolest template if the post has lots of cool stuff' do
|
|
||||||
TemplatePicker.new(post).template_name.should_not be_nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#status_with_photo_backdrop?' do
|
|
||||||
it 'is false even if the post contains a single photo and text' do
|
|
||||||
@post_stubs.merge!(:photos => stub(:size => 1))
|
|
||||||
TemplatePicker.new(post).should_not be_status_with_photo_backdrop
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#note?' do
|
|
||||||
it 'is true if the post contains text more than 300 characters long' do
|
|
||||||
TemplatePicker.new(post).should be_note
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#photo_backdrop?' do
|
|
||||||
it 'is false even if the post contains only one photo' do
|
|
||||||
@post_stubs.merge!(:photos => stub(:size => 1))
|
|
||||||
TemplatePicker.new(post).should_not be_photo_backdrop
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#status?' do
|
|
||||||
it 'is true if the post contains text' do
|
|
||||||
TemplatePicker.new(post).should be_status
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'factories' do
|
|
||||||
# No photo_backdrop for now.
|
|
||||||
(TemplatePicker::TEMPLATES - ['status_with_photo_backdrop', 'photo_backdrop']).each do |template|
|
|
||||||
describe "#{template} factory" do
|
|
||||||
it 'works' do
|
|
||||||
post = FactoryGirl.build(template.to_sym, :author => alice.person)
|
|
||||||
template_name = TemplatePicker.new(post).template_name.gsub('-', '_')
|
|
||||||
template_name.should == template
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
Loading…
Reference in a new issue