added the uploading photo wjava script
This commit is contained in:
parent
66f66b85a6
commit
36abb19e2c
5 changed files with 43 additions and 10 deletions
|
|
@ -3,12 +3,9 @@ class PhotosController < ApplicationController
|
|||
|
||||
def create
|
||||
begin
|
||||
@photo = Photo.instantiate(params[:photo])
|
||||
@photo = Photo.instantiate(params)
|
||||
@photo.person = current_user
|
||||
|
||||
|
||||
|
||||
|
||||
if @photo.save
|
||||
flash[:notice] = "Successfully uploaded photo."
|
||||
redirect_to @photo.album
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class Photo < Post
|
|||
validates_presence_of :album
|
||||
|
||||
def self.instantiate params = {}
|
||||
image_file = params[:image]
|
||||
params.delete :image
|
||||
image_file = params[:user_file][0]
|
||||
params.delete :user_file
|
||||
photo = Photo.new(params)
|
||||
photo.image.store! image_file
|
||||
photo
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
%div.time
|
||||
= link_to(how_long_ago(post), object_path(post))
|
||||
%div.image_cycle
|
||||
- for photo in post.photos
|
||||
- for photo in post.photos[0..3]
|
||||
= image_tag photo.image.url(:thumb_large)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
= javascript_include_tag 'satisfaction' , 'satisfaction-display'
|
||||
|
||||
= javascript_include_tag 'jquery.html5_upload'
|
||||
|
||||
%body
|
||||
%header
|
||||
.container
|
||||
|
|
@ -53,7 +55,7 @@
|
|||
.span-18.append-3.last
|
||||
= yield
|
||||
.span-3.last
|
||||
= link_to (person_image_tag(current_user), root_path)
|
||||
= link_to(person_image_tag(current_user), root_path)
|
||||
= link_to "Edit your profile", edit_user_path(current_user)
|
||||
%br
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -1,8 +1,42 @@
|
|||
:javascript
|
||||
$(function() {
|
||||
$("#photo_image").html5_upload({
|
||||
// WE INSERT ALBUM_ID PARAM HERE
|
||||
url: "/photos?album_id=#{album.id}",
|
||||
sendBoundary: window.FormData || $.browser.mozilla,
|
||||
onStart: function(event, total) {
|
||||
return confirm("You are trying to upload " + total + " files. Are you sure?");
|
||||
},
|
||||
setName: function(text) {
|
||||
$("#progress_report_name").text(text);
|
||||
},
|
||||
setStatus: function(text) {
|
||||
$("#progress_report_status").text(text);
|
||||
},
|
||||
setProgress: function(val) {
|
||||
$("#progress_report_bar").css('width', Math.ceil(val*100)+"%");
|
||||
},
|
||||
onFinishOne: function(event, response, name, number, total) {
|
||||
//alert(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
= form_for photo, :html => {:multipart => true} do |f|
|
||||
= f.error_messages
|
||||
|
||||
= f.hidden_field :album_id, :value => album.id
|
||||
|
||||
%p
|
||||
= f.file_field :image
|
||||
= f.submit 'post it!', :class => 'button'
|
||||
= f.file_field :image, :multiple => 'multiple'
|
||||
|
||||
#progress_report
|
||||
#progress_report_name
|
||||
#progress_report_status{ :style => "font-style: italic;" }
|
||||
#progress_report_bar_container{ :style => "width: 90%; height: 5px;" }
|
||||
#progress_report_bar{ :style => "background-color: blue; width: 0; height: 100%;" }
|
||||
|
||||
/= f.submit 'post it!', :class => 'button'
|
||||
|
|
|
|||
Loading…
Reference in a new issue