Add resources

* don’t use git-lfs
* add published www resources
* create bin/build-www-json to generate localized-urls.json needed by www
* add sources for activity cards and guides for translators.
This commit is contained in:
chrisgarrity 2017-06-14 11:14:47 -04:00
parent a8604860cc
commit 642b1213af
1088 changed files with 363075 additions and 8 deletions
.eslintrc.js.travis.yml
bin
package.json
resources
index.htmllocalized-urls.json
source
OriginalCards
cards/InDesign-files
catch
Catch Cards (8.5 x 11).pdfCatch Cards (8.5x11).inddCatch Game - Scratch Cards Files.idmlCatch Game - Scratch Cards Files.inddCatch Game - Scratch Cards Files.pdf
Document fonts
Instructions.txt
Links
Catch1.psdCatch2.psdCatch3.psdCatch4.psdPasted image at 2016_05_05 01_50 PM.psdScratch-Logo-CMYK.aiScreen Shot 2015-10-09 at 1.46.30 PM.psdScreen Shot 2016-04-25 at 2.21.57 PM.psdScreen Shot 2016-04-25 at 5.30.48 PM.psdScreen Shot 2016-04-26 at 9.47.29 AM.psdScreen Shot 2016-05-03 at 10.02.36 AM.psdScreen Shot 2016-05-03 at 10.06.14 AM.psdScreen Shot 2016-05-03 at 10.44.40 AM.psdScreen Shot 2016-05-03 at 10.44.59 AM.psdScreen Shot 2016-05-03 at 10.45.09 AM.psdScreen Shot 2016-05-03 at 5.48.18 PM.psdScreen Shot 2016-05-04 at 10.48.02 AM.psdScreen Shot 2016-05-04 at 10.49.17 AM.psdScreen Shot 2016-05-04 at 10.57.59 AM.psdScreen Shot 2016-05-04 at 11.08.49 AM.psdScreen Shot 2016-05-04 at 11.09.14 AM.psdScreen Shot 2016-05-04 at 11.14.19 AM.psdScreen Shot 2016-05-04 at 12.06.09 PM.psdScreen Shot 2016-05-05 at 1.49.18 PM.psdScreen Shot 2016-05-05 at 1.54.35 PM.psdScreen Shot 2016-05-05 at 1.55.38 PM.psdScreen Shot 2016-05-05 at 2.54.52 PM.psdScreen Shot 2016-05-05 at 4.16.56 PM.psdScreen Shot 2016-05-05 at 4.17.39 PM.psdScreen Shot 2016-07-08 at 4.54.31 PM.psdScreen Shot 2016-07-11 at 4.11.39 PM.psdStampSELECT.aiTC catch-31.psdapple.psdapple2.psdbackdrop_new.psdbowl.psdcatch game img-20.psdcatch game img-21.psdchange-y-block_1.psdfront_01_2.psdfront_07.psdgetready_06A.psdgreen-flag_1.psdhide Screen Shot 2015-10-09 at 1.46.30 PM.psdnew-sprite-area.psdscore 0.psdscore 1.psdscore 2.psdscore 5.psdselect_Apple.psdselect_sprite.psdsound.psdstage_bluesky.psdtab_Costumes.psdtab_Scripts.psdtab_Sounds.psd
dance

View file

@ -26,7 +26,7 @@ module.exports = {
'no-invalid-this': [2],
'no-iterator': [2],
'no-lone-blocks': [2],
'no-loop-func': [2],
'no-loop-func': [1],
'no-multi-spaces': [2],
'no-multi-str': [2],
'no-new': [1],
@ -76,7 +76,7 @@ module.exports = {
'comma-style': [2],
'eol-last': [2, 'always'],
'func-call-spacing': [2, 'never'],
'func-style': [2, 'declaration'],
'func-style': [1, 'expression'],
'indent': [2, 4],
'jsx-quotes': [2, 'prefer-double'],
'key-spacing': [2, {

View file

@ -1,7 +1,6 @@
language: node_js
node_js:
- 6
- 'node'
cache:
directories:
- node_modules

123
bin/build-www-json Normal file
View file

@ -0,0 +1,123 @@
#!/usr/bin/env node
/*
Generates json file defining the localized URLS for www. Assumes that
files will be hosted on the scratch-resources bucket within a www folder.
The key is based on the path to the file, for example the catch.pdf file
with the cards folder would generate:
'''
{
"en": {
"cards.catchLink" : "//scratch-resources.s3.amazonaws.com/www/cards/catch.pdf"
},
"es": {
"cards.catchLink" : "//scratch-resources.s3.amazonaws.com/www/cards/es/catch.pdf"
},
"sv": {
"cards.catchLink" : "//scratch-resources.s3.amazonaws.com/www/cards/sv/catch.pdf"
}
... etc ...
}
'''
*/
// eslint-disable func-style
//
var fs = require('fs');
var path = require('path');
var merge = require('lodash.merge');
// -----------------------------------------------------------------------------
// Utility function
// -----------------------------------------------------------------------------
const allFilesSync = (dir, fileList = []) => {
fs.readdirSync(dir).forEach(file => {
const filePath = path.join(dir, file);
if (!/\.DS*/.test(file)) {
fileList.push(
fs.statSync(filePath).isDirectory() ?
{
[file]: allFilesSync(filePath)
} :
file
);
}
});
return fileList;
};
const fileId = (dir, file) => {
return dir + '.' + path.parse(file).name + "Link" ;
};
const bucketPath = (resource, locale, file) => {
const bucketRoot = 'https://resources.scratch.mit.edu/www/';
return path.join(bucketRoot, resource, locale, file);
};
const localeURL = (resource, locale, file) => {
return {[fileId(resource, file)]: bucketPath(resource, locale, file)};
};
const parseFileList = (dirData, data = {}) => {
// first level of data is the resource, e.g. 'cards', 'guides', etc.
dirData.forEach(resData => {
for (var resId in resData) {
var locales = resData[resId];
locales.forEach(localeData => { // eslint-disable-line no-loop-func
for (var locale in localeData) {
var localeFiles = localeData[locale];
var localeMap = {};
localeFiles.forEach(f => { // eslint-disable-line no-loop-func
merge(localeMap, localeURL(resId, locale, f));
});
merge(data, {[locale]: localeMap});
}
});
}
});
return data;
};
var writeJsonFile = function (outputDir, data) {
var fileName = path.join(outputDir, 'localized-urls.json');
fs.writeFileSync(fileName, JSON.stringify(data), 'utf8');
};
// -----------------------------------------------------------------------------
// Main script
// -----------------------------------------------------------------------------
var args = process.argv.slice(2);
if (!args.length) {
process.stdout.write('An input directory of resources, and a target output directory must be specified.\n');
process.exit(1);
}
var inputsDir = path.resolve(process.cwd(), args.shift());
try {
fs.accessSync(inputsDir, fs.F_OK);
} catch (err) {
process.stdout.write('Fatal error: No input directory.\n');
process.exit(1);
}
if (!args.length) {
process.stdout.write('A destination directory must be specified.\n');
process.exit(1);
}
var outputDir = path.resolve(process.cwd(), args[0]);
try {
fs.accessSync(outputDir, fs.F_OK);
} catch (err) {
// Doesn't exist - create it.
fs.mkdirSync(outputDir);
}
var allFiles = allFilesSync(inputsDir);
var output = parseFileList(allFiles);
writeJsonFile(outputDir, output);

View file

@ -4,7 +4,8 @@
"description": "Source and published versions of Scratch materials and resources",
"scripts": {
"lint": "eslint ./resources/js/list.js",
"test": "npm run lint"
"test": "npm run lint",
"locale": "node ./bin/build-www-json ./resources/www/ ./resources/"
},
"author": "Massachusetts Institute of Technology",
"license": "BSD-3-Clause",
@ -14,6 +15,7 @@
"url": "git+ssh://git@github.com/LLK/scratch-resources.git"
},
"devDependencies": {
"eslint": "^3.19.0"
"eslint": "3.19.0",
"lodash.merge": "4.6.0"
}
}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>S3 Bucket Listing Generator</title>
<title>Scratch Resources browser</title>
<link rel="stylesheet" type="text/css" href="resources.css">
</head>
<body>
@ -30,8 +30,9 @@
<script>
// Configuration variables:
var S3BL_IGNORE_PATH = true;
var BUCKET_NAME = 'scratch-resources';
// var BUCKET_URL = 'https://BUCKET.s3.amazonaws.com';
// var BUCKET_NAME = 'scratch-resources';
var BUCKET_URL = 'https://scratch-resources.s3.amazonaws.com';
var BUCKET_WEBSITE_URL = 'https://resources.scratch.mit.edu';
var S3B_ROOT_DIR = 'source/';
var S3B_SORT = 'A2Z';
// var EXCLUDE_FILE = '.DS_Store';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more