2022-11-24 14:44:31 +01:00
|
|
|
module Cms
|
|
|
|
|
|
|
|
class ImageController < ApplicationController
|
|
|
|
|
|
|
|
@@root = "app/assets/images/cms/"
|
2022-11-24 21:28:56 +01:00
|
|
|
@@files = Set.new Dir.new(Rails.root + @@root).children
|
2022-11-24 14:44:31 +01:00
|
|
|
|
|
|
|
def index
|
|
|
|
@files = files
|
|
|
|
end
|
|
|
|
|
2022-11-24 21:28:56 +01:00
|
|
|
def new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
io = params['image_file']
|
|
|
|
ending = io.original_filename.split("/").last.split(".").last
|
|
|
|
filename = params['filename'] + "." + ending
|
|
|
|
File.open(Rails.root.join('app/assets/images/cms', filename), "wb") do |f|
|
|
|
|
f.write io.read
|
|
|
|
end
|
|
|
|
@@files << filename
|
|
|
|
redirect_to cms_image_index_path
|
|
|
|
end
|
|
|
|
|
2022-11-24 14:44:31 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def files
|
|
|
|
@@files
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|