Browse Source

add create and delete hotkeys, update readme

main
familyfriendlymikey 2 years ago
parent
commit
14abde7168
  1. 53
      app/client.imba
  2. 2
      package.json
  3. 39
      readme.md

53
app/client.imba

@ -89,10 +89,10 @@ tag app
state.links = await db.links.toArray() state.links = await db.links.toArray()
sort_links! sort_links!
def can_add get can_add
return no if loading return no if loading
return no if settings_active return no if settings_active
await get_valid_link(state.query) get_valid_link(state.query)
def sort_links def sort_links
if state.query.trim!.length > 0 if state.query.trim!.length > 0
@ -188,9 +188,38 @@ tag app
await increment_link_frequency link await increment_link_frequency link
window.location.href = link.url 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 def handle_click_add
handle_add!
def handle_add
loading = yes loading = yes
let link = await get_valid_link(state.query) let link = get_valid_link(state.query)
unless link unless link
err "adding link", "Invalid link." err "adding link", "Invalid link."
return return
@ -203,20 +232,6 @@ tag app
selection_index = 0 selection_index = 0
sort_links! 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 def handle_click_import e
loading = yes loading = yes
let id_exists = do |newid| let id_exists = do |newid|
@ -392,6 +407,8 @@ tag app
bind=state.query bind=state.query
placeholder=pretty_date placeholder=pretty_date
@hotkey('return').capture=handle_return @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('down').capture=increment_selection_index
@hotkey('up').capture=decrement_selection_index @hotkey('up').capture=decrement_selection_index
@input=handle_input @input=handle_input
@ -407,7 +424,7 @@ tag app
.disabled=loading .disabled=loading
@click.if(!loading)=toggle_settings @click.if(!loading)=toggle_settings
> "..." > "..."
elif await can_add! elif can_add
<.middle-button@click=handle_click_add> "+" <.middle-button@click=handle_click_add> "+"
else else
<.middle-button.disabled> "+" <.middle-button.disabled> "+"

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fuzzyhome", "name": "fuzzyhome",
"version": "0.1.33", "version": "0.1.35",
"scripts": { "scripts": {
"start": "imba run -SMH --baseurl . -w server.imba", "start": "imba run -SMH --baseurl . -w server.imba",
"build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba", "build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba",

39
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. 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. 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 ### Fuzzy Find
Search for a link by typing. Search for a link by typing.
The fuzzy sorting algorithm makes searching very fast, 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 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. 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 ### Search
If there are no matching links, a search will be performed with your query. 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, 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=`. 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. Your search query simply gets encoded and pasted to the end of your configured search engine url.
### Quick Search ### Importing / Exporting Links
If you paste while the input is empty, fuzzyhome will immediately make a search with your pasted query. 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 Hotkey | Action
-|- -|-
Return | Navigate to the currently selected link, or perform a search if there are no matching links. Return | Navigate to the currently selected link, or perform a search if there are no matching links.
Up Arrow | Move selection up. Up Arrow | Move selection up.
Down Arrow | Move selection down. Down Arrow | Move selection down.
Paste | If input is empty, immediately search with pasted query. 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 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. 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. 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, 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. 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.

Loading…
Cancel
Save