sumanchapai / patro

patro
3 stars 0 forks source link

Chrome extension for patro #4

Closed paudsu01 closed 11 months ago

paudsu01 commented 11 months ago

Create a browser extension for patro.

paudsu01 commented 11 months ago

@sumanchapai, The browser extension folder will need to be a standalone folder once uploaded to the web store. However, since it will need access to the data files in the root directory, should I move the data folder inside the browser_extension folder and create a symlink from the root directory data to the data folder inside the browser extension ?. Please look at chrome-extension branch if necessary

sumanchapai commented 11 months ago

I think that symlink only works for local systems for example inside your computer, not well in with git. I think there are a couple options:

  1. Browser extension downloads the data from the api: for example: https://sumanchapai.github.io/patro/2080.json. This method will work if browser extensions are allowed to save this downloaded data for future use.
  2. Alternative to 1. is just creating a duplicate data folder inside the directory you're thinking of.

In either case, here are some tips (assuming that the extension shows the today's nepali date and the event details for today, and in phase 2 something like future and past events ):

  1. Implement a nepali date converter in js. Don't forget to write tests!
  2. Once you know what date you want the event detail for, you can parse the JSON for the appropriate year only and get to the event details for that day.
paudsu01 commented 11 months ago

1). I think sending an API request would just work fine. Rather than storing data for future use, we can store the current data after the API request is made on popup (after the user clicks the extension). The data persists as long as the extension popup is open. This would however also mean making a request every time the user opens the extension.

2). For the current Nepali date and time. I have found a GitHub repo: Nepali-date. We can just it as CDN in our index.html and use that to convert the dates. Would that work @sumanchapai ? However, if we don't want to increase our dependencies, I can write a date converter function which shouldn't be that hard.

sumanchapai commented 11 months ago

Lets implement it for now like the way you suggested for 1. and 2.

The pro and con for 1. are:

pro:

  1. Easier. Don't have to think about storing data locally. Also, don't have to worry about data corruption locally (imagine you store the JSON files in user's home directory and the user accidentally/intentionally changes the data in that file). In other words, we don't have to worry about consistency issues since the data will always have the single source of truth (i.e the server).

con:

  1. It costs network connection. Bad for people in mobile data, that costs actual money etc. Also, we assume the user is connected to the internet. But this isn't a huge problem because if you're using a browser, it's mostly true that you've a network connection.
sumanchapai commented 11 months ago

For 2. dependency is a problem, but not right now. So lets use the package you suggested.

paudsu01 commented 11 months ago

@sumanchapai I have pushed the changes to the chrome-extension branch. Please review the changes

For 1). It makes an API request and it should work fine for now. For 2) I have written a date converter instead of relying on a dependency. However, there needs to be tests written for the date converter js file.

The next steps would now be publishing the extension to the chrome store if the pull request gets approved.

paudsu01 commented 11 months ago

Update: I have added few test cases for the date converter js file. Commit d90b1e985