From 7a0432d85c01e36564f80d598e1d43dad148875a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 Jan 2015 09:04:52 +0000 Subject: Adds support for macro and Redmine links in PDF export (#13051). git-svn-id: http://svn.redmine.org/redmine/trunk@13944 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 6 ++---- app/controllers/wiki_controller.rb | 6 ++---- app/helpers/application_helper.rb | 2 ++ app/helpers/issues_helper.rb | 1 + app/helpers/wiki_helper.rb | 1 + app/views/issues/index.pdf.erb | 1 + app/views/issues/show.pdf.erb | 1 + app/views/wiki/export.pdf.erb | 1 + app/views/wiki/show.pdf.erb | 1 + 9 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 app/views/issues/index.pdf.erb create mode 100644 app/views/issues/show.pdf.erb create mode 100644 app/views/wiki/export.pdf.erb create mode 100644 app/views/wiki/show.pdf.erb (limited to 'app') diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b8ec626da..d1cac203e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -49,7 +49,6 @@ class IssuesController < ApplicationController include SortHelper include IssuesHelper helper :timelog - include Redmine::Export::PDF def index retrieve_query @@ -89,7 +88,7 @@ class IssuesController < ApplicationController } format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } format.csv { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') } - format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'issues.pdf') } + format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' } end else respond_to do |format| @@ -130,8 +129,7 @@ class IssuesController < ApplicationController format.api format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf" } end end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index f6dc0ffca..6f6c6bbdf 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -78,7 +78,7 @@ class WikiController < ApplicationController end if User.current.allowed_to?(:export_wiki_pages, @project) if params[:format] == 'pdf' - send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + send_file_headers! :type => 'application/pdf', :filename => "#{@page.title}.pdf" return elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false @@ -283,9 +283,7 @@ class WikiController < ApplicationController send_data(export, :type => 'text/html', :filename => "wiki.html") } format.pdf { - send_data(wiki_pages_to_pdf(@pages, @project), - :type => 'application/pdf', - :filename => "#{@project.identifier}.pdf") + send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}.pdf" } end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 53b9037bd..db10ed604 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -622,6 +622,8 @@ module ApplicationHelper end def parse_inline_attachments(text, project, obj, attr, only_path, options) + return if options[:inline_attachments] == false + # when using an image link, try to use an attachment, if possible attachments = options[:attachments] || [] attachments += obj.attachments if obj.respond_to?(:attachments) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 5706bf53d..da9995345 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -19,6 +19,7 @@ module IssuesHelper include ApplicationHelper + include Redmine::Export::PDF::IssuesPdfHelper def issue_list(issues, &block) ancestors = [] diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index aa1584a44..77ac01835 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module WikiHelper + include Redmine::Export::PDF::WikiPdfHelper def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0) pages = pages.group_by(&:parent) unless pages.is_a?(Hash) diff --git a/app/views/issues/index.pdf.erb b/app/views/issues/index.pdf.erb new file mode 100644 index 000000000..810818a83 --- /dev/null +++ b/app/views/issues/index.pdf.erb @@ -0,0 +1 @@ +<%= raw issues_to_pdf(@issues, @project, @query) %> \ No newline at end of file diff --git a/app/views/issues/show.pdf.erb b/app/views/issues/show.pdf.erb new file mode 100644 index 000000000..f26589f9e --- /dev/null +++ b/app/views/issues/show.pdf.erb @@ -0,0 +1 @@ +<%= raw issue_to_pdf(@issue, :journals => @journals) %> \ No newline at end of file diff --git a/app/views/wiki/export.pdf.erb b/app/views/wiki/export.pdf.erb new file mode 100644 index 000000000..84d596a5a --- /dev/null +++ b/app/views/wiki/export.pdf.erb @@ -0,0 +1 @@ +<%= raw wiki_pages_to_pdf(@pages, @project) %> \ No newline at end of file diff --git a/app/views/wiki/show.pdf.erb b/app/views/wiki/show.pdf.erb new file mode 100644 index 000000000..b1f738ddc --- /dev/null +++ b/app/views/wiki/show.pdf.erb @@ -0,0 +1 @@ +<%= raw wiki_page_to_pdf(@page, @project) %> \ No newline at end of file -- cgit v1.2.3