Skip to content

Commit

Permalink
Implement auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
soroushchehresa committed Mar 14, 2020
1 parent f3a4930 commit b22535f
Show file tree
Hide file tree
Showing 13 changed files with 455 additions and 163 deletions.
280 changes: 159 additions & 121 deletions README.md

Large diffs are not rendered by default.

Binary file added awesome-coronavirus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions data/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"title": "MG-ng/Virus-Ticker-Widget",
"url": "https://www.github.com/MG-ng/Virus-Ticker-Widget",
"description": "Android App to display a homescreen widget and useful websites in fullscreen."
},
}
]
},
{
Expand Down Expand Up @@ -160,6 +160,6 @@
"description": "Location based statistics, news, charts, maps based dashboard."
}
]
},
}
]
}
95 changes: 95 additions & 0 deletions data/contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"title": "Contents",
"list": [
{
"category": "Get to Know",
"anchor": "get-to-know",
"list": []
},
{
"category": "Open Source Projects",
"anchor": "open-source-projects",
"list": [
{
"title": "API",
"anchor": "api"
},
{
"title": "Statistics",
"anchor": "statistics"
},
{
"title": "Learning",
"anchor": "learning"
},
{
"title": "Maps",
"anchor": "maps"
},
{
"title": "Applications and Bots",
"anchor": "applications-and-bots"
},
{
"title": "Packages and Scripts",
"anchor": "packages-and-scripts"
}
]
},
{
"category": "Applications",
"anchor": "applications",
"list": [
{
"title": "Open Source Apps",
"anchor": "open-source-apps"
},
{
"title": "Web Apps",
"anchor": "web-apps"
},
{
"title": "Android Apps",
"anchor": "android-apps"
},
{
"title": "IOS Apps",
"anchor": "ios-apps"
}
]
},
{
"category": "Social",
"anchor": "social",
"list": [
{
"title": "Twitter",
"anchor": "twitter"
},
{
"title": "Telegram",
"anchor": "telegram"
},
{
"title": "WhatsApp",
"anchor": "whatsApp"
}
]
},
{
"category": "Research Outlets",
"anchor": "research-outlets",
"list": []
},
{
"category": "Interactive Applications",
"anchor": "interactive-applications",
"list": []
},
{
"category": "Current Status",
"anchor": "current-status",
"list": []
}
]
}
15 changes: 15 additions & 0 deletions data/current-status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"title": "Current Status",
"list": [
{
"title": "WHO",
"url": "https://www.who.int/emergencies/diseases/novel-coronavirus-2019",
"description": "World Health Orginization."
},
{
"title": "CDC",
"url": "https://www.cdc.gov/coronavirus/2019-ncov/about/index.html",
"description": "Center for Disease control."
}
]
}
25 changes: 25 additions & 0 deletions data/interactive-applications.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"title": "Interactive Applications",
"list": [
{
"title": "University of Virginia: COVID-19 Surveillance Dashboard",
"url": "http://nssac.bii.virginia.edu/covid-19/dashboard",
"description": "Dashboard showing."
},
{
"title": "Johns Hopkins CSSE: Coronavirus COVID-19 Global Cases",
"url": "https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6",
"description": "Dashboard application providing interaction to global case data."
},
{
"title": "WHO Novel Coronavirus (COVID-19) Situation",
"url": "https://experience.arcgis.com/experience/685d0ace521648f8a5beeeee1b9125cd",
"description": "WHO data visualization page."
},
{
"title": "Worldometer",
"url": "https://www.worldometers.info/coronavirus",
"description": "Showcasing coronavirus stats."
}
]
}
2 changes: 1 addition & 1 deletion data/open-source-projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"category": "Learning",
"repositories": [
"mattroconnor/deep_learning_coronavirus_cur"
"mattroconnor/deep_learning_coronavirus_cure"
]
},
{
Expand Down
45 changes: 45 additions & 0 deletions data/research-outlets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"title": "Research Outlets",
"list": [
{
"title": "The Lancet COVID-19 Resource Centre",
"url": "https://www.thelancet.com/coronavirus",
"description": "Journal page that aggregates coronavirus related research output."
},
{
"title": "American Society for Microbiology",
"url": "https://journals.asm.org/search/coronavirus%20jcode%3Aaem%7C%7Caac%7C%7Ccdli%7C%7Ccmr%7C%7Ceukcell%7C%7Ciai%7C%7Cjb%7C%7Cjcm%7C%7Cjvi%7C%7Cmbio%7C%7Cmmbr%7C%7Cga%7C%7Cmcb%7C%7Cmsph%7C%7Cmsys%20limit_from%3A2019-01-01%20limit_to%3A2020-01-23%20numresults%3A10%20sort%3Arelevance-rank%20format_result%3Astandard?_ga=2.34252577.1885462816.1583650093-393486013.1583650093",
"description": "AMS search portal."
},
{
"title": "American Chemical Society",
"url": "https://pubs.acs.org/page/vi/chemistry_coronavirus_research?utm_source=pubs_content_marketing&utm_medium=axial&utm_campaign=0120_JHS_coronavirus&ref=pubs_content_marketing",
"description": "Free issue of ACS with a focus on coronavirus."
},
{
"title": "Annals of Internal Medicine",
"url": "https://annals.org/aim/pages/coronavirus-content",
"description": "Annals page showcasing paper submissions."
},
{
"title": "European Respiratory Journal",
"url": "https://erj.ersjournals.com/cc/sars-cov-2-and-covid-19",
"description": "ERJ journal portal on coronaviruses."
},
{
"title": "Oxford Academic",
"url": "https://academic.oup.com/journals/pages/coronavirus?cc=us&lang=en&#997df937b5eb5a4ab1a9",
"description": "age of journal articles on the coronavirus."
},
{
"title": "Jama Network",
"url": "https://jamanetwork.com/journals/jama/pages/coronavirus-alert",
"description": "A variery of papers that span clinicians and researchers."
},
{
"title": "Springer Nature",
"url": "https://www.springernature.com/gp/researchers/campaigns/coronavirus",
"description": "Springer Nature campaign page."
}
]
}
37 changes: 16 additions & 21 deletions data/socials.json → data/social.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Socials",
"list" : [
"title": "Social",
"list": [
{
"category": "Twitter",
"list": [
Expand Down Expand Up @@ -74,56 +74,51 @@
{
"category": "Telegram",
"list": [
{
"title": "CoronaTracker-Public",
"url": "https://t.me/coronatracker_public",
"description": ""
},
{
"title": "SG Fight Coronavirus",
"url": "https://t.me/sgFight",
"description": ""
"description": "Let's Fight Coronavirus together in Singapore."
},
{
"title": "Coronavirus Updates",
"url": "https://t.me/coronavirusupdates",
"description": ""
"description": "Info-sharing on COVID-19."
},
{
"title": "Coronavirus Info",
"url": "https://t.me/coronavirusinfo",
"description": ""
"description": "Today's top stories regarding the COVID-19 Pandemic."
},
{
"title": "Wuhan 2019 Novel Coronavirus",
"url": "https://t.me/TheWuhanVirus",
"description": ""
},
{
"title": "SG-Wuhan 2019-nCoV Watchgroup",
"url": "https://t.me/SGWuhan2019nCoV",
"description": ""
"description": "A collation of Singapore News Articles on 2019-nCoV Wuhan Virus COVID-2019."
},
{
"title": "SG Wuhan Coronavirus Info Group",
"url": "https://t.me/SGWuhanCoronaVirusNews",
"description": ""
"description": "Providing news and updates on the Wuhan Coronavirus."
},
{
"title": "Wuhan Quarantine #nCoV #武汉封城",
"url": "https://t.me/wuhanquarantinefrom20200123",
"description": ""
"description": "点击标签查看相关消息:新闻 生活实景 求助信息 捐赠 应灾技巧 专家解答 辟谣 重要通知 疫情动态"
},
{
"title": "CoronaTracker-Public",
"url": "https://t.me/coronatracker_public",
"description": "CoronaTracker-Public super group."
}
]
},
{
"category": "WhatsApp",
"list": [
{
"title": "Gov.sg",
"title": "latest information about the COVID-19",
"url": "https://go.gov.sg/whatsapp",
"description": ""
},
"description": "Gov.sg WhatsApp Subscription"
}
]
}
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"author": "Soroush Chehresa",
"license": "MIT",
"dependencies": {
"dotenv": "^8.2.0",
"ejs": "^2.4.2",
"github": "^2.1.0"
}
Expand Down
46 changes: 30 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,50 @@ const fs = require('fs');
const GitHubApi = require('github');
const ejs = require('ejs');

require('dotenv')
.config();

const DEBUG = process.env.NODE_ENV === 'development';
const GITHUB_AUTH_TOKEN = process.env.GITHUB_AUTH_TOKEN;

const templateFilePath = `${__dirname}/template.md`;
const outputFilePath = `${__dirname}/../README.md`;

let data = require('./../data.json');
const getToKnowData = require('../data/get-to-know.json');
let openSourceProjectsData = require('../data/open-source-projects.json');
const applicationsData = require('../data/applications.json');
const socialData = require('../data/social.json');
const researchOutletsData = require('../data/research-outlets.json');
const interactiveApplicationsData = require('../data/interactive-applications.json');
const currentStatusData = require('../data/current-status.json');
const contentsData = require('../data/contents.json');

const github = new GitHubApi({
debug: DEBUG,
followRedirects: false,
timeout: 10000,
Promise: Promise
Promise: Promise,
});

github.authenticate({
type: "oauth",
token: GITHUB_AUTH_TOKEN
type: 'oauth',
token: GITHUB_AUTH_TOKEN,
});

const repositories = data.curated
const repositories = openSourceProjectsData.list
.map(item => {
const fetchReposPromise = item.repos
const fetchReposPromise = item.repositories
.map(repoPath => {
const separatedRepoPath = repoPath.split('/');
return github.repos.get({
user: separatedRepoPath[0],
repo: separatedRepoPath[1]
repo: separatedRepoPath[1],
});
});

const allSettled = fetchReposPromise.map(p => Promise.resolve(p)
.then(
val => ({ state: 'fulfilled', value: val }),
err => ({ state: 'rejected', reason: err })));

return Promise
.all(allSettled)
.then(rawResult => {
Expand All @@ -48,25 +56,31 @@ const repositories = data.curated
if (state === 'fulfilled' && value && value.name && value.owner) {
return true;
}

console.log('Skipping repo - fetch error', reason);
})
.map(({ value }) => value);
return {
category: item.category,
repos: result.sort((a, b) => a.stargazers_count < b.stargazers_count ? 1 : -1),
anchor: item.anchor || item.category.toLowerCase()
repositories: result.sort((a, b) => a.stargazers_count < b.stargazers_count ? 1 : -1),
anchor: item.anchor || item.category.toLowerCase(),
};
});
});

Promise
.all(repositories)
.then(curated => {
data = Object.assign(data, { curated });
.then(openSourceList => {
const data = {
contents: contentsData,
openSource: { list: openSourceList, title: openSourceProjectsData.title },
getToKnow: getToKnowData,
applications: applicationsData,
social: socialData,
researchOutlets: researchOutletsData,
interactiveApplications: interactiveApplicationsData,
currentStatus: currentStatusData,
};
const template = fs.readFileSync(templateFilePath, 'utf8');
const markdown = ejs.render(template, data);

fs.writeFileSync(outputFilePath, markdown);
})
.catch(error => {
Expand Down
Loading

0 comments on commit b22535f

Please sign in to comment.