annotate app/controllers/previews_controller.rb @ 1478:5ca1f4a47171 bibplugin_db_migrations

Close obsolete branch bibplugin_db_migrations
author Chris Cannam
date Fri, 30 Nov 2012 14:40:50 +0000
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@441 1 # Redmine - project management software
Chris@441 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@441 3 #
Chris@441 4 # This program is free software; you can redistribute it and/or
Chris@441 5 # modify it under the terms of the GNU General Public License
Chris@441 6 # as published by the Free Software Foundation; either version 2
Chris@441 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@441 9 # This program is distributed in the hope that it will be useful,
Chris@441 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@441 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@441 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@441 14 # You should have received a copy of the GNU General Public License
Chris@441 15 # along with this program; if not, write to the Free Software
Chris@441 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@441 17
Chris@14 18 class PreviewsController < ApplicationController
Chris@14 19 before_filter :find_project
Chris@14 20
Chris@14 21 def issue
Chris@14 22 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
Chris@14 23 if @issue
Chris@14 24 @attachements = @issue.attachments
Chris@14 25 @description = params[:issue] && params[:issue][:description]
Chris@14 26 if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
Chris@14 27 @description = nil
Chris@14 28 end
Chris@14 29 @notes = params[:notes]
Chris@14 30 else
Chris@14 31 @description = (params[:issue] ? params[:issue][:description] : nil)
Chris@14 32 end
Chris@14 33 render :layout => false
Chris@14 34 end
Chris@14 35
chris@37 36 def news
chris@37 37 @text = (params[:news] ? params[:news][:description] : nil)
chris@37 38 render :partial => 'common/preview'
chris@37 39 end
chris@37 40
Chris@14 41 private
Chris@909 42
Chris@14 43 def find_project
Chris@14 44 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
Chris@14 45 @project = Project.find(project_id)
Chris@14 46 rescue ActiveRecord::RecordNotFound
Chris@14 47 render_404
Chris@14 48 end
Chris@909 49
Chris@14 50 end