This commit is contained in:
Kate Hudson 2014-03-20 18:25:32 -04:00
Родитель d41e4434cb
Коммит 6b980cf9e4
10 изменённых файлов: 282 добавлений и 172 удалений

Просмотреть файл

@ -1,17 +1,46 @@
module.exports = function(grunt) {
var path = require('path');
var STRINGS_FOLDER = 'strings/';
var FUNCTION_NAME = 'WebLiteracyClient';
var DEFAULT_LANG = 'en';
grunt.initConfig({
convert: {
strings: {
src: 'latest/weblitmap.json',
dest: 'latest/'
}
},
concat: {
options: {
banner: grunt.file.read('./src/umd.header.js'),
footer: grunt.file.read('./src/umd.footer.js'),
process: function(src, filepath) {
console.log(filepath);
if (filepath.match('weblitmap.json')) {
var json = JSON.parse(src);
return FUNCTION_NAME + '.prototype.template = ' + JSON.stringify(json.literacies, null, ' ') + ';';
} else if (filepath.match(STRINGS_FOLDER)) {
var lang = path.basename(filepath, '.json');
return FUNCTION_NAME + '.prototype.langs["'+ lang +'"] = ' + src + ';';
} else {
return src;
}
}
},
dist: {
src: ['src/web-literacy-client.js', 'latest/**/*.json'],
dest: 'dist/web-literacy-client.with-langs.js',
}
}
});
grunt.registerMultiTask('convert', 'Convert map to locale files', function() {
grunt.loadNpmTasks('grunt-contrib-concat');
var path = require('path');
grunt.registerMultiTask('convert', 'Convert map to locale files', function() {
function specToTransifex(json) {
var output = {};
@ -52,7 +81,7 @@ module.exports = function(grunt) {
var archiveDir = 'archive/' + json.version + '/';
// Write transifex file
var transifexFileName = 'strings/' + path.basename(filepath, '.json') + '_strings_default' + '.json';
var transifexFileName = STRINGS_FOLDER + DEFAULT_LANG + '.json';
grunt.file.write(file.dest + transifexFileName, JSON.stringify(transifex, null, ' '));
grunt.log.writeln('File "' + file.dest + transifexFileName + '" created.');
@ -72,6 +101,6 @@ module.exports = function(grunt) {
});
grunt.registerTask('build', ['convert']);
grunt.registerTask('build', ['convert', 'concat']);
};

172
dist/web-literacy-client.with-langs.js поставляемый Normal file
Просмотреть файл

@ -0,0 +1,172 @@
// if the module has no dependencies, the above pattern can be simplified to
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function() {
function WebLiteracyClient(options) {
var DEFAULT_LANG = 'en';
var self = this;
options = options || {};
self.lang = DEFAULT_LANG;
self.descriptionSuffix = options.descriptionSuffix | '_desc';
self.all = function() {
var strings = self.langs[self.lang];
return self.template.map(function(item) {
return {
term: strings[item.tag] || self.langs[DEFAULT_LANG][item.tag],
tag: item.tag
};
});
};
};
// Set up languages
WebLiteracyClient.prototype.langs = {};
WebLiteracyClient.prototype.langs["en"] = {
"WBLIT-MAP": "Web Literacy Map",
"weblit-Navigation": "Navigation",
"weblit-Navigation_desc": "Using software tools to browse the Web",
"weblit-WebMechanics": "Web Mechanics",
"weblit-WebMechanics_desc": "Understanding the Web ecosystem",
"weblit-Search": "Search",
"weblit-Search_desc": "Locating information, people and resources via the Web",
"weblit-Credibility": "Credibility",
"weblit-Credibility_desc": "Critically evaluating information found on the Web",
"weblit-Security": "Security",
"weblit-Security_desc": "Keeping systems, identities, and content safe",
"weblit-Composing": "Composing for the Web",
"weblit-Composing_desc": "Creating and curating content for the Web",
"weblit-Remix": "Remixing",
"weblit-Remix_desc": "Modifying existing Web resources to create something new",
"weblit-DesignAccessibility": "Design and Accessibility",
"weblit-DesignAccessibility_desc": "Creating universally effective communications through Web resources",
"weblitCodingScripting": "Coding/Scripting",
"weblitCodingScripting_desc": "Creating interactive experiences on the Web",
"weblit-Infrastructure": "Infrastructure",
"weblit-Infrastructure_desc": "Understanding the Internet stack",
"weblit-Sharing": "Sharing",
"weblit-Sharing_desc": "Providing access to Web resources",
"weblit-SharingCollaborating": "Sharing",
"weblit-SharingCollaborating_desc": "Providing access to Web resources",
"weblit-Collaborating": "Collaborating",
"weblit-Collaborating_desc": "Creating Web resources with others",
"weblit-Community": "Community Participation",
"weblit-Community_desc": "Getting involved in web communities and understanding their practices",
"weblit-Privacy": "Privacy",
"weblit-Privacy_desc": "Examining the consequences of sharing data online",
"weblit-OpenPractices": "Open Practices",
"weblit-OpenPractices_desc": "Helping to keep the Web democratic and universally accessible"
};
WebLiteracyClient.prototype.template = [
{
"term": "Navigation",
"description": "Using software tools to browse the Web",
"tag": "weblit-Navigation",
"deprecates": []
},
{
"term": "Web Mechanics",
"description": "Understanding the Web ecosystem",
"tag": "weblit-WebMechanics",
"deprecates": []
},
{
"term": "Search",
"description": "Locating information, people and resources via the Web",
"tag": "weblit-Search",
"deprecates": []
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the Web",
"tag": "weblit-Credibility",
"deprecates": []
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"tag": "weblit-Security",
"deprecates": []
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the Web",
"tag": "weblit-Composing",
"deprecates": []
},
{
"term": "Remixing",
"description": "Modifying existing Web resources to create something new",
"tag": "weblit-Remix",
"deprecates": []
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through Web resources",
"tag": "weblit-DesignAccessibility",
"deprecates": []
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the Web",
"tag": "weblitCodingScripting",
"deprecates": []
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"tag": "weblit-Infrastructure",
"deprecates": []
},
{
"term": "Sharing",
"description": "Providing access to Web resources",
"tag": "weblit-Sharing",
"deprecates": [
"weblit-SharingCollaborating"
]
},
{
"term": "Collaborating",
"description": "Creating Web resources with others",
"tag": "weblit-Collaborating",
"deprecates": []
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"tag": "weblit-Community",
"deprecates": []
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"tag": "weblit-Privacy",
"deprecates": []
},
{
"term": "Open Practices",
"description": "Helping to keep the Web democratic and universally accessible",
"tag": "weblit-OpenPractices",
"deprecates": []
}
];
return WebLiteracyClient;
}));

Просмотреть файл

@ -1,3 +1,4 @@
var wlc = require('../src/web-literacy-client');
var webLiteracyClient = require('../dist/web-literacy-client.with-langs');
console.log(wlc);
var w = new webLiteracyClient();
console.log(w.all());

35
latest/strings/en.json Normal file
Просмотреть файл

@ -0,0 +1,35 @@
{
"WBLIT-MAP": "Web Literacy Map",
"weblit-Navigation": "Navigation",
"weblit-Navigation_desc": "Using software tools to browse the Web",
"weblit-WebMechanics": "Web Mechanics",
"weblit-WebMechanics_desc": "Understanding the Web ecosystem",
"weblit-Search": "Search",
"weblit-Search_desc": "Locating information, people and resources via the Web",
"weblit-Credibility": "Credibility",
"weblit-Credibility_desc": "Critically evaluating information found on the Web",
"weblit-Security": "Security",
"weblit-Security_desc": "Keeping systems, identities, and content safe",
"weblit-Composing": "Composing for the Web",
"weblit-Composing_desc": "Creating and curating content for the Web",
"weblit-Remix": "Remixing",
"weblit-Remix_desc": "Modifying existing Web resources to create something new",
"weblit-DesignAccessibility": "Design and Accessibility",
"weblit-DesignAccessibility_desc": "Creating universally effective communications through Web resources",
"weblitCodingScripting": "Coding/Scripting",
"weblitCodingScripting_desc": "Creating interactive experiences on the Web",
"weblit-Infrastructure": "Infrastructure",
"weblit-Infrastructure_desc": "Understanding the Internet stack",
"weblit-Sharing": "Sharing",
"weblit-Sharing_desc": "Providing access to Web resources",
"weblit-SharingCollaborating": "Sharing",
"weblit-SharingCollaborating_desc": "Providing access to Web resources",
"weblit-Collaborating": "Collaborating",
"weblit-Collaborating_desc": "Creating Web resources with others",
"weblit-Community": "Community Participation",
"weblit-Community_desc": "Getting involved in web communities and understanding their practices",
"weblit-Privacy": "Privacy",
"weblit-Privacy_desc": "Examining the consequences of sharing data online",
"weblit-OpenPractices": "Open Practices",
"weblit-OpenPractices_desc": "Helping to keep the Web democratic and universally accessible"
}

Просмотреть файл

@ -18,5 +18,8 @@
"homepage": "https://github.com/k88hudson/weblit-keys",
"dependencies": {
"grunt": "~0.4.4"
},
"devDependencies": {
"grunt-contrib-concat": "~0.3.0"
}
}

4
src/umd.footer.js Normal file
Просмотреть файл

@ -0,0 +1,4 @@
return WebLiteracyClient;
}));

15
src/umd.header.js Normal file
Просмотреть файл

@ -0,0 +1,15 @@
// if the module has no dependencies, the above pattern can be simplified to
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function() {

Просмотреть файл

@ -1,173 +1,24 @@
var exports;
function WebLiteracyClient(options) {
if (module && module.exports) {
exports = module.exports;
} else {
exports = this;
}
var DEFAULT_LANG = 'en';
(function (exports) {
var self = this;
options = options || {};
function WebLiteracyClient(options) {
self.lang = DEFAULT_LANG;
self.descriptionSuffix = options.descriptionSuffix | '_desc';
var self = this;
options = options || {};
self.defaultLang = 'en';
self.lang = options.lang | self.defaultLang;
self.descriptionSuffix = options.descriptionSuffix | '_desc';
self.all = function(l) {
var language = l | self.lang;
return self.template.map(function(item) {
return {
term: self.langs[self.lang] | self.langs[self.defaultLang] | item.term,
tag: item.tag
};
});
self.all = function() {
var strings = self.langs[self.lang];
return self.template.map(function(item) {
return {
term: strings[item.tag] || self.langs[DEFAULT_LANG][item.tag],
tag: item.tag
};
});
};
};
};
WebLiteracyClient.prototype.langs = {};
WebLiteracyClient.prototype.template = [];
exports.WebLiteracyClient = WebLiteracyClient;
})(exports);
(function(WebLiteracyClient) {
WebLiteracyClient.prototype.template = [
{
"term": "Navigation",
"description": "Using software tools to browse the Web",
"tag": "weblit-Navigation",
"deprecates": []
},
{
"term": "Web Mechanics",
"description": "Understanding the Web ecosystem",
"tag": "weblit-WebMechanics",
"deprecates": []
},
{
"term": "Search",
"description": "Locating information, people and resources via the Web",
"tag": "weblit-Search",
"deprecates": []
},
{
"term": "Credibility",
"description": "Critically evaluating information found on the Web",
"tag": "weblit-Credibility",
"deprecates": []
},
{
"term": "Security",
"description": "Keeping systems, identities, and content safe",
"tag": "weblit-Security",
"deprecates": []
},
{
"term": "Composing for the Web",
"description": "Creating and curating content for the Web",
"tag": "weblit-Composing",
"deprecates": []
},
{
"term": "Remixing",
"description": "Modifying existing Web resources to create something new",
"tag": "weblit-Remix",
"deprecates": []
},
{
"term": "Design and Accessibility",
"description": "Creating universally effective communications through Web resources",
"tag": "weblit-DesignAccessibility",
"deprecates": []
},
{
"term": "Coding/Scripting",
"description": "Creating interactive experiences on the Web",
"tag": "weblitCodingScripting",
"deprecates": []
},
{
"term": "Infrastructure",
"description": "Understanding the Internet stack",
"tag": "weblit-Infrastructure",
"deprecates": []
},
{
"term": "Sharing",
"description": "Providing access to Web resources",
"tag": "weblit-Sharing",
"deprecates": ["weblit-SharingCollaborating"]
},
{
"term": "Collaborating",
"description": "Creating Web resources with others",
"tag": "weblit-Collaborating",
"deprecates": []
},
{
"term": "Community Participation",
"description": "Getting involved in web communities and understanding their practices",
"tag": "weblit-Community",
"deprecates": []
},
{
"term": "Privacy",
"description": "Examining the consequences of sharing data online",
"tag": "weblit-Privacy",
"deprecates": []
},
{
"term": "Open Practices",
"description": "Helping to keep the Web democratic and universally accessible",
"tag": "weblit-OpenPractices",
"deprecates": []
}
];
})(exports.WebLiteracyClient);
(function(WebLiteracyClient) {
WebLiteracyClient.prototype.langs.en = {
"WBLIT-MAP": "Web Literacy Map",
"weblit-Navigation": "Navigation",
"weblit-Navigation_desc": "Using software tools to browse the Web",
"weblit-WebMechanics": "Web Mechanics",
"weblit-WebMechanics_desc": "Understanding the Web ecosystem",
"weblit-Search": "Search",
"weblit-Search_desc": "Locating information, people and resources via the Web",
"weblit-Credibility": "Credibility",
"weblit-Credibility_desc": "Critically evaluating information found on the Web",
"weblit-Security": "Security",
"weblit-Security_desc": "Keeping systems, identities, and content safe",
"weblit-Composing": "Composing for the Web",
"weblit-Composing_desc": "Creating and curating content for the Web",
"weblit-Remix": "Remixing",
"weblit-Remix_desc": "Modifying existing Web resources to create something new",
"weblit-DesignAccessibility": "Design and Accessibility",
"weblit-DesignAccessibility_desc": "Creating universally effective communications through Web resources",
"weblitCodingScripting": "Coding/Scripting",
"weblitCodingScripting_desc": "Creating interactive experiences on the Web",
"weblit-Infrastructure": "Infrastructure",
"weblit-Infrastructure_desc": "Understanding the Internet stack",
"weblit-Sharing": "Sharing",
"weblit-Sharing_desc": "Providing access to Web resources",
"weblit-SharingCollaborating": "Sharing",
"weblit-SharingCollaborating_desc": "Providing access to Web resources",
"weblit-Collaborating": "Collaborating",
"weblit-Collaborating_desc": "Creating Web resources with others",
"weblit-Community": "Community Participation",
"weblit-Community_desc": "Getting involved in web communities and understanding their practices",
"weblit-Privacy": "Privacy",
"weblit-Privacy_desc": "Examining the consequences of sharing data online",
"weblit-OpenPractices": "Open Practices",
"weblit-OpenPractices_desc": "Helping to keep the Web democratic and universally accessible"
};
})(exports.WebLiteracyClient);
// Set up languages
WebLiteracyClient.prototype.langs = {};