grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" );
});
-// only needed for 1.8
-grunt.registerTask( "download_docs", function() {
- function capitalize(value) {
- return value[0].toUpperCase() + value.slice(1);
+grunt.registerTask( "generate_themes", function() {
+ var download, files, done,
+ target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
+ distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
+ try {
+ require.resolve( "download.jqueryui.com" );
+ } catch( e ) {
+ throw "You need to manually install download.jqueryui.com for this task to work";
}
- // should be grunt.config("pkg.version")?
- var version = "1.8",
- docsDir = "dist/docs",
- files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
- .split(" ").map(function(widget) {
- return {
- url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget),
- dest: docsDir + '/' + widget + '.html'
- };
- });
- files = files.concat("animate addClass effect hide removeClass show switchClass toggle toggleClass".split(" ").map(function(widget) {
- return {
- url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
- dest: docsDir + '/' + widget + '.html'
- };
- }));
- files = files.concat("Blind Clip Drop Explode Fade Fold Puff Slide Scale Bounce Highlight Pulsate Shake Size Transfer".split(" ").map(function(widget) {
- return {
- url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
- dest: docsDir + '/effect-' + widget.toLowerCase() + '.html'
- };
- }));
- grunt.file.mkdir( "dist/docs" );
- grunt.utils.async.forEach( files, function( file, done ) {
- var out = fs.createWriteStream( file.dest );
- out.on( "close", done );
- request( file.url ).pipe( out );
- }, this.async() );
-});
-grunt.registerTask( "download_themes", function() {
- // var AdmZip = require('adm-zip');
- var done = this.async(),
- themes = grunt.file.read( "build/themes" ).split(","),
- requests = 0;
- grunt.file.mkdir( "dist/tmp" );
- themes.forEach(function( theme, index ) {
- requests += 1;
- grunt.file.mkdir( "dist/tmp/" + index );
- var zipFileName = "dist/tmp/" + index + ".zip",
- out = fs.createWriteStream( zipFileName );
- out.on( "close", function() {
- grunt.log.writeln( "done downloading " + zipFileName );
- // TODO AdmZip produces "crc32 checksum failed", need to figure out why
- // var zip = new AdmZip(zipFileName);
- // zip.extractAllTo('dist/tmp/' + index + '/');
- // until then, using cli unzip...
- grunt.utils.spawn({
- cmd: "unzip",
- args: [ "-d", "dist/tmp/" + index, zipFileName ]
- }, function( err, result ) {
- grunt.log.writeln( "Unzipped " + zipFileName + ", deleting it now" );
- fs.unlinkSync( zipFileName );
- requests -= 1;
- if (requests === 0) {
- done();
- }
- });
- });
- request( "http://ui-dev.jquery.com/download/?" + theme ).pipe( out );
+ // copy release files into download builder to avoid cloning again
+ grunt.file.expandFiles( distFolder + "/**" ).forEach(function( file ) {
+ grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist/, "") );
});
-});
-grunt.registerTask( "copy_themes", function() {
- // each package includes the base theme, ignore that
- var filter = /themes\/base/,
- files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
- return !filter.test( file );
- }),
- // TODO the grunt.template.process call shouldn't be necessary
- target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
- distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
- files.forEach(function( fileName ) {
- var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" );
- grunt.file.copy( fileName, target + targetFile );
- });
+ download = new ( require( "download.jqueryui.com" ) )();
- // copy minified base theme from regular release
files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
files.forEach(function( fileName ) {
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
});
+
+ done = this.async();
+ grunt.utils.async.forEach( download.themeroller.gallery(), function( theme, done ) {
+ var folderName = theme.folderName(),
+ concatTarget = "css-" + folderName,
+ cssContent = theme.css(),
+ cssFolderName = target + "themes/" + folderName + "/",
+ cssFileName = cssFolderName + "jquery.ui.theme.css",
+ cssFiles = grunt.config.get( "concat.css.src" )[ 1 ].slice();
+
+ grunt.file.write( cssFileName, cssContent );
+
+ // get css components, replace the last file with the current theme
+ cssFiles.splice(-1);
+ cssFiles.push( "<strip_all_banners:" + cssFileName + ">" );
+ grunt.config.get( "concat" )[ concatTarget ] = {
+ src: [ "<banner:meta.bannerCSS>", cssFiles ],
+ dest: cssFolderName + "jquery-ui.css"
+ };
+ grunt.task.run( "concat:" + concatTarget );
+
+ theme.fetchImages(function( err, files ) {
+ if ( err ) {
+ done( err );
+ return;
+ }
+ files.forEach(function( file ) {
+ grunt.file.write( cssFolderName + "images/" + file.path, file.data );
+ });
+ done();
+ });
+ }, function( err ) {
+ if ( err ) {
+ grunt.log.error( err );
+ }
+ done( !err );
+ });
});
grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});
-};
\ No newline at end of file
+};