Class: MainController
- Inherits:
-
ApplicationController
show all
- Defined in:
- app/controllers/main_controller.rb
Overview
COPYRIGHT:
Copyright (c) 2005-2009 North Carolina State University
Developed with funding for the National eXtension Initiative.
LICENSE:
BSD(-compatible)
see LICENSE file or view at http://about.extension.org/wiki/LICENSE
Instance Method Summary
(collapse)
#content_date_sort, #do_404, #do_410, #do_invalid_page, #get_county_options, #get_location_options, #mobile_detection, #set_analytics_visitor, #set_app_location, #set_default_request_ip_address, #set_locale, #set_request_url_options, #unescape_params
#check_openidurl_foruser, #log_user_activity, #validate_datepicker
Methods included from AuthLib
#current_person, #set_current_person
Instance Method Details
- (Object) category_tag
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
|
# File 'app/controllers/main_controller.rb', line 33
def category_tag
if(!@community.nil?)
return redirect_to site_index_url(:content_tag => content_tag_url_display_name(params[:content_tag])), :status=>301
elsif(redirect = CategoryTagRedirect.where("term = ?",params[:content_tag].downcase).first)
return redirect_to(redirect.target_url, :status=>301)
elsif(!canonicalized_category?(params[:content_tag]))
return redirect_to category_tag_index_url(:content_tag => content_tag_url_display_name(params[:content_tag])), :status=>301
end
if(!@content_tag.nil?)
set_title("Content tagged with:", @content_tag.name.titleize)
set_titletag("Content tagged with '#{@content_tag.name}' - eXtension")
@youth = true if @content_tag.name == 'youth'
@right_column = true
else
set_title("All Content")
set_titletag("All Content - eXtension")
end
if(@content_tag.nil?)
@news = Page.recent_content({:datatypes => ['News'], :limit => 3})
@recent_learning_lessons = Page.main_lessons_list({:limit => 3})
@faqs = Page.recent_content({:datatypes => ['Faq'], :limit => 3})
@articles = Page.ordered(Page.orderings['Newest to oldest']).limit(3)
else
@canonical_link = category_tag_index_url(:content_tag => @content_tag.url_display_name)
@news = Page.recent_content({:datatypes => ['News'], :content_tag => @content_tag, :limit => 3})
@recent_learning_lessons = Page.main_lessons_list({:content_tag => @content_tag, :limit => 3})
@faqs = Page.recent_content({:datatypes => ['Faq'], :content_tags => [@content_tag], :limit => 3})
@newsicles = Page.recent_content({:datatypes => ['Article','News'], :content_tags => [@content_tag], :limit => 8}) unless @community
@recent_newsicles= Page.recent_content({:datatypes => ['Article','News'], :content_tags => [@content_tag], :limit => 3}) unless @in_this_section
end
return render(:template => 'main/category_landing')
end
|
- (Object) communities
132
133
134
135
136
137
138
139
140
141
|
# File 'app/controllers/main_controller.rb', line 132
def communities
@published_content = true
@canonical_link = main_communities_url
@right_column = false
@special_page = SpecialPage.find_by_path('communities')
@page = @special_page.page
set_title(@special_page.main_heading, @special_page.sub_heading)
set_titletag(@special_page.titletag)
@communities = PublishingCommunity.launched.ordered_by_topic
end
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'app/controllers/main_controller.rb', line 74
def
@published_content = true
if(@community.nil?)
if(redirect = CategoryTagRedirect.where("term = ?",params[:content_tag].downcase).first)
return redirect_to(redirect.target_url, :status=>301)
else
return redirect_to category_tag_index_url(:content_tag => content_tag_url_display_name(params[:content_tag])), :status=>301
end
elsif(!canonicalized_category?(params[:content_tag]))
return redirect_to site_index_url(:content_tag => content_tag_url_display_name(params[:content_tag])), :status=>301
end
if(@community and @community.aae_group_id.present?)
@ask_two_point_oh_form = "#{@community.ask_an_expert_group_url}/ask"
else
@ask_two_point_oh_form = AppConfig.configtable['ask_two_point_oh_form']
end
set_title(@community.public_name,@community.public_description)
set_titletag("#{@community.public_name} - eXtension")
@canonical_link = site_index_url(:content_tag => @content_tag.url_display_name)
= @community.content_tag_names
@sponsors = Sponsor.tagged_with_any_content_tags().prioritized
@in_this_section = Page.contents_for_content_tag({:content_tag => @content_tag})
@community_highlights = Page.main_feature_list({:content_tag => @content_tag, :limit => 8})
@youth = true if @topic and @topic.name == 'Youth'
flash.now[:googleanalytics] = "/" + @content_tag.name.gsub(' ','_')
flash.now[:googleanalyticsresourcearea] = @content_tag.name.gsub(' ','_')
@news = Page.recent_content({:datatypes => ['News'], :content_tag => @content_tag, :limit => 3})
@recent_learning_lessons = Page.main_lessons_list({:content_tag => @content_tag, :limit => 3})
@faqs = Page.recent_content({:datatypes => ['Faq'], :content_tags => [@content_tag], :limit => 3})
@newsicles = Page.recent_content({:datatypes => ['Article','News'], :content_tags => [@content_tag], :limit => 8}) unless @community
@recent_newsicles= Page.recent_content({:datatypes => ['Article','News'], :content_tags => [@content_tag], :limit => 3}) unless @in_this_section
return render(:template => 'main/community_landing')
end
|
- (Object) index
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/main_controller.rb', line 13
def index
@published_content = true
set_title('Objective. Research-based. Credible. Information and tools you can use every day to improve your life.')
set_titletag('eXtension - Objective. Research-based. Credible.')
@right_column = false
@sitehome = true
@includejquery = true
= Sponsor.all
@sponsors = Hash.new
Sponsor::SPONSORSHIP_LEVELS.each{ |level| @sponsors[level] = Array.new}
.each{ || @sponsors[.level] << if .level}
@community_highlights = Page.diverse_feature_list({:limit => 6})
@recent_content = Page.recent_content({:datatypes => ['Article','Faq','News'], :limit => 10})
@ask_two_point_oh_form = AppConfig.configtable['ask_two_point_oh_form']
end
|
- (Object) legacy_events_redirect
115
116
117
118
119
120
121
122
123
|
# File 'app/controllers/main_controller.rb', line 115
def legacy_events_redirect
if(@content_tag)
redirect_params = {:content_tag => @content_tag.url_display_name, :year => params[:year], :month => params[:month], :event_state => params[:event_state]}
else
redirect_params = {:content_tag => 'all', :year => params[:year], :month => params[:month], :event_state => params[:event_state]}
end
return redirect_to site_events_url(redirect_params), :status=>301
end
|
- (Object) search
125
126
127
128
129
130
|
# File 'app/controllers/main_controller.rb', line 125
def search
@right_column = false
@ask_two_point_oh_form = AppConfig.configtable['ask_two_point_oh_form']
set_title("Search results")
set_titletag("eXtension - Search results")
end
|
- (Object) set_institution
200
201
202
203
204
205
206
207
|
# File 'app/controllers/main_controller.rb', line 200
def set_institution
if(institution = BrandingInstitution.find_by_id(params[:institution_id]))
session[:branding_institution_id] = institution.id
session[:location_and_county] = {:location_id => institution.location.id}
session[:multistate] = nil
end
request.env["HTTP_REFERER"] ? (redirect_to :back) : (redirect_to home_url)
end
|
- (Object) show_institution_list
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'app/controllers/main_controller.rb', line 158
def show_institution_list
if params[:zip_or_state]
if params[:zip_or_state].to_i > 0
state = to_state(params[:zip_or_state].to_i)
else
state = params[:zip_or_state].upcase
end
if(!(location = Location.find_by_abbreviation(state)))
render(:update) do |page|
page.replace_html "logo", :partial => "shared/no_institution"
end
return
else
branding_institutions_for_location = location.branding_institutions
if(!branding_institutions_for_location.blank?)
if(branding_institutions_for_location.length == 1)
@personal[:institution] = branding_institutions_for_location[0]
@personal[:location] = location
session[:location_and_county] = {:location_id => location.id}
session[:branding_institution_id] = @personal[:institution].id.to_s
session[:multistate] = nil
render(:update) do |page|
page.replace_html "logo", :partial => "shared/logo"
end
return
else
render(:update) do |page|
page.replace_html "logo", :partial => "shared/multistate", :locals => {:institutions => branding_institutions_for_location}
end
return
end
else
render(:update) do |page|
page.replace_html "logo", :partial => "shared/no_institution"
end
return
end
end
end
render :nothing => true
end
|
- (Object) special
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'app/controllers/main_controller.rb', line 143
def special
path = params[:path]
if(!path or !@special_page = SpecialPage.find_by_path(path))
return do_404
end
@published_content = true
@canonical_link = main_special_url(:path => @special_page.path)
@right_column = false
@page = @special_page.page
set_title(@special_page.main_heading, @special_page.sub_heading)
set_titletag(@special_page.titletag)
end
|