diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 633c2288..c9aa46ec 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -51,11 +51,41 @@ class WikiController < ApplicationController
end
def export_html
+ stylesheet = File.read(File.join(RAILS_ROOT, 'public', 'stylesheets', 'instiki.css'))
export_pages_as_zip('html') do |page|
- @page = page
- @renderer = PageRenderer.new(page.revisions.last)
- @link_mode = :export
- render_to_string('wiki/print', use_layout = (@params['layout'] != 'no'))
+
+ renderer = PageRenderer.new(page.revisions.last)
+ rendered_page = <<-EOL
+
+
+
+ #{page.plain_name} in #{@web.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(page.author.name, @web, nil, { :mode => :export }) }
+
+
+
+ EOL
+ rendered_page
end
end
@@ -256,7 +286,7 @@ class WikiController < ApplicationController
def export_page_to_tex(file_path)
tex
- File.open(file_path, 'w') { |f| f.write(render_to_string('wiki/tex')) }
+ File.open(file_path, 'w') { |f| f.write(render_to_string(:template => 'wiki/tex', :layout => nil)) }
end
def export_pages_as_zip(file_type, &block)
@@ -285,7 +315,7 @@ class WikiController < ApplicationController
def export_web_to_tex(file_path)
@tex_content = table_of_contents(@web.page('HomePage').content, render_tex_web)
- File.open(file_path, 'w') { |f| f.write(render_to_string('wiki/tex_web')) }
+ File.open(file_path, 'w') { |f| f.write(render_to_string(:template => 'wiki/tex_web', :layout => nil)) }
end
def get_page_and_revision
@@ -346,16 +376,6 @@ class WikiController < ApplicationController
end
end
- def render_to_string(template_name, with_layout = false)
- add_variables_to_assigns
- self.assigns['content_for_layout'] = @template.render_file(template_name)
- if with_layout
- @template.render_file('layouts/default')
- else
- self.assigns['content_for_layout']
- end
- end
-
def rss_with_content_allowed?
@web.password.nil? or @web.published?
end
diff --git a/app/models/page.rb b/app/models/page.rb
index e45b609e..1896ac5f 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -94,6 +94,10 @@ class Page < ActiveRecord::Base
locked_at + LOCKING_PERIOD > comparison_time unless locked_at.nil?
end
+ def to_param
+ name
+ end
+
private
def continous_revision?(time, author)
diff --git a/app/models/web.rb b/app/models/web.rb
index c38c8061..a53fc25b 100644
--- a/app/models/web.rb
+++ b/app/models/web.rb
@@ -79,6 +79,10 @@ class Web < ActiveRecord::Base
PageSet.new(self, pages, nil)
end
+ def to_param
+ address
+ end
+
private
# Returns an array of all the wiki words in any current revision
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index e5646da5..70654b50 100755
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -116,7 +116,6 @@ class WikiControllerTest < Test::Unit::TestCase
assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
- assert_equal :export, r.template_objects['link_mode']
# Tempfile doesn't know how to open files with binary flag, hence the two-step process
Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path }
@@ -145,7 +144,6 @@ class WikiControllerTest < Test::Unit::TestCase
assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
- assert_equal :export, r.template_objects['link_mode']
end
def test_export_markup