From 7851427a39ecf4bb30b5f173aa10ee78feadec1c Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 11 Dec 2022 23:18:08 +0100 Subject: Add wikipedia substitution, bookmark file keybinding --- res/config.toml | 5 +++++ src/display/pager.nim | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/res/config.toml b/res/config.toml index deb7e5c9..af4a0dc9 100644 --- a/res/config.toml +++ b/res/config.toml @@ -22,6 +22,10 @@ force-clear = false url = '^ddg:' substitute_url = '(x) => "https://lite.duckduckgo.com/lite/?kp=-1&kd=-1&q=" + x.substring(4)' +[[siteconf]] +url = '^wk:' +substitute_url = '(x) => "https://en.wikipedia.org/wiki/Special:Search?search=" + x.substring(4)' + [page] q = 'quit()' h = 'pager.cursorLeft()' @@ -63,6 +67,7 @@ C-j = 'pager.click()' M-u = 'pager.dupeBuffer()' C-l = 'pager.load()' C-k = 'pager.load("ddg:")' +M-b = 'pager.load("~/.w3m/bookmark.html\n")' U = 'pager.reload()' r = 'pager.redraw()' R = 'pager.reshape()' diff --git a/src/display/pager.nim b/src/display/pager.nim index 464e7323..765e1e73 100644 --- a/src/display/pager.nim +++ b/src/display/pager.nim @@ -513,10 +513,12 @@ proc loadURL*(pager: Pager, url: string, ctype = none(string)) = pager.gotoURL(newRequest(firstparse.get), prev, ctype) return var urls: seq[URL] - let pageurl = parseURL("https://" & url) - if pageurl.isSome: # attempt to load remote page - urls.add(pageurl.get) + if url[0] != '/': + let pageurl = parseURL("https://" & url) + if pageurl.isSome: # attempt to load remote page + urls.add(pageurl.get) let cdir = parseURL("file://" & getCurrentDir() & DirSep) + let url = if url[0] == '~': expandPath(url) else: url let purl = percentEncode(url, LocalPathPercentEncodeSet) if purl != url: let newurl = parseURL(purl, cdir) @@ -631,7 +633,7 @@ proc updateReadLine*(pager: Pager) = # Open a URL prompt and visit the specified URL. proc load(pager: Pager, s = "") {.jsfunc.} = if s.len > 0 and s[^1] == '\n': - pager.loadURL(s) + pager.loadURL(s[0..^2]) else: var url = s if url == "": -- cgit 1.4.1-2-gfad0