diff --git a/wiki/app/controllers/wiki_controller.rb b/wiki/app/controllers/wiki_controller.rb index 2dbc3724b..251ef8ca0 100644 --- a/wiki/app/controllers/wiki_controller.rb +++ b/wiki/app/controllers/wiki_controller.rb @@ -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 diff --git a/wiki/app/helpers/application_helper.rb b/wiki/app/helpers/application_helper.rb index 779c54cbe..16ade7b9d 100644 --- a/wiki/app/helpers/application_helper.rb +++ b/wiki/app/helpers/application_helper.rb @@ -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])/, "#\\1\\2") diff --git a/wiki/app/views/projects/_form.rhtml b/wiki/app/views/projects/_form.rhtml index 159c06047..b10379cf0 100644 --- a/wiki/app/views/projects/_form.rhtml +++ b/wiki/app/views/projects/_form.rhtml @@ -42,6 +42,9 @@
<%= wiki.text_field :start_page, :size => 60, :required => true %>
+<% # 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 %>