saadhan icon indicating copy to clipboard operation
saadhan copied to clipboard

Make fetching of resources dynamic with GitHub API

Open Bhupesh-V opened this issue 2 years ago • 11 comments

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

Bhupesh-V avatar Feb 06 '23 15:02 Bhupesh-V

can I work on this? @Bhupesh-V

pratik9333 avatar Feb 08 '23 07:02 pratik9333

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

Bhupesh-V avatar Feb 08 '23 07:02 Bhupesh-V

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 avatar Feb 12 '23 12:02 AmanSal1

@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.

Animesh-Ghosh avatar Feb 13 '23 13:02 Animesh-Ghosh

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.

jatinb92 avatar Feb 13 '23 13:02 jatinb92

@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 .

AmanSal1 avatar Feb 13 '23 14:02 AmanSal1

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.

pratik9333 avatar Feb 14 '23 08:02 pratik9333

@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) ?

AmanSal1 avatar Feb 15 '23 07:02 AmanSal1

@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

Bhupesh-V avatar Feb 15 '23 13:02 Bhupesh-V

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 👍

1

Automatically updated the CATEGORIES

3

RUST UPDATED IN THE SITE

4

AmanSal1 avatar Feb 19 '23 10:02 AmanSal1

@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.

Bhupesh-V avatar Feb 20 '23 10:02 Bhupesh-V