|
@ -32,6 +32,7 @@ tag app |
|
|
fatal_error = no |
|
|
fatal_error = no |
|
|
bang = no |
|
|
bang = no |
|
|
holding_shift = no |
|
|
holding_shift = no |
|
|
|
|
|
editing_link = no |
|
|
|
|
|
|
|
|
get render? do mounted? |
|
|
get render? do mounted? |
|
|
|
|
|
|
|
@ -225,11 +226,13 @@ tag app |
|
|
link_text |
|
|
link_text |
|
|
|
|
|
|
|
|
def handle_edit link |
|
|
def handle_edit link |
|
|
|
|
|
editing_link = link |
|
|
|
|
|
state.query = construct_link_text(link) |
|
|
|
|
|
|
|
|
|
|
|
def make_edit link, new_link_text |
|
|
def edit_link |
|
|
def edit_link |
|
|
let input = window.prompt "Enter the new link name and url:", construct_link_text(link) |
|
|
|
|
|
return if input is null |
|
|
|
|
|
try |
|
|
try |
|
|
await update_link link, input |
|
|
await update_link link, new_link_text |
|
|
catch e |
|
|
catch e |
|
|
return err "editing link", e |
|
|
return err "editing link", e |
|
|
loading = yes |
|
|
loading = yes |
|
@ -281,12 +284,12 @@ tag app |
|
|
sort_links! |
|
|
sort_links! |
|
|
|
|
|
|
|
|
def handle_click_delete link |
|
|
def handle_click_delete link |
|
|
|
|
|
return unless window.confirm "Do you really want to delete {link..display_name}?" |
|
|
handle_delete link |
|
|
handle_delete link |
|
|
|
|
|
|
|
|
def handle_delete link |
|
|
def handle_delete link |
|
|
|
|
|
|
|
|
def delete_link |
|
|
def delete_link |
|
|
return unless window.confirm "Do you really want to delete {link..display_name}?" |
|
|
|
|
|
try |
|
|
try |
|
|
await db.links.delete(link.id) |
|
|
await db.links.delete(link.id) |
|
|
catch e |
|
|
catch e |
|
@ -322,11 +325,31 @@ tag app |
|
|
window.alert "{link.display_name} is now the default bang" |
|
|
window.alert "{link.display_name} is now the default bang" |
|
|
|
|
|
|
|
|
def handle_shift_backspace |
|
|
def handle_shift_backspace |
|
|
return unless state.scored_links.length > 0 |
|
|
if editing_link |
|
|
handle_edit state.scored_links[selection_index] |
|
|
await handle_delete editing_link |
|
|
|
|
|
editing_link = no |
|
|
|
|
|
state.query = '' |
|
|
|
|
|
sort_links! |
|
|
|
|
|
else |
|
|
|
|
|
return unless state.scored_links.length > 0 |
|
|
|
|
|
handle_edit state.scored_links[selection_index] |
|
|
|
|
|
|
|
|
def handle_shift_return |
|
|
def handle_shift_return |
|
|
handle_add! |
|
|
if editing_link |
|
|
|
|
|
try |
|
|
|
|
|
await update_link editing_link, state.query |
|
|
|
|
|
editing_link = no |
|
|
|
|
|
state.query = '' |
|
|
|
|
|
sort_links! |
|
|
|
|
|
catch e |
|
|
|
|
|
err "updating link", e |
|
|
|
|
|
else |
|
|
|
|
|
handle_add! |
|
|
|
|
|
|
|
|
|
|
|
def handle_esc |
|
|
|
|
|
editing_link = no |
|
|
|
|
|
state.query = '' |
|
|
|
|
|
sort_links! |
|
|
|
|
|
|
|
|
def handle_click_add |
|
|
def handle_click_add |
|
|
handle_add! |
|
|
handle_add! |
|
@ -617,6 +640,7 @@ tag app |
|
|
# 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+return').capture.if(can_add)=handle_shift_return |
|
|
|
|
|
@hotkey('esc').capture=handle_esc |
|
|
@hotkey('shift+backspace').capture=handle_shift_backspace |
|
|
@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 |
|
@ -632,81 +656,105 @@ tag app |
|
|
<svg src="./assets/settings.svg"> |
|
|
<svg src="./assets/settings.svg"> |
|
|
|
|
|
|
|
|
if config.enable_tips and not config.enable_simplify_ui |
|
|
if config.enable_tips and not config.enable_simplify_ui |
|
|
<.middle-button> |
|
|
if editing_link |
|
|
<.tip[jc:start ta:left fl:1] @click=handle_return> |
|
|
<.middle-button> |
|
|
<.tip-hotkey> "Return" |
|
|
|
|
|
<.tip-content> "Navigate To Link" |
|
|
<.tip[jc:start ta:left fl:1] |
|
|
<.tip[jc:center ta:center fl:2 px:15px] |
|
|
@click=handle_esc |
|
|
@click=handle_shift_return |
|
|
> |
|
|
> |
|
|
<.tip-hotkey> "Esc" |
|
|
<.tip-hotkey> "Shift + Return" |
|
|
<.tip-content> "Cancel Edits" |
|
|
<.tip-content[of:hidden text-overflow:ellipsis white-space:nowrap]> |
|
|
|
|
|
<span> "Add New Link" |
|
|
<.tip[jc:center ta:center fl:1 px:15px] |
|
|
<span[ws:pre]> " " |
|
|
@click=handle_shift_return |
|
|
let sq = state.query.trim!.split /\s+/ |
|
|
> |
|
|
if sq.length >= 2 |
|
|
<.tip-hotkey> "Shift + Return" |
|
|
let url = sq.pop! |
|
|
<.tip-content[of:hidden text-overflow:ellipsis white-space:nowrap]> |
|
|
<span> '"' |
|
|
"Update Link" |
|
|
<span> sq.join ' ' |
|
|
|
|
|
<span[ws:pre]> ' ' |
|
|
<.tip[jc:end ta:right fl:1] |
|
|
<span[c:blue3]> url |
|
|
@click=handle_shift_backspace |
|
|
<span> '"' |
|
|
> |
|
|
else |
|
|
<.tip-hotkey> "Shift + Backspace" |
|
|
<span> '"' |
|
|
<.tip-content> "Delete Link" |
|
|
<span> sq.join ' ' |
|
|
|
|
|
<span> '"' |
|
|
|
|
|
<.tip[jc:end ta:right fl:1] |
|
|
|
|
|
@click=handle_shift_backspace |
|
|
|
|
|
> |
|
|
|
|
|
<.tip-hotkey> "Shift + Backspace" |
|
|
|
|
|
<.tip-content> "Edit Link" |
|
|
|
|
|
|
|
|
|
|
|
<.links> |
|
|
|
|
|
if bang or state.scored_links.length < 1 |
|
|
|
|
|
<a.link.selected |
|
|
|
|
|
href=encoded_bang_query |
|
|
|
|
|
@click=handle_click_bang |
|
|
|
|
|
> |
|
|
|
|
|
<.link-left> |
|
|
|
|
|
<img.link-icon src=active_bang.icon> |
|
|
|
|
|
<.display-name.bang-text> encoded_bang_query |
|
|
|
|
|
<.link-right[jc:flex-end]> |
|
|
|
|
|
<.frequency> active_bang.frequency |
|
|
|
|
|
else |
|
|
else |
|
|
for link, index in state.scored_links |
|
|
<.middle-button> |
|
|
<a.link |
|
|
<.tip[jc:start ta:left fl:1] @click=handle_return> |
|
|
href=link.url |
|
|
<.tip-hotkey> "Return" |
|
|
@pointerover=(selection_index = index) |
|
|
<.tip-content> "Navigate To Link" |
|
|
@click.prevent=handle_click_link(link) |
|
|
<.tip[jc:center ta:center fl:2 px:15px] |
|
|
.selected=(index is selection_index) |
|
|
@click=handle_shift_return |
|
|
|
|
|
> |
|
|
|
|
|
<.tip-hotkey> "Shift + Return" |
|
|
|
|
|
<.tip-content[of:hidden text-overflow:ellipsis white-space:nowrap]> |
|
|
|
|
|
<span> "Add New Link" |
|
|
|
|
|
<span[ws:pre]> " " |
|
|
|
|
|
let sq = state.query.trim!.split /\s+/ |
|
|
|
|
|
if sq.length >= 2 |
|
|
|
|
|
let url = sq.pop! |
|
|
|
|
|
<span> '"' |
|
|
|
|
|
<span> sq.join ' ' |
|
|
|
|
|
<span[ws:pre]> ' ' |
|
|
|
|
|
<span[c:blue3]> url |
|
|
|
|
|
<span> '"' |
|
|
|
|
|
else |
|
|
|
|
|
<span> '"' |
|
|
|
|
|
<span> sq.join ' ' |
|
|
|
|
|
<span> '"' |
|
|
|
|
|
<.tip[jc:end ta:right fl:1] |
|
|
|
|
|
@click=handle_shift_backspace |
|
|
|
|
|
> |
|
|
|
|
|
<.tip-hotkey> "Shift + Backspace" |
|
|
|
|
|
<.tip-content> "Edit Link" |
|
|
|
|
|
|
|
|
|
|
|
unless editing_link |
|
|
|
|
|
<.links> |
|
|
|
|
|
if bang or state.scored_links.length < 1 |
|
|
|
|
|
<a.link.selected |
|
|
|
|
|
href=encoded_bang_query |
|
|
|
|
|
@click=handle_click_bang |
|
|
> |
|
|
> |
|
|
<.link-left> |
|
|
<.link-left> |
|
|
<img.link-icon src=link.icon> |
|
|
<img.link-icon src=active_bang.icon> |
|
|
<.display-name |
|
|
<.display-name.bang-text> encoded_bang_query |
|
|
[c:#FAD4AB]=link.is_bang |
|
|
<.link-right[jc:flex-end]> |
|
|
> link.display_name |
|
|
<.frequency> active_bang.frequency |
|
|
if link.display_name isnt link.name and config.enable_effective_names |
|
|
else |
|
|
<.name> |
|
|
for link, index in state.scored_links |
|
|
<span.parens> "(" |
|
|
<a.link |
|
|
<span> link.name |
|
|
href=link.url |
|
|
<span.parens> ")" |
|
|
@pointerover=(selection_index = index) |
|
|
<.link-right> |
|
|
@click.prevent=handle_click_link(link) |
|
|
<.link-buttons .buttons-disabled=(not config.enable_buttons or config.enable_simplify_ui)> |
|
|
.selected=(index is selection_index) |
|
|
<.link-button |
|
|
> |
|
|
@click.if(link.is_bang).prevent.stop=handle_click_make_default_bang(link) |
|
|
<.link-left> |
|
|
[visibility:hidden]=!link.is_bang |
|
|
<img.link-icon src=link.icon> |
|
|
> |
|
|
<.display-name |
|
|
<svg src='./assets/search.svg'> |
|
|
[c:#FAD4AB]=link.is_bang |
|
|
<.link-button@click.prevent.stop=handle_click_edit(link)> |
|
|
> link.display_name |
|
|
<svg src='./assets/edit-2.svg'> |
|
|
if link.display_name isnt link.name and config.enable_effective_names |
|
|
<.link-button@click.prevent.stop=handle_click_delete(link)> |
|
|
<.name> |
|
|
<svg src='./assets/trash.svg'> |
|
|
<span.parens> "(" |
|
|
<.link-button |
|
|
<span> link.name |
|
|
@click.prevent.stop=handle_click_pin(link) |
|
|
<span.parens> ")" |
|
|
[visibility:visible c:purple3/50]=(link.is_pinned and (index isnt selection_index or not config.enable_buttons or config.enable_simplify_ui)) |
|
|
<.link-right> |
|
|
> |
|
|
<.link-buttons .buttons-disabled=(not config.enable_buttons or config.enable_simplify_ui)> |
|
|
<svg src='./assets/star.svg'> |
|
|
<.link-button |
|
|
<.frequency> link.frequency |
|
|
@click.if(link.is_bang).prevent.stop=handle_click_make_default_bang(link) |
|
|
|
|
|
[visibility:hidden]=!link.is_bang |
|
|
|
|
|
> |
|
|
|
|
|
<svg src='./assets/search.svg'> |
|
|
|
|
|
<.link-button@click.prevent.stop=handle_click_edit(link)> |
|
|
|
|
|
<svg src='./assets/edit-2.svg'> |
|
|
|
|
|
<.link-button@click.prevent.stop=handle_click_delete(link)> |
|
|
|
|
|
<svg src='./assets/trash.svg'> |
|
|
|
|
|
<.link-button |
|
|
|
|
|
@click.prevent.stop=handle_click_pin(link) |
|
|
|
|
|
[visibility:visible c:purple3/50]=(link.is_pinned and (index isnt selection_index or not config.enable_buttons or config.enable_simplify_ui)) |
|
|
|
|
|
> |
|
|
|
|
|
<svg src='./assets/star.svg'> |
|
|
|
|
|
<.frequency> link.frequency |
|
|
$main-input.focus! |
|
|
$main-input.focus! |
|
|
|
|
|
|
|
|
imba.mount <app> |
|
|
imba.mount <app> |
|
|