Skip to content

Commit

Permalink
enabled album art uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
drtoast committed Mar 5, 2011
1 parent 359be96 commit d4d543a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def upload_cover
@album.cover = nil
file = params[:file]
ext = File.extname(file.original_filename)[1..-1]
@album.add_cover(file.local_path, ext)
@album.add_cover(file.path, ext, false) # TODO: segfault when processing thumbnail in mongrel
logger.info "*** FILE: #{file.original_filename}, #{file.path}, #{file.inspect}"
if @album.save
# TODO: ajax upload doesn't work
Expand Down
8 changes: 5 additions & 3 deletions app/models/album.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ def extract_cover(replace_cover=true)
end

# resize and attach the image at the raw path
def add_cover(original, format=nil)
def add_cover(original, format=nil, thumb=true)
processor = Toastunes::ImageProcessor.new
full_path = processor.save_cover(id, original, format)
thumbnail_path = processor.write_thumbnail(id, full_path)
self.cover = File.basename(full_path)
self.thumbnail = File.basename(thumbnail_path)
if thumb
thumbnail_path = processor.write_thumbnail(id, full_path)
self.thumbnail = File.basename(thumbnail_path)
end
end

def download_cover(url)
Expand Down
1 change: 1 addition & 0 deletions app/views/albums/_album_art.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
.error= error
- if album.cover_download_at
.error= "Last checked on #{album.cover_download_at.strftime("%m/%d/%Y")}"
= render :partial => "album_cover_upload", :locals => {:album => album}
.clear

0 comments on commit d4d543a

Please sign in to comment.