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
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
72
73
74
75
76
77
78
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 32
def show
ActiveSupport::Notifications.instrument("goldencobra.article.show", :params => params) before_init() params[:session] = session.except(:user_location)
Goldencobra::Article::LiquidParser["url_params"] = params
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)
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
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 17
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' : ''
offset = params[:start].present? ? "offset_#{params[:start].to_i}" : ""
limit = params[:limit].present? ? "limit_#{params[:limit].to_i}" : ""
generated_cache_key = "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}#{offset}#{limit}"
return Zlib.crc32(generated_cache_key).to_s
end
|
#sitemap ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 94
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
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'app/controllers/goldencobra/articles_controller.rb', line 80
def switch_language
if params[:locale].present?
I18n.locale = params[:locale]
session[:locale] = I18n.locale.to_s
else
I18n.locale = session[:locale]
end
if params[:redirect_to].present?
redirect_to params[:redirect_to]
else
redirect_to "/"
end
end
|