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

Vieb bookmarks #391

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft

Vieb bookmarks #391

wants to merge 27 commits into from

Conversation

yosoymau
Copy link
Contributor

@yosoymau yosoymau commented Jul 1, 2022

@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 1, 2022

This is what i have right now.
Now things are less convoluted than before as i moved everything to a new file, more organized. I have some things i'd like to discuss.

The bmadd command

What should we expect bmadd to do and how? Right now i have it set up like this:

Case 1:

bmadd
If the user sends the command with no arguments it creates a new bookmark, with the current page's url, title and name.

Case 2:

bmadd github my repos
When the user gives the command just a string of text, that string is considered to be the name, and the url and title are set to the current page's data.

Case 3:

bmadd name=github~title=main page of github~url=https://github.com
The user can give to the command a string like this, using this kind of style: option=value, and every option separated by a ~.

My concerns are:

  1. Should the bookmarks be filled automatically if some piece of data is missing?
  2. In case 3, should the missing data be filled automatically from the current page? Maybe this could be a setting?
  3. My mind tells me that the url is kind of essential to the concept of what a bookmark even is, so i think this should be filled automatically if the user fails to specify one, but should any property of a bookmark be required?
  4. If the user doesn't give a name for a bookmark? What should be the result? Right now it just gets the current page's title, but this seems bad to me.
  5. I think the formatting of the string is not a very good one because both equal signs and tildes can be used in urls and titles, and that would mess things up, but i don't know what could be appropriate.
  6. Also for the formatting, how should we accept list like properties? if the user wanted to give multiple tags to a bookmark, what would be a good format? Right now these are not supported.

Sorry if this are too many questions i just think we need to define this clearly before continuing much further with this.

Copy link
Owner

@Jelmerro Jelmerro left a comment

Choose a reason for hiding this comment

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

Thanks so much for starting work on this, looks fairly good, just a lot of small nitpick things 😉. Your overall approach and setup seem solid and correct. As for your other questions:

  1. Yes, all info should have a fallback, even if empty in some cases. Pretty much everything besides the url should be considered optional in a bookmark.
  2. Yes, if users don't want the info they can delete it later I think, unless you think a setting is needed as well.
  3. Only the url is required, so if there is no page url, we need the user to supply one (only for the newtab page actually, but other pages are all fair as the url fallback).
  4. Page title is fine to me, users can edit this later or set the title they want to.
  5. I would imagine adding a url field specifically to the bmadd command not being that common, as usually users would like to simply add the current page, not some other url. Having said that, it should still be supported. I'm also not that big of a fan of how the command currently looks with lots of arguments, initially I thought of automatically guessing what each argument of the bmadd command would be for, but with so many different fields/options to a bookmark that seems not possible, so we do need this actually. I think the tilde is fine, it needs to be escaped in proper urls anyway, and is not stored as such in the bookmarks file, so even if users can't add it with the command when they are not on the page, they can still add it when they ARE on the page or by editing the bookmarksfile. Equal signs should be allowed in the options, you can split each part on the = and take the first part as the name, then join the other parts with = to get the remaining string with = intact.
  6. Commas seem like a good option to me. Ideally the tags should follow simpler naming rules, you can use the specialchars variable of util.js to check for characters that should be blocked. Maybe choose the one that does allow spaces.

Hopefully you can continue with all these comments and answers, let me know if anything is still unclear. Finally please also refer to my later comments in #100 for a general description of how it should work.

app/renderer/bookmarks.js Outdated Show resolved Hide resolved
app/renderer/bookmarks.js Outdated Show resolved Hide resolved
app/renderer/settings.js Outdated Show resolved Hide resolved
app/renderer/settings.js Show resolved Hide resolved
app/renderer/settings.js Outdated Show resolved Hide resolved
app/renderer/settings.js Outdated Show resolved Hide resolved
app/renderer/settings.js Show resolved Hide resolved
app/renderer/settings.js Outdated Show resolved Hide resolved
@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 2, 2022

So now i've pushed an update where i started to add suggestions to the bookmark commands, it's still not working properly, i'm still not sure what's wrong, but i believe it's on the right track. Thanks for the feedback!

@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 3, 2022

Hello @Jelmerro good day!
I've been thinking about the way that the command :bmload should work. I was working on the suggestions under the assumption that the user would load a bookmark referring to it by it's name, but then i remembered about the keywords and tags, and i'm not sure how these would fit here.

Can you explain what was the purpose that you intended for keywords, tags and names or how you expected them to work when you made the specifications on #100? This is so i can better understand what i should be aiming for, because right now i feel like i'm just kinda using the name as something like a keyword.

Also what do you think of this idea:

  1. The user can do :bmload mytagand all the bookmarks with that tag get loaded.

Thanks!

app/renderer/bookmarks.js Outdated Show resolved Hide resolved
@Jelmerro
Copy link
Owner

Jelmerro commented Jul 3, 2022

The tags and keywords should also be searchable using bmload, probably using the same syntax as bmadd, but i like the idea of just mentioning a tag and loading all of them. Not sure if the same should happen for keywords, but for tags that would be nice. The suggestions for bmload should help letting users know which bookmarks match their query, and load them all or just the one if selected.

The big difference of tags and keywords, should be that tags can be colored and have their own set of keywords, see #100 (comment). This should be all the more useful once there is a bookmarks page to visualize the bookmarks in the folders, where they are shown with these tags in their own colors.

@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 4, 2022

I'm starting to work on the special page to manage bookmarks, and i ran into a roadblock that i haven't been able to solve. I'm trying to get the bookmark data from a function in renderer/bookmarks.js to preload/bookmarks.js. Now i found out these exist in different contexts, as far as i understand, these can't communicate directly. Is this right?

So my guess is that this should be done via ipcRenderer messages. I was looking around the code i dont have any idea on how i could get the data from renderer/bookmarks.js to maybe index.js (? not sure about this) and then get that sent to preload/bookmarks.js.

Any suggestion would be appreciated.

As for the bmload situation, i like the idea of using bmload with the same syntax as bmadd. I'll change what i have now and see how could i make this work in a nice way.

@Jelmerro
Copy link
Owner

Jelmerro commented Jul 4, 2022

You are correct, I would like to recommend the newtab page as a quick and easy example on how to do ipc-renderer communication: https://github.com/Jelmerro/Vieb/blob/master/app/preload/newtab.js, you can find the other side of things in a range of places, but the first point of action is here:

if (e.channel === "new-tab-info-request") {
. You do NOT need to go through main (unlike a lot of other things), as you don't need to interact with subframes or main-only APIs.

Basically, from renderer to preload/pages you can do webview.send and inside the preload you can do ipcRenderer.sendToHost to send it back to the renderer, which is received in the tabs file as an event on the webview. If you do ipcRenderer.send from the preload, you end up in main, but you won't need that in this case.

@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 6, 2022

This was exactly what i needed, i'll be back when i get something working. Thanks a lot.

@yosoymau
Copy link
Contributor Author

yosoymau commented Jul 7, 2022

Now i've added the start of the special page for managing bookmarks, and this is what i got.
I don't know if this is the direction we were aiming for, right now it's kinda ugly, because it needs some css love, and things like tags or the editing functionality are not implemented yet.

My question is this: is this kind of solution good?
Right now this produces this page:
image

Should i keep going with this or should i change my approach?

@Jelmerro Jelmerro mentioned this pull request Nov 8, 2022
@Jelmerro
Copy link
Owner

Jelmerro commented Apr 1, 2023

Hey @yosoymau I hope you are well, I was wondering if you were planning to continue work on this PR. Thanks for the work so far, let me know if you need help with anything!

@Jelmerro Jelmerro mentioned this pull request May 24, 2023
3 tasks
@yosoymau
Copy link
Contributor Author

yosoymau commented Jun 6, 2023

Hello again, i'm back and i'll keep working on this, so expect to hear back from me soon.

I apologize for my absence and leaving this halfway for such a long time.

@Jelmerro
Copy link
Owner

Jelmerro commented Jun 6, 2023

Welcome back, glad you are willing to continue work on it, just let me know if there's anything you need help with. I'm a bit inactive for the last weeks as well, I will be back in a few.

Copy link
Owner

@Jelmerro Jelmerro left a comment

Choose a reason for hiding this comment

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

I went through the current code, most of it looks very good, just some small suggestions so far. I'm very happy with your commitment to build this feature over the past years, let me know if I can help with anything.

}

ipcRenderer.on("bookmark-data-response", (_, bookmarkData) => {
// Create folder structure
Copy link
Owner

Choose a reason for hiding this comment

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

This comment seems redundant.

"use strict"
const {ipcRenderer} = require("electron")

// Create tree structure to keep track of added folders.
Copy link
Owner

Choose a reason for hiding this comment

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

This comment seems redundant.

@@ -350,6 +350,9 @@ body:not(#app) ::placeholder {color: var(--placeholder-text);}
#downloadspage .misc {display: flex;margin: .5em;flex-direction: column;width: calc(100% - 1em);}
#downloadspage .filelocation {cursor: pointer;}
#downloadspage img {cursor: pointer;}
/* Bookmarks */
Copy link
Owner

Choose a reason for hiding this comment

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

Bookmarks in lowercase here please.

Comment on lines +55 to +57
const update = () => {
ipcRenderer.sendToHost("bookmark-data-request")
}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const update = () => {
ipcRenderer.sendToHost("bookmark-data-request")
}
const update = () => ipcRenderer.sendToHost("bookmark-data-request")

let currentCheckingFolder = tree
folderElements.forEach(e => {
// Ignore / because it already exists.
if (e !== "/") {
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe filter these before doing the forEach? And possibly make this into a function as this is intended quite a bit.

Comment on lines +251 to +256
{
"id": t,
"keywords": [],
"name": ""
}
)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
{
"id": t,
"keywords": [],
"name": ""
}
)
{"id": t, "keywords": [], "name": ""})

Comment on lines +304 to +307
// Check path format
// Check color hex values
// Check keywords and tags.
// Single words?
Copy link
Owner

Choose a reason for hiding this comment

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

I presume these are still on the TODO list? Let me know if you are stuck and/or need help to implement this :)

// Check keywords and tags.
// Single words?

if (badOptions.length !== 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if (badOptions.length !== 0) {
if (badOptions.length) {

Comment on lines +744 to +747
[
"bmload",
"bmdel"
].forEach(
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
[
"bmload",
"bmdel"
].forEach(
["bmload", "bmdel"].forEach(

Comment on lines +750 to +751
const {getBookmarkData,
validBookmarkOptions} = require("./bookmarks")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const {getBookmarkData,
validBookmarkOptions} = require("./bookmarks")
const {
getBookmarkData, validBookmarkOptions
} = require("./bookmarks")

@TiagoRCorreia
Copy link

Still in development?

@Jelmerro
Copy link
Owner

I haven't seen @yosoymau around for a while, so this PR has been stale indeed. I am personally in no rush to get this implemented, but have outlined my proposal in the main ticket #100. I'm not going to rush @yosoymau to do it for us, they can take as long as they need to implement this huge feature, if at all, any contribution is optional and they shouldn't feel obliged to finish the PR, that's why it's still in draft as well. Feel free to pick up where this PR left and make a new one, or please wait for it to be done patiently.

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.

3 participants