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

Misc. Makefile improvements #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
PROJECT_NAME=jquery-qrcode
PROJECT_NAME ?= jquery-qrcode
USER_NAME ?= jeromeetienne

all:
ALL += jquery.qrcode.min.js
ALL += index.html

CLEAN += $(ALL)
CLEAN += jquery.qrcode.js

all: $(ALL)

clean:
rm -f $(CLEAN)

server:
which python || sudo apt-get install python
python -m SimpleHTTPServer

build: minify

minify:
echo > /tmp/jquery.qrcode.tmp.js
head -2 src/jquery.qrcode.js >> /tmp/jquery.qrcode.tmp.js
cat src/qrcode.js >> /tmp/jquery.qrcode.tmp.js
tail -n +3 src/jquery.qrcode.js >> /tmp/jquery.qrcode.tmp.js
curl --data-urlencode "js_code@/tmp/jquery.qrcode.tmp.js" \
-d "output_format=text&output_info=compiled_code&compilation_level=SIMPLE_OPTIMIZATIONS" \
http://closure-compiler.appspot.com/compile \
> jquery.qrcode.min.js
minify: jquery.qrcode.min.js

jquery.qrcode.js: src/jquery.qrcode.js src/qrcode.js
(head -2 src/jquery.qrcode.js; cat src/qrcode.js; tail -n +3 src/jquery.qrcode.js) > $@

%.min.js: %.js
which closure-compiler || sudo apt-get install libclosure-compiler-java
closure-compiler --compilation_level SIMPLE_OPTIMIZATIONS $< > $@

homepage_build: index.html

~/.pandoc.header.html:
touch $@

homepage_build:
pandoc -A ~/.pandoc.header.html -s README.md -o index.html
sed -i "s/github.com\/you/github.com\/jeromeetienne\/$(PROJECT_NAME)/g" index.html
index.html: README.md ~/.pandoc.header.html
which pandoc || sudo apt-get install pandoc
pandoc -A ~/.pandoc.header.html -s README.md | sed "s|github.com/you|github.com/$(USER_NAME)/$(PROJECT_NAME)|g" > $@

#################################################################################
# deploy #
Expand All @@ -29,4 +44,4 @@ deploy: build
# assume there is something to commit
# use "git diff --exit-code HEAD" to know if there is something to commit
# so two lines: one if no commit, one if something to commit
git commit -a -m "New deploy" && git push -f origin HEAD:gh-pages && git reset HEAD~
git commit -a -m "New deploy" && git push -f origin HEAD:gh-pages && git reset HEAD~
9 changes: 8 additions & 1 deletion src/jquery.qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// typeNumber < 1 for automatic calculation
options = $.extend( {}, {
render : "canvas",
pixelsPerTile : 2,
width : 256,
height : 256,
typeNumber : -1,
Expand All @@ -23,6 +24,9 @@
qrcode.addData(options.text);
qrcode.make();

options.width = qrcode.getModuleCount() * options.pixelsPerTile;
options.height = qrcode.getModuleCount() * options.pixelsPerTile;

// create canvas element
var canvas = document.createElement('canvas');
canvas.width = options.width;
Expand Down Expand Up @@ -52,7 +56,10 @@
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
qrcode.addData(options.text);
qrcode.make();


options.width = qrcode.getModuleCount() * options.pixelsPerTile;
options.height = qrcode.getModuleCount() * options.pixelsPerTile;

// create table element
var $table = $('<table></table>')
.css("width", options.width+"px")
Expand Down