diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 18:42:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 18:42:14 +0000 |
commit | 3d27bf5318ef22d5d66e1863a62c3c6c1f203d66 (patch) | |
tree | 41da619407d5a38bd1538434597fc34fdb23d310 /app | |
parent | a03c585a84d3197e0c35617dc78c9e3ca264c56a (diff) | |
download | redmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.tar.gz redmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.zip |
Adds export of all wiki pages to a PDF file (#3463).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8734 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/wiki_controller.rb | 22 | ||||
-rw-r--r-- | app/views/wiki/date_index.html.erb | 5 | ||||
-rw-r--r-- | app/views/wiki/index.html.erb | 7 |
3 files changed, 23 insertions, 11 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 1aaff4071..aaf593e2b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -73,7 +73,7 @@ class WikiController < ApplicationController @content = @page.content_for_version(params[:version]) if User.current.allowed_to?(:export_wiki_pages, @project) if params[:format] == 'pdf' - send_data(wiki_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") return elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false @@ -239,14 +239,22 @@ class WikiController < ApplicationController redirect_to :action => 'index', :project_id => @project end - # Export wiki to a single html file + # Export wiki to a single pdf or html file def export - if User.current.allowed_to?(:export_wiki_pages, @project) - @pages = @wiki.pages.find :all, :order => 'title' - export = render_to_string :action => 'export_multiple', :layout => false - send_data(export, :type => 'text/html', :filename => "wiki.html") - else + unless User.current.allowed_to?(:export_wiki_pages, @project) redirect_to :action => 'show', :project_id => @project, :id => nil + return + end + + @pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75) + respond_to do |format| + format.html { + export = render_to_string :action => 'export_multiple', :layout => false + 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") + } end end diff --git a/app/views/wiki/date_index.html.erb b/app/views/wiki/date_index.html.erb index c822d8a39..4bc31dcd7 100644 --- a/app/views/wiki/date_index.html.erb +++ b/app/views/wiki/date_index.html.erb @@ -24,7 +24,10 @@ <% unless @pages.empty? %> <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> - <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> + <% if User.current.allowed_to?(:export_wiki_pages, @project) %> + <%= f.link_to('PDF', :url => {:action => 'export', :format => 'pdf'}) %> + <%= f.link_to('HTML', :url => {:action => 'export'}) %> + <% end %> <% end %> <% end %> diff --git a/app/views/wiki/index.html.erb b/app/views/wiki/index.html.erb index e89513906..60dbd58f2 100644 --- a/app/views/wiki/index.html.erb +++ b/app/views/wiki/index.html.erb @@ -20,9 +20,10 @@ :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> - <%= f.link_to('HTML', - :url => {:action => 'export'} - ) if User.current.allowed_to?(:export_wiki_pages, @project) %> + <% if User.current.allowed_to?(:export_wiki_pages, @project) %> + <%= f.link_to('PDF', :url => {:action => 'export', :format => 'pdf'}) %> + <%= f.link_to('HTML', :url => {:action => 'export'}) %> + <% end %> <% end %> <% end %> |