Class: Virgo::Admin::ImagesController
Instance Method Summary
collapse
#authorize_admin_user, #search, #set_is_admin_view
#render_content, #with_format
#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 15
def create
@image = Image.new(image_params.merge(user: current_user))
if @image.save
flash[:notice] = "Image uploaded successfully"
redirect_to edit_admin_image_path(@image)
else
render :new
end
end
|
#destroy ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 38
def destroy
@image.destroy
flash[:notice] = "Image successfully deleted"
redirect_to admin_images_path
end
|
#edit ⇒ Object
26
27
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 26
def edit
end
|
#embed ⇒ Object
62
63
64
65
66
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 62
def embed
render json: {
html: compact_html(Shortcode.process(render_to_string(partial: "/virgo/images/shortcode", locals: {image: @image})))
}
end
|
#index ⇒ Object
7
8
9
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 7
def index
@images = Image.all.search(filter_params).order(sort_order).page(params[:page]).per(40)
end
|
#new ⇒ Object
11
12
13
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 11
def new
@image = Image.new
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 29
def update
if @image.update(image_params)
flash[:notice] = "Image properties updated successfully"
redirect_to edit_admin_image_path(@image)
else
render :new
end
end
|
#upload ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/virgo/admin/images_controller.rb', line 46
def upload
@image = Image.new
file = params[:file]
@image.image = UploadHelpers::Http.normalize_param(file, request)
@image.user = current_user
if @image.save
render :text => { :filelink => @image.image.url }.to_json
else
render json: { error: @image.errors }
end
end
|