mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-16 05:58:12 +00:00
added wiki functionalities:
* simple page export to plain text * full wiki export to a single html file with index git-svn-id: http://redmine.rubyforge.org/svn/branches/work@299 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
abe5696906
commit
6186117886
@ -32,6 +32,9 @@ class WikiController < ApplicationController
|
||||
export = render_to_string :action => 'export', :layout => false
|
||||
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
||||
return
|
||||
elsif params[:export] == 'txt'
|
||||
send_data(@page.content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
|
||||
return
|
||||
end
|
||||
render :action => 'show'
|
||||
end
|
||||
@ -66,11 +69,18 @@ class WikiController < ApplicationController
|
||||
def special
|
||||
page_title = params[:page].downcase
|
||||
case page_title
|
||||
# show pages index, sorted by title
|
||||
when 'page_index'
|
||||
# eagger load information about last updates, without loading text
|
||||
# eager load information about last updates, without loading text
|
||||
@pages = @wiki.pages.find :all, :select => "wiki_pages.*, wiki_contents.updated_on",
|
||||
:joins => "LEFT JOIN wiki_contents ON wiki_contents.page_id = wiki_pages.id",
|
||||
:order => 'title'
|
||||
# export wiki to a single html file
|
||||
when 'export'
|
||||
@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")
|
||||
return
|
||||
else
|
||||
# requested special page doesn't exist, redirect to default page
|
||||
redirect_to :action => 'index', :id => @project, :page => nil and return
|
||||
|
||||
@ -93,11 +93,17 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
# 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 = {})
|
||||
case options[:wiki_links]
|
||||
when :local
|
||||
wiki_link_format = 'Wiki.titleize($1) + ".html"'
|
||||
when :anchor
|
||||
wiki_link_format = '"#" + Wiki.titleize($1)'
|
||||
else
|
||||
wiki_link_format = '"/wiki/#{@project.id}/#{Wiki.titleize($1)}"'
|
||||
end
|
||||
# turn wiki links in textile links: "text":url
|
||||
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + (options[:wiki_basename] ? Wiki.titleize($1) : "/wiki/#{@project.id}/#{Wiki.titleize($1)}") } if @project
|
||||
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + (eval wiki_link_format) } 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")
|
||||
|
||||
@ -42,6 +42,9 @@
|
||||
<div id="wiki">
|
||||
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %>
|
||||
<p><%= wiki.text_field :start_page, :size => 60, :required => true %></p>
|
||||
<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") +
|
||||
# auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } })
|
||||
%>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= javascript_tag "Element.hide('wiki');" if @project.wiki.nil? %>
|
||||
|
||||
@ -3,10 +3,14 @@
|
||||
<head>
|
||||
<title><%=h @page.pretty_title %></title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
body { font:80% Verdana,Tahoma,Arial,sans-serif; }
|
||||
h1, h2, h3, h4 { font-family: Trebuchet MS,Georgia,"Times New Roman",serif; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1><%=h @page.pretty_title %></h1>
|
||||
<hr />
|
||||
<%= textilizable @content.text, :wiki_basename => true %>
|
||||
<%= textilizable @content.text, :wiki_links => :local %>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
27
wiki/app/views/wiki/export_multiple.rhtml
Normal file
27
wiki/app/views/wiki/export_multiple.rhtml
Normal file
@ -0,0 +1,27 @@
|
||||
<!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 @wiki.project.name %></title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
body { font:80% Verdana,Tahoma,Arial,sans-serif; }
|
||||
h1, h2, h3, h4 { font-family: Trebuchet MS,Georgia,"Times New Roman",serif; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<strong><%= l(:label_page_index) %></strong>
|
||||
<ul>
|
||||
<% @pages.each do |page| %>
|
||||
<li><a href="#<%= page.title %>"><%= page.pretty_title %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% @pages.each do |page| %>
|
||||
<hr />
|
||||
<h1 class="page-title"><a name="<%= page.title %>"><%=h page.pretty_title %></a></h1>
|
||||
<%= textilizable page.content.text, :wiki_links => :anchor %>
|
||||
<% end %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -27,5 +27,6 @@
|
||||
|
||||
<div class="contextual">
|
||||
<%= l(:label_export_to) %>
|
||||
<%= link_to 'HTML', {:export => 'html'}, :class => 'icon icon-html' %>
|
||||
<%= link_to 'HTML', {:export => 'html'}, :class => 'icon icon-html' %>,
|
||||
<%= link_to 'TXT', {:export => 'txt'}, :class => 'icon icon-txt' %>
|
||||
</div>
|
||||
@ -1,3 +1,9 @@
|
||||
<div class="contextual">
|
||||
<% unless @pages.empty? %>
|
||||
<%= l(:label_export_to) %> <%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'icon icon-html' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<h2><%= l(:label_page_index) %></h2>
|
||||
|
||||
<% if @pages.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
|
||||
|
||||
@ -321,7 +321,7 @@ label_search: Recherche
|
||||
label_result: %d résultat
|
||||
label_result_plural: %d résultats
|
||||
label_wiki: Wiki
|
||||
label_page_index: Index des pages
|
||||
label_page_index: Index
|
||||
label_current_version: Version actuelle
|
||||
|
||||
button_login: Connexion
|
||||
|
||||
BIN
wiki/public/images/txt.png
Normal file
BIN
wiki/public/images/txt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 633 B |
@ -140,6 +140,7 @@ vertical-align: middle;
|
||||
.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-txt { background-image: url(../images/txt.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); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user