Class: LogoController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logo_controller.rb

Overview

COPYRIGHT:

Copyright (c) 2005-2009 North Carolina State University
Developed with funding for the National eXtension Initiative.

LICENSE:

see LICENSE file

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#content_date_sort, #do_404, #do_410, #get_county_options, #get_location_options, #set_app_location, #set_default_request_ip_address, #set_locale, #set_request_url_options, #unescape_params

Methods included from AuthLib

#current_person, #set_current_person

Instance Method Details

- (Object) display



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/logo_controller.rb', line 10

def display
  begin
    @logo = Logo.find_by_filename(params[:file].to_s + "." + params[:format].to_s)
    @logo = Logo.find(params[:file]) unless @logo
    if(@logo.nil?)
      send_data(data, :filename => "unknown.gif", :type => "image/gif", :disposition => 'inline')
    else
      show_thumbnail = (params[:thumb] == "true")
      respond_to do |format|
        format.html { render :action => 'show', :layout => false }
        format.xml  { render :xml => @logo.to_xml }
        format.jpg  { send_data(@logo.image_data(show_thumbnail),
                                :type  => @logo.content_type,
                                :filename => @logo.filename,
                                :disposition => 'inline') }
        format.gif  { send_data(@logo.image_data(show_thumbnail),
                                :type  => @logo.content_type,
                                :filename => @logo.filename,
                                :disposition => 'inline') }
        format.png  { send_data(@logo.image_data(show_thumbnail),
                                :type  => @logo.content_type,
                                :filename => @logo.filename,
                                :disposition => 'inline') }
      end
    end
  rescue Exception => err
    file = Rails.root.join("app","assets","images","loading.gif")
    data = File.open(file, 'r').read
    send_data(data, :filename => "unknown.gif", :type => "image/gif", :disposition => 'inline')
  end
end