From 00faf35e05eb91e6cb3d21acb93066e0babb3f62 2011-11-06 10:49:09 From: Toshi MARUYAMA Date: 2011-11-06 10:49:09 Subject: [PATCH] pdf: add a new feature to export wiki pdf (#401) Contributed by Jun NAITOH. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7741 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index d95f9ba..8111a61 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -40,6 +40,7 @@ class WikiController < ApplicationController helper :attachments include AttachmentsHelper helper :watchers + include Redmine::Export::PDF # List of pages, sorted alphabetically and by parent (hierarchy) def index @@ -71,7 +72,10 @@ class WikiController < ApplicationController end @content = @page.content_for_version(params[:version]) if User.current.allowed_to?(:export_wiki_pages, @project) - if params[:format] == 'html' + if params[:format] == 'pdf' + send_data(wiki_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + return + elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") return diff --git a/app/views/wiki/show.html.erb b/app/views/wiki/show.html.erb index ef17112..564fc89 100644 --- a/app/views/wiki/show.html.erb +++ b/app/views/wiki/show.html.erb @@ -53,6 +53,7 @@ <% end %> <% other_formats_links do |f| %> + <%= f.link_to 'PDF', :url => {:id => @page.title, :version => @content.version} %> <%= f.link_to 'HTML', :url => {:id => @page.title, :version => @content.version} %> <%= f.link_to 'TXT', :url => {:id => @page.title, :version => @content.version} %> <% end if User.current.allowed_to?(:export_wiki_pages, @project) %>