mirror of
https://github.com/makew0rld/amfora.git
synced 2024-06-13 19:10:42 +00:00
Merge branch 'makeworld-the-better-one:master' into master
This commit is contained in:
commit
f63703970a
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go-version: ['1.15', '1.16', '1.17']
|
||||
go-version: ['1.16', '1.17', '1.18']
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `include` theme key to import themes from an external file (#154, #290)
|
||||
- Support SOCKS5 proxying by setting `AMFORA_SOCKS5` environment variable (#155)
|
||||
- When bookmarking a page, the first level one heading is suggested as the name (#267, #293)
|
||||
- Confirmation prompts for URL schemes in new `[url-prompts]` config section (#301, #302)
|
||||
|
||||
### Changed
|
||||
- Center text automatically, removing `left_margin` from the config (#233)
|
||||
|
|
|
@ -27,3 +27,4 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
|
|||
* Josias (@justjosias)
|
||||
* mntn (@mntn-xyz)
|
||||
* Maxime Bouillot (@Arkaeriit)
|
||||
* Emily (@emily-is-my-username)
|
||||
|
|
|
@ -257,6 +257,7 @@ func Init() error {
|
|||
viper.SetDefault("keybindings.shift_numbers", "")
|
||||
viper.SetDefault("keybindings.bind_url_handler_open", "Ctrl-U")
|
||||
viper.SetDefault("url-handlers.other", "default")
|
||||
viper.SetDefault("url-prompts.other", false)
|
||||
viper.SetDefault("cache.max_size", 0)
|
||||
viper.SetDefault("cache.max_pages", 20)
|
||||
viper.SetDefault("cache.timeout", 1800)
|
||||
|
@ -375,7 +376,12 @@ func Init() error {
|
|||
// Include key comes first
|
||||
if incPath := configTheme.GetString("include"); incPath != "" {
|
||||
incViper := viper.New()
|
||||
incViper.SetConfigFile(incPath)
|
||||
newIncPath, err := homedir.Expand(incPath)
|
||||
if err == nil {
|
||||
incViper.SetConfigFile(newIncPath)
|
||||
} else {
|
||||
incViper.SetConfigFile(incPath)
|
||||
}
|
||||
incViper.SetConfigType("toml")
|
||||
err = incViper.ReadInConfig()
|
||||
if err != nil {
|
||||
|
|
|
@ -218,6 +218,18 @@ underline = true
|
|||
# application on your computer for opening this kind of URI.
|
||||
other = 'default'
|
||||
|
||||
[url-prompts]
|
||||
# Specify whether a confirmation prompt should be shown before following URL schemes.
|
||||
# The special key 'other' matches all schemes that don't match any other key.
|
||||
#
|
||||
# Example: prompt on every non-gemini URL
|
||||
# other = true
|
||||
# gemini = false
|
||||
#
|
||||
# Example: only prompt on HTTP(S)
|
||||
# other = false
|
||||
# http = true
|
||||
# https = true
|
||||
|
||||
# [[mediatype-handlers]] section
|
||||
# ---------------------------------
|
||||
|
|
|
@ -215,6 +215,18 @@ underline = true
|
|||
# application on your computer for opening this kind of URI.
|
||||
other = 'default'
|
||||
|
||||
[url-prompts]
|
||||
# Specify whether a confirmation prompt should be shown before following URL schemes.
|
||||
# The special key 'other' matches all schemes that don't match any other key.
|
||||
#
|
||||
# Example: prompt on every non-gemini URL
|
||||
# other = true
|
||||
# gemini = false
|
||||
#
|
||||
# Example: only prompt on HTTP(S)
|
||||
# other = false
|
||||
# http = true
|
||||
# https = true
|
||||
|
||||
# [[mediatype-handlers]] section
|
||||
# ---------------------------------
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"code.rocketnine.space/tslocum/cview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
@ -54,9 +53,6 @@ var layout = cview.NewFlex()
|
|||
|
||||
var newTabPage structs.Page
|
||||
|
||||
// Global mutex for changing the size of the left margin on all tabs.
|
||||
var reformatMu = sync.Mutex{}
|
||||
|
||||
var App = cview.NewApplication()
|
||||
|
||||
func Init(version, commit, builtBy string) {
|
||||
|
@ -82,23 +78,18 @@ func Init(version, commit, builtBy string) {
|
|||
termH = height
|
||||
|
||||
// Make sure the current tab content is reformatted when the terminal size changes
|
||||
go func(t *tab) {
|
||||
reformatMu.Lock() // Only allow one reformat job at a time
|
||||
for i := range tabs {
|
||||
// Overwrite all tabs with a new, differently sized, left margin
|
||||
browser.AddTab(
|
||||
strconv.Itoa(i),
|
||||
tabs[i].label(),
|
||||
makeContentLayout(tabs[i].view, leftMargin()),
|
||||
)
|
||||
if tabs[i] == t {
|
||||
// Reformat page ASAP, in the middle of loop
|
||||
reformatPageAndSetView(t, t.page)
|
||||
}
|
||||
for i := range tabs {
|
||||
// Overwrite all tabs with a new, differently sized, left margin
|
||||
browser.AddTab(
|
||||
strconv.Itoa(i),
|
||||
tabs[i].label(),
|
||||
makeContentLayout(tabs[i].view, leftMargin()),
|
||||
)
|
||||
if tabs[i] == tabs[curTab] {
|
||||
// Reformat page ASAP, in the middle of loop
|
||||
reformatPageAndSetView(tabs[curTab], tabs[curTab].page)
|
||||
}
|
||||
App.Draw()
|
||||
reformatMu.Unlock()
|
||||
}(tabs[curTab])
|
||||
}
|
||||
})
|
||||
|
||||
panels.AddPanel(PanelBrowser, browser, true, true)
|
||||
|
|
|
@ -252,6 +252,15 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
|||
return ret("", false)
|
||||
}
|
||||
|
||||
// check if a prompt is needed to handle this url
|
||||
prompt := viper.GetBool("url-prompts.other")
|
||||
if viper.IsSet("url-prompts." + parsed.Scheme) {
|
||||
prompt = viper.GetBool("url-prompts." + parsed.Scheme)
|
||||
}
|
||||
if prompt && !(YesNo("Follow URL?\n" + u)) {
|
||||
return ret("", false)
|
||||
}
|
||||
|
||||
proxy := strings.TrimSpace(viper.GetString("proxies." + parsed.Scheme))
|
||||
usingProxy := false
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ func (t *tab) label() string {
|
|||
}
|
||||
if strings.HasPrefix(t.page.URL, "file://") {
|
||||
// File URL, use file or folder as tab name
|
||||
return path.Base(t.page.URL[7:])
|
||||
return cview.Escape(path.Base(t.page.URL[7:]))
|
||||
}
|
||||
// Otherwise, it's a Gemini URL
|
||||
pu, err := url.Parse(t.page.URL)
|
||||
|
|
|
@ -31,4 +31,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
|
|||
* Josias (@justjosias)
|
||||
* mntn (@mntn-xyz)
|
||||
* Maxime Bouillot (@Arkaeriit)
|
||||
* Emily (@emily-is-my-username)
|
||||
`)
|
||||
|
|
Loading…
Reference in New Issue
Block a user