diff --git a/.gitignore b/.gitignore index 646ac519e..617aa1704 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.idea .DS_Store node_modules/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a5d74b480..000000000 --- a/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[submodule "libs/Blob.js"] - path = libs/Blob.js - url = https://github.com/eligrey/Blob.js.git -[submodule "libs/FileSaver.js"] - path = libs/FileSaver.js - url = https://github.com/eligrey/FileSaver.js.git -[submodule "libs/pdf.js"] - path = libs/pdf.js - url = https://github.com/mozilla/pdf.js.git -[submodule "libs/zpipe"] - path = libs/zpipe - url = https://github.com/richardassar/zpipe.git -[submodule "libs/adler32cs.js"] - path = libs/adler32cs.js - url = https://github.com/chick307/adler32cs.js.git diff --git a/Makefile b/Makefile deleted file mode 100644 index b38428934..000000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - npm install - npm install -g uglify-js - bower install - ./build.sh \ No newline at end of file diff --git a/README.md b/README.md index 2f685779d..9deb0eb23 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ You can [catch me on twitter](http://twitter.com/MrRio): [@MrRio](http://twitter See examples/basic.html. There's a live editor example at index.html. ```javascript - var doc = new jsPDF(); doc.text(20, 20, 'Hello world.'); doc.save('Test.pdf'); @@ -19,38 +18,15 @@ doc.save('Test.pdf'); **Head over to [jsPDF.com](http://jspdf.com) for details or [_here_](http://mrrio.github.io/jsPDF/) for our most recent live editor and examples.** -## Checking out the source - -```bash -git clone --recursive git://github.com/MrRio/jsPDF.git -``` - -## Building - -To build, simply run the 'make' command. This will fetch all npm and bower deps, then compile minified JS files. - -## Running locally - -Due to certain restrictions that local files have, you'll need to run a web server. Just run: - -``` -npm start -``` - -You can then access the site at localhost:8000 +## Contributing +Build the library with `npm run build`. This will fetch all dependencies and then compile the `dist` files. To see the examples locally you can start a web server with `npm start` and go to `localhost:8000`. ## Credits +- Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase. +- Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript). +- Everyone else that's contributed patches or bug reports. You rock. -Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase. - -Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript). - -Everyone else that's contributed patches or bug reports. You rock. - -## License - -(MIT License) - +## License (MIT) Copyright (c) 2010-2016 James Hall, https://github.com/MrRio/jsPDF Permission is hereby granted, free of charge, to any person obtaining diff --git a/build.sh b/build.sh index 376c796af..3998abab8 100755 --- a/build.sh +++ b/build.sh @@ -7,33 +7,27 @@ output=dist/jspdf.min.js options="-m -c --wrap --stats" -version="`python -c 'import time;t=time.gmtime(time.time());print("1.%d.%d" % (t[0] - 2014, t[7]))'`" -libs="`find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`" +version="$(node -p -e "require('./package.json').version")" +npm_libs="node_modules/cf-blob.js/Blob.js node_modules/filesaver.js/FileSaver.js node_modules/adler32cs/adler32cs.js" +libs="${npm_libs} `find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`" files="jspdf.js plugins/*js" build=`date +%Y-%m-%dT%H:%M` commit=`git rev-parse --short=10 HEAD` whoami=`whoami` -# Update submodules -git submodule init libs/FileSaver.js/ -git submodule init libs/adler32cs.js/ -git submodule init libs/Blob.js/ - -git submodule foreach git pull origin master - echo "Building version ${version}" # Update Bower sed -i.bak "s/\"version\": \"(.*)\"/\"${version}\"/" bower.json # Fix conflict with adler32 & FileSaver -adler1="libs/adler32cs.js/adler32cs.js" +adler1="node_modules/adler32cs/adler32cs.js" adler2="adler32-tmp.js" cat ${adler1} \ | sed -e 's/this, function/jsPDF, function/' \ | sed -e 's/typeof define/0/' > $adler2 libs="$(echo $libs | sed "s#$adler1#$adler2#")" -saveas1="libs/FileSaver.js/FileSaver.js" +saveas1="node_modules/filesaver.js/FileSaver.js" saveas2="FileSaver-tmp.js" cat ${saveas1} \ | sed -e 's/define !== null) && (define.amd != null/0/' > $saveas2 @@ -44,7 +38,7 @@ cat ${files} ${libs} \ | sed s/\${versionID}/${version}-git\ Built\ on\ ${build}/ \ | sed s/\${commitID}/${commit}/ \ | sed "s/\"1\.0\.0-trunk\"/\"${version}-debug ${build}:${whoami}\"/" > "$(echo $output | sed s/min/debug/)" -uglifyjs ${options} -o ${output} ${files} ${libs} +./node_modules/.bin/uglifyjs ${options} -o ${output} ${files} ${libs} # Pretend license information to minimized file for fn in ${files} ${libs}; do diff --git a/libs/Blob.js b/libs/Blob.js deleted file mode 160000 index 0cef27464..000000000 --- a/libs/Blob.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0cef2746414269b16834878a8abc52eb9d53e6bd diff --git a/libs/FileSaver.js b/libs/FileSaver.js deleted file mode 160000 index 230de7d14..000000000 --- a/libs/FileSaver.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 230de7d1426d0d04abe782e0aed5800838892dd7 diff --git a/libs/adler32cs.js b/libs/adler32cs.js deleted file mode 160000 index c6576b4ed..000000000 --- a/libs/adler32cs.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6576b4ed91b4216973bf85d8478a49970934515 diff --git a/package.json b/package.json index 6ebba9cce..5a3ea4e93 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,15 @@ }, "dependencies": {}, "devDependencies": { - "local-web-server": "^0.5.19" + "adler32cs": "github:chick307/adler32cs.js", + "cf-blob.js": "0.0.1", + "filesaver.js": "github:andyinabox/FileSaver.js", + "local-web-server": "^0.5.19", + "uglify-js": "^2.6.2" }, "scripts": { - "start": "ws" + "start": "ws", + "build": "npm install && bower install && ./build.sh", + "version": "npm run build && git add -A dist" } }