jarun / buku

:bookmark: Personal mini-web in text
GNU General Public License v3.0
6.47k stars 295 forks source link

Add search option to include and exclude columns #740

Closed sjehuda closed 4 weeks ago

sjehuda commented 4 months ago

Feature requests

Search bookmarks with tags that contain string.

At the moment it is only possible to select bookmarks with tags that exactly match to the string that is input with -t, --stag (in code: args.stag), and it is not possible to select bookmarks that - for instance - contain tags that begin with a given string (e.g. code:, interface:, niche:, software: etc.).

1. buku (by Arun Prakash Jana) [18]
   > https://github.com/jarun/buku
   + Personal and independent bookmarks system in text
   # code:python,code:roff,interface:cli,interface:html,interface:tui,license:gpl3,name:arun.prakash.jana,niche:bookmarks,software:buku

2. buku_demo [116]
   > https://asciinema.org/a/137065
   # tutorial:buku

3. buku-dmenu (by Ben Oliver) [124]
 > https://gitlab.com/benoliver999/buku-dmenu
 # brand:buku,brand:dmenu,code:bash,interface:plugin,niche:bookmarks,software:buku-dmenu

4. buku-dmenu [170]
   > https://github.com/proycon/dotfiles/blob/master/buku-dmenu
   + A bash script to open buku bookmarks using dmenu
   # brand:buku,brand:dmenu,code:bash,interface:plugin,niche:bookmarks,software:buku-dmenu

5. BukuBot (by Schimon Jehudah Zackary) [171]
   > https://git.xmpp-it.net/sch/BukuBot
   + An XMPP bookmarks chat bot powered by buku.
   # brand:buku,brand:slixmpp,code:python,interface:chat,interface:cli,niche:bookmarks,software:buku-chatbot

6. buku-rofi (by Daniel) [176]
   > https://gitlab.com/danisztls/buku-rofi
   # code:bash,brand:buku,niche:bookmarks,software:buku-rofi,software:buku-rofi

Currently, the only fashion to do so is by an SQLite software; for example:

sqlite3 -noheader -list /path/to/bookmarks.db "SELECT * FROM bookmarks WHERE tags LIKE'%software:%'"

Please consider contributing the feature back to Buku yourself. Feel free to discuss. We are more than happy to help.

I intend to write code which does this.

I would be glad to receive guidance to add this feature.


I am still contemplating

Suppose this feature is added.

Next time, someone might ask to search only titles (metadata) or descriptions (desc) or URLs (urls), so I might want to make this possible, now, instead of writing code specific to tags.

So I might want to add these search options:

LeXofLeviafan commented 4 months ago

I believe the --deep option is meant to cover this sort of thing:

      --deep               match substrings ('pen' matches 'opens')

…Though it's likely only implemented for --sany/--sall (and --sreg doesn't search for it in the first place).

That being said, you're likely meant to use additional tags if you want to use them as search criteria (i.e. code in addition to code:bash if you want to search for all code-related bookmarks); and UX-wise it may be better to collect the list of all existing tags and provide them as available options to the user instead of requesting for arbitrary input.

sjehuda commented 4 months ago

I might want to exxclude columns. Suppose title is "Software directory for niche: Bookmarks" (please notice the colon), a search will detect that titile if niche: is searched for, yet I might only want to search the tags that begin with niche:.

LeXofLeviafan commented 4 months ago

Alternatively you could implement search-with-markers, like it's done in Bukubrow: the prompt

 title substring  :url substring :https > description substring #tag substring: # another tag *global substring 

searches for a bookmark with title substring as a substring within the title, url substring & https as substrings within the URL (though naked whitespaces are rather uncommon there I believe), description substring as a substring within the description, tag substring: & another tag as substrings within tags (commas aren't legal here but the same tag can match multiple tokens), and global substring within any of these fields.

(The split regex used there is \s+[:>#*], if that wasn't obvious.)

LeXofLeviafan commented 1 month ago

Alternatively you could implement search-with-markers

…Come to think of it, I might give it a shot (albeit with slightly altered syntax); the current lack of search field distinction (particularly stuff like "finding a specific URL that I just added") had been kind of bothering me lately :sweat_smile:

LeXofLeviafan commented 4 weeks ago

Note: my implementation is slightly different from the Bukubrew one:

Quick search in Bukuserver navbar uses the same options which are enabled by default in the index page search (markers + all-keywords); these are default primarily because markers don't interfere with most searches unless used explicitly, but also because there's no splitting done with markers disabled.

jarun commented 4 weeks ago

You may want to document this in the wiki somewhere.

LeXofLeviafan commented 6 days ago

You may want to document this in the wiki somewhere.

https://github.com/jarun/buku/wiki/Searching-and-ordering

(The Markers section describing this logic can be found in the article ToC.)

jarun commented 6 days ago

Thank you!