kill rich-media type with fire
This commit is contained in:
parent
0960a090fa
commit
777c037e16
16 changed files with 59 additions and 104 deletions
14
app/assets/javascripts/app/helpers/o_embed.js
Normal file
14
app/assets/javascripts/app/helpers/o_embed.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
(function(){
|
||||||
|
app.helpers.oEmbed = {
|
||||||
|
html : function (o_embed_cache) {
|
||||||
|
if (!o_embed_cache) { return "" }
|
||||||
|
|
||||||
|
var data = o_embed_cache.data;
|
||||||
|
if (data.type == "photo") {
|
||||||
|
return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />'
|
||||||
|
} else {
|
||||||
|
return data.html || ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
@ -63,14 +63,5 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
||||||
"Night",
|
"Night",
|
||||||
"Wallpaper",
|
"Wallpaper",
|
||||||
"Newspaper"
|
"Newspaper"
|
||||||
],
|
|
||||||
|
|
||||||
legacyTemplateNames : [
|
|
||||||
"status-with-photo-backdrop",
|
|
||||||
"note",
|
|
||||||
"rich-media",
|
|
||||||
"photo-backdrop",
|
|
||||||
"activity-streams-photo",
|
|
||||||
"status"
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ app.views.framerControls = app.views.Base.extend({
|
||||||
|
|
||||||
presenter : function() {
|
presenter : function() {
|
||||||
var selectedFrame = this.model.get("frame_name")
|
var selectedFrame = this.model.get("frame_name")
|
||||||
, templates =_.union(app.models.Post.frameMoods, _.without(app.models.Post.legacyTemplateNames, ["status", "status-with-photo-backdrop", "photo-backdrop", "activity-streams-photo", "note"])) //subtract re-implemented templates
|
, templates = app.models.Post.frameMoods //subtract re-implemented templates
|
||||||
return _.extend(this.defaultPresenter(), {
|
return _.extend(this.defaultPresenter(), {
|
||||||
templates :_.map(templates, function(template) {
|
templates :_.map(templates, function(template) {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ app.views.CanvasFrame = app.views.SmallFrame.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
presenter : function(){
|
presenter : function(){
|
||||||
console.log(this.adjustedImageHeight())
|
|
||||||
return _.extend(this.smallFramePresenter(), {
|
return _.extend(this.smallFramePresenter(), {
|
||||||
adjustedImageHeight : this.adjustedImageHeight()
|
adjustedImageHeight : this.adjustedImageHeight()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -84,26 +84,14 @@ app.views.OEmbed = app.views.Base.extend({
|
||||||
|
|
||||||
presenter:function () {
|
presenter:function () {
|
||||||
return _.extend(this.defaultPresenter(), {
|
return _.extend(this.defaultPresenter(), {
|
||||||
o_embed_html:this.embedHTML()
|
o_embed_html : app.helpers.oEmbed.html(this.model.get("o_embed_cache"))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
embedHTML:function () {
|
|
||||||
if (!this.model.get("o_embed_cache")) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
var data = this.model.get("o_embed_cache").data;
|
|
||||||
if (data.type == "photo") {
|
|
||||||
return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />';
|
|
||||||
} else {
|
|
||||||
return data.html || ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
showOembedContent : function () {
|
showOembedContent : function () {
|
||||||
var insertHTML = $(this.embedHTML());
|
var insertHTML = $(app.helpers.oEmbed.html(this.model.get("o_embed_cache")));
|
||||||
var paramSeparator = ( /\?/.test(insertHTML.attr("src")) ) ? "&" : "?";
|
var paramSeparator = ( /\?/.test(insertHTML.attr("src")) ) ? "&" : "?";
|
||||||
insertHTML.attr("src", insertHTML.attr("src") + paramSeparator + "autoplay=1");
|
insertHTML.attr("src", insertHTML.attr("src") + paramSeparator + "autoplay=1");
|
||||||
this.$el.html(insertHTML);
|
this.$el.html(insertHTML);
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -21,7 +21,7 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
showFactory : function(model) {
|
showFactory : function(model) {
|
||||||
var frameName = model.get("frame_name");
|
var frameName = model.get("frame_name");
|
||||||
|
|
||||||
//translate obsolete template names to the new Moods, should be removed when template picker comes cliente side.
|
//translate obsolete template names to the new Moods, should be removed when template picker comes client side.
|
||||||
var map = {
|
var map = {
|
||||||
'status-with-photo-backdrop' : 'Wallpaper', //equivalent
|
'status-with-photo-backdrop' : 'Wallpaper', //equivalent
|
||||||
'status' : 'Day', //equivalent
|
'status' : 'Day', //equivalent
|
||||||
|
|
@ -31,13 +31,9 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
|
|
||||||
frameName = map[frameName] || frameName
|
frameName = map[frameName] || frameName
|
||||||
|
|
||||||
if(_.include(app.models.Post.legacyTemplateNames, frameName)){
|
|
||||||
return legacyShow(model)
|
|
||||||
} else {
|
|
||||||
return new app.views.Post[frameName]({
|
return new app.views.Post[frameName]({
|
||||||
model : model
|
model : model
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
function legacyShow(model) {
|
function legacyShow(model) {
|
||||||
return new app.views.Post.Legacy({
|
return new app.views.Post.Legacy({
|
||||||
|
|
|
||||||
|
|
@ -14,40 +14,6 @@ a { color : rgb(42,156,235) }
|
||||||
.icon-red { background-image: image_url("img/glyphicons-halflings-red.png"); }
|
.icon-red { background-image: image_url("img/glyphicons-halflings-red.png"); }
|
||||||
.icon-blue { background-image: image_url("img/glyphicons-halflings-blue.png"); }
|
.icon-blue { background-image: image_url("img/glyphicons-halflings-blue.png"); }
|
||||||
|
|
||||||
.rich-media {
|
|
||||||
background-color: $night-background-color;
|
|
||||||
|
|
||||||
p {
|
|
||||||
@include media-text();
|
|
||||||
color: #999;
|
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: smaller;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iframe {
|
|
||||||
@include box-shadow(0, 3px, 15px, #000);
|
|
||||||
|
|
||||||
width: 857px;
|
|
||||||
height: 480px;
|
|
||||||
max-width: 100%;
|
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.rich-media-container {
|
|
||||||
display: table;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rich-media-container2 {
|
|
||||||
display: table-cell;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
&.micro {
|
&.micro {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
|
@ -115,9 +81,17 @@ a { color : rgb(42,156,235) }
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
img {
|
img,
|
||||||
|
iframe {
|
||||||
@include photo-shadow();
|
@include photo-shadow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
width: 857px;
|
||||||
|
height: 480px;
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
article { //mood posts
|
article { //mood posts
|
||||||
|
|
|
||||||
|
|
@ -305,11 +305,6 @@
|
||||||
min-height : $two-row-height + px;
|
min-height : $two-row-height + px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.rich-media {
|
|
||||||
width: auto;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.wallpaper {
|
&.wallpaper {
|
||||||
.image-container {
|
.image-container {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
background-color : rgba(0,0,0,0.8);
|
background-color : rgba(0,0,0,0.8);
|
||||||
z-index : 200;
|
z-index : 200;
|
||||||
|
|
||||||
|
text-align : left;
|
||||||
|
|
||||||
position : absolute;
|
position : absolute;
|
||||||
left : 0;
|
left : 0;
|
||||||
top : 0;
|
top : 0;
|
||||||
|
|
@ -36,14 +38,8 @@
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
legend {
|
|
||||||
color : #fff;
|
|
||||||
text-align : left;
|
|
||||||
border : none;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea#post_text{
|
textarea#post_text{
|
||||||
height: 200px;
|
height: 100px;
|
||||||
padding : 10px;
|
padding : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<section class="photo_viewer"></section>
|
<section class="photo_viewer"></section>
|
||||||
|
|
||||||
|
<!--Temp hacks-->
|
||||||
|
{{#if o_embed_cache}}
|
||||||
|
{{#if o_embed_cache.data}}
|
||||||
|
{{{o_embed_cache.data.html}}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<header>{{{headline}}}</header>
|
<header>{{{headline}}}</header>
|
||||||
<section class="body">{{{body}}}</section>
|
<section class="body">{{{body}}}</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
<div class='span5'>
|
<h3 class="span8">
|
||||||
|
Make something!
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="span8 new_picture"/>
|
||||||
|
|
||||||
|
<div class='span8'>
|
||||||
<form class="new-post">
|
<form class="new-post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
|
||||||
Make Something!
|
|
||||||
</legend>
|
|
||||||
<textarea name="text" id='post_text' class="text span8" placeholder="Add Text">{{text}}</textarea>
|
<textarea name="text" id='post_text' class="text span8" placeholder="Add Text">{{text}}</textarea>
|
||||||
<textarea id="text_with_markup" style="display:none;"/>
|
<textarea id="text_with_markup" style="display:none;"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span3 new_picture"/>
|
|
||||||
|
|
|
||||||
8
db/migrate/20120521191429_remove_rich_media_type.rb
Normal file
8
db/migrate/20120521191429_remove_rich_media_type.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
class RemoveRichMediaType < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
execute("UPDATE posts SET frame_name='Night' WHERE frame_name='rich-media'")
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20120519015723) do
|
ActiveRecord::Schema.define(:version => 20120521191429) do
|
||||||
|
|
||||||
create_table "account_deletions", :force => true do |t|
|
create_table "account_deletions", :force => true do |t|
|
||||||
t.string "diaspora_handle"
|
t.string "diaspora_handle"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ class TemplatePicker
|
||||||
|
|
||||||
TEMPLATES = %w{ status_with_photo_backdrop
|
TEMPLATES = %w{ status_with_photo_backdrop
|
||||||
note
|
note
|
||||||
rich_media
|
|
||||||
photo_backdrop
|
photo_backdrop
|
||||||
activity_streams_photo
|
activity_streams_photo
|
||||||
status
|
status
|
||||||
|
|
@ -29,10 +28,6 @@ class TemplatePicker
|
||||||
self.status? && post.text(:plain_text => true).length > 200
|
self.status? && post.text(:plain_text => true).length > 200
|
||||||
end
|
end
|
||||||
|
|
||||||
def rich_media?
|
|
||||||
post.o_embed_cache.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def photo_backdrop?
|
def photo_backdrop?
|
||||||
post.photos.size == 1
|
post.photos.size == 1
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -215,9 +215,5 @@ FactoryGirl.define do
|
||||||
text SecureRandom.hex(1000)
|
text SecureRandom.hex(1000)
|
||||||
end
|
end
|
||||||
|
|
||||||
factory(:rich_media, :parent => :status_message) do
|
|
||||||
association(:o_embed_cache)
|
|
||||||
end
|
|
||||||
|
|
||||||
factory(:status, :parent => :status_message)
|
factory(:status, :parent => :status_message)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,6 @@ describe TemplatePicker do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#rich_media?' do
|
|
||||||
it 'is true if the post contains an o_embed object' do
|
|
||||||
TemplatePicker.new(post).should be_rich_media
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#photo_backdrop?' do
|
describe '#photo_backdrop?' do
|
||||||
it 'is true if the post contains only one photo' do
|
it 'is true if the post contains only one photo' do
|
||||||
@post_stubs.merge!(:photos => stub(:size => 1))
|
@post_stubs.merge!(:photos => stub(:size => 1))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue