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

add import & export of xattr tags #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rareshp
Copy link

@Rareshp Rareshp commented Aug 24, 2024

Loving the application. Thank you for your work.

As I have used KDE Plasma for years, I have tagged some files. The tagging system in KDE uses extended file attributes. To be more exact, Dolphin is using user.xdg.tags in the following format:

tag1, tag2, parentTag/subTag, parentTag2/subParent/subTag2

This pull request aims to add 2 additional buttons in the Settings, and the corresponding functions for them:

  • import from xattr, just user.xdg.tags and user.baloo.rating
  • export tags back to xattr (tags and rating)

The PR does not include:

  • user.xdg.comment (I simply never used it)
  • no automated tests. The existing tests do pass. Manual testing was performed for import and export several times.

In addition trying to run yarn start I would get a warning about APPIMAGE environment variable not being set. I had to add this line to src/main.ts. This is not part of the PR.

--- a/src/main.ts
+++ b/src/main.ts
@@ -27,6 +27,8 @@ const basePath = app.getPath('userData');
 const preferencesFilePath = path.join(basePath, 'preferences.json');
 const windowStateFilePath = path.join(basePath, 'windowState.json');
 
+process.env.APPIMAGE = path.join(__dirname, 'dist', `OneFolder-${app.getVersion()}.AppImage`)
+
 // if (IS_DEV) {
 //   Object.defineProperty(app, 'isPackaged', {
 //     get() {

@Antoine-lb
Copy link
Contributor

thank you very much for this, it looks great.

Would you mind sharing some pictures with those tags so I can test it on my machine?

@Rareshp
Copy link
Author

Rareshp commented Aug 27, 2024

Hello,

You can use these terminal commands to set tags and get tags. In KDE Dolphin (with baloo indexing enabled), the xattr show up in the GUI.
Of course, this can be turned into a javascript test instead:

setfattr -n user.baloo.rating -v "10" audiophiles.png  # 10 is 5 stars

setfattr -n user.xdg.tags -v "comics/xkcd, black_and_white, stick_figures, parent/subparent/subtag1, parent/subparent/subtag2" audiophiles.png

# to get the attributes back:
getfattr -e text --only-values -d --match="user.xdg.tags" audiophiles.png

Note

"comics/xkcd" will show up as xkcd below. "comics" parent is still a tag, but also regarded as a "folder" per se.
Similarly, "parent/subparent/subtag1" shows up as "subtag1" only.

On my end it looks like this:
image

After importing into OneFolder it looks like this:

Tags in the sidebar:
image

Tag chips over the image itself:
image

Important

Many of my pictures do not have scores, or tags, or both. As such in the code I added try catch for both to simply console.error. Please, feel free to change this to better suit your standards.

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.

2 participants