jarun / buku

:bookmark: Personal mini-web in text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add search option to include and exclude columns

sjehuda opened this issue · comments

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:

  • Include specified columns;
  • Exclude specified columns.

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.

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:.

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.)

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 😅

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

  • the no-prefix substring is treated as global (*); to search within title only, use . prefix
  • Deep Search (--deep in CLI) affects all substrings except for the tags-only ones (#); and when applying a global substring to tags, non-deep search matches exact tags instead of full words
  • when searching within tags (global or tag substring), the keyword is split by commas; this means "must contain all listed tags to match the keyword"
    • if the tags-only substring starts with a comma (#,), it contains exact tags (otherwise they're partial); when applying a global substring to tags, this exact/partial behaviour is based on current Deep Search mode
  • Regex search (--regex in CLI) works with markers, but splitting tags by comma (as well as Deep Search and All Keywords Search) is not done in this mode; regular expressions are applied as-is, with the markers used only for splitting and field selection
  • when the input allows for multiple keywords (CLI/API), there's no splitting done – the search function checks first character of each keyword when looking for markers instead

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.

commented

You may want to document this in the wiki somewhere.