Start on LaTeX
Pave the way for Jason's LaTeX macro support. Also, uniformize the capitalization of "ETag".
This commit is contained in:
parent
b0e316e37c
commit
c67382d340
|
@ -135,7 +135,7 @@ module ActionController
|
||||||
controller.response.headers['Cache-Control'] == 'no-cache'
|
controller.response.headers['Cache-Control'] == 'no-cache'
|
||||||
controller.response.headers['Cache-Control'] = "max-age=#{controller.response.time_to_live}"
|
controller.response.headers['Cache-Control'] = "max-age=#{controller.response.time_to_live}"
|
||||||
end
|
end
|
||||||
controller.response.headers['Etag'] = %{"#{MD5.new(controller.response.body).to_s}"}
|
controller.response.headers['ETag'] = %{"#{MD5.new(controller.response.body).to_s}"}
|
||||||
controller.response.headers['Last-Modified'] ||= Time.now.httpdate
|
controller.response.headers['Last-Modified'] ||= Time.now.httpdate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,13 +148,13 @@ module ActionController
|
||||||
|
|
||||||
def send_not_modified(controller)
|
def send_not_modified(controller)
|
||||||
controller.logger.info "Send Not Modified"
|
controller.logger.info "Send Not Modified"
|
||||||
controller.response.headers['Etag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
|
controller.response.headers['ETag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
|
||||||
controller.render(:text => "", :status => 304)
|
controller.render(:text => "", :status => 304)
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_has_latest?(cache_entry, controller)
|
def client_has_latest?(cache_entry, controller)
|
||||||
requestEtag = controller.request.env['HTTP_IF_NONE_MATCH'] rescue nil
|
requestEtag = controller.request.env['HTTP_IF_NONE_MATCH'] rescue nil
|
||||||
responseEtag = cache_entry.headers['Etag'] rescue nil
|
responseEtag = cache_entry.headers['ETag'] rescue nil
|
||||||
return true if (requestEtag and responseEtag and requestEtag == responseEtag)
|
return true if (requestEtag and responseEtag and requestEtag == responseEtag)
|
||||||
requestTime = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
|
requestTime = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
|
||||||
responseTime = Time.rfc2822(cache_entry.headers['Last-Modified']) rescue nil
|
responseTime = Time.rfc2822(cache_entry.headers['Last-Modified']) rescue nil
|
||||||
|
|
12
vendor/plugins/maruku/lib/maruku/ext/math/latex_fix.rb
vendored
Normal file
12
vendor/plugins/maruku/lib/maruku/ext/math/latex_fix.rb
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class String
|
||||||
|
|
||||||
|
# fix some LaTeX command-name clashes
|
||||||
|
def fix_latex
|
||||||
|
if #{html_math_engine} == 'itex2mml'
|
||||||
|
s = self.gsub("\\mathop{", "\\operatorname{")
|
||||||
|
s.gsub("\\space{", "\\itexspace{")
|
||||||
|
else
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,16 +1,17 @@
|
||||||
|
|
||||||
module MaRuKu; module Out; module Latex
|
module MaRuKu; module Out; module Latex
|
||||||
|
|
||||||
|
require 'maruku/ext/math/latex_fix'
|
||||||
|
|
||||||
def to_latex_inline_math
|
def to_latex_inline_math
|
||||||
"$#{self.math.strip}$"
|
s = "$#{self.math.strip}$".fix_latex
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_latex_equation
|
def to_latex_equation
|
||||||
if self.label
|
if self.label
|
||||||
l = "\\label{#{self.label}}"
|
l = "\\label{#{self.label}}"
|
||||||
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n"
|
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n".fix_latex
|
||||||
else
|
else
|
||||||
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n"
|
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n".fix_latex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue