#!/usr/bin/python

import sys
import os

sys.path.append('../htdocs/OpenLayers-2.7/tools')
from jsmin import jsmin

priority_files = ['geomoose/config.js']

jsRoot = '../htdocs/';
jsFolders = ['geomoose/'];

all_files = list()
for path in jsFolders:
	imgs = os.listdir(jsRoot+path)
	imgs = map(lambda x: jsRoot+path+x, imgs)
	for i in imgs:
		if(not(i in priority_files)):
			all_files.append(i)
#	all_files = all_files + imgs

allCode = ''

all_files = map(lambda x: jsRoot+x, priority_files) + all_files
for f in all_files:
	# this test should be better... but I'm lazy.
	if(f.find('.js') > 0 and f.find('.svn') < 0):
		allCode += open(f, 'r').read()


f = open(jsRoot+'compiled.js', 'w')
#f.write(jsmin(allCode))
f.write('/*\n'+open('../LICENSE', 'r').read()+'*/\n\n');
f.write(allCode);
f.close()
