mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-11-26 10:15:13 +03:00
✨ Add built in search
This commit is contained in:
parent
fdd98a1487
commit
847bd6eefa
@ -19,7 +19,7 @@ Amfora aims to be the best looking [Gemini](https://gemini.circumlunar.space/) c
|
|||||||
|
|
||||||
It also aims to be completely cross platform, with full Windows support. If you're on Windows, I would not recommend using the default terminal software. Maybe use [Cmder](https://cmder.net/) instead?
|
It also aims to be completely cross platform, with full Windows support. If you're on Windows, I would not recommend using the default terminal software. Maybe use [Cmder](https://cmder.net/) instead?
|
||||||
|
|
||||||
It fully passes Sean Conman's client torture test. It mostly passes the Egsam test.
|
It fully passes Sean Conman's client torture test, including the new Unicode tests. It mostly passes the Egsam test.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ The project keeps many standard terminal keybindings and is intuitive. Press <kb
|
|||||||
It is designed with large or fullscreen terminals in mind. For optimal usage, make your terminal fullscreen. It was also designed with a dark background terminal in mind, but please file an issue if the colour choices look bad on your terminal setup.
|
It is designed with large or fullscreen terminals in mind. For optimal usage, make your terminal fullscreen. It was also designed with a dark background terminal in mind, but please file an issue if the colour choices look bad on your terminal setup.
|
||||||
|
|
||||||
## Features / Roadmap
|
## Features / Roadmap
|
||||||
Features in italics are in the master branch, but not in the latest release.
|
Features in *italics* are in the master branch, but not in the latest release.
|
||||||
|
|
||||||
- [x] URL browsing with TOFU and error handling
|
- [x] URL browsing with TOFU and error handling
|
||||||
- [x] Tabbed browsing
|
- [x] Tabbed browsing
|
||||||
@ -43,7 +43,7 @@ Features in italics are in the master branch, but not in the latest release.
|
|||||||
- [x] Basic forward/backward history, for each tab
|
- [x] Basic forward/backward history, for each tab
|
||||||
- [x] Input (Status Code 10 & 11)
|
- [x] Input (Status Code 10 & 11)
|
||||||
- [x] *Multiple charset support (over 55)*
|
- [x] *Multiple charset support (over 55)*
|
||||||
- [ ] Built-in search using GUS
|
- [x] *Built-in search using GUS*
|
||||||
- [ ] Bookmarks
|
- [ ] Bookmarks
|
||||||
- [ ] Search in pages with <kbd>Ctrl-F</kbd>
|
- [ ] Search in pages with <kbd>Ctrl-F</kbd>
|
||||||
- [ ] Download pages and arbitrary data
|
- [ ] Download pages and arbitrary data
|
||||||
|
@ -4,10 +4,16 @@ package config
|
|||||||
var defaultConf = []byte(`# This is the default config file.
|
var defaultConf = []byte(`# This is the default config file.
|
||||||
# It also shows all the default values, if you don't create the file.
|
# It also shows all the default values, if you don't create the file.
|
||||||
|
|
||||||
# All URL values may omit the scheme and/or port.
|
# All URL values may omit the scheme and/or port, as well as the beginning double slash
|
||||||
|
# Valid URL examples:
|
||||||
|
# gemini://example.com
|
||||||
|
# //example.com
|
||||||
|
# example.com
|
||||||
|
# example.com:1901
|
||||||
|
|
||||||
[a-general]
|
[a-general]
|
||||||
home = "gemini://gemini.circumlunar.space"
|
home = "gemini://gemini.circumlunar.space"
|
||||||
|
|
||||||
# What command to run to open a HTTP URL. Set to "default" to try to guess the browser,
|
# What command to run to open a HTTP URL. Set to "default" to try to guess the browser,
|
||||||
# or set to "off" to not open HTTP URLs.
|
# or set to "off" to not open HTTP URLs.
|
||||||
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
||||||
@ -29,5 +35,5 @@ wrap_width = 100 # How many columns to wrap a page's text to. Preformatted bloc
|
|||||||
[cache]
|
[cache]
|
||||||
# Zero values mean there is no limit
|
# Zero values mean there is no limit
|
||||||
max_size = 0 # Size in bytes
|
max_size = 0 # Size in bytes
|
||||||
max_pages = 30 # The maximum number of pages the cache can store
|
max_pages = 30 # The maximum number of pages the cache will store
|
||||||
`)
|
`)
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
# This is the default config file.
|
# This is the default config file.
|
||||||
# It also shows all the default values, if you don't create the file.
|
# It also shows all the default values, if you don't create the file.
|
||||||
|
|
||||||
# All URL values may omit the scheme and/or port.
|
# All URL values may omit the scheme and/or port, as well as the beginning double slash
|
||||||
|
# Valid URL examples:
|
||||||
|
# gemini://example.com
|
||||||
|
# //example.com
|
||||||
|
# example.com
|
||||||
|
# example.com:1901
|
||||||
|
|
||||||
[a-general]
|
[a-general]
|
||||||
home = "gemini://gemini.circumlunar.space"
|
home = "gemini://gemini.circumlunar.space"
|
||||||
|
|
||||||
# What command to run to open a HTTP URL. Set to "default" to try to guess the browser,
|
# What command to run to open a HTTP URL. Set to "default" to try to guess the browser,
|
||||||
# or set to "off" to not open HTTP URLs.
|
# or set to "off" to not open HTTP URLs.
|
||||||
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
||||||
@ -26,4 +32,4 @@ wrap_width = 100 # How many columns to wrap a page's text to. Preformatted bloc
|
|||||||
[cache]
|
[cache]
|
||||||
# Zero values mean there is no limit
|
# Zero values mean there is no limit
|
||||||
max_size = 0 # Size in bytes
|
max_size = 0 # Size in bytes
|
||||||
max_pages = 30 # The maximum number of pages the cache can store
|
max_pages = 30 # The maximum number of pages the cache will store
|
||||||
|
@ -119,7 +119,9 @@ func Init() {
|
|||||||
// TODO: Support search
|
// TODO: Support search
|
||||||
// Send the URL/number typed in
|
// Send the URL/number typed in
|
||||||
|
|
||||||
if strings.TrimSpace(bottomBar.GetText()) == "" {
|
query := bottomBar.GetText()
|
||||||
|
|
||||||
|
if strings.TrimSpace(query) == "" {
|
||||||
// Ignore
|
// Ignore
|
||||||
bottomBar.SetLabel("")
|
bottomBar.SetLabel("")
|
||||||
bottomBar.SetText(tabMap[curTab].Url)
|
bottomBar.SetText(tabMap[curTab].Url)
|
||||||
@ -127,15 +129,21 @@ func Init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i, err := strconv.Atoi(bottomBar.GetText())
|
i, err := strconv.Atoi(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// It's a full URL
|
// It's a full URL or search term
|
||||||
URL(bottomBar.GetText())
|
// Detect if it's a search or URL
|
||||||
|
if strings.Contains(query, " ") || (!strings.Contains(query, "//") && !strings.Contains(query, ".")) {
|
||||||
|
URL(viper.GetString("a-general.search") + "?" + pathEscape(query))
|
||||||
|
} else {
|
||||||
|
// Full URL
|
||||||
|
URL(query)
|
||||||
|
}
|
||||||
bottomBar.SetLabel("")
|
bottomBar.SetLabel("")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if i <= len(tabMap[curTab].Links) && i > 0 {
|
if i <= len(tabMap[curTab].Links) && i > 0 {
|
||||||
// Valid link number
|
// It's a valid link number
|
||||||
followLink(tabMap[curTab].Url, tabMap[curTab].Links[i-1])
|
followLink(tabMap[curTab].Url, tabMap[curTab].Links[i-1])
|
||||||
bottomBar.SetLabel("")
|
bottomBar.SetLabel("")
|
||||||
return
|
return
|
||||||
@ -195,7 +203,7 @@ func Init() {
|
|||||||
switch string(event.Rune()) {
|
switch string(event.Rune()) {
|
||||||
case " ":
|
case " ":
|
||||||
// Space starts typing, like Bombadillo
|
// Space starts typing, like Bombadillo
|
||||||
bottomBar.SetLabel("[::b]URL: [::-]")
|
bottomBar.SetLabel("[::b]URL or search: [::-]")
|
||||||
bottomBar.SetText("")
|
bottomBar.SetText("")
|
||||||
App.SetFocus(bottomBar)
|
App.SetFocus(bottomBar)
|
||||||
return nil
|
return nil
|
||||||
|
@ -18,6 +18,11 @@ import (
|
|||||||
|
|
||||||
// This file contains the functions that aren't part of the public API.
|
// This file contains the functions that aren't part of the public API.
|
||||||
|
|
||||||
|
// pathEscape is the same as url.PathEscape, but it also replaces the +.
|
||||||
|
func pathEscape(path string) string {
|
||||||
|
return strings.ReplaceAll(url.PathEscape(path), "+", "%2B")
|
||||||
|
}
|
||||||
|
|
||||||
// tabHasContent returns true when the current tab has a page being displayed.
|
// tabHasContent returns true when the current tab has a page being displayed.
|
||||||
// The most likely situation where false would be returned is when the default
|
// The most likely situation where false would be returned is when the default
|
||||||
// new tab content is being displayed.
|
// new tab content is being displayed.
|
||||||
@ -185,7 +190,7 @@ func handleURL(u string) (string, bool) {
|
|||||||
if ok {
|
if ok {
|
||||||
// Make another request with the query string added
|
// Make another request with the query string added
|
||||||
// + chars are replaced because PathEscape doesn't do that
|
// + chars are replaced because PathEscape doesn't do that
|
||||||
parsed.RawQuery = strings.ReplaceAll(url.PathEscape(userInput), "+", "%2B")
|
parsed.RawQuery = pathEscape(userInput)
|
||||||
return handleURL(parsed.String())
|
return handleURL(parsed.String())
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
|
Loading…
Reference in New Issue
Block a user