Controlador para la parte pública de las noticias.
Devuelve un archivo zip con todas las fotos o vídeos del documento
# File app/controllers/news_controller.rb, line 84 def compress @news = News.published.find(params[:id]) @w = params[:w] || 'photos' if @news.send("zip_#{@w}") send_file(@news.send("zip_#{@w}_file")) else flash[:error] = t('documents.error_zip') redirect_to news_url(:id => @news.id) end end
RSS para las noticias de cada departamento
# File app/controllers/news_controller.rb, line 106 def department @department = Department.find(params[:id]) @feed_title = t('documents.feed_title', :name => @department.name) organization_ids = [@department.id] + @department.organization_ids @documents = News.published.translated.find :all, :conditions => "organization_id in (#{organization_ids.join(',')})", :order => 'published_at DESC', :limit => 10 respond_to :rss end
Devuelve una imagen de una noticia, generando el tamaño solicitado por el camino si este no existe ya
# File app/controllers/news_controller.rb, line 96 def image if params[:path].present? && params[:size].present? file_to_send = get_or_generate_desired_image(params[:path], params[:size]) send_file(file_to_send, :type => 'image/jpeg', :disposition => 'inline') else render :nothing => true end end
# File app/controllers/news_controller.rb, line 29 def index prepare_news(@context, request.xhr?) respond_to do |format| format.html do if request.xhr? render :partial => '/shared/list_items', :locals => {:items => @news, :type => 'news'}, :layout => false else render end end format.rss do @feed_title = t('documents.feed_title', :name => @context ? @context.name : t('site_name')) render :layout => false end end end
Vista de una noticia
# File app/controllers/news_controller.rb, line 54 def show begin @document = News.published.find(params[:id]) rescue ActiveRecord::RecordNotFound if can_edit?("news") @document = News.find(params[:id]) else raise ActiveRecord::RecordNotFound end end @title = @document.title # @parent = @document @comments = @document.comments.approved.paginate :page => params[:page], :per_page => 25 # Mostramos todos los vídeos de la noticia get_news_videos_and_photos(@document) @videos_mpg = @document.videos_mpg respond_to do |format| format.html { render } format.xml format.iphone { render } format.android { render } format.floki { render } end end
# File app/controllers/news_controller.rb, line 47 def summary @leading_news = News.featured_a @secondary_news = News.featured_4b render :layout => !request.xhr? end