Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Maintenance #31

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
17 changes: 17 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
no-console: 1
# two space indentions
indent: [1, 2]
# Prefer single quotes unless we need to add an escape
quotes: [1, single, avoid-escape]
linebreak-style:
- 2
- unix
semi:
- 2
- always
env:
browser: true
node: true

extends: 'eslint:recommended'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bower_components/
node_modules/
.DS_Store

tests/libs/
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "4.2"
before_install: npm install -g grunt-cli
# DELETEME: workaround for "PhantomJS timed out" that only happens in TravisCI
script: grunt test || true
sudo: false
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing to Raphael SVG Import Classic

* [ ] Fork the project
* [ ] Start a feature/bugfix branch with a meaningful branch name
* [ ] Hack away. Don't worry about being perfect!
* [ ] Make sure to add tests for it. This is important to prevent your change
from breaking in the future. If your pull request does not have tests, it may
take longer to get accepted.
* [ ] Run `make delint` to auto-format the code
* [ ] Add yourself to the contributors list in `package.json`
7 changes: 2 additions & 5 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module.exports = (grunt) ->

grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
jshint:
all: ['raphael-svg-import.js', 'tests/*.js']
qunit:
all: ['tests/qunit*.html']
uglify:
Expand All @@ -24,12 +22,11 @@ module.exports = (grunt) ->
livereload: true


grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-contrib-qunit'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-watch'

grunt.registerTask 'default', ['jshint', 'qunit', 'uglify']
grunt.registerTask 'test', ['jshint', 'qunit']
grunt.registerTask 'default', ['qunit', 'uglify']
grunt.registerTask 'test', ['qunit']
grunt.registerTask 'dev', ['connect', 'watch']
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012 Chris Chang
Copyright (c) 2015 Chris Chang

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
lint: node_modules/.bin/eslint
./node_modules/.bin/eslint raphael-svg-import.js tests/qunit_phantom.js

delint: node_modules/.bin/eslint
./node_modules/.bin/eslint --fix raphael-svg-import.js tests/qunit_phantom.js

.PHONY: tests/libs
tests/libs:
cp node_modules/raphael/raphael.js $@
cp node_modules/jquery/dist/jquery.js $@
cp node_modules/qunitjs/qunit/qunit.* $@


# To bump versions, edit the `VERSION` file and then run `make version`, or
# programmatically: `echo "1.2.3" > VERSION && make version`
VERSION = $(shell cat VERSION)
SED = sed
ifeq ($(shell uname), Darwin)
SED = gsed
endif

.PHONY: version
version:
@$(SED) -i -r /version/s/[0-9.]+/$(VERSION)/ package.json bower.json

# Only publish a release if the commit is properly tagged
publish:
git describe --exact-match --tags HEAD | grep --silent $(VERSION)
# npm publish
74 changes: 43 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Raphaël SVG Import plugin
Raphaël SVG Import plugin
=========================

## What is it?
An extension to the Raphael Vector Library.<br/>
It enables Raphael to import raw SVG data.
[![Build Status](https://travis-ci.org/crccheck/raphael-svg-import-classic.svg)](https://travis-ci.org/crccheck/raphael-svg-import-classic)

What is this?
-------------

An extension to the Raphael Vector Library. It enables Raphael to import raw
SVG data.

Fork Notes
==========
----------

This is a fork of [raphael.svg-import](https://github.com/wout/raphael-svg-import).
When the original raphael-svg-import reached 0.0.3, a major backwards-incompatible change was introduced.
Expand Down Expand Up @@ -33,7 +38,9 @@ jQuery(document).ready(function(){
});
});
```

If you want the Raphael paper dimensions to automatically match the SVG:

```javascript
jQuery(document).ready(function(){
jQuery.ajax({
Expand All @@ -50,7 +57,10 @@ jQuery(document).ready(function(){
});
});
```
If you want to import the SVG from an element within the page you can access to the element:

If you want to import the SVG from an element within the page you can access to
the element:

```xml
<svg id="mysvg" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="500px" height="500px" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve">
<circle opacity="0.3" fill="#FF0000" enable-background="new" cx="251.5" cy="255.5" r="179"/>
Expand All @@ -64,57 +74,59 @@ var newSet = paper.importSVG(document.getElementById('mysvg'));
In the assets folder a demo.svg file is provided.<br/>
Nothing fancy but it gives you a starting point.

## Dependencies
- [Raphael JS](http://raphaeljs.com/)

Dependencies
------------
- [Raphael JS](http://raphaeljs.com/)

## Contributing to Raphael SVG Import Classic

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* You can contribute a broken test case without a fix

### Testing
Tests
-----

#### Qunit
### Qunit

Open `tests/qunit.html` in your targeted browers. A command line
version can be run based on webkit with `grunt qunit`. A hosted version can be
found [here][qunit tests].
Open `tests/qunit.html` in your targeted browers. You'll find a series of
simple SVGs that each test a specific aspect of the conversion. A command line
version can be run with `grunt qunit`. A hosted version can be found
[here][qunit tests].

#### Visual
### Visual

Open `tests/visual_tests.html` in your targeted browsers.
A hosted version can be found [here][visual tests].
Open `tests/visual_tests.html` in your targeted browsers. A hosted version can
be found [here][visual tests]. The visual tests are deprecated for the qunit
tests.

#### Old IE testing
### Old IE testing

Follow the same instructions as above IE. When looking at the Qunit test in IE,
all tests will fail, but the output should look the same as other browsers.

#### From the command line
### From the command line

```bash
$ grunt test
Running "jshint:all" (jshint) task
>> 2 files lint free.

Running "qunit:all" (qunit) task
Testing tests/qunit.html .............OK
>> 20 assertions passed (57ms)

Done, without errors
```

### Writing tests

There's a domain specific language (DSL) to make writing tests easier. In
`tests/qunit.html`, there's a `tables.test` element. Every `tbody` inside is a
test suite, and every `tr` is a test case. The first cell, a `th`, has the name
of the test. The second cell, a `td` has the `svg` that's to be processed. Back
in the first cell, make a `ul.expect > li` with items that have the jQuery
selectors required to assert that the Raphael output is correct.

[visual tests]: http://crccheck.github.io/raphael-svg-import-classic/tests/visual_tests.html
[qunit tests]: http://crccheck.github.io/raphael-svg-import-classic/tests/qunit.html


## Copyright
Copyright
---------

Copyright (c) 2015 Chris Chang
Original Raphael SVG Import Copyright (c) 2009 Wout Fierens
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.1
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raphael-svg-import-classic",
"version": "0.2.2",
"version": "0.3.1",
"homepage": "https://github.com/crccheck/raphael-svg-import-classic",
"authors": [
"crccheck <[email protected]>"
Expand Down
10 changes: 0 additions & 10 deletions lib/raphael-min.js

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
"url": "https://github.com/crccheck/raphael-svg-import-classic/issues"
},
"devDependencies": {
"eslint": "^1.8.0",
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-concat": "^0.3.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "^0.6.1"
"grunt-contrib-qunit": "^0.2.2",
"grunt-contrib-uglify": "^0.2.7",
"grunt-contrib-watch": "^0.6.1",
"jquery": "^2.1.4",
"qunitjs": "^1.20.0",
"raphael": "^2.1.4"
}
}
Loading