SVG-Edit -> 2.5final
Vendored Rack -> 1.2.1
This commit is contained in:
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: #:stopdoc:
TO_ESCAPE = {
'&' => '&',
'<' => '&lt;',
'>' => '&gt;',
"'" => '&#39;',
'"' => '&quot;',
}
TO_ESCAPE_PATTERN = Regexp.union(TO_ESCAPE.keys)
def escapeHTML def escapeHTML
self.gsub( /&/, "&amp;" ). self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
gsub( /</, "&lt;" ).
gsub( />/, "&gt;" ).
gsub(/'/, "&#39;" ).
gsub(/"/, "&quot;" )
end end
def unescapeHTML def unescapeHTML

View file

@ -18,6 +18,8 @@ module Rack
end end
end end
if Rack.release <= "1.2"
# The Tempfile bug is fixed in the bundled version of Rack
class RewindableInput class RewindableInput
def make_rewindable def make_rewindable
# Buffer all data into a tempfile. Since this tempfile is private to this # 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 ruby_engine == "ruby" && RUBY_VERSION == "1.9.1" && RUBY_PATCHLEVEL >= 152
end end
end 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) { function showPanel(on) {
var conn_rules = $('#connector_rules'); var conn_rules = $('#connector_rules');
if(!conn_rules.length) { if(!conn_rules.length) {
@ -73,8 +82,43 @@ svgEditor.addExtension("Connector", function(S) {
} }
} }
function findConnectors() { function updateLine(diff_x, diff_y) {
var elems = selElems; // 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); var connectors = $(svgcontent).find(conn_sel);
connections = []; connections = [];
@ -99,7 +143,6 @@ svgEditor.addExtension("Connector", function(S) {
$(this).remove(); $(this).remove();
continue; continue;
} }
if($.inArray(c_elem, elems) !== -1 || add_this) { if($.inArray(c_elem, elems) !== -1 || add_this) {
var bb = svgCanvas.getStrokedBBox([c_elem]); var bb = svgCanvas.getStrokedBBox([c_elem]);
connections.push({ connections.push({
@ -114,11 +157,11 @@ svgEditor.addExtension("Connector", function(S) {
}); });
} }
function updateConnectors() { function updateConnectors(elems) {
// Updates connector lines based on selected elements // Updates connector lines based on selected elements
// Is not used on mousemove, as it runs getStrokedBBox every time, // Is not used on mousemove, as it runs getStrokedBBox every time,
// which isn't necessary there. // which isn't necessary there.
findConnectors(); findConnectors(elems);
if(connections.length) { if(connections.length) {
// Update line with element // Update line with element
var i = connections.length; var i = connections.length;
@ -127,7 +170,7 @@ svgEditor.addExtension("Connector", function(S) {
var line = conn.connector; var line = conn.connector;
var elem = conn.elem; var elem = conn.elem;
var sw = line.getAttribute('stroke-width'); var sw = line.getAttribute('stroke-width') * 5;
var pre = conn.is_start?'start':'end'; var pre = conn.is_start?'start':'end';
// Update bbox for this element // Update bbox for this element
@ -145,11 +188,11 @@ svgEditor.addExtension("Connector", function(S) {
var src_y = bb2.y + bb2.height/2; var src_y = bb2.y + bb2.height/2;
// Set point of element being moved // 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); setPoint(line, conn.is_start?0:'end', pt.x, pt.y, true);
// Set point of connected element // 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); setPoint(line, conn.is_start?'end':0, pt2.x, pt2.y, true);
// Update points attribute manually for webkit // Update points attribute manually for webkit
@ -337,8 +380,9 @@ svgEditor.addExtension("Connector", function(S) {
if(mode == "connector" && started) { if(mode == "connector" && started) {
var sw = cur_line.getAttribute('stroke-width') * 3;
// Set start point (adjusts based on bb) // 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_x = pt.x;
start_y = pt.y; start_y = pt.y;
@ -360,38 +404,8 @@ svgEditor.addExtension("Connector", function(S) {
} }
} }
if(connections.length) { if(connections.length) {
// Update line with element updateLine(diff_x, diff_y);
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);
}
} }
} }
@ -449,7 +463,7 @@ svgEditor.addExtension("Connector", function(S) {
var bb = svgCanvas.getStrokedBBox([end_elem]); 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); setPoint(cur_line, 'end', pt.x, pt.y, true);
$(cur_line) $(cur_line)
.data("c_start", start_id) .data("c_start", start_id)
@ -492,6 +506,7 @@ svgEditor.addExtension("Connector", function(S) {
showPanel(false); showPanel(false);
} }
} }
updateConnectors();
}, },
elementChanged: function(opts) { elementChanged: function(opts) {
var elem = opts.elems[0]; var elem = opts.elems[0];
@ -540,10 +555,16 @@ svgEditor.addExtension("Connector", function(S) {
svgCanvas.clearSelection(); svgCanvas.clearSelection();
pline.id = id; pline.id = id;
svgCanvas.addToSelection([pline]); 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) { toolButtonStateUpdate: function(opts) {
if(opts.nostroke) { if(opts.nostroke) {

View file

@ -261,6 +261,7 @@ svgEditor.addExtension("Markers", function(S) {
if (val=='') val='\\nomarker'; if (val=='') val='\\nomarker';
if (val=='\\nomarker') { if (val=='\\nomarker') {
setIcon(pos,val); setIcon(pos,val);
S.call("changed", selElems);
return; return;
} }
// Set marker on element // 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="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 id="palette_holder"><div id="palette" title="Click to change fill color, shift-click to change stroke color"></div></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>
<div id="option_lists"> <div id="option_lists">

View file

@ -308,6 +308,11 @@ run on port 11211) and memcache-client installed.
* Various multipart fixes * Various multipart fixes
* Switch test suite to bacon * 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 == Contact
Please post bugs, suggestions and patches to Please post bugs, suggestions and patches to

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
require 'thread'
module Rack module Rack
class Lock class Lock
FLAG = 'rack.multithread'.freeze 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.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
@rewindable_io.binmode @rewindable_io.binmode
if filesystem_has_posix_semantics? 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? raise 'Unlink failed. IO closed.' if @rewindable_io.closed?
@unlinked = true @unlinked = true
end end

View file

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

View file

@ -135,7 +135,7 @@ module Rack
"'" => "&#39;", "'" => "&#39;",
'"' => "&quot;", '"' => "&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. # Escape ampersands, brackets and quotes to their HTML/XML entities.
def escape_html(string) def escape_html(string)

View file

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

View file

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

View file

@ -1,3 +1,4 @@
begin
require File.expand_path('../testrequest', __FILE__) require File.expand_path('../testrequest', __FILE__)
require 'rack/handler/cgi' require 'rack/handler/cgi'
@ -7,6 +8,10 @@ describe Rack::Handler::CGI do
@host = '0.0.0.0' @host = '0.0.0.0'
@port = 9203 @port = 9203
if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end
# Keep this first. # Keep this first.
$pid = fork { $pid = fork {
ENV['RACK_ENV'] = 'deployment' ENV['RACK_ENV'] = 'deployment'
@ -89,3 +94,7 @@ describe Rack::Handler::CGI do
Process.wait($pid).should == $pid Process.wait($pid).should == $pid
end end
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 File.expand_path('../testrequest', __FILE__)
require 'rack/handler/fastcgi' require 'rack/handler/fastcgi'
@ -7,6 +8,10 @@ describe Rack::Handler::FastCGI do
@host = '0.0.0.0' @host = '0.0.0.0'
@port = 9203 @port = 9203
if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end
# Keep this first. # Keep this first.
$pid = fork { $pid = fork {
ENV['RACK_ENV'] = 'deployment' ENV['RACK_ENV'] = 'deployment'
@ -94,3 +99,9 @@ describe Rack::Handler::FastCGI do
Process.wait($pid).should.equal $pid Process.wait($pid).should.equal $pid
end end
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 describe Rack::Handler do
it "has registered default handlers" do it "has registered default handlers" do
Rack::Handler.get('cgi').should.equal Rack::Handler::CGI 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 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 end
should "raise NameError if handler doesn't exist" do should "raise NameError if handler doesn't exist" do

View file

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

View file

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