saadhan
saadhan copied to clipboard
Make fetching of resources dynamic with GitHub API
Feature details?
Currently, we manually have to update this map to introduce any new categories
CATEGORIES = {
"Python": "python",
"JavaScript": "javascript",
"C++": "cpp",
"C":"c",
"CSS":"css",
"Data Structures & Algorithms": "dsa",
"Machine Learning": "machine-learning",
"Deep Learning": "deep-learning",
"Computer Science": "computer-science",
"Computer Graphics": "computer-graphics",
"Git": "git",
"Android": "android",
"Surprise Me!": "miscellaneous",
}
This can be automated by calling the GitHub API to find directories that contain the index.json
file.
# get repo file paths
curl -H "Authorization: token YOUR_ACCESS_TOKEN" https://api.github.com/repos/OWNER/REPO/contents
# get paths inside a directory
curl -H "Authorization: token YOUR_ACCESS_TOKEN" https://api.github.com/repos/OWNER/REPO/contents/path/to/directory
The work will involve automatically calling the correct endpoints to dynamically generate resource categories.
Bonus points if you can do this asynchronoisly to reduce the latency!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
can I work on this? @Bhupesh-V
can I work on this? @Bhupesh-V
Sure, go ahead, this is going to be a big change, so if you need help, feel free to reach out here or maybe create draft PRs to ask any questions
So for example if we click on Python then all the resources are shown up . I wanted to ask are these resources put up by you or are the fetched by the api ?
@AmanSal1 the resources are in developersIndia/resources. So the idea here is fetching the resources from that repository using the GitHub APIs @Bhupesh-V mentioned on the issue description.
Hi @Bhupesh-V , I would like to contribute as well. @pratik9333, please let me know if we can work on this together or you need any other help.
@Animesh-Ghosh oh got it ! now basically you want the resource to get fetched automatically from the git hub repository of resources when ever there is an updated of new resources in that repository .
Hi @Bhupesh-V , I would like to contribute as well. @pratik9333, please let me know if we can work on this together or you need any other help.
sure, I haven't started yet but about to start.
@Bhupesh-V i have a doubt do you want your API path to get automatically updated whenever there is a new change in the resources repository( resourcer.py ) or you just want the categories to get updated automatically in the (main.py) ?
@Bhupesh-V i have a doubt do you want your API path to get automatically updated whenever there is a new change in the resources repository( resourcer.py ) or you just want the categories to get updated automatically in the (main.py) ?
The categories should dynamically update. This involves finding file paths that end with index.json
find their necessary category and build the necessary HTML as in main.py
I have applied a different logic to add the content automatically to the website but then you have to update the API PATH in the resourcer.py
here are some of the screenshots i tried adding manually to the API PATH to check the result 👍
Automatically updated the CATEGORIES
RUST UPDATED IN THE SITE
@AmanSal1 could you possibly open a draft PR with whatever implementation you have, it will be better since we will be on the same page, and any feedback/discussions can be done on that PR.