diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 29a0155d..d133a9f2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base
Wiki.new
end
- helper_method :xhtml_enabled?, :html_ext
+ helper_method :xhtml_enabled?, :html_ext, :darken
protected
@@ -36,6 +36,11 @@ class ApplicationController < ActionController::Base
end
end
+ def darken(s)
+ n=s.length/3
+ s.scan( %r(\w{#{n},#{n}}) ).collect {|a| (a.hex * 2/3).to_s(16).rjust(n,'0')}.join
+ end
+
def check_authorization
if in_a_web? and authorization_needed? and not authorized?
redirect_to :controller => 'wiki', :action => 'login', :web => @web_name
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 221586ba..93e41d86 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -74,36 +74,61 @@ class WikiController < ApplicationController
renderer = PageRenderer.new(page.revisions.last)
rendered_page = <<-EOL
-
-
- #{page.plain_name} in #{@web.name}
-
+
+
+ #{page.plain_name} in #{@web.name}
+
-
-
-
-
-
- #{@web.name}
- #{page.plain_name}
-
- #{renderer.display_content_for_export}
-
- #{page.revisions? ? "Revised" : "Created" } on #{ page.revised_at.strftime('%B %d, %Y %H:%M:%S') }
- by
- #{ UrlGenerator.new(self).make_link(@web, page.author.name, @web, nil, { :mode => :export }) }
-
-
-
- EOL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ #{xhtml_enabled? ? %{} : ''}
+ #{@web.name}
+ #{page.plain_name}
+
+#{renderer.display_content_for_export}
+
+ #{page.revisions? ? "Revised" : "Created" } on #{ page.revised_at.strftime('%B %d, %Y %H:%M:%S') }
+ by
+ #{ UrlGenerator.new(self).make_link(@web, page.author.name, @web, nil, { :mode => :export }) }
+
+
+
+
+
+EOL
rendered_page
end
end
@@ -422,16 +447,27 @@ class WikiController < ApplicationController
file_path = @wiki.storage_path.join(file_prefix + timestamp + '.zip')
tmp_path = "#{file_path}.tmp"
- Zip::ZipOutputStream.open(tmp_path) do |zip_out|
+ Zip::ZipFile.open(tmp_path, Zip::ZipFile::CREATE) do |zip_out|
@web.select.by_name.each do |page|
- zip_out.put_next_entry("#{CGI.escape(page.name)}.#{file_type}")
- zip_out.puts(block.call(page))
+ zip_out.get_output_stream("#{CGI.escape(page.name)}.#{file_type}") do |f|
+ f.puts(block.call(page))
+ end
end
- # add an index file, if exporting to HTML
+ # add an index file, and the stylesheet and javascript directories, if exporting to HTML
if file_type.to_s.downcase == html_ext
- zip_out.put_next_entry "index.#{html_ext}"
- zip_out.puts "" +
- ""
+ zip_out.get_output_stream("index.#{html_ext}") do |f|
+ f.puts "" +
+ ""
+ end
+ dir = Rails.root.join('public')
+ Dir["#{dir}/**/*"].each do |f|
+ zip_out.add "public#{f.sub(dir,'')}", f
+ end
+ end
+ files = @web.files_path
+ Dir.foreach(files) do |f|
+ next if ['.', '..'].include?(f)
+ zip_out.add "files/#{f}", File.join(files, f)
end
end
FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip').to_s])
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 75d61601..62ce7a22 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -127,9 +127,4 @@ require 'stringsupport'
end
end
- def darken(s)
- n=s.length/3
- s.scan( %r(\w{#{n},#{n}}) ).collect {|a| (a.hex * 2/3).to_s(16).rjust(n,'0')}.join
- end
-
end
diff --git a/app/views/wiki/print.rhtml b/app/views/wiki/print.rhtml
index b8ab69c9..317a2d3f 100644
--- a/app/views/wiki/print.rhtml
+++ b/app/views/wiki/print.rhtml
@@ -4,7 +4,7 @@
@style_additions = ".newWikiWord { background-color: white; font-style: italic; }"
-%>
-<%= @renderer.display_content_for_export %>
+<%= @renderer.display_content %>
<%= @page.revisions? ? "Revised" : "Created" %> on <%= format_date(@page.revised_at) %>
diff --git a/lib/url_generator.rb b/lib/url_generator.rb
index 74976e81..9cb87930 100644
--- a/lib/url_generator.rb
+++ b/lib/url_generator.rb
@@ -64,7 +64,7 @@ class UrlGenerator < AbstractUrlGenerator
case mode
when :export
if known_file
- %{
#{text}}
+ %{
#{text}}
else
%{
#{text}}
end
@@ -119,7 +119,7 @@ class UrlGenerator < AbstractUrlGenerator
case mode
when :export
if known_pic
- %{
}
+ %{
}
else
%{
}
end
@@ -144,7 +144,7 @@ class UrlGenerator < AbstractUrlGenerator
case mode
when :export
if known_media
- %{<#{media_type} src="#{CGI.escape(name)}" controls="controls">#{text}#{media_type}>}
+ %{<#{media_type} src="files/#{CGI.escape(name)}" controls="controls">#{text}#{media_type}>}
else
text
end
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 94ab59d3..9282ce39 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -152,7 +152,7 @@ class WikiControllerTest < ActionController::TestCase
zip.file.read('Oak.xhtml').gsub(/\s+/, ' ')
assert_match /.*/,
zip.file.read('HomePage.xhtml').gsub(/\s+/, ' ')
- assert_equal '
', zip.file.read('index.xhtml').gsub(/\s+/, ' ')
+ assert_equal '
', zip.file.read('index.xhtml').gsub(/\s+/, ' ')
end
ensure
File.delete(@tempfile_path) if File.exist?(@tempfile_path)
@@ -183,7 +183,7 @@ class WikiControllerTest < ActionController::TestCase
zip.file.read('Oak.html').gsub(/\s+/, ' ')
assert_match /.*/,
zip.file.read('HomePage.html').gsub(/\s+/, ' ')
- assert_equal '
', zip.file.read('index.html').gsub(/\s+/, ' ')
+ assert_equal '
', zip.file.read('index.html').gsub(/\s+/, ' ')
end
ensure
File.delete(@tempfile_path) if File.exist?(@tempfile_path)