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

Directory is not shown in the search results #304

Closed
bruce30262 opened this issue May 20, 2021 · 11 comments
Closed

Directory is not shown in the search results #304

bruce30262 opened this issue May 20, 2021 · 11 comments
Labels
Milestone

Comments

@bruce30262
Copy link
Contributor

Describe the bug
pigallery2 is not showing the directory in the searching result, an example can be seen in the following URL:

https://pigallery2.herokuapp.com/search/%7B%22type%22:102,%22text%22:%22emptydirectory%22,%22matchType%22:1%7D

You can see that while searching for "emptydirectory", the result didn't show the directory we want to search.

Expected behavior: showing the directory we want to search and allow us to click in and browse the pictures inside the directory.

Photo/video (optional) that causes the bug
N/A

Screenshots

擷取

Environment (please complete the following information):

  • OS: Window 10 64 bit
  • Browser: Brave 1.24.85

Used app version:

@bpatrik
Copy link
Owner

bpatrik commented May 20, 2021

Yeah I kinda know about the issue:

// TODO: implement directory search. Search now only returns with photos and videos

Although the search work, but it only returns photos within that directory and the emptydirectory does not have photos. So I consider this low prio.

@bpatrik bpatrik added the bug label May 20, 2021
@kagahd
Copy link
Contributor

kagahd commented May 22, 2021

@bpatrik, the example of @bruce30262 wouldn't show any photos inside the folder, even if it was not empty, as this example demonstrates.
However, if the quotation marks are omitted, photos inside this folder are shown, as the example demonstrates.
PS: I had to use an AND query on all the folder name parts since the folder name is composed of several words. However, if the folder name does not contain spaces, just omitting the quotation marks worked already.

Is it because the URL parameter matchType:1 has been omitted?
I found the answer by myself by reading other comments: As written here:

You should be able to do 2 type of search:

  1. exact match: directory:"the directory"
  2. any match: directory:(the directory)

And here:

exact match: directory:"the directory"
any match: directory:(the directory)
any match: directory:(all images/some dir/the directory) <-- flattening the "the directory", assuming this is the full path

So, to answer my own question, yes, if matchType:1 (which corresponds to exact match) is omitted, then PiGallery2 does an any match which shows the content of the flattened folder structure.

I also wonder if it's a good idea to show only the folder as @bruce30262 requested, instead to show the folder content as it's the case how PiGallery2 works today. Why do you want first to click the folder instead to see immediately its contents?
Seeing the content immediately is especially useful when the the folder contains subfolders. In such a case, all photos of the searched folder and it subfolders are shown altogether. If I'm not wrong, this behaviour does already what #174 is about, namely flattening a folder structure from non-root. Even sorting (ascending or descending) by date, name or random works already.

@bruce30262
Copy link
Contributor Author

bruce30262 commented May 22, 2021

I also wonder if it's a good idea to show only the folder as @bruce30262 requested, instead to show the folder content as it's the case how PiGallery2 works today. Why do you want first to click the folder instead to see immediately its contents?

So first of all, I use pigallery2 to host my comics and CG collections, which is a little different from hosting photos. Those comics/CG are all stored in different folders ( all in the format of .jpg, .png...etc ), and if some of them are created by the same author, I'll store those folders into another folder. So it looks something like:

├── CG_collection1
│   ├── pic1.jpg
│   ├── pic2.jpg
│   ├── ...
├── Author1
│   ├── Comic_title_A
│   │   ├── 0.jpg
│   │   ├── 1.jpg
│   │   ......
│   ├── Comic_title_B
│   ├── ...
├── Author2
│   ├── Comic_title_C
│   ├── Comic_title_D
│   ├── ...

The whole collection contains hundreds of sub-folder, and that's why the directory searching feature is important to me, since it helps me get to the folder I want to access. A use case will be :

  • I want to watch a comic create by Author1, but I can't remember the title, so I just search "Author1" in the search bar, which will show me the "Author1" directory, then I'll click into the folder and look for that comic.

Seeing the content immediately is especially useful when the the folder contains subfolders. In such a case, all photos of the searched folder and it subfolders are shown altogether.

To me it's quite the contrary : It is important to NOT showing the pictures altogether in a folder that contains subfolders because in my case it might show all the comics at once, and I don't want that.

Right now I'm using an older version of pigallery2 ( my fork and my docker image ) which will show the directory in the search results. It would be nice to upgrade to the latest version, however unless it brings back the directory searching or else I guess I'm going to stick with the old version for a little longer :P

@kagahd
Copy link
Contributor

kagahd commented May 22, 2021

@bruce30262, thanks for the description of your use case. I now understand why you need this feature.
Did PiGallery2 work like you described in the past? Is this the reason that you are using the old version or did you adapt it to your needs? If you are familiar with the code, perhaps you could implement your feature into the newest PiGallery2 version and create a pull request?
It would be nice to have both options though, means, show either the contents of the flatten folder structure or just the clickable folder icon itself.

@bruce30262
Copy link
Contributor Author

Did PiGallery2 work like you described in the past? Is this the reason that you are using the old version or did you adapt it to your needs?

Yes the old version does show the directory in the search results ( I'm using the version at 7f321a3 ). I was trying to upgrade to the latest version, however decided not to because I found the directory searching is removed in the latest version.

If you are familiar with the code, perhaps you could implement your feature into the newest PiGallery2 version and create a pull request?

Unfortunately I'm not familiar with the code ( also not familiar with web app developing ) so I guess it's up to @bpatrik to decide when to bring back the feature. I'm fine with the old version though, since it suits my need and works fine for now. Again it would be nice to upgrade to the latest version, but I'm also OK with staying in the version I'm using right now :)

@kagahd
Copy link
Contributor

kagahd commented May 22, 2021

@bruce30262

I want to watch a comic create by Author1, but I can't remember the title, so I just search "Author1" in the search bar, which will show me the "Author1" directory, then I'll click into the folder and look for that comic.

I might have found a workaround for such a use case but maybe you have others.
My suggestion:

  1. Search for "Author1"
  2. PiGallery2 will show all photos of folder "Author1" and its subfolders altogether
  3. Click on one of the photos
  4. Click on info
  5. In the info box, click on the file name
  6. PiGallery2 will show only the folder of the clicked photo and the complete path to this folder whereas each path entry (=folder) is clickable. So you would also see your searched "Author1" folder as a clickable link.
  7. Once clicked on "Author1", PiGallery2 will show only subfolders of folder "Authors1", in your example "Comic_title_A" and "Comic_title_B".

Would this help you?

@bruce30262
Copy link
Contributor Author

@kagahd thanks for providing this workaround ! However although it does work, it's still kinda inconvenient and not as intuitive as the old version, so I think I'm still gonna use the old one.

bpatrik added a commit that referenced this issue May 23, 2021
Creates a settings that can enable and disable directories in search result
@bpatrik
Copy link
Owner

bpatrik commented May 23, 2021

Added this functionality with a config switch. By default does not search among folders.

Also updated the docs to explain how one can use the search: http://bpatrik.github.io/pigallery2/

@bpatrik bpatrik added this to the v1.9 milestone May 23, 2021
@bpatrik
Copy link
Owner

bpatrik commented May 24, 2021

+1: I can also suggest to tag (keyword) your photos. You can use like exiftool to batch keyword them, but in Windows it is also simple to to select all and add keywords to all of them at once.

@kagahd
Copy link
Contributor

kagahd commented May 25, 2021

I tested the newly added functionality List directories. It works really great. Very appreciated, thanks @bpatrik!

@bruce30262
Copy link
Contributor Author

Tested against 77b2d7e and can confirm that List directories works really well. Guess it's time to upgrade to v1.9.0 :)

Since now the directories are being shown I'm closing this issue. A big thank to @kagahd for joining the discussion and @bpatrik for fixing the issue, keep up the good work !

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

No branches or pull requests

3 participants