diff options
Diffstat (limited to 'app/controllers/general_controller.rb')
| -rw-r--r-- | app/controllers/general_controller.rb | 49 | 
1 files changed, 4 insertions, 45 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index beefef4e6..b01a67027 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -12,56 +12,15 @@ class GeneralController < ApplicationController      # New, improved front page!      def frontpage          medium_cache -        # get some example searches and public bodies to display -        # either from config, or based on a (slow!) query if not set -        body_short_names = AlaveteliConfiguration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ")          @locale = self.locale_from_params() -        locale_condition = 'public_body_translations.locale = ?' -        conditions = [locale_condition, @locale] -        I18n.with_locale(@locale) do -            if body_short_names.empty? -                # This is too slow -                @popular_bodies = PublicBody.visible.find(:all, -                    :order => "info_requests_count desc", -                    :limit => 32, -                    :conditions => conditions, -                    :joins => :translations -                ) -            else -                conditions[0] += " and public_bodies.url_name in (" + body_short_names + ")" -                @popular_bodies = PublicBody.find(:all, -                     :conditions => conditions, -                     :joins => :translations) -            end -        end -        # Get some successful requests -        begin -            query = 'variety:response (status:successful OR status:partially_successful)' -            sortby = "newest" -            max_count = 5 -            xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count) -            @request_events = xapian_object.results.map { |r| r[:model] } - -            # If there are not yet enough successful requests, fill out the list with -            # other requests -            if @request_events.count < max_count -                @request_events_all_successful = false -                query = 'variety:sent' -                xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count) -                more_events = xapian_object.results.map { |r| r[:model] } -                @request_events += more_events -                # Overall we still want the list sorted with the newest first -                @request_events.sort!{|e1,e2| e2.created_at <=> e1.created_at} -            else -                @request_events_all_successful = true -            end -        rescue -            @request_events = [] -        end      end      # Display blog entries      def blog +        if AlaveteliConfiguration::blog_feed.empty? +            raise ActiveRecord::RecordNotFound.new("Page not enabled") +        end +          medium_cache          @feed_autodetect = []          @feed_url = AlaveteliConfiguration::blog_feed  | 
