To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / controllers / previews_controller.rb @ 1298:4f746d8966dd

History | View | Annotate | Download (1.91 KB)

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