Class: Goldencobra::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/goldencobra/application_controller.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object (private)

Catcher for undefined Goldencobra Callback Hooks



73
74
75
76
77
# File 'app/controllers/goldencobra/application_controller.rb', line 73

def method_missing(meth, *args)
  unless [:before_init, :before_render, :after_init, :after_index].include?(meth.to_sym)
    super
  end
end

Instance Method Details

#after_sign_in_path_for(resource_or_scope) ⇒ Object



17
18
19
# File 'app/controllers/goldencobra/application_controller.rb', line 17

def (resource_or_scope)
  request.referrer
end

#after_sign_out_path_for(resource_or_scope) ⇒ Object



13
14
15
# File 'app/controllers/goldencobra/application_controller.rb', line 13

def after_sign_out_path_for(resource_or_scope)
  request.referrer
end

#initialize_article(current_article) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/goldencobra/application_controller.rb', line 35

def initialize_article(current_article)
  Goldencobra::Article::LiquidParser["current_article"] = current_article

  meta_tags = {
    :site => s('goldencobra.page.default_title_tag'),
    :title => current_article.metatag("Title Tag").present? ? current_article.metatag("Title Tag") : current_article.title,
    :reverse => true,
    :description => current_article.metatag("Meta Description"),
    :keywords => current_article.metatag("Keywords"),
    :open_graph => {
      :title => current_article.metatag("OpenGraph Title"),
      :description => current_article.metatag("OpenGraph Description"),
      :type => current_article.metatag("OpenGraph Type"),
      :url => current_article.metatag("OpenGraph URL"),
      :image => current_article.metatag("OpenGraph Image")
    }
  }

  if current_article.robots_no_index
    # with noindex for meta name="robots"
    meta_tags[:noindex] = current_article.robots_no_index
  end

  if current_article.canonical_url.present?
    # with an canonical_url for rel="canonical"
    meta_tags[:canonical] = current_article.canonical_url
  else
    d = Goldencobra::Domain.main
    if d.present? && @current_client.present? && @current_client.id != d.id
      meta_tags[:canonical] = "http://#{d.hostname}#{current_article.public_url}"
    end
  end

  set_meta_tags meta_tags
end

#s(name) ⇒ Object



29
30
31
32
33
# File 'app/controllers/goldencobra/application_controller.rb', line 29

def s(name)
  if name.present?
    Goldencobra::Setting.for_key(name)
  end
end

#set_localeObject



7
8
9
10
11
# File 'app/controllers/goldencobra/application_controller.rb', line 7

def set_locale
  unless Rails.env == "test"
    I18n.locale = params[:locale] || session[:locale]
  end
end