#!/bin/sh

echo '// core' > wp-tinymce.js
cat tiny_mce.js >> wp-tinymce.js

for file in `find . -name editor_template.js`
do
	echo "// $file" >> wp-tinymce.js
	cat $file >> wp-tinymce.js
	echo '' >> wp-tinymce.js
done

for file in `find . -name editor_plugin.js`
do
	echo "// $file" >> wp-tinymce.js
	cat $file >> wp-tinymce.js
	echo '' >> wp-tinymce.js
done

echo "// mark as loaded" >> wp-tinymce.js
cat >> wp-tinymce.js <<HERE
(function(){if('undefined'==tinyMCEPreInit)return;var b=tinyMCEPreInit,a=tinymce.ScriptLoader,f=b.mceInit.language,e=b.mceInit.theme,c=b.mceInit.plugins,d=b.suffix;a.markDone(b.base+"/langs/"+f+".js");a.markDone(b.base+"/themes/"+e+"/editor_template"+d+".js");a.markDone(b.base+"/themes/"+e+"/langs/"+f+".js");a.markDone(b.base+"/themes/"+e+"/langs/"+f+"_dlg.js");tinymce.each(c.split(","),function(g){if(g&&g.charAt(0)!="-"){a.markDone(b.base+"/plugins/"+g+"/editor_plugin"+d+".js");a.markDone(b.base+"/plugins/"+g+"/langs/"+f+".js");a.markDone(b.base+"/plugins/"+g+"/langs/"+f+"_dlg.js")}})})();
HERE

gzip wp-tinymce.js