Giter Club home page Giter Club logo

bookmark-sync's Introduction

bookmark-sync's People

Watchers

 avatar

bookmark-sync's Issues

Sweep (map):

Details

Items that need work:

  1. Refactor script.js in the extension subfolder so that the login/register buttons are appropriately hidden/shown as needed.
  2. Any other refactors to script.js to make it a more manageable codebase going forwards.
  3. Create a new function in script.js to pull from endpoint /bookmarks on the upstream API, and then use the returned json to add/remove bookmarks as needed.
  4. Implement the required endpoint(s) in server/app.py to support the above functionality

Checklist:

Refactor script.js for better visibility control of login/register buttons

  • In extension/script.js, create a function that checks the session status and updates the visibility of the login/register buttons accordingly.

Refactor script.js for a more manageable codebase

  • In extension/script.js, modularize the code by separating different functionalities into different functions.
  • In extension/script.js, organize the code in a more structured way.

Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, handle the returned JSON data in the new function to add/remove bookmarks as needed.

Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, return the required JSON data in the new route handler.


Checklist:

Refactor script.js for better visibility control of login/register buttons

  • In extension/script.js, create a function that checks the session status and updates the visibility of the login/register buttons accordingly.

Refactor script.js for a more manageable codebase

  • In extension/script.js, modularize the code by separating different functionalities into different functions.
  • In extension/script.js, organize the code in a more structured way.

Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, handle the returned JSON data in the new function to add/remove bookmarks as needed.

Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, return the required JSON data in the new route handler.

Sweep: Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, handle the returned JSON data in the new function to add/remove bookmarks as needed.

Parent issue: #4

Checklist
  • extension/script.js

• Add a new function named fetchBookmarks. This function should send a GET request to the /bookmarks endpoint. Use the fetch function to send the request. The endpoint URL should be constructed using the endpoint variable and the string '/bookmarks'.
• In the fetchBookmarks function, handle the returned response. Parse the response as JSON using the json method of the response object.
• After parsing the response, iterate over the returned data. For each item in the data, check if a bookmark with the same URL already exists. If it does not exist, add a new bookmark with the URL and title from the item. If it does exist and the title is different, update the title of the bookmark. If the item has a property indicating that the bookmark should be removed, remove the bookmark.
• Call the fetchBookmarks function after the user has successfully logged in. This can be done in the then block of the fetch call in the auth function, after the response has been logged.

Sweep: Implement the two todo's in server/app.py

As noted in the comments starting on line 16 and 21 of app.py, respectively.

Both should use the simpleusers functions mentioned. Here's a cut of their documentation to help you.

 def auth_user(self, uid, attempt)

    Authenticates a user.
    Args

    uid : str
        User ID or filename.
    attempt : str
        Password attempt for authentication.

    Returns

    bool
        True if authentication is successful, False otherwise. 
 def make_user(self, uid, passw)

    Creates a new user.
    Args

    uid : str
        User ID or filename.
    passw : str
        User password.

    Returns

    None
Checklist
  • server/app.py

• Implement the first TODO on line 16 by calling the make_user function from the simpleusers module with the username and password parameters obtained from the request.
• Implement the second TODO on line 21 by calling the auth_user function from the simpleusers module with the username and password parameters obtained from the request. Return the session token if authentication is successful.

Sweep: Refactor script.js for a more manageable codebase

  • In extension/script.js, modularize the code by separating different functionalities into different functions.
  • In extension/script.js, organize the code in a more structured way.

Parent issue: #4

Checklist
  • extension/script.js

• Separate the code for fetching bookmarks from the server into a separate function named fetchBookmarksFromServer.
• Separate the code for adding a bookmark into a separate function named addBookmark.
• Separate the code for checking if a bookmark exists into a separate function named bookmarkExists.
• Separate the code for removing a bookmark into a separate function named removeBookmark.
• Separate the code for getting local bookmarks into a separate function named getLocalBookmarks.
• Group the functions related to bookmarks (fetchBookmarksFromServer, addBookmark, bookmarkExists, removeBookmark, getLocalBookmarks) together in the code.
• Separate the code for showing an element into a separate function named showElement.
• Separate the code for hiding an element into a separate function named hideElement.
• Separate the code for updating button visibility into a separate function named updateButtonVisibility.
• Group the functions related to UI (showElement, hideElement, updateButtonVisibility) together in the code.
• Separate the code for checking session status into a separate function named checkSessionStatus.
• Group the function related to session (checkSessionStatus) with the functions related to UI.
• Separate the code for authentication into a separate function named auth.
• Group the function related to authentication (auth) with the functions related to session and UI.
• Test the code after refactoring to ensure it still works as expected.

Sweep: Refactor script.js for better visibility control of login/register buttons

  • In extension/script.js, create a function that checks the session status and updates the visibility of the login/register buttons accordingly.

Parent issue: #4

Checklist
  • extension/script.js

• Modify the checkSessionStatus() function to call updateButtonVisibility(sessionExists) after checking the session status. This will ensure that the button visibility is updated every time the session status is checked.
• Modify the event listener for the "endpointsetbutton" to call the checkSessionStatus() function instead of directly checking the session status and updating the button visibility.
• Modify the event listener for the "endpointremovebutton" to call the checkSessionStatus() function instead of directly checking the session status and updating the button visibility.
• Modify the event listener for the "signinbutton" to call the checkSessionStatus() function instead of directly checking the session status and updating the button visibility.
• Modify the event listener for the "registerbutton" to call the checkSessionStatus() function instead of directly checking the session status and updating the button visibility.

Sweep: Refactor script.js for better visibility control of login/register buttons

  • In extension/script.js, create a function that checks the session status and updates the visibility of the login/register buttons accordingly.

Parent issue: #4

Checklist
  • extension/script.js

• Create a new function named checkSessionStatus. This function should use browser.storage.local.get to retrieve the session token from the local storage. If a session token exists, the function should return true; otherwise, it should return false.
• Create a new function named updateButtonVisibility. This function should take a boolean parameter named sessionExists. If sessionExists is true, the function should hide the login and register buttons by calling hideE with "signinbutton" and "registerbutton" as arguments, respectively. If sessionExists is false, the function should show the login and register buttons by calling showE with "signinbutton" and "registerbutton" as arguments, respectively.
• In the event listener for the DOMContentLoaded event, replace the existing code that checks the session status and updates the button visibility with calls to checkSessionStatus and updateButtonVisibility.
• In the event listeners for the "endpointsetbutton" and "endpointremovebutton" clicks, after the endpoint is set or removed, call checkSessionStatus and updateButtonVisibility to update the button visibility based on the new session status.

Sweep: Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, return the required JSON data in the new route handler.

Parent issue: #4

Checklist
  • server/app.py

• Replace the current implementation of the /bookmarks endpoint with a new function that fetches the bookmark data from the database.
• The new function should return the bookmark data in the required JSON format.
• Add a check to ensure that the /bookmarks endpoint is only accessible to authenticated users.

Sweep: Refactor script.js for a more manageable codebase

  • In extension/script.js, modularize the code by separating different functionalities into different functions.
  • In extension/script.js, organize the code in a more structured way.

Parent issue: #4

Checklist
  • extension/script.js

• Create a new function named 'setEndpoint' that encapsulates the logic for setting the endpoint. This function should take the endpoint as a parameter and set it in the browser's local storage.
• Create a new function named 'getEndpoint' that encapsulates the logic for getting the endpoint from the browser's local storage.
• Create a new function named 'auth' that encapsulates the logic for authentication. This function should take the mode (signin or register) as a parameter and perform the appropriate action.
• Create a new function named 'updateButtonVisibility' that encapsulates the logic for updating the visibility of the buttons. This function should take a boolean parameter indicating whether a session exists or not.
• Create a new function named 'checkSessionStatus' that encapsulates the logic for checking the session status. This function should return a promise that resolves with a boolean indicating whether a session exists or not.
• Organize these functions in a more structured way by grouping related functions together and separating unrelated functions.
• Refactor the code to make it more readable and maintainable by following best practices for writing JavaScript code.

Sweep: Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, in the new route handler, return the required JSON data.

Parent issue: #4

Checklist
  • server/app.py

• Replace the current /bookmarks route handler with a new one. The new route handler should fetch the bookmarks from the database and return them as JSON data.
• Add the @login_required decorator to the /bookmarks route handler to ensure that it is accessible only to authenticated users.

Sweep: Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, return the required JSON data in the new route handler.

Parent issue: #4

Checklist
  • server/app.py

• Add a new route handler for the /bookmarks endpoint using the @app.route decorator. The route should respond to GET requests.
• In the new route handler, return a list of bookmarks. Each bookmark should be a dictionary with keys for the bookmark's title and URL. For now, you can return a static list of bookmarks for testing purposes.

Sweep: Implement /bookmarks endpoint in server/app.py

  • In server/app.py, create a new route handler for the /bookmarks endpoint.
  • In server/app.py, return the required JSON data in the new route handler.

Parent issue: #4

Checklist
  • server/app.py

• Add a new route handler for the /bookmarks endpoint using the @app.route decorator. The route should accept both GET and POST requests.
• In the new route handler, check if the request method is GET. If it is, return a JSON object with a list of all bookmarks. For now, you can return a static list of bookmarks.
• If the request method is POST, extract the bookmark data from the request body and add it to the list of bookmarks. Then return a success message in JSON format.

Sweep: Refactor script.js for better visibility control of login/register buttons

  • In extension/script.js, create a function that checks the session status and updates the visibility of the login/register buttons accordingly.

Parent issue: #4

Checklist
  • extension/script.js

• Create a function named checkSessionStatus that checks if a session exists. This function should return a boolean value indicating whether a session exists or not. Use the existing code in the checkSessionStatus function as a starting point, but modify it to return a boolean value instead of resolving a promise.
• Create a function named updateButtonVisibility that takes a boolean argument sessionExists. This function should call hideElement for the "signinbutton" and "registerbutton" if sessionExists is true, and showElement for these buttons if sessionExists is false.
• Replace the existing calls to hideElement and showElement for the "signinbutton" and "registerbutton" with calls to updateButtonVisibility. Pass the result of checkSessionStatus as an argument to updateButtonVisibility.
• In the DOMContentLoaded event listener, replace the existing call to updateButtonVisibility with a call to checkSessionStatus, and use the result to call updateButtonVisibility.

Sweep: Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, handle the returned JSON data in the new function to add/remove bookmarks as needed.

Parent issue: #4

Checklist
  • extension/script.js

• Add a new function named fetchBookmarks that sends a GET request to the /bookmarks endpoint. Use the fetch function to send the request, and the endpoint variable for the URL.
• In the fetchBookmarks function, handle the returned response by converting it to JSON with the json method.
• After converting the response to JSON, iterate over the returned bookmarks. For each bookmark, check if it exists in the local bookmarks. If it does not exist, add it. If it exists in the local bookmarks but not in the server data, remove it.

Sweep: Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, handle the returned JSON data in the new function to add/remove bookmarks as needed.

Parent issue: #4

Checklist
  • extension/script.js

• Create a new function named syncBookmarks().
• Inside syncBookmarks(), send a GET request to the /bookmarks endpoint using the fetch function.
• Handle the returned response by converting it to JSON using the json() method.
• Iterate over the returned bookmarks. For each bookmark, check if it exists in the local bookmarks using the bookmarkExists(bookmark) function. If it does not exist, add it using the addBookmark(bookmark) function.
• After adding the new bookmarks, iterate over the local bookmarks using the getLocalBookmarks() function. For each local bookmark, check if it exists in the returned bookmarks. If it does not exist, remove it using the removeBookmark(bookmark) function.

Sweep: Refactor script.js for a more manageable codebase

  • In extension/script.js, modularize the code by separating different functionalities into different functions.
  • In extension/script.js, organize the code in a more structured way.

Parent issue: #4

Checklist
  • extension/script.js

• Create a new function named 'setEndpoint' and move the code for setting the endpoint from the 'DOMContentLoaded' event listener to this new function.
• Create a new function named 'removeEndpoint' and move the code for removing the endpoint from the 'DOMContentLoaded' event listener to this new function.
• Create a new function named 'signIn' and move the code for signing in from the 'DOMContentLoaded' event listener to this new function.
• Create a new function named 'register' and move the code for registering from the 'DOMContentLoaded' event listener to this new function.
• Create a new function named 'showElement' and move the code for showing an element from the 'showE' function to this new function.
• Create a new function named 'hideElement' and move the code for hiding an element from the 'hideE' function to this new function.
• Group the newly created functions together and add comments to explain what each function does.
• Replace the calls to the old functions in the 'DOMContentLoaded' event listener with calls to the new functions.

Sweep: Create a new function in script.js to interact with /bookmarks endpoint

  • In extension/script.js, create a new function fetchBookmarks that sends a GET request to the /bookmarks endpoint.
  • In extension/script.js, in the fetchBookmarks function, handle the returned JSON data to add/remove bookmarks as needed.

Parent issue: #4

Checklist
  • extension/script.js

• Add a new function fetchBookmarks that sends a GET request to the /bookmarks endpoint. Use the fetch API for this. The fetch function should be called with the endpoint variable concatenated with the string '/bookmarks'.
• In the fetchBookmarks function, handle the returned response by converting it to JSON using the json method of the response.
• After converting the response to JSON, iterate over the returned bookmarks. For each bookmark, check if it exists in the local bookmarks. If it does not exist, add it to the local bookmarks. This can be done using the bookmarkExists and addBookmark functions.
• After iterating over the returned bookmarks, iterate over the local bookmarks. For each local bookmark, check if it exists in the returned bookmarks. If it does not exist, remove it from the local bookmarks. This can be done using the removeBookmark function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.