MS DC You can has choose a template
This commit is contained in:
parent
11eb1eb7d8
commit
775eca0026
9 changed files with 25 additions and 17 deletions
|
|
@ -21,7 +21,7 @@ class StatusMessage < Post
|
||||||
# therefore, we put the validation in a before_destory callback instead of a validation
|
# therefore, we put the validation in a before_destory callback instead of a validation
|
||||||
before_destroy :presence_of_content
|
before_destroy :presence_of_content
|
||||||
|
|
||||||
attr_accessible :text, :provider_display_name
|
attr_accessible :text, :provider_display_name, :frame_name
|
||||||
attr_accessor :oembed_url
|
attr_accessor :oembed_url
|
||||||
|
|
||||||
after_create :create_mentions
|
after_create :create_mentions
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class PostPresenter
|
||||||
:reshares => self.reshares,
|
:reshares => self.reshares,
|
||||||
:comments => self.comments,
|
:comments => self.comments,
|
||||||
:participations => self.participations,
|
:participations => self.participations,
|
||||||
:templateName => template_name,
|
:frame_name => self.post.frame_name || template_name,
|
||||||
:title => title
|
:title => title
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
5
db/migrate/20120322223517_add_template_name_to_posts.rb
Normal file
5
db/migrate/20120322223517_add_template_name_to_posts.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddTemplateNameToPosts < ActiveRecord::Migration
|
||||||
|
def change # thanks josh susser
|
||||||
|
add_column :posts, :frame_name, :string
|
||||||
|
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 => 20120301143226) do
|
ActiveRecord::Schema.define(:version => 20120322223517) 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"
|
||||||
|
|
@ -334,6 +334,7 @@ ActiveRecord::Schema.define(:version => 20120301143226) do
|
||||||
t.integer "o_embed_cache_id"
|
t.integer "o_embed_cache_id"
|
||||||
t.integer "reshares_count", :default => 0
|
t.integer "reshares_count", :default => 0
|
||||||
t.datetime "interacted_at"
|
t.datetime "interacted_at"
|
||||||
|
t.string "frame_name"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "posts", ["author_id", "root_guid"], :name => "index_posts_on_author_id_and_root_guid", :unique => true
|
add_index "posts", ["author_id", "root_guid"], :name => "index_posts_on_author_id_and_root_guid", :unique => true
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ app.pages.Framer = app.views.Base.extend({
|
||||||
postView : function(){
|
postView : function(){
|
||||||
//we might be leaky like cray cray with this
|
//we might be leaky like cray cray with this
|
||||||
|
|
||||||
var templateType = this.model.get("templateName")
|
var templateType = this.model.get("frame_name")
|
||||||
|
|
||||||
this._postView = new app.views.Post({
|
this._postView = new app.views.Post({
|
||||||
model : this.model,
|
model : this.model,
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,13 @@ app.pages.PostViewer = app.views.Base.extend({
|
||||||
this.authorView = new app.views.PostViewerAuthor({ model : this.model });
|
this.authorView = new app.views.PostViewerAuthor({ model : this.model });
|
||||||
this.interactionsView = new app.views.PostViewerInteractions({ model : this.model });
|
this.interactionsView = new app.views.PostViewerInteractions({ model : this.model });
|
||||||
this.navView = new app.views.PostViewerNav({ model : this.model });
|
this.navView = new app.views.PostViewerNav({ model : this.model });
|
||||||
|
|
||||||
|
var frameName = this.model.get("frame_name")
|
||||||
this.postView = new app.views.Post({
|
this.postView = new app.views.Post({
|
||||||
model : this.model,
|
model : this.model,
|
||||||
className : this.model.get("templateName") + " post loaded",
|
className : frameName + " post loaded",
|
||||||
templateName : "post-viewer/content/" + this.model.get("templateName"),
|
templateName : "post-viewer/content/" + frameName,
|
||||||
attributes : {"data-template" : this.model.get("templateName")}
|
attributes : {"data-template" : frameName}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ app.views.TemplatePicker = app.views.Base.extend({
|
||||||
templateName : "template-picker",
|
templateName : "template-picker",
|
||||||
|
|
||||||
initialize : function(){
|
initialize : function(){
|
||||||
this.model.set({templateName : 'status'})
|
this.model.set({frame_name : 'status'})
|
||||||
},
|
},
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
|
|
@ -10,11 +10,11 @@ app.views.TemplatePicker = app.views.Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
postRenderTemplate : function(){
|
postRenderTemplate : function(){
|
||||||
this.$("select[name=template]").val(this.model.get("templateName"))
|
this.$("select[name=template]").val(this.model.get("frame_name"))
|
||||||
},
|
},
|
||||||
|
|
||||||
setModelTemplate : function(evt){
|
setModelTemplate : function(evt){
|
||||||
this.model.set({"templateName": this.$("select[name=template]").val()})
|
this.model.set({"frame_name": this.$("select[name=template]").val()})
|
||||||
},
|
},
|
||||||
|
|
||||||
presenter : function() {
|
presenter : function() {
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ describe StatusMessagesController do
|
||||||
{ :status_message => {
|
{ :status_message => {
|
||||||
:public => "true",
|
:public => "true",
|
||||||
:text => "facebook, is that you?",
|
:text => "facebook, is that you?",
|
||||||
},
|
},
|
||||||
:aspect_ids => [@aspect1.id.to_s] }
|
:aspect_ids => [@aspect1.id.to_s] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
describe("app.views.TemplatePicker", function(){
|
describe("app.views.TemplatePicker", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.model = factory.statusMessage({templateName: undefined})
|
this.model = factory.statusMessage({frame_name: undefined})
|
||||||
this.view = new app.views.TemplatePicker({model : this.model })
|
this.view = new app.views.TemplatePicker({model : this.model })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("initialization", function(){
|
describe("initialization", function(){
|
||||||
it("sets the post_type of the model to 'status' by default", function(){
|
it("sets the frame_name of the model to 'status' by default", function(){
|
||||||
expect(this.view.model.get("templateName")).toBe("status")
|
expect(this.view.model.get("frame_name")).toBe("status")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -15,14 +15,14 @@ describe("app.views.TemplatePicker", function(){
|
||||||
this.view.render()
|
this.view.render()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("selects the model's templateName from the dropdown", function(){
|
it("selects the model's frame_name from the dropdown", function(){
|
||||||
expect(this.view.$("select[name=template]").val()).toBe("status")
|
expect(this.view.$("select[name=template]").val()).toBe("status")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("changes the templateName on the model when is is selected", function(){
|
it("changes the frame_name on the model when is is selected", function(){
|
||||||
this.view.$("select[name=template]").val("note")
|
this.view.$("select[name=template]").val("note")
|
||||||
this.view.$("select[name=template]").trigger("change")
|
this.view.$("select[name=template]").trigger("change")
|
||||||
expect(this.model.get("templateName")).toBe('note')
|
expect(this.model.get("frame_name")).toBe('note')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Loading…
Reference in a new issue