From 14abde71688202b2615e04e5b079f5de187a86ba Mon Sep 17 00:00:00 2001 From: familyfriendlymikey Date: Tue, 16 Aug 2022 18:35:22 -0400 Subject: [PATCH] add create and delete hotkeys, update readme --- app/client.imba | 53 ++++++++++++++++++++++++++++++++----------------- package.json | 2 +- readme.md | 39 ++++++++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/app/client.imba b/app/client.imba index 9a676ee..1000855 100644 --- a/app/client.imba +++ b/app/client.imba @@ -89,10 +89,10 @@ tag app state.links = await db.links.toArray() sort_links! - def can_add + get can_add return no if loading return no if settings_active - await get_valid_link(state.query) + get_valid_link(state.query) def sort_links if state.query.trim!.length > 0 @@ -188,9 +188,38 @@ tag app await increment_link_frequency link window.location.href = link.url + def handle_click_delete link + handle_delete link + + def handle_shift_backspace + return unless state.scored_links.length > 0 + handle_delete state.scored_links[selection_index] + + def handle_delete link + loading = yes + let delete_link = do + return unless window.confirm "Do you really want to delete {link..name}?" + try + await db.links.delete(link.id) + catch e + err "deleting link", e + try + await reload_db! + catch e + err "reloading db after successful delete", e + selection_index = Math.min selection_index, state.scored_links.length - 1 + await delete_link! + loading = no + + def handle_shift_return + handle_add! + def handle_click_add + handle_add! + + def handle_add loading = yes - let link = await get_valid_link(state.query) + let link = get_valid_link(state.query) unless link err "adding link", "Invalid link." return @@ -203,20 +232,6 @@ tag app selection_index = 0 sort_links! - def handle_click_delete link - loading = yes - return unless window.confirm "Do you really want to delete {link..name}?" - try - await db.links.delete(link.id) - catch e - err "deleting link", e - try - await reload_db! - catch e - err "reloading db after successful delete", e - selection_index = 0 - loading = no - def handle_click_import e loading = yes let id_exists = do |newid| @@ -392,6 +407,8 @@ tag app bind=state.query placeholder=pretty_date @hotkey('return').capture=handle_return + @hotkey('shift+return').capture.if(can_add)=handle_shift_return + @hotkey('shift+backspace').capture=handle_shift_backspace @hotkey('down').capture=increment_selection_index @hotkey('up').capture=decrement_selection_index @input=handle_input @@ -407,7 +424,7 @@ tag app .disabled=loading @click.if(!loading)=toggle_settings > "..." - elif await can_add! + elif can_add <.middle-button@click=handle_click_add> "+" else <.middle-button.disabled> "+" diff --git a/package.json b/package.json index b388108..dd0e521 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fuzzyhome", - "version": "0.1.33", + "version": "0.1.35", "scripts": { "start": "imba run -SMH --baseurl . -w server.imba", "build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba", diff --git a/readme.md b/readme.md index b4543a9..3071401 100644 --- a/readme.md +++ b/readme.md @@ -24,6 +24,8 @@ imba home page https://imba.io/ The last space-separated string will be used as the url for your link. In most cases if you do not specify a protocol, `https` will be used. +You can also use the hotkey `shift+return` to create a new link. + ### Fuzzy Find Search for a link by typing. The fuzzy sorting algorithm makes searching very fast, @@ -34,24 +36,44 @@ Navigate to the currently selected search result by pressing `return`. You can also click on a link to navigate to it. You can also press the up or down arrow keys to move your selection up and down. +### Move Selection +You can move your selection up and down with the arrow keys. + ### Search If there are no matching links, a search will be performed with your query. + +### Quick Search +If you paste while the input is empty, fuzzyhome will immediately make a search with your pasted query. + +### Delete +You can delete notes by clicking the purple `x` on the currently selected link. +You can also use the hotkey `shift+backspace` to delete the currently selected link. + +### Customize Search Engine The default search engine is Google Search, however you can customize it by clicking the three dots to go to settings, clicking `config`, and pasting in your search engine url, such as `https://search.brave.com/search?q=`. Your search query simply gets encoded and pasted to the end of your configured search engine url. -### Quick Search -If you paste while the input is empty, fuzzyhome will immediately make a search with your pasted query. +### Importing / Exporting Links +If you want to export your links to use them on another computer, go to the settings menu and click `EXPORT`. +This downloads a `.json` file, which you can then send to your other computer and import by clicking the `IMPORT` button +and selecting your file. -### Hotkeys +## Hotkeys Hotkey | Action -|- Return | Navigate to the currently selected link, or perform a search if there are no matching links. Up Arrow | Move selection up. Down Arrow | Move selection down. Paste | If input is empty, immediately search with pasted query. +Shift + Return | Create new link. +Shift + Backspace | Delete currently selected link. + +## FAQ + +### The Link I Want Is Showing Up Last +TLDR either rename the desired link to something shorter or the undesired link to something longer. -### Tips Fuzzyhome doesn't use an algorithm that attempts to be intelligent about which links it ranks first because having a more predictable behavior lets you work faster since you know it will do the same thing every single time. @@ -70,3 +92,12 @@ either lengthen `mpv`'s name to something like `_mpv`, or shorten `messenger`'s With either of these solutions, typing `m` will always result in the desired link showing up first. That will be the behavior every single time, regardless of which link you accessed more recently, what time of day it is, or some other random variable. + +### A Link Is Blocking My Search +This happens very rarely if at all. Just throw some spaces at the end of your query. + +### The Quick Search Function Is Stopping Me From Finishing My Query +Just type a single space before you paste in text. + +### My Localhost Link Isn't Working +If you want to make a link that points to `localhost`, you likely need to specify the `http` protocol when creating your link.