Sorted out pdf action
This commit is contained in:
parent
0367f67fba
commit
01c5a65405
|
@ -28,9 +28,11 @@ rss_with_content
|
|||
rss_with_headlines
|
||||
export_html
|
||||
export_markup
|
||||
pdf
|
||||
|
||||
TODO
|
||||
|
||||
pdf
|
||||
tex
|
||||
export_pdf
|
||||
export_tex
|
||||
|
||||
|
|
|
@ -186,8 +186,9 @@ class WikiController < ApplicationController
|
|||
file_path = WikiService.storage_path + file_name
|
||||
|
||||
export_page_to_tex(file_path + '.tex') unless FileTest.exists?(file_path + '.tex')
|
||||
# NB: this is _very_ slow
|
||||
convert_tex_to_pdf(file_path + '.tex')
|
||||
send_file(file_name + '.pdf')
|
||||
send_file(file_path + '.pdf')
|
||||
end
|
||||
|
||||
def print
|
||||
|
@ -273,7 +274,9 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def convert_tex_to_pdf(tex_path)
|
||||
`cd #{File.dirname(tex_path)}; pdflatex --interaction=scrollmode '#{File.basename(tex_path)}'`
|
||||
# TODO remove earlier PDF files with the same prefix
|
||||
# TODO handle gracefully situation where pdflatex is not available
|
||||
logger.info `pdflatex --interaction=nonstopmode --output-directory #{File.dirname(tex_path)} #{File.basename(tex_path)}`
|
||||
end
|
||||
|
||||
def export_page_to_tex(file_path)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/env ruby
|
||||
|
||||
# Uncomment the line below to enable pdflatex tests; don't forget to comment them again
|
||||
# commiting to SVN
|
||||
$INSTIKI_TEST_PDFLATEX = true
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'wiki_controller'
|
||||
require 'rexml/document'
|
||||
|
||||
unless RedClothForTex.available?
|
||||
$stderr.puts 'Warning: latex is not available, skipping all related tests'
|
||||
end
|
||||
|
||||
# Raise errors beyond the default web-based presentation
|
||||
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
|
||||
|
||||
|
@ -33,7 +33,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
|
||||
def test_authenticate
|
||||
@web.password = 'pswd'
|
||||
|
||||
|
||||
r = process('authenticate', 'web' => 'wiki1', 'password' => 'wrong password')
|
||||
assert_redirected_to :action => 'login'
|
||||
assert_nil r.cookies['web_address']
|
||||
|
@ -263,12 +263,20 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
|
||||
if ENV['INSTIKI_TEST_LATEX'] or defined? $INSTIKI_TEST_PDFLATEX
|
||||
|
||||
def test_pdf
|
||||
if RedClothForTex.available?
|
||||
process('pdf', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
puts "Warning: tests involving pdflatex are very slow, therefore they are disable by default."
|
||||
puts " Set environment variable INSTIKI_TEST_PDFLATEX or global Ruby variable"
|
||||
puts " $INSTIKI_TEST_PDFLATEX to enable them."
|
||||
end
|
||||
|
||||
|
||||
def test_print
|
||||
process('print', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||
|
|
Loading…
Reference in a new issue