From 21ab265cd2c0ccf0039bf662b9c1f0c3ddba08d5 Mon Sep 17 00:00:00 2001 From: familyfriendlymikey Date: Wed, 17 Aug 2022 09:07:06 -0400 Subject: [PATCH] add bangs --- app/client.imba | 39 +++++++++++++++++++++++++++++++++++---- package.json | 2 +- readme.md | 13 +++++++++++++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/client.imba b/app/client.imba index 3bb3037..001140b 100644 --- a/app/client.imba +++ b/app/client.imba @@ -32,6 +32,7 @@ tag app settings_active = no loading = no fatal_error = no + bang = no get render? do mounted? @@ -120,8 +121,10 @@ tag app save_config! get encoded_search_query - let encoded_query = window.encodeURIComponent(state.query) - "{config.search_engine.url}{encoded_query}" + "{config.search_engine.url}{window.encodeURIComponent(state.query)}" + + get encoded_bang_query + "{bang.url}{window.encodeURIComponent(state.query)}" def use_search_engine increment_search_engine_frequency! @@ -180,14 +183,31 @@ tag app def handle_click_search increment_search_engine_frequency! + def handle_bang + return unless bang + let url = encoded_bang_query + await increment_link_frequency bang + window.location.href = url + + def handle_click_bang + handle_bang! + def handle_return - if state.scored_links.length < 1 + if bang + handle_bang! + elif state.scored_links.length < 1 use_search_engine! else let link = state.scored_links[selection_index] await increment_link_frequency link window.location.href = link.url + def handle_tab + return bang = no if bang + return unless state.scored_links.length > 0 + state.query = '' + bang = state.scored_links[selection_index] + def handle_click_delete link handle_delete link @@ -410,6 +430,7 @@ tag app @hotkey('shift+backspace').capture=handle_shift_backspace @hotkey('down').capture=increment_selection_index @hotkey('up').capture=decrement_selection_index + @hotkey('tab').capture=handle_tab @input=handle_input @paste=handle_paste @blur=this.focus @@ -429,7 +450,17 @@ tag app <.middle-button.disabled> "+" <.links> - if state.scored_links.length > 0 + if bang + + <.link-left> + + <.name[tt:none]> encoded_bang_query + <.link-right[jc:flex-end]> + <.frequency> bang.frequency + elif state.scored_links.length > 0 for link, index in state.scored_links `. +This will allow you to start typing a query which will be appended onto the url of that link. +To navigate to the link, just press `return` or click the link. +To cancel, just press `tab` again. + ### 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.