aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-15 12:34:39 +0100
committerwout <wout@impinc.co.uk>2012-12-15 12:34:39 +0100
commit72c882328e7ea13af205575f31c5ce1626006d55 (patch)
tree37975cb5ee31679034052d538725ca2ea5c4dcbe
parent3fbcfce61d8449b7c47a845fcc7be7cfb867bf45 (diff)
downloadsvg.js-72c882328e7ea13af205575f31c5ce1626006d55.tar.gz
svg.js-72c882328e7ea13af205575f31c5ce1626006d55.zip
Initial commit
-rw-r--r--.gitignore4
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock17
-rw-r--r--MIT-LICENSE21
-rw-r--r--README.markdown8
-rw-r--r--README.md4
-rw-r--r--Rakefile145
-rw-r--r--src/clip_path.js0
-rw-r--r--src/container.js0
-rw-r--r--src/defs.js0
-rw-r--r--src/dispatcher.js0
-rw-r--r--src/document.js0
-rw-r--r--src/draggable.js0
-rw-r--r--src/element.js0
-rw-r--r--src/group.js0
-rw-r--r--src/image.js0
-rw-r--r--src/nested.js0
-rw-r--r--src/object.js0
-rw-r--r--src/shape.js0
-rw-r--r--src/svg.js0
20 files changed, 199 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8decbad
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+dist/
+dist/svg.min.js
+dist/svg.js \ No newline at end of file
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..dd15469
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem 'rake'
+gem 'uglifier' \ No newline at end of file
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..d39262a
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,17 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ execjs (1.4.0)
+ multi_json (~> 1.0)
+ multi_json (1.5.0)
+ rake (10.0.3)
+ uglifier (1.3.0)
+ execjs (>= 0.3.0)
+ multi_json (~> 1.0, >= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rake
+ uglifier
diff --git a/MIT-LICENSE b/MIT-LICENSE
new file mode 100644
index 0000000..951a65e
--- /dev/null
+++ b/MIT-LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2012-2013 Wout Fierens
+http://svgjs.com/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..0bc9815
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,8 @@
+# svg.js
+
+svg.js is a JavaScript library for manipulating SVG
+following the original SVG specification.
+
+Have a look at [svgjs.com][] for a examples.
+
+svg.js is licensed under the terms of the MIT License.
diff --git a/README.md b/README.md
deleted file mode 100644
index dd0f207..0000000
--- a/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-svgjs
-=====
-
-A lightweight framework for manipulating SVG \ No newline at end of file
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..7eac669
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,145 @@
+SVGJS_VERSION = '0.1'
+
+DEFAULT_MODULES = %w[ svg ]
+
+KILO = 1024 # how many bytes in a "kilobyte"
+
+task :default => :dist
+
+# module-aware file task
+class BuildTask < Rake::FileTask
+ def modules
+ prerequisites.map {|f| File.basename(f, '.js') }
+ end
+
+ def remove_prerequisites to_remove
+ @prerequisites -= to_remove
+ return self
+ end
+
+ def needed?() super or modules_mismatch? end
+
+ def modules_mismatch?
+ previous_modules != modules
+ end
+
+ def previous_modules
+ first_line =~ / - ([\w,\s]+) - / && $1.split(/\W+/)
+ end
+
+ def first_line
+ File.open(name, 'r') {|f| f.gets }
+ end
+end
+
+BuildTask.define_task 'dist/svg.js' => DEFAULT_MODULES.map {|m| "src/#{ m }.js" } do |task|
+ mkdir_p 'dist', :verbose => false
+ File.open(task.name, 'w') do |svgjs|
+ svgjs.puts "/* svg.js %s - %s - svgjs.com/license */" %
+ [version_string, task.modules.join(' ')]
+
+ task.prerequisites.each do |src|
+ # bring in source files one by one, but without copyright info
+ copyright = true
+ File.open(src).each_line do |line|
+ copyright = false if copyright and line !~ %r{^(/|\s*$)}
+ svgjs.puts line unless copyright
+ end
+ end
+ end
+end
+
+file 'dist/svg.min.js' => 'dist/svg.js' do |task|
+ require 'rubygems'
+ begin require 'uglifier'
+ rescue LoadError; fail "Uglifier not available: #{$!}"
+ else
+ File.open(task.name, 'w') do |min|
+ min << Uglifier.new.compile(File.read(task.prerequisites.first))
+ end
+ end
+end
+
+file 'dist/svg.min.gz' => 'dist/svg.min.js' do |task|
+ verbose false do
+ tmp_file = task.name.sub('.gz', '')
+ cp task.prerequisites.first, tmp_file
+ sh 'gzip', '--best', tmp_file
+ end
+end
+
+desc "Concatenate source files to build svg.js"
+task :concat, [:modules] do |task, args|
+ modules = args[:modules].to_s.split(':')
+ to_add, to_exclude = modules.partition {|m| m.sub!(/^(-)?(.+)/, 'src/\2.js'); !$1 }
+
+ Rake::Task['dist/svg.js'].
+ remove_prerequisites(to_exclude).enhance(to_add).
+ invoke
+end
+
+desc "Generate svg.js distribution files and report size statistics"
+task :dist => ['dist/svg.js', 'dist/svg.min.js', 'dist/svg.min.gz'] do |task|
+ orig_size, min_size, gz_size = task.prerequisites.map {|f| File.size(f) }
+
+ puts "Original version: %.3fk" % (orig_size.to_f / KILO)
+ puts "Minified: %.3fk" % (min_size.to_f / KILO)
+ puts "Minified and gzipped: %.3fk, compression factor %.3f" % [gz_size.to_f / KILO, orig_size.to_f / gz_size]
+
+ rm_f 'dist/svg.min.gz', :verbose => false
+end
+
+desc "List available modules"
+task :modules do
+ Dir['src/**/*.js'].each do |file|
+ name = file.gsub(/^src\//,'').gsub(/.js$/,'')
+ puts name + (DEFAULT_MODULES.include?(name) ? '*' : '')
+ end
+ puts "\n*included in default build"
+end
+
+task(:clean) { rm_rf 'dist' }
+
+desc "Run tests with PhantomJS"
+task :test do
+ sh 'script/test'
+ Rake::Task[:check_whitespace].invoke
+end
+
+desc "Strip trailing whitespace and ensure each file ends with a newline"
+task :whitespace do
+ verbose false do
+ files = Dir['{src,test,examples}/**/*.{js,html}']
+ ruby(*%w'-p -i -e $_.sub!(/\s*\Z/,"\n")'.concat(files))
+ end
+end
+
+desc "Checks for trailing whitespace in source files and tests"
+task :check_whitespace do
+ flunked = false
+ flunk = lambda {|file, num| flunked = true; puts "#{file}:#{num}" }
+ Dir['{src,test,examples}/**/*.{js,html}'].each do |file|
+ File.open(file, 'r') {|f| f.each_with_index {|ln, num| flunk.call(file, num + 1) if ln.chomp =~ /\s+$/ } }
+ end
+ fail if flunked
+end
+
+# desc "Generate docco documentation from source files"
+# task :docco do
+# verbose false do
+# sh 'docco', *Dir['src/*.js']
+# end
+# end
+
+# svg.js version number + git sha if available
+def version_string
+ desc = `git describe --tags HEAD 2>&1`.chomp
+ if $?.success?
+ desc
+ else
+ suffix, dir = '', File.basename(Dir.pwd)
+ # detect git sha from directory name of GitHub zip/tarball
+ suffix = "-g#{$1}" if dir =~ /^wout-svg.js-([a-f0-9]{7,40})$/
+ SVGJS_VERSION + suffix
+ end
+end \ No newline at end of file
diff --git a/src/clip_path.js b/src/clip_path.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/clip_path.js
diff --git a/src/container.js b/src/container.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/container.js
diff --git a/src/defs.js b/src/defs.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/defs.js
diff --git a/src/dispatcher.js b/src/dispatcher.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/dispatcher.js
diff --git a/src/document.js b/src/document.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/document.js
diff --git a/src/draggable.js b/src/draggable.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/draggable.js
diff --git a/src/element.js b/src/element.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/element.js
diff --git a/src/group.js b/src/group.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/group.js
diff --git a/src/image.js b/src/image.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/image.js
diff --git a/src/nested.js b/src/nested.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/nested.js
diff --git a/src/object.js b/src/object.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/object.js
diff --git a/src/shape.js b/src/shape.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/shape.js
diff --git a/src/svg.js b/src/svg.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/svg.js