class PostImageManager

A singleton class for managing all image attachments for a post

Attributes

downloaded_images[R]
root_dir[RW]
uploaders[R]

Public Class Methods

new() click to toggle source

The constructor for PostImageManager which initializes the array of Carrierware image uploaders to use when submiting a post and the array of downloaded images

# File lib/models/post_image_manager.rb, line 19
def initialize
  @uploaders = []
  @downloaded_images = []
  @root_dir = ''
end

Public Instance Methods

add_downloaded_image(downloaded_image) click to toggle source

Adds an image that was downloaded from the Jekyll website repo

Params:

downloaded_image

A PostImage object representing the downloaded image

# File lib/models/post_image_manager.rb, line 42
def add_downloaded_image(downloaded_image)
  # @downloaded_images << downloaded_image
end
add_file(file) click to toggle source

Adds an image to be uploaded in a Jekyll website post

Params:

file

A ActionDispatch::Http::UploadedFile object containing the file to be used in a post

# File lib/models/post_image_manager.rb, line 30
def add_file(file)
  # uploader_to_add = PostImageUploader.new
  # uploader_to_add.cache!(file)
  # @uploaders.delete_if { |x| x.filename == file.original_filename }
  # @uploaders << uploader_to_add
end
clear() click to toggle source

Clears the manager of all currently exisiting image uploaders and delete's their cache directories. Also clears the manager of all of the downloaded images

# File lib/models/post_image_manager.rb, line 49
def clear
  # @uploaders.each do |uploader|
  #   full_preview_path = "#{@root_dir}/public/uploads/tmp/#{uploader.preview.cache_name}"
  #   cache_dir = File.expand_path('..', full_preview_path)
  #   uploader.remove!
  #   Dir.delete(cache_dir)
  # end

  # @uploaders.clear
  # @downloaded_images.clear
end