Skip to content

Commit fe0b975

Browse files
committed
Merge branch 'main'
2 parents 06ba6c4 + 9d52a9e commit fe0b975

File tree

9 files changed

+361
-10
lines changed

9 files changed

+361
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
2+
debug.log
23
.now
34
.DS_Store
4-
.now
5+
.now

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# COVID-19 Tracker CLI [![Developed by Waren Gonzaga](https://img.shields.io/badge/Developed%20by-Waren%20Gonzaga-blue.svg?longCache=true&style=for-the-badge)](https://facebook.com/warengonzagaofficial)
1+
# COVID-19 Tracker CLI [![Mentioned in Awesome Coronavirus](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/soroushchehresa/awesome-coronavirus)
22

3-
[![Github Release](https://img.shields.io/github/release/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli/releases) [![Github Star](https://img.shields.io/github/stars/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![Github Fork](https://img.shields.io/github/forks/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![License](https://img.shields.io/github/license/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![Powered By](https://img.shields.io/badge/Powered%20By-NodeJS-green.svg?style=for-the-badge)](https://nodejs.org)
3+
[![Developed by Waren Gonzaga](https://img.shields.io/badge/Developed%20by-Waren%20Gonzaga-blue.svg?longCache=true&style=for-the-badge)](https://facebook.com/warengonzagaofficial) [![Github Release](https://img.shields.io/github/release/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli/releases) [![Github Star](https://img.shields.io/github/stars/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![Github Fork](https://img.shields.io/github/forks/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![License](https://img.shields.io/github/license/trackercli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/trackercli/covid19-tracker-cli) [![Powered By](https://img.shields.io/badge/Powered%20By-NodeJS-green.svg?style=for-the-badge)](https://nodejs.org)
44

55
![Github Banner](https://raw.githubusercontent.com/trackercli/covid19-tracker-cli/master/lib/img/covid19-tracker-cli-github-banner.jpg)
66

7-
**COVID-19 Tracker CLI** is an open-source NodeJS application for command line interface to track COVID-19 cases around the world. An optimized NodeJS application and a simple tracker with real-time updates from reliable data source. [Visit Wiki](https://github.com/tracker-cli/covid19-tracker-cli/wiki)
7+
**COVID-19 Tracker CLI** is an open-source NodeJS application for command line interface to track COVID-19 cases around the world. An optimized NodeJS application and a simple tracker with real-time updates from reliable data source. It Supports terminal for linux and macos, command prompt for windows, and termux for android. [Visit Wiki](https://github.com/tracker-cli/covid19-tracker-cli/wiki)
88

99
## Public Domain Names
1010

@@ -75,7 +75,7 @@ curl -L covid19.trackercli.com
7575
#### WGET
7676

7777
```bash
78-
wget -i https://covid19.trackercli.com && cat index.html
78+
wget -qO- https://covid19.trackercli.com
7979
```
8080

8181
#### HTTPie
@@ -140,6 +140,15 @@ curl -L covid19.trackercli.com/history/ph/deaths
140140

141141
![CURL](https://github.com/trackercli/covid19-tracker-cli/raw/master/lib/img/demo-history-country.gif)
142142

143+
#### Country Tracking with History Chart (Dashboard)
144+
145+
```bash
146+
# shows result with history chart
147+
curl -L covid19.trackercli.com/history/charts/ph
148+
```
149+
150+
![CURL](./lib/img/demo-history-chart.gif)
151+
143152
## Advance Usage
144153

145154
### Check Update Automagically
@@ -190,6 +199,24 @@ covid ph --plain
190199
covid help
191200
```
192201

202+
### Local Command Line Tracker in Container
203+
```bash
204+
# Create build file
205+
$ vim covid19-tracker-cli.containerfile
206+
FROM docker.io/library/alpine
207+
RUN apk update
208+
RUN apk add git
209+
RUN apk add npm
210+
RUN git clone https://github.com/warengonzaga/covid19-tracker-cli.git
211+
RUN cd covid19-tracker-cli && npm install && npm link
212+
213+
# Build container
214+
$ podman build -t covid19-tracker-cli --file=covid19-tracker-cli.containerfile
215+
216+
# Run container
217+
$ podman run -it --rm=true localhost/covid19-tracker-cli covid PH
218+
```
219+
193220
## Official Blog
194221

195222
Many people asking me how to properly use my tracker. Here's the blog on [How to Track Coronavirus on Command Line](https://warengonza.ga/covid19-tracker-cli). If you have comments or suggestions please leave it on the comment section of the blog.
@@ -340,4 +367,4 @@ COVID-19 Tracker CLI is Developed and Maintained by **Waren Gonzaga**, **Ian Viz
340367

341368
---
342369

343-
**</>** with **<3** by **Waren Gonzaga**
370+
:computer: with :heart: by **Waren Gonzaga** with **YHWH** | Tracker CLI Developers

app.js

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const express = require('express'),
44
util = require('./bin/util'),
55
axios = require('axios'),
66
covid19 = require('./lib/cli'),
7-
covid19GFX = require('./lib/cli/gfx'),
7+
covid19GFX = require('./lib/cli/gfx'),
8+
EventEmitter = require('events'),
89
pkg = require('./package.json'), // package.json info
910
apiBaseURL = "https://corona.lmao.ninja/v2", // NovelCOVID API
1011
port = process.env.port || 7070; // set port
@@ -147,12 +148,66 @@ app.get('/history/charts/:country/:chartSize(sm|md|lg)?', async (req, res, next)
147148
s.deaths, s.todayDeaths, s.recovered,
148149
s.active, s.critical, s.casesPerOneMillion,
149150
s.updated, h, chartType, s.countryInfo, chartSize
150-
)
151+
);
151152
return null;
152153
}
153154
return next();
154155
});
155156

157+
158+
// historical chart by country
159+
app.get('/history/web/charts/:country?/:chartSize(sm|md|lg)?', async (req, res, next) => {
160+
const userAgent = req.headers['user-agent'],
161+
countryData = req.params.country || 'ph',
162+
chartType = req.params.chartType || 'cases',
163+
chartSize = req.params.chartSize || 'sm',
164+
summary = await axios.get(`${apiBaseURL}/countries/${countryData}`),
165+
history = await axios.get(`${apiBaseURL}/historical/${summary.data.country}?lastdays=all`),
166+
s = summary.data,
167+
h = history.data,
168+
terminator = `\r\n`+'\033[?25h',
169+
xtermHTMLTemplate = require('./lib/cli/gfx/terminal-html-template'),
170+
bufferEmitter = new EventEmitter();
171+
172+
let customHttpResponse = {
173+
send: (data) => {
174+
bufferEmitter.emit('screenBuffer', data)
175+
this.data = data
176+
return this;
177+
},
178+
get: () => {
179+
return this.data
180+
}
181+
};
182+
183+
covid19GFX.historyCountryTracker(
184+
req, customHttpResponse,
185+
s.country, s.cases, s.todayCases,
186+
s.deaths, s.todayDeaths, s.recovered,
187+
s.active, s.critical, s.casesPerOneMillion,
188+
s.updated, h, chartType, s.countryInfo, chartSize
189+
);
190+
191+
let screenOutput = (await new Promise((resolve, reject) => {
192+
bufferEmitter.on('screenBuffer', (screen) => {
193+
resolve(screen)
194+
})
195+
setTimeout(() => {
196+
resolve('')
197+
},5000)
198+
}));
199+
200+
201+
if(!screenOutput.length || !h) res.send('Unable to load the chart.Please refresh the page')
202+
203+
return util.isCommandline(userAgent) ? res.send(screenOutput+terminator) : res.send(xtermHTMLTemplate(screenOutput.replace(terminator, '')))
204+
205+
});
206+
207+
app.use('/xterm', express.static(__dirname + '/node_modules/xterm'));
208+
app.use('/xterm/addons', express.static(__dirname + '/node_modules/xterm-addon-fit'));
209+
210+
// route for web browser clients
156211
app.get('*', (req, res) => res.send(`
157212
Welcome to COVID-19 Tracker CLI v${pkg.version} by Waren Gonzaga\n
158213
Please visit: https://warengonza.ga/covid19-tracker-cli

lib/cli/gfx/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ exports.load = (grid, data, chartStyle) => {
3636
[
3737
['',data.cases, data.deaths, data.recovered, data.active, data.casesPerOneMillion],
3838
['','Today Cases', 'Today Deaths', 'Critical', 'Mortality %', 'Recovery %'],
39-
['',data.todayCases, data.todayDeaths, data.critical, data.mortalityPercentage, data.recoveredPercentage]
39+
['',data.todayCases, data.todayDeaths, data.critical, parseFloat(data.mortalityPercentage).toFixed(2), parseFloat(data.recoveredPercentage).toFixed(2)]
4040
]
4141
})
4242

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
const html = (data) => {
3+
return (`<!doctype html>
4+
<html>
5+
<head>
6+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/xterm.min.js"></script>
7+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/xterm-addon-fit.min.js"></script>
8+
</head>
9+
<body>
10+
<div id="terminal" style='width: 105%;height: 100vh;padding-left: 2px;'></div>
11+
</body>
12+
<script>
13+
var term = new Terminal();
14+
var fitAddon = new FitAddon.FitAddon()
15+
term.loadAddon(fitAddon);
16+
term.open(document.getElementById('terminal'));
17+
fitAddon.fit();
18+
term.write('${data}')
19+
</script>
20+
<style>
21+
body{
22+
background: #000;
23+
margin:0;padding:0;
24+
overflow:hidden;
25+
}
26+
textarea, .xterm-char-measure-element, .xterm-scroll-area{
27+
display: none;
28+
}
29+
</style>
30+
</html>`)
31+
}
32+
33+
module.exports = html

lib/img/demo-history-chart.gif

1.64 MB
Loading

0 commit comments

Comments
 (0)