Class: Virgo::Admin::MediaModalController

Inherits:
BaseController show all
Defined in:
app/controllers/virgo/admin/media_modal_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_admin_user, #search, #set_is_admin_view

Methods included from RenderHelper

#render_content, #with_format

Methods included from Virgo::ApplicationHelper

#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

#image_settingsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/virgo/admin/media_modal_controller.rb', line 44

def image_settings
  if request.get?
    render json: {
      html: render_content(partial: 'image_settings')
    }
  elsif request.patch?
    if @image.update(image_params)
      render json: {
        status: :success,
        image: @image,
        caption: caption_param,
        credit: @image.credit,
        html: compact_html(Shortcode.process(render_to_string(partial: "/virgo/images/shortcode", locals: {image: @image})))
      }
    else
      render json: {
        status: :err,
        html: render_content(partial: 'image_settings')
      }
    end
  end
end

#indexObject



9
10
11
12
13
# File 'app/controllers/virgo/admin/media_modal_controller.rb', line 9

def index
  render json: {
    html: render_content(layout: false)
  }
end

#library_panelObject



15
16
17
18
19
20
# File 'app/controllers/virgo/admin/media_modal_controller.rb', line 15

def library_panel
  render json: {
    html: render_content(partial: 'library_panel'),
    is_last_page: last_page?
  }
end

#upload_panelObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/virgo/admin/media_modal_controller.rb', line 22

def upload_panel
  if request.post?
    @image = Image.new(image_params.merge(user: current_user))

    if @image.save
      render json: {
        status: 'upload_success',
        html: render_content(partial: 'upload_success'),
        image: @image,
        img_url: @image.image.url(:content),
        image_html: compact_html(Shortcode.process(render_to_string(partial: "/virgo/images/shortcode", locals: {image: @image})))
      } and return
    end
  else
    @image = Image.new
  end

  render json: {
    html: render_content(partial: 'upload_panel')
  }
end