2019-03-16 09:37:35 +00:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 01:32:57 +00:00
|
|
|
|
2011-03-28 21:45:30 +00:00
|
|
|
# Redmine - project management software
|
2024-02-26 22:55:54 +00:00
|
|
|
# Copyright (C) 2006- Jean-Philippe Lang
|
2011-03-28 21:45:30 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-08-30 14:13:09 +00:00
|
|
|
#
|
2011-03-28 21:45:30 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2011-08-30 14:13:09 +00:00
|
|
|
#
|
2011-03-28 21:45:30 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
2010-08-18 15:01:35 +00:00
|
|
|
class PreviewsController < ApplicationController
|
2019-06-06 14:47:34 +00:00
|
|
|
before_action :find_project, :except => :text
|
2018-09-26 07:27:30 +00:00
|
|
|
before_action :find_attachments
|
2010-08-18 15:01:35 +00:00
|
|
|
|
|
|
|
|
def issue
|
2018-09-26 07:27:30 +00:00
|
|
|
@issue = Issue.visible.find_by_id(params[:issue_id]) unless params[:issue_id].blank?
|
2010-08-18 15:01:35 +00:00
|
|
|
if @issue
|
2018-09-26 07:27:30 +00:00
|
|
|
@previewed = @issue
|
2010-08-18 15:01:35 +00:00
|
|
|
end
|
2025-04-11 09:21:17 +00:00
|
|
|
@text = params[:text] || nil
|
2018-09-26 07:27:30 +00:00
|
|
|
render :partial => 'common/preview'
|
2010-08-18 15:01:35 +00:00
|
|
|
end
|
|
|
|
|
|
2010-09-24 16:26:46 +00:00
|
|
|
def news
|
2012-09-16 14:18:43 +00:00
|
|
|
if params[:id].present? && news = News.visible.find_by_id(params[:id])
|
|
|
|
|
@previewed = news
|
|
|
|
|
end
|
2025-04-11 09:21:17 +00:00
|
|
|
@text = params[:text] || nil
|
2010-09-24 16:26:46 +00:00
|
|
|
render :partial => 'common/preview'
|
|
|
|
|
end
|
|
|
|
|
|
2018-09-26 07:27:30 +00:00
|
|
|
def text
|
2025-04-11 09:21:17 +00:00
|
|
|
@text = params[:text] || nil
|
2018-09-26 07:27:30 +00:00
|
|
|
render :partial => 'common/preview'
|
|
|
|
|
end
|
2019-11-09 17:10:54 +00:00
|
|
|
|
2010-08-18 15:01:35 +00:00
|
|
|
private
|
2011-08-30 14:13:09 +00:00
|
|
|
|
2010-08-18 15:01:35 +00:00
|
|
|
def find_project
|
|
|
|
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
2014-10-05 13:24:24 +00:00
|
|
|
@project = Project.find(project_id)
|
2010-08-18 15:01:35 +00:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
|
render_404
|
|
|
|
|
end
|
|
|
|
|
end
|