Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Possible Archive.org check implementation #176

Closed
wants to merge 1 commit into from

Conversation

simonsan
Copy link

Started sketching out a possible implementation. This is WIP though, wanted to PR early for feedback and directions.

For now I relied on the redirect implementation and just checked for a 404 in a bookmark, if so check with archive.org. If there is no snapshot available keep the NOT_FOUND else return the bookmark with a NewUrl and set status to REDIRECT.

What do you think @cadeyrn?

When ready:
Fixes #147

*
* @type {boolean}
*/
disableAutomaticArchiveOrgReplacement: false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not implemented yet, also no check for this setting.

@@ -540,6 +547,60 @@ const bookmarksorganizer = {
}
},

/**
* This method sends a GET request to the archive.org API to check if there is a snapshot available for a given URL.
* It replaces the current broken URL with the archived URL.
Copy link
Author

@simonsan simonsan Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is currently not true, as I imagined it to be more clean to use it as a NewUrl and take the redirect approach.


const archived_snapshots = await response.json();

console.log(archived_snapshots);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug

Comment on lines +582 to +585
else {
bookmark.newUrl = `${snapshot_base_url}${bookmark.url}`;
bookmark.status = STATUS.REDIRECT;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe as an addition here, we could rename the bookmark. Though I'm not sure this is working out well with the approach to threat it as a possible redirect.

@cadeyrn cadeyrn self-requested a review January 25, 2022 18:47
Copy link
Owner

@cadeyrn cadeyrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thank you very much for your contribution! Do you know an example URL that can be used for testing?

I am not sure if it's the right approach to mark a bookmark as redirected if there is a snapshot saved on archive.org. I would argue that the user should be notified about the snapshot but not in the same way as with a redirect because the original bookmark would still be kind of broken.

The UI of the Bookmarks Organzier knows errors (red dot; broken bookmarks) and warnings (yellow dot; so far only redirects). I think a warning is okay if there is a saved snapshot but instead of showing the old URL and the new URL it should be shown a link to archive.org. For this we probably need a new status code in status.js and work with that in any way. Similar to the link to optionally correct the URL for a redirect we would need a link to optionally change the URL to the archive.org link. It also has to be checked that the feature to automatically repair all redirects does not change the URL of such a bookmark (because it's not a redirect) and as such shouldn't be affected by this batch operation.

@@ -612,7 +673,11 @@ const bookmarksorganizer = {
});
}

if (bookmark.status > STATUS.REDIRECT) {
if (bookmark.status == STATUS.NOT_FOUND) {
Copy link
Owner

@cadeyrn cadeyrn Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use strict equality operators (=== instead of ==).

By the way: If you run npm run lint:js you can run the linter. It complains about things like that. :)

@cadeyrn cadeyrn marked this pull request as draft February 6, 2022 13:14
@cadeyrn
Copy link
Owner

cadeyrn commented Mar 13, 2022

closed due to inactivity.

@cadeyrn cadeyrn closed this Mar 13, 2022
@simonsan
Copy link
Author

closed due to inactivity.

Hey, yes sorry. Lost a bit track of it due to other projects.

@cadeyrn
Copy link
Owner

cadeyrn commented Jan 10, 2023

Not a problem at all! Just let me know if you want to give it a try again. :)

@simonsan
Copy link
Author

Not a problem at all! Just let me know if you want to give it a try again. :)

I'm unsure, as I'm more working in Systems Programming (Rust) and not really know much about TS/JS. So I'm probably not the best for the job 😅 as I don't know all the patterns usually being used. I guess it would be much easier for someone actually used to the language to implement it in a good way. Thing is, I can't use bookmarks-organizer without that feature, as I don't want any of the 10k+ bookmarks being deleted without making sure there is not even one way to access them (archive.org). So I felt this feature is important to me, hence I tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate with Wayback machine
2 participants