Ruby 1.9.1 Fixes
Some more fixes to deal with Ruby 1.9.1.
This commit is contained in:
parent
063a8ca5a7
commit
f7044ecbb4
|
@ -269,3 +269,8 @@ module Instiki
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Monkey patch, to make Hash#key work in Ruby 1.8
|
||||||
|
class Hash
|
||||||
|
alias_method(:key, :index) unless method_defined?(:key)
|
||||||
|
end
|
||||||
|
|
|
@ -438,7 +438,7 @@ class WikiController < ApplicationController
|
||||||
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=HomePage.#{file_type}\"></head></html>"
|
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=HomePage.#{file_type}\"></head></html>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip')])
|
FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip').to_s])
|
||||||
FileUtils.mv(tmp_path, file_path)
|
FileUtils.mv(tmp_path, file_path)
|
||||||
send_file file_path
|
send_file file_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module ActionView
|
||||||
session[:form_keys][Digest::SHA1.hexdigest(form_key)] = [Time.now, 0]
|
session[:form_keys][Digest::SHA1.hexdigest(form_key)] = [Time.now, 0]
|
||||||
if session[:form_keys].length > 30
|
if session[:form_keys].length > 30
|
||||||
first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0]
|
first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0]
|
||||||
session[:form_keys].delete(session[:form_keys].index(first))
|
session[:form_keys].delete(session[:form_keys].key(first))
|
||||||
end
|
end
|
||||||
out << domEnkode(form_key)
|
out << domEnkode(form_key)
|
||||||
end
|
end
|
||||||
|
|
|
@ -338,19 +338,19 @@ Otherwise, a standard `verbatim` environment is used.
|
||||||
\\end{#{name}}\n"
|
\\end{#{name}}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
SAFE_CHARS = Set.new((?a..?z).to_a + (?A..?Z).to_a)
|
SAFE_CHARS = Set.new(('a'..'z').to_a + ('A'..'Z').to_a)
|
||||||
# the ultimate escaping
|
# the ultimate escaping
|
||||||
# (is much better than using \verb)
|
# (is much better than using \verb)
|
||||||
def latex_escape(source)
|
def latex_escape(source)
|
||||||
s="";
|
s="";
|
||||||
|
|
||||||
source.each_byte do |b|
|
source.each_char do |b|
|
||||||
if b == ?\
|
if b == '\\'
|
||||||
s << '~'
|
s << '~'
|
||||||
elsif SAFE_CHARS.include? b
|
elsif SAFE_CHARS.include? b
|
||||||
s << b
|
s << b
|
||||||
else
|
else
|
||||||
s += "\\char%d" % b
|
s += "\\char%d" % b.ord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
|
|
Loading…
Reference in a new issue