Comparing version 1.9.9 to 2.0.0
#!/usr/bin/env node | ||
console.log("Make It A Grateful Day! (~);}"); | ||
var lib = require('../lib/index.js'); | ||
var news = lib.terminalTimes(); |
153
lib/index.js
@@ -7,61 +7,13 @@ 'use strict'; | ||
// function terminalTimesDeprecated(){ | ||
// | ||
// var reqOptions = { | ||
// url: "https://www.nytimes.com", | ||
// headers: { | ||
// 'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" | ||
// } | ||
// }; | ||
// | ||
// request(reqOptions, function(error, response, body) { | ||
// if (error) { | ||
// console.log("error with http request\n", error); | ||
// } else if (!error && response.statusCode) { | ||
// let $ = cheerio.load(body); | ||
// $('a').each(function(i, elem) { | ||
// var current = $(this).text(); | ||
// var link = $(this).attr('href'); | ||
// current = current.replace(/ /g, ''); | ||
// current = current.replace(/(\r\n|\n|\r)/gm, ""); | ||
// | ||
// if(link.indexOf('2018') > -1 && (current.length > 2)){ | ||
// var topLine = ''; | ||
// var bottomLine = ''; | ||
// for(var i = 0; i < current.length + 5; i++){ | ||
// topLine = topLine + '-'; | ||
// } | ||
// for(var i = 0; i < link.length + 4; i++){ | ||
// bottomLine = bottomLine + '-'; | ||
// } | ||
// | ||
// console.log("\n "+topLine+"\n |",current, " |\n "+bottomLine); | ||
// console.log(" |",link, "|\n "+bottomLine); | ||
// } | ||
// }); | ||
// } | ||
// }); | ||
// | ||
// }; | ||
function terminalTimes(){ | ||
var holder = []; | ||
var reqOptions = { | ||
var holder = []; | ||
var reqOptions = { | ||
url: "https://www.nytimes.com", | ||
headers: { | ||
'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" | ||
} | ||
} | ||
}; | ||
request(reqOptions, function(error, response, body) { | ||
console.log(` | ||
___________ .__ | ||
\\\__ ___/__________ _____ |__| ____ ______ _ ________ | ||
| |_/ __ \\\_ __ \\\/ \\\| |/ \\\_/ __ \\\ \\\/ \\\/ / ___/ | ||
| |\\\ ___/| | \\\/ Y Y \\\ | | \\\ ___/\\\ /\\\___ \\\\ | ||
|____| \\\___ >__| |__|_| /__|___| /\\\___ >\\\/\\\_//____ >`); | ||
console.log(" TERMINEWS - RANDOM NEWS IN YOUR TERMINAL - 2018"); | ||
console.log(" "+localTime('','*')); | ||
if (error) { | ||
@@ -86,66 +38,43 @@ console.log("error with http request n", error); | ||
for(var z = 0; z < holder.length; z++){ | ||
for(var z = 0; z <holder.length; z++){ | ||
// console.log("holder[z][0][0]:",holder[z][0][0]); | ||
var title = '' | ||
var link = '' | ||
var titleLength = 0 | ||
var linkLength = 0 | ||
var dottedLineA = ' ' | ||
var dottedLineB = ' ' | ||
if(holder[z][0][0].indexOf('Comments') === -1){ | ||
// console.log("holder[z][0][0]:",holder[z][0][0]); | ||
title = holder[z][0][0]; | ||
link = holder[z][0][1] | ||
var randomNumber1 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber2 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber3 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber4 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber5 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber6 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber7 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber8 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber9 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber10 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber11 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber12 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber13 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber14 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber15 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber16 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber17 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber18 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber19 = (Math.random() * holder.length).toFixed(0); | ||
var randomNumber20 = (Math.random() * holder.length).toFixed(0); | ||
var topLine = ''; | ||
var bottomLine = ''; | ||
// console.log("A: ",holder[z][0][0]); | ||
// console.log("B: ",holder[z][0][1]); | ||
titleLength = title.length | ||
for(var zz = 0; zz < titleLength+4; zz++){ | ||
dottedLineA = dottedLineA + '-' | ||
} | ||
linkLength = link.length | ||
for(var zzz = 0; zzz < linkLength+4; zzz++){ | ||
dottedLineB = dottedLineB + '-' | ||
} | ||
console.log("\n"+dottedLineA); | ||
console.log(" | " + title + " | "); | ||
console.log(dottedLineB); | ||
console.log(" | " + link + " | "); | ||
console.log(dottedLineB); | ||
} | ||
for(var i = 0; i < holder[z][0][0].length + 5; i++){ | ||
topLine = topLine + '-'; | ||
} | ||
for(var i = 0; i < holder[z][0][1].length + 4; i++){ | ||
bottomLine = bottomLine + '-'; | ||
} | ||
if(z === holder.length - randomNumber1 - randomNumber2){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber3 - randomNumber4){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber5 - randomNumber6){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber7 - randomNumber8){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber9 - randomNumber10){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber11 - randomNumber12){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber13 - randomNumber14){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber15 - randomNumber16){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber17 - randomNumber18){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
else if(z === holder.length - randomNumber19 - randomNumber20){ | ||
console.log("\n "+topLine+"\n |",holder[z][0][0], " |\n "+bottomLine+"\n |",holder[z][0][1], "|\n "+bottomLine); | ||
} | ||
} | ||
console.log(` | ||
___________ .__ | ||
\\\__ ___/__________ _____ |__| ____ ______ _ ________ | ||
| |_/ __ \\\_ __ \\\/ \\\| |/ \\\_/ __ \\\ \\\/ \\\/ / ___/ | ||
| |\\\ ___/| | \\\/ Y Y \\\ | | \\\ ___/\\\ /\\\___ \\\\ | ||
|____| \\\___ >__| |__|_| /__|___| /\\\___ >\\\/\\\_//____ >`); | ||
console.log("\n\n TERMINEWS - READ THE NEWS IN YOUR TERMINAL "); | ||
console.log("\n SCROLL UP TO READ"); | ||
console.log(" "+localTime('','*')); | ||
console.log("\n\n To open a link in your browser hold command and click the link \n\n\n"); | ||
console.log("\n SCROLL UP TO READ"); | ||
}); | ||
@@ -152,0 +81,0 @@ |
{ | ||
"name": "terminews", | ||
"version": "1.9.9", | ||
"version": "2.0.0", | ||
"description": "read the latest news headlines from your terminal window", | ||
@@ -15,3 +15,3 @@ "main": "./lib/index.js", | ||
"type": "git", | ||
"url": "https://github.com/DanielDwyer/termiNews.git" | ||
"url": "https://github.com/DanielDwyerPersonal/terminews" | ||
}, | ||
@@ -18,0 +18,0 @@ "keywords": [ |
@@ -30,6 +30,6 @@ # terminews | ||
![example news](http://i63.tinypic.com/2585xcm.png) | ||
![example news](http://i66.tinypic.com/6sdgkz.png) | ||
### To Install Using GitHub | ||
- ```$ git clone https://github.com/DanielDwyer/termiNews.git``` | ||
- ```$ git clone https://github.com/DanielDwyerPersonal/terminews``` | ||
- ```$ cd termiNews``` | ||
@@ -43,1 +43,9 @@ - ```$ npm i --save``` | ||
MIT | ||
Copyright 2018 Daniel P. Dwyer | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50
5534
72