Jdrewniak has uploaded a new change for review.
https://gerrit.wikimedia.org/r/296458
Change subject: Generating checksum for translation dir syncronously.
......................................................................
Generating checksum for translation dir syncronously.
Change-Id: I06caab2e2be396608b4e29b0c489cfc3e83e94a9
---
M dev/wikipedia.org/controller.js
M package.json
M prod/wikipedia.org/index.html
3 files changed, 30 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/portals
refs/changes/58/296458/1
diff --git a/dev/wikipedia.org/controller.js b/dev/wikipedia.org/controller.js
index ffa4879..55ddf02 100644
--- a/dev/wikipedia.org/controller.js
+++ b/dev/wikipedia.org/controller.js
@@ -6,10 +6,11 @@
stats = require( '../../data/stats' ),
otherProjects = require( './other-projects.json' ),
otherLanguages = require( './other-languages.json' ),
+ crypto = require( 'crypto' ),
top100000List,
top100000Dropdown,
Controller,
- dirsum = require( 'dirsum' );
+ translationHashes = [];
// Format the dropdown for ./templates/search.mustache
top100000List = stats.getRange( 'wiki', 'numPages', 100000 );
@@ -51,19 +52,39 @@
*/
var translationPath = __dirname + '/assets/translations/';
+function createTranslationsChecksum( hashes ) {
+ hashes.sort();
+
+ var hashString = hashes.join( '' ),
+ checksum = crypto.createHash( 'md5' ).update( hashString
).digest( 'hex' );
+
+ return checksum;
+
+}
+
function createTranslationFiles( translationPath, siteStats ) {
- var writeFile = function ( el ) {
- var fileName = translationPath + el.code + '.json';
- fs.writeFileSync( fileName, JSON.stringify( el ) );
+ var writeFile = function ( el, lang ) {
+
+ if ( el.code ) {
+ lang = el.code;
+ }
+
+ var fileName = translationPath + lang + '.json',
+ fileContent = JSON.stringify( el ),
+ fileHash = crypto.createHash( 'md5' ).update(
fileContent ).digest( 'hex' );
+
+ translationHashes.push( fileHash );
+
+ fs.writeFileSync( fileName, fileContent );
+
};
for ( var lang in siteStats ) {
if ( siteStats[ lang ].sublinks ) {
siteStats[ lang ].sublinks.forEach( writeFile );
} else {
- var fileName = translationPath + lang + '.json';
- fs.writeFileSync( fileName, JSON.stringify( siteStats[
lang ] ) );
+ writeFile( siteStats[ lang ], lang );
}
}
}
@@ -84,11 +105,8 @@
top100Articles: stats.getRangeFormatted( 'wiki', 'numPages', 100, 1000
),
top100000Dropdown: top100000Dropdown,
otherProjects: otherProjects,
- otherLanguages: otherLanguages
+ otherLanguages: otherLanguages,
+ translationChecksum: createTranslationsChecksum( translationHashes )
};
-
-dirsum.digest( translationPath, 'md5', function ( err, hashes ) {
- Controller.translationChecksum = hashes.hash;
-} );
module.exports = Controller;
diff --git a/package.json b/package.json
index 5521fca..0cd4ee4 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,6 @@
"cssnext": "^1.8.4",
"deepmerge": "^0.2.10",
"del": "^2.2.0",
- "dirsum": "^0.1.1",
"gulp": "^3.9.0",
"gulp-compile-handlebars": "^0.5.0",
"gulp-downloader": "^1.0.4",
diff --git a/prod/wikipedia.org/index.html b/prod/wikipedia.org/index.html
index e133deb..e85fe40 100644
--- a/prod/wikipedia.org/index.html
+++ b/prod/wikipedia.org/index.html
@@ -681,7 +681,7 @@
<small>This page is available under the <a
href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
Attribution-ShareAlike License</a>.</small>
</p>
<![if gt IE 7]>
-<script>var translationsHash = "26b2fe071a3b12d5b681f3141e079cc9";</script>
+<script>var translationsHash = "647ae5cb9705b8bdbaf5d091db181826";</script>
<script src="portal/wikipedia.org/assets/js/index-aa2b43f445.js"></script>
<![endif]>
<![if gt IE 9]>
--
To view, visit https://gerrit.wikimedia.org/r/296458
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06caab2e2be396608b4e29b0c489cfc3e83e94a9
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/portals
Gerrit-Branch: master
Gerrit-Owner: Jdrewniak <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits