SVG-Edit -> 2.5final
Vendored Rack -> 1.2.1
master
Jacques Distler 2010-06-17 19:27:39 -05:00
parent 6338a3bcb2
commit 0d8f680d4f
82 changed files with 138 additions and 70 deletions

View File

@ -2306,12 +2306,17 @@ end
#:stopdoc:
TO_ESCAPE = {
'&' => '&',
'<' => '&lt;',
'>' => '&gt;',
"'" => '&#39;',
'"' => '&quot;',
}
TO_ESCAPE_PATTERN = Regexp.union(TO_ESCAPE.keys)
def escapeHTML
self.gsub( /&/, "&amp;" ).
gsub( /</, "&lt;" ).
gsub( />/, "&gt;" ).
gsub(/'/, "&#39;" ).
gsub(/"/, "&quot;" )
self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
end
def unescapeHTML

View File

@ -18,6 +18,8 @@ module Rack
end
end
if Rack.release <= "1.2"
# The Tempfile bug is fixed in the bundled version of Rack
class RewindableInput
def make_rewindable
# Buffer all data into a tempfile. Since this tempfile is private to this
@ -58,4 +60,6 @@ module Rack
ruby_engine == "ruby" && RUBY_VERSION == "1.9.1" && RUBY_PATCHLEVEL >= 152
end
end
end
end

View File

@ -36,6 +36,15 @@ svgEditor.addExtension("Connector", function(S) {
]
};
function getOffset(side, line) {
var give_offset = !!line.getAttribute('marker-' + side);
// var give_offset = $(line).data(side+'_off');
// TODO: Make this number (5) be based on marker width/height
var size = line.getAttribute('stroke-width') * 5;
return give_offset ? size : 0;
}
function showPanel(on) {
var conn_rules = $('#connector_rules');
if(!conn_rules.length) {
@ -73,8 +82,43 @@ svgEditor.addExtension("Connector", function(S) {
}
}
function findConnectors() {
var elems = selElems;
function updateLine(diff_x, diff_y) {
// Update line with element
var i = connections.length;
while(i--) {
var conn = connections[i];
var line = conn.connector;
var elem = conn.elem;
var pre = conn.is_start?'start':'end';
// var sw = line.getAttribute('stroke-width') * 5;
// Update bbox for this element
var bb = $(line).data(pre+'_bb');
bb.x = conn.start_x + diff_x;
bb.y = conn.start_y + diff_y;
$(line).data(pre+'_bb', bb);
var alt_pre = conn.is_start?'end':'start';
// Get center pt of connected element
var bb2 = $(line).data(alt_pre+'_bb');
var src_x = bb2.x + bb2.width/2;
var src_y = bb2.y + bb2.height/2;
// Set point of element being moved
var pt = getBBintersect(src_x, src_y, bb, getOffset(pre, line)); // $(line).data(pre+'_off')?sw:0
setPoint(line, conn.is_start?0:'end', pt.x, pt.y, true);
// Set point of connected element
var pt2 = getBBintersect(pt.x, pt.y, $(line).data(alt_pre + '_bb'), getOffset(alt_pre, line));
setPoint(line, conn.is_start?'end':0, pt2.x, pt2.y, true);
}
}
function findConnectors(elems) {
if(!elems) elems = selElems;
var connectors = $(svgcontent).find(conn_sel);
connections = [];
@ -99,7 +143,6 @@ svgEditor.addExtension("Connector", function(S) {
$(this).remove();
continue;
}
if($.inArray(c_elem, elems) !== -1 || add_this) {
var bb = svgCanvas.getStrokedBBox([c_elem]);
connections.push({
@ -114,11 +157,11 @@ svgEditor.addExtension("Connector", function(S) {
});
}
function updateConnectors() {
function updateConnectors(elems) {
// Updates connector lines based on selected elements
// Is not used on mousemove, as it runs getStrokedBBox every time,
// which isn't necessary there.
findConnectors();
findConnectors(elems);
if(connections.length) {
// Update line with element
var i = connections.length;
@ -127,7 +170,7 @@ svgEditor.addExtension("Connector", function(S) {
var line = conn.connector;
var elem = conn.elem;
var sw = line.getAttribute('stroke-width');
var sw = line.getAttribute('stroke-width') * 5;
var pre = conn.is_start?'start':'end';
// Update bbox for this element
@ -145,11 +188,11 @@ svgEditor.addExtension("Connector", function(S) {
var src_y = bb2.y + bb2.height/2;
// Set point of element being moved
var pt = getBBintersect(src_x, src_y, bb, add_offset?sw:0);
var pt = getBBintersect(src_x, src_y, bb, getOffset(pre, line));
setPoint(line, conn.is_start?0:'end', pt.x, pt.y, true);
// Set point of connected element
var pt2 = getBBintersect(pt.x, pt.y, $(line).data(alt_pre + '_bb'), $(line).data(alt_pre + '_off')?sw:0);
var pt2 = getBBintersect(pt.x, pt.y, $(line).data(alt_pre + '_bb'), getOffset(alt_pre, line));
setPoint(line, conn.is_start?'end':0, pt2.x, pt2.y, true);
// Update points attribute manually for webkit
@ -336,9 +379,10 @@ svgEditor.addExtension("Connector", function(S) {
var mode = svgCanvas.getMode();
if(mode == "connector" && started) {
var sw = cur_line.getAttribute('stroke-width') * 3;
// Set start point (adjusts based on bb)
var pt = getBBintersect(x, y, $(cur_line).data('start_bb'));
var pt = getBBintersect(x, y, $(cur_line).data('start_bb'), getOffset('start', cur_line));
start_x = pt.x;
start_y = pt.y;
@ -360,38 +404,8 @@ svgEditor.addExtension("Connector", function(S) {
}
}
if(connections.length) {
// Update line with element
var i = connections.length;
while(i--) {
var conn = connections[i];
var line = conn.connector;
var elem = conn.elem;
var pre = conn.is_start?'start':'end';
var sw = line.getAttribute('stroke-width');
// Update bbox for this element
var bb = $(line).data(pre+'_bb');
bb.x = conn.start_x + diff_x;
bb.y = conn.start_y + diff_y;
$(line).data(pre+'_bb', bb);
var alt_pre = conn.is_start?'end':'start';
// Get center pt of connected element
var bb2 = $(line).data(alt_pre+'_bb');
var src_x = bb2.x + bb2.width/2;
var src_y = bb2.y + bb2.height/2;
// Set point of element being moved
var pt = getBBintersect(src_x, src_y, bb, $(line).data(pre+'_off')?sw:0);
setPoint(line, conn.is_start?0:'end', pt.x, pt.y, true);
// Set point of connected element
var pt2 = getBBintersect(pt.x, pt.y, $(line).data(alt_pre + '_bb'), $(line).data(alt_pre+'_off')?sw:0);
setPoint(line, conn.is_start?'end':0, pt2.x, pt2.y, true);
updateLine(diff_x, diff_y);
}
}
}
@ -449,7 +463,7 @@ svgEditor.addExtension("Connector", function(S) {
var bb = svgCanvas.getStrokedBBox([end_elem]);
var pt = getBBintersect(start_x, start_y, bb);
var pt = getBBintersect(start_x, start_y, bb, getOffset('start', cur_line));
setPoint(cur_line, 'end', pt.x, pt.y, true);
$(cur_line)
.data("c_start", start_id)
@ -492,6 +506,7 @@ svgEditor.addExtension("Connector", function(S) {
showPanel(false);
}
}
updateConnectors();
},
elementChanged: function(opts) {
var elem = opts.elems[0];
@ -540,10 +555,16 @@ svgEditor.addExtension("Connector", function(S) {
svgCanvas.clearSelection();
pline.id = id;
svgCanvas.addToSelection([pline]);
elem = pline;
}
}
updateConnectors();
// Update line if it's a connector
if(elem.getAttribute('class') == conn_sel.substr(1)) {
var start = getElem($(elem).data('c_start'));
updateConnectors([start]);
} else {
updateConnectors();
}
},
toolButtonStateUpdate: function(opts) {
if(opts.nostroke) {

View File

@ -261,6 +261,7 @@ svgEditor.addExtension("Markers", function(S) {
if (val=='') val='\\nomarker';
if (val=='\\nomarker') {
setIcon(pos,val);
S.call("changed", selElems);
return;
}
// Set marker on element

View File

@ -507,7 +507,7 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
<div id="tools_bottom_3">
<div id="palette_holder"><div id="palette" title="Click to change fill color, shift-click to change stroke color"></div></div>
</div>
<div id="copyright"><span id="copyrightLabel">Powered by</span> <a href="http://svg-edit.googlecode.com/" target="_blank">SVG-edit v2.5-RC1</a></div>
<div id="copyright"><span id="copyrightLabel">Powered by</span> <a href="http://svg-edit.googlecode.com/" target="_blank">SVG-edit v2.5</a></div>
</div>
<div id="option_lists">

View File

@ -308,6 +308,11 @@ run on port 11211) and memcache-client installed.
* Various multipart fixes
* Switch test suite to bacon
* June 15th, 2010: Eleventh public release 1.2.1.
* Make CGI handler rewindable
* Rename spec/ to test/ to not conflict with SPEC on lesser
operating systems
== Contact
Please post bugs, suggestions and patches to

View File

@ -25,14 +25,13 @@ task :officialrelease_really => ["SPEC", :dist, :gem] do
end
def release
require File.dirname(__FILE__) + "/lib/rack"
"rack-#{Rack.release}.0"
"rack-#{File.read("rack.gemspec")[/s.version *= *"(.*?)"/, 1]}"
end
desc "Make binaries executable"
task :chmod do
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
Dir["spec/cgi/spec*"].each { |binary| File.chmod(0775, binary) }
Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) }
end
desc "Generate a ChangeLog"
@ -69,16 +68,16 @@ desc "Run all the fast tests"
task :test do
opts = ENV['TEST'] || '-a'
specopts = ENV['TESTOPTS'] ||
"-q -t '^(?!Rack::Handler|Rack::Adapter|Rack::Session::Memcache|rackup)'"
"-q -t '^(?!Rack::Adapter|Rack::Session::Memcache|rackup)'"
sh "bacon -I./lib:./spec -w #{opts} #{specopts}"
sh "bacon -I./lib:./test -w #{opts} #{specopts}"
end
desc "Run all the tests"
task :fulltest => [:chmod] do
opts = ENV['TEST'] || '-a'
specopts = ENV['TESTOPTS'] || '-q'
sh "bacon -I./lib:./spec -w #{opts} #{specopts}"
sh "bacon -I./lib:./test -w #{opts} #{specopts}"
end
task :gem => ["SPEC"] do

View File

@ -20,7 +20,7 @@ module Rack
# Return the Rack release as a dotted string.
def self.release
"1.2"
"1.2.1"
end
autoload :Builder, "rack/builder"

View File

@ -20,7 +20,7 @@ module Rack
class FastCGI
def self.run(app, options={})
file = options[:File] and STDIN.reopen(UNIXServer.new(file))
port = options[:Port] and STDIN.reopen(TCPServer.new(port))
port = options[:Port] and STDIN.reopen(TCPServer.new(options[:Host], port))
FCGI.each { |request|
serve request, app
}

View File

@ -1,3 +1,5 @@
require 'thread'
module Rack
class Lock
FLAG = 'rack.multithread'.freeze

View File

@ -77,7 +77,8 @@ module Rack
@rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
@rewindable_io.binmode
if filesystem_has_posix_semantics?
@rewindable_io.unlink
# Use ::File.unlink as 1.9.1 Tempfile has a bug where unlink closes the file!
::File.unlink @rewindable_io.path
raise 'Unlink failed. IO closed.' if @rewindable_io.closed?
@unlinked = true
end

View File

@ -69,7 +69,7 @@ module Rack
end
opts.on_tail("--version", "Show version") do
puts "Rack #{Rack.version}"
puts "Rack #{Rack.version} (Release: #{Rack.release})"
exit
end
end
@ -144,7 +144,7 @@ module Rack
def default_options
{
:environment => "development",
:environment => ENV['RACK_ENV'] || "development",
:pid => nil,
:Port => 9292,
:Host => "0.0.0.0",

View File

@ -135,7 +135,7 @@ module Rack
"'" => "&#39;",
'"' => "&quot;",
}
ESCAPE_HTML_PATTERN = Regexp.union(ESCAPE_HTML.keys)
ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys)
# Escape ampersands, brackets and quotes to their HTML/XML entities.
def escape_html(string)

View File

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "rack"
s.version = "1.2.0"
s.version = "1.2.1"
s.platform = Gem::Platform::RUBY
s.summary = "a modular Ruby webserver interface"
@ -14,14 +14,14 @@ middleware) into a single method call.
Also see http://rack.rubyforge.org.
EOF
s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*,spec/**/*}'] +
s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*,test/**/*}'] +
%w(COPYING KNOWN-ISSUES rack.gemspec README SPEC)
s.bindir = 'bin'
s.executables << 'rackup'
s.require_path = 'lib'
s.has_rdoc = true
s.extra_rdoc_files = ['README', 'SPEC', 'KNOWN-ISSUES']
s.test_files = Dir['spec/spec_*.rb']
s.test_files = Dir['test/spec_*.rb']
s.author = 'Christian Neukirchen'
s.email = 'chneukirchen@gmail.com'

View File

@ -17,7 +17,7 @@ fastcgi.server = (
"test.ru" => ("localhost" =>
("min-procs" => 1,
"socket" => "/tmp/rack-test-ru-fcgi",
"bin-path" => "test.ru")),
"bin-path" => CWD + "/rackup_stub.rb test.ru")),
"sample_rackup.ru" => ("localhost" =>
("min-procs" => 1,
"socket" => "/tmp/rack-test-rackup-fcgi",

View File

@ -1,3 +1,4 @@
begin
require File.expand_path('../testrequest', __FILE__)
require 'rack/handler/cgi'
@ -7,6 +8,10 @@ describe Rack::Handler::CGI do
@host = '0.0.0.0'
@port = 9203
if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end
# Keep this first.
$pid = fork {
ENV['RACK_ENV'] = 'deployment'
@ -89,3 +94,7 @@ describe Rack::Handler::CGI do
Process.wait($pid).should == $pid
end
end
rescue RuntimeError
$stderr.puts "Skipping Rack::Session::FastCGI tests (lighttpd is required). Install lighttpd and try again."
end

View File

@ -1,3 +1,4 @@
begin
require File.expand_path('../testrequest', __FILE__)
require 'rack/handler/fastcgi'
@ -7,6 +8,10 @@ describe Rack::Handler::FastCGI do
@host = '0.0.0.0'
@port = 9203
if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end
# Keep this first.
$pid = fork {
ENV['RACK_ENV'] = 'deployment'
@ -94,3 +99,9 @@ describe Rack::Handler::FastCGI do
Process.wait($pid).should.equal $pid
end
end
rescue RuntimeError
$stderr.puts "Skipping Rack::Session::FastCGI tests (lighttpd is required). Install lighttpd and try again."
rescue LoadError
$stderr.puts "Skipping Rack::Handler::FastCGI tests (FCGI is required). `gem install fcgi` and try again."
end

View File

@ -6,9 +6,17 @@ class RockLobster; end
describe Rack::Handler do
it "has registered default handlers" do
Rack::Handler.get('cgi').should.equal Rack::Handler::CGI
Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI
Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel
Rack::Handler.get('webrick').should.equal Rack::Handler::WEBrick
begin
Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI
rescue LoadError
end
begin
Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel
rescue LoadError
end
end
should "raise NameError if handler doesn't exist" do

View File

@ -177,7 +177,6 @@ describe Rack::Handler::Mongrel do
@acc.raise Mongrel::StopServer
end
rescue LoadError => ex
warn ex
rescue LoadError
warn "Skipping Rack::Handler::Mongrel tests (Mongrel is required). `gem install mongrel` and try again."
end

View File

@ -24,6 +24,9 @@ begin
incrementor.call(env)
end
# test memcache connection
Rack::Session::Memcache.new(incrementor)
it "faults on no connection" do
if RUBY_VERSION < "1.9"
lambda{