From eb018727ef16f72b1c2bddb4c23ccc4b3ed72fbb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 4 Mar 2007 16:28:11 +0000 Subject: [PATCH] added html export of wiki page git-svn-id: http://redmine.rubyforge.org/svn/branches/work@297 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- wiki/app/controllers/wiki_controller.rb | 5 +++++ wiki/app/helpers/application_helper.rb | 7 +++++-- wiki/app/views/wiki/export.rhtml | 12 ++++++++++++ wiki/app/views/wiki/show.rhtml | 5 +++++ wiki/public/images/html.png | Bin 0 -> 551 bytes wiki/public/stylesheets/application.css | 1 + 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 wiki/app/views/wiki/export.rhtml create mode 100644 wiki/public/images/html.png diff --git a/wiki/app/controllers/wiki_controller.rb b/wiki/app/controllers/wiki_controller.rb index 056d26d2f..2dbc3724b 100644 --- a/wiki/app/controllers/wiki_controller.rb +++ b/wiki/app/controllers/wiki_controller.rb @@ -28,6 +28,11 @@ class WikiController < ApplicationController render :action => 'edit' and return end @content = (params[:version] ? @page.content.versions.find_by_version(params[:version]) : @page.content) + if params[:export] == 'html' + export = render_to_string :action => 'export', :layout => false + send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") + return + end render :action => 'show' end diff --git a/wiki/app/helpers/application_helper.rb b/wiki/app/helpers/application_helper.rb index 09afadc61..779c54cbe 100644 --- a/wiki/app/helpers/application_helper.rb +++ b/wiki/app/helpers/application_helper.rb @@ -92,9 +92,12 @@ module ApplicationHelper html end - def textilizable(text) + # textilize text according to system settings and RedCloth availability + # options: + # - basename: if set to true, generates local wiki links (used for html exports) + def textilizable(text, options = {}) # turn wiki links in textile links: "text":url - text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":/wiki/#{@project.id}/#{Wiki.titleize($1)}" } if @project + text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + (options[:wiki_basename] ? Wiki.titleize($1) : "/wiki/#{@project.id}/#{Wiki.titleize($1)}") } if @project text = (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? auto_link(RedCloth.new(text, [:filter_html]).to_html) : simple_format(auto_link(h(text))) # turn "#id" patterns into links to issues text = text.gsub(/#(\d+)([^;\d])/, "#\\1\\2") diff --git a/wiki/app/views/wiki/export.rhtml b/wiki/app/views/wiki/export.rhtml new file mode 100644 index 000000000..fbaf71b42 --- /dev/null +++ b/wiki/app/views/wiki/export.rhtml @@ -0,0 +1,12 @@ + + + +<%=h @page.pretty_title %> + + + +

<%=h @page.pretty_title %>

+
+<%= textilizable @content.text, :wiki_basename => true %> + + diff --git a/wiki/app/views/wiki/show.rhtml b/wiki/app/views/wiki/show.rhtml index 92037d8dc..a0d0035c3 100644 --- a/wiki/app/views/wiki/show.rhtml +++ b/wiki/app/views/wiki/show.rhtml @@ -23,4 +23,9 @@ <% cache :action => 'page', :id => @page.id, :ver => @content.version do %> <%= textilizable @content.text %> <% end %> + + +
+<%= l(:label_export_to) %> +<%= link_to 'HTML', {:export => 'html'}, :class => 'icon icon-html' %>
\ No newline at end of file diff --git a/wiki/public/images/html.png b/wiki/public/images/html.png new file mode 100644 index 0000000000000000000000000000000000000000..efb32e7c5951fde18b833049203d6f7d52ae6eea GIT binary patch literal 551 zcmV+?0@(eDP)WdLk-ZZ04=AZlT5b}k??FfcbDF*!OhIXW{nAS*C2Ffd^NxS#+400(qQ zO+^RS0|XEV8X~Z}vH$=832;bRa{vGe@Bjb`@Bu=sG?)MY00d`2O+f$vv5yP02R7L*)0QdLz=jZ3|@9);$@80M4*5~)<@Bi=j|K8{C&ff3F*6;84_qERFjHS+u zt=_fP|EZaN{r`Hl;>lm_j9fHW2NtuwdXN& z)|}4&N{rsl-uHy9-XUwwLWJI0rSHz?|9iFf2vWwS#_u_M)|9>XYo+fgbJhS#y;6+c zT9n=pTE;nZ&Xm3HrN;M+weNGK=lB2r@9+0(l-{kq=l}ozvaA%V6nXh9t5;M@FmEhRv-tklNbt{DOfU3$ zJV{8lJGxH~tOt{^U>$@k?k1|gq^rOVBO(9+V>0z-b8q2d3931^Y{zo-0YU p5te{dJivqyjX?1fb|Kgvd;v%u4{V!cGC%+T002ovPDHLkV1i|>{;U81 literal 0 HcmV?d00001 diff --git a/wiki/public/stylesheets/application.css b/wiki/public/stylesheets/application.css index 6f42054c4..f0bae4d8a 100644 --- a/wiki/public/stylesheets/application.css +++ b/wiki/public/stylesheets/application.css @@ -139,6 +139,7 @@ vertical-align: middle; .icon-cancel { background-image: url(../images/cancel.png); } .icon-pdf { background-image: url(../images/pdf.png); } .icon-csv { background-image: url(../images/csv.png); } +.icon-html { background-image: url(../images/html.png); } .icon-file { background-image: url(../images/file.png); } .icon-folder { background-image: url(../images/folder.png); } .icon-package { background-image: url(../images/package.png); }