Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Add Landing Page #560

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ff130e1
added landing.ejs file, added a get route in various-routes.ts, and m…
Apr 2, 2020
dd5fddb
added the rest of copy, the map
Apr 3, 2020
a22008d
add contribute now! button
Apr 3, 2020
5e8ce02
move globe emoji from translation string to html
Apr 3, 2020
ae9a053
added static/countries.json
Apr 3, 2020
7712ea2
landing.ejs
Apr 3, 2020
11db356
added contribute now dropdown with countries, exposed countries.json …
Apr 3, 2020
baf645d
create/plot country markers, added marker png, discovered the coordni…
Apr 4, 2020
2eea4aa
fix error where country link list doesn't open on mobile, remove unus…
Apr 4, 2020
d52a65c
update logo text, add icon attribution link, remove postal code attri…
Apr 4, 2020
8253837
location whooshing, show location, change icon
Apr 4, 2020
7a47c29
I've decided to use the browser geolocation. Going from timezone to a…
Apr 4, 2020
1a14a3c
update first seven countries geoposition
Apr 4, 2020
1111fde
Use custom map theme.
lseelenbinder Apr 4, 2020
516b780
Merge pull request #1 from zacel/add-custom-theme
zacel Apr 4, 2020
f8c92d6
Moved country to top and added flag
amritnagi Apr 4, 2020
07c91f4
Tweaks to survey and share layout
amritnagi Apr 4, 2020
aeb20e9
Changed section headers
amritnagi Apr 4, 2020
c723999
Merge remote-tracking branch 'upstream/master'
amritnagi Apr 4, 2020
6dab24a
fix error caused by not having Romanian /landing route, fixed Ukraine…
Apr 5, 2020
8114d8e
-refactor js in landing.ejs
Apr 5, 2020
6d1771b
cleanup
Apr 5, 2020
d69db4c
update marker
Apr 5, 2020
59ce715
pause/play map animation, resize marker icon
Apr 5, 2020
627ddac
even out the play/pause bottom margins
Apr 5, 2020
7b00773
Merge remote-tracking branch 'upstream/master'
amritnagi Apr 5, 2020
81ce3e5
Merge branch 'master' of https://github.com/zacel/coronastatus
amritnagi Apr 5, 2020
827b935
added python script to build static/countries.json
Apr 6, 2020
db96270
fix wrong coordinates and split it into a lat/lng object instead
fossecode Apr 6, 2020
06e1530
Merge remote-tracking branch 'upstream/fix-lat-lng-order'
Apr 6, 2020
7c950e2
- added server option to pick if a users location should be requested…
Apr 6, 2020
f4fe042
Delete textCountries.json
zacel Apr 6, 2020
960de60
make all strings ready to be translated
Apr 6, 2020
3bdbf94
fix linting issues
Apr 6, 2020
2e5324a
make python script less complex
Apr 6, 2020
288e4fe
remove out of date attribution link, resize map marker
Apr 6, 2020
da51017
move countries.json generator script to scripts/
Apr 7, 2020
6da8a32
-create api route to expose some countrySpecific fields to the frontend
Apr 8, 2020
64b4185
fix some of the linting errors
Apr 8, 2020
97130ca
-remove contries.json and python script for it's creation
Apr 8, 2020
061891a
simplify the countries api route
Apr 8, 2020
3c8c52c
clean up api/countries
Apr 8, 2020
a439389
cache countries when the server starts
fossecode Apr 8, 2020
a81e0e2
Merge pull request #2 from zacel/countries
zacel Apr 8, 2020
efe9983
Fix links to countries bug found by @trkoch
Apr 10, 2020
c41f3bf
Merge remote-tracking branch 'upstream/master'
Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/domain/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface CountrySpecificUrls {
apiDocs: string;
statistics: string;
limit: string;
landing: string;
}

type Urls = {
Expand All @@ -60,6 +61,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estadisticas',
landing: '/landing',
limit: '/limit'
},
au: {
Expand All @@ -71,6 +73,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
bd: {
Expand All @@ -82,6 +85,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
br: {
Expand All @@ -93,6 +97,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estatisticas',
landing: '/landing',
limit: '/limit'
},
ca: {
Expand All @@ -104,6 +109,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
cl: {
Expand All @@ -115,6 +121,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estadisticas',
landing: '/landing',
limit: '/limit'
},
co: {
Expand All @@ -126,6 +133,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estadisticas',
landing: '/landing',
limit: '/limit'
},
cz: {
Expand All @@ -137,6 +145,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistiky',
landing: '/landing',
limit: '/limit'
},
de: {
Expand All @@ -148,6 +157,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistiken',
landing: '/landing',
limit: '/limit'
},
dk: {
Expand All @@ -159,6 +169,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistikker',
landing: '/landing',
limit: '/limit'
},
en: {
Expand All @@ -170,6 +181,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
es: {
Expand All @@ -181,6 +193,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estadisticas',
landing: '/landing',
limit: '/limit'
},
fr: {
Expand All @@ -192,6 +205,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistiques',
landing: '/landing',
limit: '/limit'
},
id: {
Expand All @@ -203,6 +217,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistik',
landing: '/landing',
limit: '/limit'
},
in: {
Expand All @@ -214,6 +229,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
it: {
Expand All @@ -225,6 +241,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistiche',
landing: '/landing',
limit: '/limit'
},
lt: {
Expand All @@ -236,6 +253,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistika',
landing: '/landing',
limit: '/limit'
},
mt: {
Expand All @@ -247,6 +265,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
mx: {
Expand All @@ -258,6 +277,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estadisticas',
landing: '/landing',
limit: '/limit'
},
my: {
Expand All @@ -269,6 +289,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistik',
landing: '/landing',
limit: '/limit'
},
ng: {
Expand All @@ -280,6 +301,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
nl: {
Expand All @@ -291,6 +313,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistieken',
landing: '/landing',
limit: '/limit'
},
no: {
Expand All @@ -302,6 +325,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistikk',
landing: '/landing',
limit: '/limit'
},
np: {
Expand All @@ -313,6 +337,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
ph: {
Expand All @@ -324,6 +349,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
pt: {
Expand All @@ -335,6 +361,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/estatistica',
landing: '/landing',
limit: '/limit'
},
ro: {
Expand All @@ -346,6 +373,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistici',
landing: '/landing',
limit: '/limit'
},
se: {
Expand All @@ -357,6 +385,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistik',
landing: '/landing',
limit: '/limit'
},
sg: {
Expand All @@ -368,6 +397,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
sk: {
Expand All @@ -379,6 +409,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistiky',
landing: '/landing',
limit: '/limit'
},
tr: {
Expand All @@ -390,6 +421,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/istatistikler',
landing: '/landing',
limit: '/limit'
},
ua: {
Expand All @@ -401,6 +433,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
},
us: {
Expand All @@ -412,6 +445,7 @@ export const countrySpecificUrls: Urls = {
api: '/api',
apiDocs: '/api-docs',
statistics: '/statistics',
landing: '/landing',
limit: '/limit'
}
};
Expand Down
17 changes: 17 additions & 0 deletions app/openAPI/reports.swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ export const getReportsCsv = {
}
}
};

export const getCountries = {
tags: ['Countries'],
description: 'Returns list of countries where coronastatus is available',
operationId: 'getCountries',
version: '0.0.1',
responses: {
'200': {
description: 'Countries',
content: {
'application/json': {
schema: {}
}
}
}
}
};
58 changes: 58 additions & 0 deletions app/repository/CountryRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-disable global-require, import/no-dynamic-require */
import { readdirSync, Dirent } from 'fs';
import path from 'path';
import { Config, CountrySpecificTexts, Coordinate } from '../domain/types';
import { CountryCode } from '../domain/urls';

const countriesDir = path.join(__dirname, '..', 'countrySpecific');

interface Country {
url: string;
countryCode: CountryCode;
mapCenter: Coordinate;
countryName: string;
}

interface ConfigFile {
countrySpecificConfig: Config;
}

interface TextVariablesFile {
countrySpecificTexts: CountrySpecificTexts;
}

const readFromFile = <T>(dirent: Dirent, fileName: string): T =>
require(`../countrySpecific/${dirent.name}/${fileName}`);

export class CountryRepository {
private countries: Country[];

constructor() {
console.log('Reading countries from files...');
this.countries = this.readCountriesFromFiles();
}

private readCountriesFromFiles = (): Country[] =>
readdirSync(countriesDir, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => {
const { countrySpecificConfig } = readFromFile<ConfigFile>(
dirent,
'config.ts'
);
const { countrySpecificTexts } = readFromFile<TextVariablesFile>(
dirent,
'text-variables.ts'
);
return {
url: countrySpecificConfig.BASE_URL,
countryCode: countrySpecificConfig.COUNTRY_CODE,
mapCenter: countrySpecificConfig.MAP_CENTER,
countryName: countrySpecificTexts.COUNTRY_NAME
};
});

public getCountries(): Country[] {
return this.countries;
}
}
7 changes: 7 additions & 0 deletions app/routes/api-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import {
SmokingHabit,
IsolationStatus
} from '../domain/types';
import { CountryRepository } from '../repository/CountryRepository';

const router = express.Router();
const reportRepo = new CovidReportRepository();
const countryRepo = new CountryRepository();

router.get('/aggregated', cors(), async (req, res) => {
const reports = await reportRepo.getLatestCovidReports();
Expand Down Expand Up @@ -183,6 +185,11 @@ router.get('/reports', cors(), async (req, res) => {
return res.json(result);
});

router.get('/countries', cors(), async (req, res) => {
const countries = countryRepo.getCountries();
res.json(countries);
});

router.get('*', (req, res) => {
res.status(404).json({
status: 404,
Expand Down
4 changes: 4 additions & 0 deletions app/routes/various-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ router.get(urls.contributors, (req, res) => {
return res.render('pages/contributors');
});

router.get(`${urls.landing}`, (req, res) => {
return res.render('pages/landing');
});

router.get(urls.limit, (req, res) => {
return res.render('pages/limit');
});
Expand Down
Loading