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 @@ + + +
+