Skip to content
Browse files

Add filesize calculations back in

  • Loading branch information...
1 parent 1f0fdb6 commit a7029042c1497e3c6d7c906476f90834c6a629c3 @timrwood timrwood committed Jun 6, 2014
View
24 data/size.js
@@ -0,0 +1,24 @@
+var fs = require('fs'),
+ gzipSize = require('gzip-size'),
+ moment = require('../libs/moment/moment.js'),
+ timezone = require('../libs/moment-timezone/moment-timezone.js').tz;
+
+function size (file) {
+ var src = fs.readFileSync('./libs/' + file + '.js', 'utf8');
+
+ return {
+ size : src.length,
+ gzip : gzipSize.sync(src)
+ };
+}
+
+module.exports = {
+ moment : size('moment/moment'),
+ moment_min : size('moment/min/moment.min'),
+ moment_with_langs : size('moment/min/moment-with-langs'),
+ moment_with_langs_min : size('moment/min/moment-with-langs.min'),
+ moment_timezone : size('moment-timezone/moment-timezone'),
+ moment_timezone_min : size('moment-timezone/moment-timezone'),
+ moment_version : moment.version,
+ moment_timezone_version : timezone.version
+};
View
8 package.json
@@ -8,7 +8,6 @@
"devDependencies": {
"assemble": "^0.4.37",
"assemble-yaml": "^0.2.1",
- "async": "0.2.5",
"grunt": "^0.4.5",
"grunt-autoprefixer": "^0.7.3",
"grunt-contrib-clean": "^0.5.0",
@@ -19,12 +18,9 @@
"grunt-contrib-watch": "0.6.1",
"grunt-gh-pages": "^0.9.1",
"grunt-sass": "^0.12.1",
- "highlight.js": "7.3.0",
+ "gzip-size": "^0.2.0",
"load-grunt-tasks": "^0.4.0",
- "marked": "0.2.8",
"moment": "^2.6.0",
- "swig": "0.13.5",
- "time-grunt": "^0.3.1",
- "underscore": ">= 1.3.1"
+ "time-grunt": "^0.3.1"
}
}
View
0 pages/helpers/nav.js → pages/helpers/stripIndex.js
File renamed without changes.
View
3 pages/helpers/toKb.js
@@ -0,0 +1,3 @@
+module.exports.toKb = function (src) {
+ return +((src / 1024).toFixed(1)) + 'k';
+};
View
6 pages/layout/moment-base.hbs
@@ -14,7 +14,7 @@ layout : base.hbs
</div>
<div class="title">
<div class="title-inset">
- <h1>Moment.js <span>{{ version }}</span></h1>
+ <h1>Moment.js<span>{{ size.moment_version }}</span></h1>
<h2>{{intro}}</h2>
</div>
</div>
@@ -27,11 +27,11 @@ layout : base.hbs
<strong>moment-with-langs.js</strong>
</a><a class="button gzipped" href="/downloads/moment-with-langs.min.js">
<strong>moment-with-langs.min.js</strong>
- <span class="filesize">{{ library.bundle_gzipped }}</span>
+ <span class="filesize">{{toKb size.moment_with_langs_min.gzip }}</span>
<span class="zipped">gz</span>
</a><a class="button gzipped" href="/downloads/moment.min.js">
<strong>moment.min.js</strong>
- <span class="filesize">{{ library.core_gzipped }}</span>
+ <span class="filesize">{{toKb size.moment_min.gzip }}</span>
<span class="zipped">gz</span>
</a>
</div>
View
14 pages/layout/moment-timezone-base.hbs
@@ -19,4 +19,18 @@ layout : base.hbs
</div>
</header>
+
+<aside>
+ <div class="download section">
+ <a class="button source" href="/downloads/moment-timezone.js">
+ <strong>moment-timezone.js</strong>
+ <span class="filesize">{{toKb size.moment_timezone_min.gzip }}</span>
+ <span class="zipped">gz</span>
+ </a>
+ </div>
+ <div class="section">
+ <pre class="shell"><code>npm install moment-timezone --save</code></pre>
+ </div>
+</aside>
+
{{>body}}
View
50 source/data/library.js
@@ -1,50 +0,0 @@
-var fs = require('fs'),
- zlib = require('zlib'),
- moment = require('../../libs/moment/moment.js'),
- timezone = require('../../libs/moment-timezone/moment-timezone.js').tz;
-
-function filename(fn) {
- fn.unshift(process.cwd());
- var output = fn.join('/');
- return output;
-}
-
-function toKb(input){
- var num = parseFloat((input / 1000).toFixed(1), 10);
- return num + 'kb';
-}
-
-var core_src = fs.readFileSync(process.cwd() + '/libs/moment/moment.js', 'utf8');
-var bundle_src = fs.readFileSync(process.cwd() + '/libs/moment/min/moment-with-langs.js', 'utf8');
-var core_min = fs.readFileSync(process.cwd() + '/libs/moment/min/moment.min.js', 'utf8');
-var bundle_min = fs.readFileSync(process.cwd() + '/libs/moment/min/moment-with-langs.min.js', 'utf8');
-var timezone_src = fs.readFileSync(process.cwd() + '/libs/moment-timezone/moment-timezone.js', 'utf8');
-var timezone_min = fs.readFileSync(process.cwd() + '/libs/moment-timezone/min/moment-timezone.min.js', 'utf8');
-
-module.exports = {
- core_size : toKb(core_src.length),
- core_gzipped : null,
- bundle_size : toKb(bundle_src.length),
- bundle_gzipped : null,
- core_version : moment.version,
-
- timezone_size : toKb(timezone_src.length),
- timezone_gzipped : null,
- timezone_version : timezone.version,
-
- ready : function (cb) {
- zlib.gzip(core_min, function(err, gzip) {
- module.exports.core_gzipped = toKb(gzip.length);
-
- zlib.gzip(timezone_min, function(err, gzip) {
- module.exports.timezone_gzipped = toKb(gzip.length);
-
- zlib.gzip(bundle_min, function(err, gzip) {
- module.exports.bundle_gzipped = toKb(gzip.length);
-
- cb();
- })
- });
- });
- }
-};
View
24 source/data/zones.js
@@ -1,24 +0,0 @@
-var data = require("../../libs/moment-timezone/moment-timezone.json"),
- name, group,
- i;
-
-module.exports = {};
-
-for (i in data.meta) {
- name = i.split('/');
- group = name.shift();
-
- if (!name.length) {
- name = [i];
- group = 'Generic';
- }
-
- if (!module.exports[group]) {
- module.exports[group] = [];
- }
- module.exports[group].push({
- name : name.join('/'),
- group : group,
- id : i
- });
-}
View
7 tasks/html.js
@@ -16,12 +16,13 @@ module.exports = function(grunt) {
partials : 'pages/partials/**/*.hbs',
layoutdir : 'pages/layout',
helpers : 'pages/helpers/**/*.js',
- marked : { sanitize: false }
+ marked : { sanitize: false },
+ lang : require('../data/lang.js'),
+ size : require('../data/size.js')
},
'moment' : {
options : {
- docs : require('../.temp/docs/moment.json'),
- lang : require('../data/lang.js')
+ docs : require('../.temp/docs/moment.json')
},
files: [{
expand : true,

0 comments on commit a702904

Please sign in to comment.
Something went wrong with that request. Please try again.