added html export of wiki page

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@297 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-03-04 16:28:11 +00:00
parent f14e2db66b
commit eb018727ef
6 changed files with 28 additions and 2 deletions

View File

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

View File

@@ -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])/, "<a href='/issues/show/\\1'>#\\1</a>\\2")

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title><%=h @page.pretty_title %></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1><%=h @page.pretty_title %></h1>
<hr />
<%= textilizable @content.text, :wiki_basename => true %>
</body>
</html>

View File

@@ -23,4 +23,9 @@
<% cache :action => 'page', :id => @page.id, :ver => @content.version do %>
<%= textilizable @content.text %>
<% end %>
</div>
<div class="contextual">
<%= l(:label_export_to) %>
<%= link_to 'HTML', {:export => 'html'}, :class => 'icon icon-html' %>
</div>

BIN
wiki/public/images/html.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

View File

@@ -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); }