Class: ImagesController

Inherits:
KitController show all
Defined in:
app/controllers/images_controller.rb

Constant Summary

Constants inherited from KitController

KitController::Pagebase

Instance Attribute Summary

Attributes inherited from KitController

#is_image_request, #kit_request, #layout_being_used, #requested_url, #template_being_used

Instance Method Summary collapse

Methods inherited from KitController

#anti_spam_okay?, #app_name, #can_moderate, #can_use, #captcha_okay?, #check_and_record_goal, #check_user, #csv_headers, #dif, #edit_page_path, #feature?, #get_asset, #get_view_content, #host_name, #index_name, #info_page_path, #kit_layout_in_use, #kit_render, #kit_session, #kit_session_end, #link_to, #mailchimp_connect, #mobile_template, #no_read, #no_write, #not_found, #not_found_404, #offline, #page_path, #pref, #rails_app_name, #render, #render_error, #render_page, #render_page_by_url, #routing_error, #sanity_check_okay?, #session_id, #set_requested_url, #show_form, #stylesheets, #super_render, #user_sees_menu?

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/images_controller.rb', line 9

def create
  add_sid(:image)
  @image = Asset.new(params[:image])
  unless current_user
    page_id = get_page_id_from_referer
    @image.tags = "##{page_id}"
  end
  @image.save
  logger.debug "Sending image #{@image.url}"
  respond_with @image
end

#destroyObject



21
22
23
24
25
26
# File 'app/controllers/images_controller.rb', line 21

def destroy
  can_use
  @image = Asset.find_sys_id(_sid, params[:id])
  @image.destroy
  respond_with @image
end

#indexObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/images_controller.rb', line 37

def index
  if params[:search]
    search = params[:search][:search]
    @images = Asset.wild_search(search, _sid)
  else
    @images = Asset
  end
  params[:page_id] ||= -1 # precent any funny business
  @images = @images.where("tags like '%#demo%' or tags like '%#trial-#{params[:page_id]}%'") unless current_user
  @images = @images.order("updated_at desc").sys(_sid)
  @images = @images.where(:is_image=>1) unless params[:files] 
  @images = @images.page(params[:page]).per((Preference.get_cached(_sid, "image_browser_per_page") || "10").to_i)
  render :layout=>"minimal"
end

#media_modalObject



5
6
7
# File 'app/controllers/images_controller.rb', line 5

def media_modal
  
end

#updateObject



28
29
30
31
32
33
34
35
# File 'app/controllers/images_controller.rb', line 28

def update
  can_use
  @image = Asset.sys(_sid).where(:id=>params[:id]).first
  @image.update_attributes(params[:asset])
  respond_to do |format|
    format.json { respond_with_bip(@image) }
  end
end