Export Multiple Pages to TeX
Per a suggestion of Marco Gualtieri.
This commit is contained in:
parent
1c5df9e8b5
commit
aee4f8b3a9
9 changed files with 312 additions and 278 deletions
|
@ -138,15 +138,4 @@ class AdminController < ApplicationController
|
|||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def is_post
|
||||
unless (request.post? || Rails.env.test?)
|
||||
headers['Allow'] = 'POST'
|
||||
render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error')
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -190,7 +190,7 @@ class ApplicationController < ActionController::Base
|
|||
response.charset = 'utf-8'
|
||||
if %w(atom_with_content atom_with_headlines).include?(action_name)
|
||||
response.content_type = Mime::ATOM
|
||||
elsif %w(tex).include?(action_name)
|
||||
elsif %w(tex tex_list).include?(action_name)
|
||||
response.content_type = Mime::TEXT
|
||||
elsif xhtml_enabled?
|
||||
if request.user_agent =~ /Validator/ or request.env.include?('HTTP_ACCEPT') &&
|
||||
|
@ -246,6 +246,17 @@ class ApplicationController < ActionController::Base
|
|||
(@web.published? and action_name == 's5')
|
||||
end
|
||||
|
||||
def is_post
|
||||
unless (request.post? || Rails.env.test?)
|
||||
layout = 'error'
|
||||
layout = false if %w(tex tex_list).include?(action_name)
|
||||
headers['Allow'] = 'POST'
|
||||
render(:status => 405, :text => 'You must use an HTTP POST', :layout => layout)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Mime
|
||||
|
|
|
@ -110,15 +110,6 @@ class FileController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def is_post
|
||||
unless (request.post? || Rails.env.test?)
|
||||
headers['Allow'] = 'POST'
|
||||
render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error')
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def import_from_archive(archive)
|
||||
logger.info "Importing pages from #{archive}"
|
||||
zip = Zip::ZipInputStream.open(archive)
|
||||
|
|
|
@ -184,6 +184,24 @@ EOL
|
|||
def atom_with_headlines
|
||||
render_atom(hide_description = true)
|
||||
end
|
||||
|
||||
def tex_list
|
||||
return unless is_post
|
||||
if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup)
|
||||
@tex_content = ''
|
||||
params.each do |name, p|
|
||||
if p == 'tex' && @web.has_page?(name)
|
||||
@tex_content << "\\section*\{#{name}\}\n\n".as_utf8
|
||||
@tex_content << Maruku.new(@web.page(name).content).to_latex
|
||||
end
|
||||
end
|
||||
else
|
||||
@tex_content = 'TeX export only supported with the Markdown text filters.'
|
||||
end
|
||||
expire_action :controller => 'wiki', :web => @web.address, :action => 'list', :category => params['category']
|
||||
render(:layout => 'tex')
|
||||
end
|
||||
|
||||
|
||||
def search
|
||||
@query = params['query'].purify
|
||||
|
@ -389,6 +407,7 @@ EOL
|
|||
else
|
||||
@tex_content = 'TeX export only supported with the Markdown text filters.'
|
||||
end
|
||||
render(:layout => 'tex')
|
||||
end
|
||||
|
||||
def s5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue