Class: Caboose::FontsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_delete, #admin_edit, #admin_json, #admin_json_single, #before_action, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #under_construction_or_forwarding_domain?, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in

Instance Method Details

#admin_indexObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/caboose/fonts_controller.rb', line 6

def admin_index
  @hf = Font.where(:site_id => @site.id, :name => "heading-font").last
  if !@hf then @hf = Font.create(:site_id => @site.id, :name => "heading-font", :family => "Open Sans", :variant => "600", :url => "http://fonts.gstatic.com/s/opensans/v13/MTP_ySUJH_bn48VBG8sNSi3USBnSvpkopQaUR-2r7iU.ttf") end
  @bf = Font.where(:site_id => @site.id, :name => "body-font").last
  if !@bf then @bf = Font.create(:site_id => @site.id, :name => "body-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
  @bfb = Font.where(:site_id => @site.id, :name => "body-font-bold").last
  if !@bfb then @bfb = Font.create(:site_id => @site.id, :name => "body-font-bold", :family => "Open Sans", :variant => "600", :url => "http://fonts.gstatic.com/s/opensans/v13/MTP_ySUJH_bn48VBG8sNSi3USBnSvpkopQaUR-2r7iU.ttf") end
  @bfi = Font.where(:site_id => @site.id, :name => "body-font-italic").last
  if !@bfi then @bfi = Font.create(:site_id => @site.id, :name => "body-font-italic", :family => "Open Sans", :variant => "italic", :url => "http://fonts.gstatic.com/s/opensans/v13/O4NhV7_qs9r9seTo7fnsVKCWcynf_cDxXwCLxiixG1c.ttf") end
  @bfbi = Font.where(:site_id => @site.id, :name => "body-font-bold-italic").last
  if !@bfbi then @bfbi = Font.create(:site_id => @site.id, :name => "body-font-bold-italic", :family => "Open Sans", :variant => "600italic", :url => "http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxpZ7xm-Bj30Bj2KNdXDzSZg.ttf") end
  @btn = Font.where(:site_id => @site.id, :name => "button-font").last
  if !@btn then @btn = Font.create(:site_id => @site.id, :name => "button-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
end

#admin_updateObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/caboose/fonts_controller.rb', line 22

def admin_update
  resp = StdClass.new
  family = params[:family]
  name = params[:name]
  url = params[:url]
  variant = params[:variant]

  if !family.blank? && !name.blank? && !url.blank? && !variant.blank?
    font = Font.where(:site_id => @site.id, :name => name).last
    if font
      font.family = family
      font.url = url
      font.variant = variant
      font.save
      resp.success = "Font saved!"
    else
      resp.error = "Font doesn't exist yet"
    end
  else
    resp.error = "Error saving font"
  end
  render :json => resp

end