class Recommender::EntriesController < ApplicationController def initialize @no_index = true end def index @tag_cloud = TagCloud.language_tags(Language.locale_id) unless fragment_exist?({:controller => 'entries', :action => 'index', :language => Language.locale_id}) respond_to do |format| format.html { render :template => 'entries/index' } end end def browse_by_tags @tag_filter = params[:tags] @search = @tag_filter.join(' ') if (!@tag_filter.nil? && !@tag_filter.empty?) @tag_filter = @tag_filter.join('/') @tag_cloud = TagCloud.language_tags(Language.locale_id, @tag_filter) unless fragment_exist?({:controller => 'entries', :action => 'index', :language => Language.locale_id, :filter => @tag_filter}) _search(:and) respond_to do |format| format.html { render :template => 'entries/browse_by_tags' } end end def search @search = params[:q] _search respond_to do |format| format.html { render :template => 'entries/search' } end end def show @page_title = "Related Resources" @entry = Entry.find(params[:id], :include => :feed) if @entry.nil? render_text "Unable to find the specified document" return end @entry_title = @entry.title + " (" + @entry.feed.short_title + ")" # I18n.locale = @entry.language[0..1] @limit = params[:limit] ? params[:limit].to_i : 20 @limit = 40 if @limit > 40 respond_to do |format| format.html { if params[:details] == 'true' render :template => "entries/details" else render :template => "entries/show" end }# show.html.erb format.xml { render :xml => @entry } end end def track_clicks user_agent = request.env['HTTP_USER_AGENT'] redirect_to Entry.track_click(session, params[:id], request.env['HTTP_REFERER'], params[:target], request.env['HTTP_X_FORWARDED_FOR'], user_agent) if !/Googlebot/.match(user_agent) end def collections @feeds = Feed.find(:all, :order => "harvested_from_title, title") @languages = Language.find(:all, :order => "name") render :template => "documents/collections", :layout => "default" end protected def _search operator = :or @page = (params[:page] || 0).to_i @per_page = (params[:per_page] || 10).to_i @offset = @page*@per_page if !@search.nil? @term_list = URI.escape(@search) results = Entry.search(@search, I18n.locale.to_s, @per_page, @offset, operator) @hit_count = results.total @results = results.results @paginated_results = @results.paginate(:page => @page+1, :per_page => @per_page, :total_entries => @hit_count) end end end