Open ghost opened 3 years ago
This is a good idea!
Here's the line that does the find API request https://github.com/nextcloud/bookmarks/blob/master/src/components/ViewBookmarklet.vue#L138
The API request is processed on the server here: https://github.com/nextcloud/bookmarks/blob/master/lib/Db/BookmarkMapper.php#L273 as part of the general findAll method: https://github.com/nextcloud/bookmarks/blob/master/lib/Db/BookmarkMapper.php#L193
It may be best to determine the redirected URL on the client or in a separate API call to not change the behavior of the current API.
Let me know if you'd like to work on this and also feel free to comment here or drop by on https://gitter.im/nextcloud-bookmarks/community or https://cloud.nextcloud.com/call/u52jcby9 if you'd like some pointers or discuss this some more :)
I simply changed https://github.com/nextcloud/bookmarks/blob/master/src/components/ViewBookmarklet.vue#L81 .
-this.url
+this.url.replace('https://www.youtube.com/watch?v=', 'https://youtu.be/')
Though it meets my need, I don't understand where does this.url come from.
https://github.com/nextcloud/bookmarks/blob/master/src/components/ViewBookmarklet.vue#L138
And I don't know how the API works. Changing the statements inside async findBookmark(url)
doesn't work.
-const bookmark = await this.$store.dispatch(actions.FIND_BOOKMARK, url)
+const bookmark = await this.$store.dispatch(actions.FIND_BOOKMARK, url.replace('https://www.youtube.com/watch?v=', 'https://youtu.be/'))
I am no developer so I am afraid that I cannot help with it...
The URL comes from the router: https://github.com/nextcloud/bookmarks/blob/master/src/router.js#L90
Changing the statements inside async findBookmark(url) doesn't work.
That's likely because you need to rebuild the app after changing the code.
I am no developer so I am afraid that I cannot help with it...
Ah, that's unfortunate. Nobody is a developer until they try it, though ;)
Okay I figured out something tricky. I didn't press Ctrl + Shift + R, so the bookmarklet that I actually got was cache.
Now it works well for my personal use, but I cannot make it pretty when there is a list of shorten URL rules.
Thank you for helping.
ViewBookmarklet.vue
:
...
async findShortenUrlBookmark(url) {
let shortenUrl = url.replace('https://www.youtube.com/watch?v=', 'https://youtu.be/')
shortenUrl = shortenUrl.replace('https://www.nicovideo.jp/watch/', 'https://nico.ms/')
const shortenUrlBookmark = await this.$store.dispatch(actions.FIND_BOOKMARK, shortenUrl)
if (shortenUrlBookmark) {
this.exists = true
this.bookmark = shortenUrlBookmark
if (this.bookmark.folders.length) {
this.folder = this.bookmark.folders[0]
}
} else {
this.bookmark.url = shortenUrl
}
},
...
Is your feature request related to a problem? Please describe. For example, I would like to add a YouTube video "Big Buck Bunny" to my bookmarks.
https://www.youtube.com/watch?v=YE7VzlLtp-4
However I have stored the same video in shorten URL.https://youtu.be/YE7VzlLtp-4
The bookmarklet may recognize a duplicated URL, however the shorten URL is not recognized.Describe the solution you'd like
Describe alternatives you've considered I would like to know which lines to edit for personal use if the idea sounds not helpful.