diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index cf38e3087..ced6548c9 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -9,12 +9,22 @@ class StatusMessagesController < ApplicationController respond_to :json, :only => :show def create - puts params.inspect + + + @photos = Photo.all(:id.in => params[:photos]) + + puts @photos.inspect + + + + public_flag = params[:status_message][:public] public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag status_message = current_user.build_post(:status_message, params[:status_message]) + + status_message.photos += @photos if status_message.save(:safe => true) raise 'MongoMapper failed to catch a failed save' unless status_message.id current_user.dispatch_post(status_message, :to => params[:status_message][:to]) diff --git a/app/models/photo.rb b/app/models/photo.rb index 1e6ad021e..156cba8f7 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -82,7 +82,7 @@ class Photo < Post { :photo => { :id => self.id, - :url => self.url(:thumb_small) + :url => self.url(:thumb_medium) } } end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index d67bba6fb..ecaf49514 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -9,6 +9,7 @@ class StatusMessage < Post xml_accessor :message key :message, String + many :photos, :class => Photo validates_presence_of :message attr_accessible :message diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index d19f119c3..fd593b52a 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -12,13 +12,17 @@ debug: true, button: document.getElementById('file-upload'), sizeLimit: 5000048, + onSubmit: function(id, fileName){ + $('#file-upload').text("loading"); + }, + + onComplete: function(id, fileName, responseJSON){ - //var obj = jQuery.parseJSON(responseJSON.data); - alert(responseJSON.data.photo.url); + $('#file-upload').text("add photos"); var id = responseJSON.data.photo.id; - alert($('#new_status_message').length); + var url = responseJSON.data.photo.url; $('#new_status_message').append(""); - + $('#photodropzone').append("
  • "); } }); diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 67305d47b..ceae0ebba 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -15,25 +15,27 @@ // $("#publisher .options_and_submit").fadeIn(50); //}); - $("#publisher form").live("submit", function(evt){ - $("#publisher .options_and_submit").hide(); - }); + //$("#publisher form").live("submit", function(evt){ + //$("#publisher .options_and_submit").hide(); + //}); #publisher = owner_image_link = form_for StatusMessage.new, :html => {:multipart => true,}, :remote => true do |status| - + %ul#photodropzone = status.error_messages - %params - = status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? "everyone" : aspect)) - = status.text_area :message, :rows => 2, :value => params[:prefill] + #file-upload.button + add photos + + %p + %params + = status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? "everyone" : aspect)) + = status.text_area :message, :rows => 2, :value => params[:prefill] = status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id) .options_and_submit - #file-upload.button - drag a photo to upload - if aspect == :all = status.submit t('.share'), :title => t('.share_with_all'), :disable_with => t('.posting') - else @@ -54,5 +56,5 @@ .fancybox_content #question_mark_pane = render 'shared/public_explain' - #publisher_photo_upload - = render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id) + #publisher_photo_upload + = render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id) diff --git a/app/views/status_messages/_status_message.haml b/app/views/status_messages/_status_message.haml index 85fd62688..c50d4fdf5 100644 --- a/app/views/status_messages/_status_message.haml +++ b/app/views/status_messages/_status_message.haml @@ -3,3 +3,7 @@ -# the COPYRIGHT file. = markdownify(post.message) +%br +- for photo in post.photos + /= render 'photos/photo', :post => photo + = image_tag photo.url(:thumb_medium) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 7a03f19cc..2ca8b504f 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -29,6 +29,9 @@ a h1, h2, h3, h4 :color #444 +ol, ul + :list-style none + .hidden :display none @@ -720,6 +723,30 @@ label :text :shadow 0 1px 1px #eee +#file-upload + :z-index 5 + :float right + :height 34px + :width 70px + :margin 0 + :background + :color #107FC9 + + :-webkit-border-radius 0 5px 5px 0 + :-moz-border-radius 0 5px 5px 0 + :border-radius 0 5px 5px 0 + + :background -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(0,123,194)), color-stop(1, rgb(65,182,250))) + :background -moz-linear-gradient( center bottom, rgb(0,123,194) 0%, rgb(65,182,250) 100%) + + :padding 9px + + :font + :size 18px + :weight bold + :color #eee + :text-shadow 0 1px 0 #333 + #publisher :color #999 :position relative @@ -747,13 +774,20 @@ label :left 65px :top 0 + ul + >li + :display inline + :margin-right 2px + img + :border-radius 5px + + textarea :height 42px - :display block input[type='text'], textarea - :width 490px + :width 400px :margin 0 .options_and_submit