Class: Goldencobra::ArticlesController
Instance Method Summary
collapse
#after_sign_in_path_for, #after_sign_out_path_for, #initialize_article, #s, #set_locale
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Goldencobra::ApplicationController
Instance Method Details
#show ⇒ Object
26
27
28
29
30
31
32
33
34
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
70
71
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 26
def show
ActiveSupport::Notifications.instrument("goldencobra.article.show", :params => params) before_init() if serve_iframe?
respond_to do |format|
format.html { render layout: "/goldencobra/bare_layout" }
end
elsif serve_basic_article?
initialize_article(@article)
Goldencobra::Article.load_liquid_methods(location: session[:user_location], article: @article, params: params)
Goldencobra::Article::LiquidParser["url_params"] = params
load_associated_model_into_liquid() if can_load_associated_model?
after_init()
if generate_index_list?
current_operator = current_user || current_visitor
@list_of_articles = @article.index_articles(current_operator,params[:frontend_tags])
after_index()
end
if serve_fresh_page?
set_expires_in()
ActiveSupport::Notifications.instrument("goldencobra.article.render", :params => params)
before_render()
respond_to do |format|
format.html { render layout: choose_layout() }
format.
format.json do
@article["list_of_articles"] = @list_of_articles
render json: @article.to_json
end
end
end
elsif should_statically_redirect?
redirect_to @article.external_url_redirect
elsif should_dynamically_redirect?
redirect_dynamically()
else
if @unauthorized
redirect_to_401()
else
redirect_to_404()
end
end
end
|
#show_cache_path ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 14
def show_cache_path
current_client_id = @current_client.try(:id).to_s
geo_cache = Goldencobra::Setting.for_key("goldencobra.geocode_ip_address") == "true" && session[:user_location].present? && session[:user_location].city.present? ? session[:user_location].city.parameterize.underscore : "no_geo"
date_cache = Goldencobra::Setting.for_key("goldencobra.article.max_cache_24h") == "true" ? Date.today.strftime("%Y%m%d") : "no_date"
art_cache = @article ? @article.cache_key : "no_art"
user_cache = current_user.present? ? current_user.id : "no_user"
flash_message = session.present? && session['flash'].present? ? Time.now.to_i : ""
auth_code = params[:auth_token].present? ? 'with_auth' : ''
"c-#{current_client_id}/g/#{I18n.locale.to_s}/#{geo_cache}/#{user_cache}/#{date_cache}/#{params[:article_id]}/#{art_cache}_#{params[:pdf]}_#{params[:frontend_tags]}__#{params[:iframe]}#{flash_message}_#{auth_code}"
end
|
#sitemap ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 83
def sitemap
if Goldencobra::Setting.for_key("goldencobra.use_ssl") == "true"
@use_ssl = "s"
else
@use_ssl = ""
end
@domain_name = Goldencobra::Setting.for_key("goldencobra.url")
@articles = Goldencobra::Article.for_sitemap
respond_to do |format|
format.xml
end
end
|
#switch_language ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 73
def switch_language
I18n.locale = params[:locale] || session[:locale]
session[:locale] = I18n.locale
if params[:redirect_to].present?
redirect_to params[:redirect_to]
else
redirect_to "/"
end
end
|