Skip to content

Commit

Permalink
Bug #6, add NO_LIABILITY to bin/gaad Javascript [iet:8994834]
Browse files Browse the repository at this point in the history
* Plus, fixes to README, package, locale JSON, CSS
  • Loading branch information
nfreear committed May 22, 2017
1 parent 7c663f9 commit 521eec9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

zh*
LICENSE*

test*.html
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Setting several configuration options:

## Translation

[Translations][i18n-code], [#4][i18n].

Français (French):

```html
Expand All @@ -113,6 +115,7 @@ Twitter: [@nfreear][], [@gbla11yday][].
[gaad-image]: https://github.com/nfreear/gaad-widget/raw/master/style/GAAD.widget.png
[wishlist]: https://github.com/nfreear/gaad-widget/issues/2#!-Wishlist "Bug #2, Wishlist"
[i18n]: https://github.com/nfreear/gaad-widget/issues/4 "Bug #4, Translations (v 2.x)"
[i18n-code]: https://github.com/nfreear/gaad-widget/tree/master/locales "Translations, JSON format"
[b/a]: https://github.com/nfreear/gaad-widget/issues/5 "Bug #5, Separate before and after messages (v 2.x)"
[ie]: https://github.com/nfreear/gaad-widget/issues/3#!-MSIE-9-11 "Bug #3, Browser compatibility"
[gist]: https://gist.github.com/nfreear/eef4be96147cb5c1182cbc9e595f2833
Expand Down
42 changes: 24 additions & 18 deletions bin/gaad.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
#!/usr/bin/env node

/*!
Nick, 19-May-2017.
*/
/**
* Node CLI. Build iCalendar and JSON data files.
*
* @copyright © Nick Freear, 19-May-2017.
* @license MIT.
* @link https://github.com/nfreear/gaad-widget
*/
const NO_LIABILITY =
'License: MIT. The data is provided "as is". I accept no responsibility for the accuracy or otherwise of the data, or any losses arising.';

const path = require('path');
const ICS_FILE = path.join(__dirname, '/../data/gaad.en.ics');
const JSON_FILE = path.join(__dirname, '/../data/gaad.json');
const LOCALE_DIR = path.join(__dirname, '/../locales/');
const LOCALE_FILE = path.join(__dirname, '/../src/locales.json');
// const LOCALE_FILE = path.join(__dirname, '/../src/locales.json');
// const JSON_TEXT = path.join(__dirname, '/../src/gaad-texts.json');

const GAAD_START_YEAR = 2011;
const LIMIT_YEARS = 15;
// const A_DAY = 24 * 60 * 60;

const fs = require('fs');
var icalendar = require('icalendar');
var datejs = require('datejs');
const icalendar = require('icalendar');
const datejs = require('datejs');

var texts = readLocaleTexts(LOCALE_DIR);
var today = new Date();
const texts = readLocaleTexts(LOCALE_DIR);
const GAAD_URL = texts.en.url;
const today = new Date();

var ical = new icalendar.iCalendar(); // eslint-disable-line
var gaadobj = {
'//': '', // texts[ '//' ],
'//': NO_LIABILITY,
'timestamp': today.toString('u'),
texts: texts,
dates: {}
};
var idx;

ical.setProperty('X-WR-CALNAME', 'GAAD: http://globalaccessibilityawarenessday.org');
ical.setProperty('X-WR-CALDESC', 'Developed by: Nick Freear.');
ical.setProperty('X-WR-CALNAME', 'GAAD: ' + GAAD_URL);
ical.setProperty('X-WR-CALDESC', NO_LIABILITY);

for (idx = 0; idx < LIMIT_YEARS; idx++) {
var event = ical.addComponent('VEVENT');
Expand All @@ -43,8 +50,8 @@ for (idx = 0; idx < LIMIT_YEARS; idx++) {
console.log('> GAAD %d: %s', idx + 0, GAAD_DATE.toString());

event.setSummary('Global Accessibility Awareness Day (GAAD) #' + (idx + 0));
// event2.setDate(GAAD_DATE, A_DAY); // Duration in seconds
event.setDescription('Join in at – ' + texts.en.url);
// event.setDate(GAAD_DATE, A_DAY); // Duration in seconds
event.setDescription('Join in at – ' + GAAD_URL);
event.addProperty('CREATED', today.toString('u'));
event.setProperty('DTSTART;VALUE=DATE', GAAD_DATE.toString('yyyyMMdd'));
event.setProperty('DTEND;VALUE=DATE', GAAD_DATE.toString('yyyyMMdd'));
Expand All @@ -59,11 +66,11 @@ for (idx = 0; idx < LIMIT_YEARS; idx++) {
}

var json = JSON.stringify(gaadobj, null, 2);
var locjson = JSON.stringify(texts, null, 2);
// var locjson = JSON.stringify(texts, null, 2);
var ics = ical.toString();

fs.writeFile(JSON_FILE, json);
fs.writeFile(LOCALE_FILE, locjson);
// fs.writeFile(LOCALE_FILE, locjson);
fs.writeFile(ICS_FILE, ics);

setTimeout(function () {
Expand All @@ -76,6 +83,8 @@ setTimeout(function () {

console.log(datejs);

// ------------------------------------

function readLocaleTexts (localedir) {
var texts = {};
fs.readdirSync(localedir).forEach(function (file) {
Expand All @@ -87,9 +96,6 @@ function readLocaleTexts (localedir) {
});

return texts;

// var jsontext = fs.readFileSync(JSON_TEXT, 'utf8');
// var texts = JSON.parse(jsontext);
}

// End.
4 changes: 2 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Global Accessibility Awareness Day (GAAD)",
"before": "Join us on Thursday May {d}{th}, {y} and mark the {x}th <a href='{u}' target='_top'>{g}</a>.",
"after": "Put next year's <a href='{u}' target='_top'>{g}</a>, Thursday May {d}{th}, {y}, in your diary. See you then!",
"before": "Join us on Thursday May {d}{th}, {y} and mark the {x}th <a {at}>{g}</a>{g}</a>.",
"after": "Put next year's <a {at}>{g}</a>{g}</a>, Thursday May {d}{th}, {y}, in your diary. See you then!",
"url": "http://globalaccessibilityawarenessday.org"
}
6 changes: 3 additions & 3 deletions locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"before": "Rejoignez-nous le jeudi {d} mai {y} et marquez le {x}ème <a href='{u}' target='_top'>{g}</a>.",
"after": "Mettez le <a href='{u}' target='_top'>{g}</a> de l'année prochaine, le jeudi {d} mai {y} dans votre journal. À plus tard!",
"url": "http://globalaccessibilityawarenessday.org/gaadfr.html"
"before": "Rejoignez-nous le jeudi {d} mai {y} et marquez le {x}ème <a {at}>{g}</a>.",
"after": "Mettez le <a {at}>{g}</a> de l'année prochaine, le jeudi {d} mai {y} dans votre journal. À plus tard!",
"url": "/gaadfr.html"
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
"semistandard": "^11.0.0",
"uglify-js": "^2.8.26"
},
"engines": {
"node": ">= 4.0.0"
},
"bin": {
"gaad": "./bin/gaad"
"gaad": "./bin/gaad.js"
},
"scripts": {
"install-legacy-datejs": "mkdir x_legacy; npm i --prefix x_legacy https://github.com/datejs/Datejs#8164739566",
Expand Down
1 change: 1 addition & 0 deletions style/GAAD.widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
text-align: center;
}

/*csslint adjoining-classes: false */
.gaad-widget-js.black {
background: #333;
}
Expand Down

0 comments on commit 521eec9

Please sign in to comment.