#
# Copyright (C) 2011 Dachary <loic@dachary.org>
#
# This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of
# the GNU Affero General Public License (AGPL) as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version of the AGPL published by the FSF.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
#
# wget http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
YUICOMPRESSOR=/var/www/yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar

JS=js/jquery/jquery-1.6.2.js js/supplant.js tablesorter/jquery.tablesorter.js tablesorter/jquery.tablesorter.pager.js js/jquery.metadata.js js/jquery.cookie.js jscrollpane/jquery.jscrollpane.js js/jquery.cardstories.js test/skin.js js/jquery.query-2.1.7.js js/jquery.placeholder-1.0.1.js

MINIFIED=cardstories.js cardstories.png cardstories.css index.html

all: 
	${MAKE} -C css all
	${MAKE} ${MINIFIED}

clean:

index.html: cardstories.html
	echo ' <!DOCTYPE html>' > index.html
	echo '<html>' >>  index.html
	echo '<head>' >>  index.html
	echo ' <title>Cardstories</title>'
	echo ' <meta http-equiv="Content-type" content="text/html;charset=UTF-8">' >> index.html
	echo ' <script type="text/javascript" src="cardstories.js"></script>' >> index.html
	echo ' <link rel="stylesheet" href="cardstories.css" type="text/css" media="screen">' >> index.html
	echo '</head>' >> index.html
	perl -ne 'print if(/<body>/../EOF/);' < cardstories.html >> index.html

cardstories.css cardstories.png: css/cardstories.css
	cd css ; ${MAKE} all
	cp css/cardstories.png .
	if [ -f ${YUICOMPRESSOR} ] ; then \
		java -jar ${YUICOMPRESSOR} -o cardstories.css css/cardstories.css ; \
	else \
		cp css/cardstories.css cardstories.css ; \
	fi

cardstories.js: ${JS}
	cat ${JS} > merged.js
	if [ -f ${YUICOMPRESSOR} ] ; then \
		java -jar ${YUICOMPRESSOR} -o cardstories.js merged.js ; \
	else \
		cp merged.js cardstories.js ; \
	fi
	rm merged.js
