Skip to content

Commit 8cce7a7

Browse files
committed
jQuery Color
Squashed commit of the following: commit de2f987 Author: Corey Frang <gnarf37@gmail.com> Date: Fri Jul 26 13:58:23 2013 -0400 SVG Color Names as a title commit e9f3d92 Author: Corey Frang <gnarf37@gmail.com> Date: Fri Jul 26 13:55:22 2013 -0400 updates per review from scott commit 862d0b5 Author: Corey Frang <gnarf37@gmail.com> Date: Fri Jul 26 13:12:49 2013 -0400 jQuery Color index creation
1 parent 9e28b81 commit 8cce7a7

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

grunt.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ grunt.registerTask( "build-index", function() {
5858
( match[ 4 ] ? "-" + match[ 4 ] : "" );
5959
}
6060

61+
function camelCase( str ) {
62+
return str.replace( /-([a-z])/g, function( $0, $1 ) {
63+
return $1.toUpperCase();
64+
});
65+
}
66+
6167
function getLatestStable( releases ) {
6268
return _.find( releases, function( release ) {
6369
return release.version.indexOf( "-" ) === -1;
@@ -181,6 +187,38 @@ grunt.registerTask( "build-index", function() {
181187
});
182188
}
183189

190+
function getColorData() {
191+
var files = grunt.file.expandFiles( "cdn/color/*.js" ),
192+
releases = parseReleases( files,
193+
/(jquery.color-(\d+\.\d+(?:\.\d+)?[^.]*)(?:\.(min))?\.js)/ ),
194+
modes = [ "svg-names", "plus-names" ];
195+
196+
function addTypes( release ) {
197+
release.minified = release.filename.replace( ".js", ".min.js" );
198+
199+
modes.forEach(function( mode ) {
200+
var filename = release.filename.replace( "jquery.color", "jquery.color." + mode ),
201+
minFilename = filename.replace( ".js", ".min.js" );
202+
203+
if ( files.indexOf( "cdn/color/" + filename ) !== -1 ) {
204+
release[ camelCase( mode ) ] = {
205+
filename: filename,
206+
version: release.version,
207+
minified: minFilename
208+
};
209+
}
210+
});
211+
212+
}
213+
214+
releases.forEach( addTypes );
215+
216+
return {
217+
latestStable: getLatestStable( releases ),
218+
all: releases
219+
};
220+
}
221+
184222
Handlebars.registerHelper( "release", function( prefix, release ) {
185223
var html = prefix + " " + release.version + " - " +
186224
"<a href='/" + release.filename + "'>uncompressed</a>";
@@ -221,7 +259,8 @@ grunt.registerTask( "build-index", function() {
221259
})());
222260

223261
var data = getCoreData();
224-
data.ui = getUiData();
262+
data.ui = getUiData(),
263+
data.color = getColorData();
225264

226265
grunt.file.write( "dist/wordpress/posts/page/index.html",
227266
Handlebars.compile( grunt.file.read( "templates/index.hbs" ) )( data ) );
@@ -231,6 +270,9 @@ grunt.registerTask( "build-index", function() {
231270

232271
grunt.file.write( "dist/wordpress/posts/page/ui.html",
233272
Handlebars.compile( grunt.file.read( "templates/ui.hbs" ) )( data ) );
273+
274+
grunt.file.write( "dist/wordpress/posts/page/color.html",
275+
Handlebars.compile( grunt.file.read( "templates/color.hbs" ) )( data ) );
234276
});
235277

236278
};

templates/color.hbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>{
2+
"title": "jQuery Color - All Versions"
3+
}</script>
4+
5+
{{#each color.all}}
6+
<h2>{{version}}</h2>
7+
<ul>
8+
<li>{{release "jQuery Color" this}}</li>
9+
{{#if svgNames}}
10+
<li>{{release "jQuery Color SVG Color Names" svgNames}}</li>
11+
{{/if}}
12+
{{#if plusNames}}
13+
<li>{{release "jQuery Color With Names (last two together)" plusNames}}</li>
14+
{{/if}}
15+
</ul>
16+
{{/each}}

templates/index.hbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,19 @@
6060
</li>
6161
</ul>
6262
{{/with}}
63+
64+
<h2>jQuery Color</h2>
65+
<p>
66+
Showing the latest release for jQuery Color.
67+
<a href="/color/">See all versions of jQuery Color</a>.
68+
</p>
69+
<h3>Latest Stable {{color.latestStable.version}}</h3>
70+
<ul>
71+
<li>{{release "jQuery Color" color.latestStable}}</li>
72+
{{#if color.latestStable.svgNames}}
73+
<li>{{release "jQuery Color SVG Color Names" color.latestStable.svgNames}}</li>
74+
{{/if}}
75+
{{#if color.latestStable.plusNames}}
76+
<li>{{release "jQuery Color With Names (last two together)" color.latestStable.plusNames}}</li>
77+
{{/if}}
78+
</ul>

0 commit comments

Comments
 (0)