From 62e3c8711e2ba1a654197ff8b8936c3256cbb586 Mon Sep 17 00:00:00 2001 From: martind2000 Date: Sat, 20 Feb 2016 00:44:28 +0000 Subject: [PATCH] added swedish word of the day --- .idea/jsLibraryMappings.xml | 6 ++++++ lib/jade/today.jade | 8 +++++++- lib/swedishword.js | 2 +- lib/today.js | 18 ++++++++++++++---- package.json | 1 + 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 .idea/jsLibraryMappings.xml diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..5ca0055 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lib/jade/today.jade b/lib/jade/today.jade index 4464a06..a407986 100644 --- a/lib/jade/today.jade +++ b/lib/jade/today.jade @@ -1,6 +1,6 @@ -doctype html html(lang="en") head + meta(charset='utf-8') title Today body @@ -35,6 +35,12 @@ html(lang="en") h2 Calendar each line in data.cal.entries p !{line.combined} + .swedish + h2 Word of the day + p(style="font-weight:900;")= data.swedish.xml.words.word + p It is an #{data.swedish.xml.words.wordtype} which means '#{data.swedish.xml.words.translation}'. + p Example: #{data.swedish.xml.words.fnphrase} + p Translated: #{data.swedish.xml.words.enphrase} .history h2 Today in history if data.history.length > 0 diff --git a/lib/swedishword.js b/lib/swedishword.js index 1d679ce..2c9ad07 100644 --- a/lib/swedishword.js +++ b/lib/swedishword.js @@ -42,4 +42,4 @@ module.exports = { } }; -module.exports.getSwedishWord(); \ No newline at end of file +//module.exports.getSwedishWord(); \ No newline at end of file diff --git a/lib/today.js b/lib/today.js index 7138cf9..c0d4305 100644 --- a/lib/today.js +++ b/lib/today.js @@ -7,7 +7,7 @@ var jsonfile = require('jsonfile'), fs = require('fs'), STRING = require('string var log4js = require('log4js'); var logger = log4js.getLogger(); var calHandler = require('./calHandler'); - +var swedishWord = require('./swedishword'); var todayCache = { last: 0, @@ -17,7 +17,8 @@ var todayCache = { history: [], today: '', tv:{entries:[]}, - cal:{entries:[]} + cal:{entries:[]}, + swedish:{} }, expire: ((60 * 1000) * 60) }; @@ -359,6 +360,15 @@ module.exports = { logger.error(e); } + try { + swedishWord.getSwedishWord(function(v) { + todayCache.data.swedish = v ; + }); + } + catch (e) { + logger.error(e); + } + // word of the day http://wotd.transparent.com/rss/swedish-widget.xml?t=1455840000000 @@ -389,12 +399,12 @@ function sendEmailV1() { console.log('compiled template email sent'); }); - //saveData(); + // saveData(); var fn = jade.compileFile(template.file); console.log(fn(todayCache)); - //fs.writeFileSync(htmlfile, fn(todayCache)); + // fs.writeFileSync(htmlfile, fn(todayCache)); } diff --git a/package.json b/package.json index 10ea36f..3b90286 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "request": "^2.67.0", "simple-weather": "^1.2.2", "wordsoap": "^0.2.0", + "xmljson": "^0.2.0", "xmltojson": "^1.1.0" }, "dependencies": {