Skip to content

Commit

Permalink
Merge changes from master and add note to changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mntn-xyz committed Dec 8, 2021
2 parents 7fa774b + 8596df2 commit 6873997
Show file tree
Hide file tree
Showing 41 changed files with 741 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.35
version: v1.43
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ['1.14', '1.15', '1.16']
go-version: ['1.15', '1.16', '1.17']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
6 changes: 2 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ linters:
- goerr113
- gofmt
- goimports
- golint
- revive
- goprintffuncname
- interfacer
- lll
- maligned
- misspell
- nolintlint
- prealloc
- scopelint
- exportloopref
- unconvert
- unparam

Expand Down
24 changes: 21 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `bind_beginning` and `bind_end` keybindings
- Display gemtext from stdin (#205, #242)
- Specifying `default` in the theme config uses the terminal's default background color, including transparency (#244, #245)
- Redirects occur automatically if it only adds a trailing slash (#271)
- Non-gemini links are underlined by default to help color blind users (#189)
- Text and element colors of default theme change to be black on terminals with light backgrounds (#181)
- Support paths with spaces in `[url-handlers]` config settings (#214)
- Display info modal when opening URL with custom application
- Files can be opened by relative path on the commandline (#231, #257)
- Support keybindings that use <kbd>Shift</kbd> (#269)

### Changed
- Favicon support removed (#199)
- Bookmarks are stored using XML in the XBEL format, old bookmarks are transferred (#68)
- Text no longer disappears under the left margin when scrolling (regression from v1.8.0) (#197)
- Text no longer disappears under the left margin when scrolling (regression in v1.8.0) (#197)
- Default search engine changed to geminispace.info from gus.guru
- The user's terminal theme colors are used by default (#181)
- By default, non-gemini URI schemes are opened in the default application. This requires a config change for previous users, see the [wiki](https://github.com/makeworld-the-better-one/amfora/wiki/Handling-Other-URL-Schemes) (#207)
- Windows uses paths set by `XDG` variables over `APPDATA` if they are set (#255)
- Treat status codes like 22 as equivalent to 20 as per the latest spec (#266)
- Show minimal loading page instead of `about:newtab` when loading a URL in a new tab (#272)

## Removed
- Favicon support (#199)
- The default Amfora theme, get it back [here](https://github.com/makeworld-the-better-one/amfora/blob/master/contrib/themes/amfora.toml)

### Fixed
- Help text is now the same color as `regular_text` in the theme config
- Non-ASCII (multibyte) characters can now be used as keybindings (#198, #200)
- Possible subscription update race condition on startup
- Plaintext documents are escaped properly (regression from v1.8.0)
- Plaintext documents are escaped properly (regression in v1.8.0)
- Help page scrollbar color matches what's in the theme config
- Regression where lists would not appear if `bullets = false` (#234, #235)
- Support multiple bookmarks with the same name
- Cert change message grammar: "an security" -> "a security" (#274)
- Display an error modal for status codes that can't be handled
- Prevent user from getting trapped in the help menu when keybindings are pressed (#241, #261)


## [1.8.0] - 2021-02-17
Expand Down
1 change: 0 additions & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
## Upstream Bugs
- Bookmark keys aren't deleted, just set to `""`
- Waiting on [this viper PR](https://github.com/spf13/viper/pull/519) to be merged
- [cview.Styles not being used](https://code.rocketnine.space/tslocum/cview/issues/47) - issue is circumvented in Amfora
- [ANSI conversion is messed up](https://code.rocketnine.space/tslocum/cview/issues/48)
- [WordWrap is broken in some cases](https://code.rocketnine.space/tslocum/cview/issues/27) - close #156 if this is fixed
- [Prevent panic when reformatting](https://code.rocketnine.space/tslocum/cview/issues/50) - can't reliably reproduce or debug
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

###### Recording of v1.0.0

Amfora aims to be the best looking [Gemini](https://gemini.circumlunar.space/) client with the most features... all in the terminal. It does not support Gopher or other non-Web protocols - check out [Bombadillo](http://bombadillo.colorfield.space/) for that.
Amfora aims to be the best looking [Gemini](https://geminiquickst.art/) client with the most features... all in the terminal. It does not support Gopher or other non-Web protocols - check out [Bombadillo](http://bombadillo.colorfield.space/) for that.

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. Use [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701) instead, and make sure it [works with UTF-8](https://akr.am/blog/posts/using-utf-8-in-the-windows-terminal). Note that some of the application colors might not display correctly on Windows, but all functionality will still work.

Expand Down Expand Up @@ -80,7 +80,7 @@ This section is for advanced users who want to install the latest (possibly unst
<summary>Click to expand</summary>

**Requirements:**
- Go 1.14 or later
- Go 1.15 or later
- GNU Make

Please note the Makefile does not intend to support Windows, and so there may be issues.
Expand Down Expand Up @@ -163,6 +163,8 @@ Amfora ❤️ open source!
- [progressbar](https://github.com/schollz/progressbar)
- [go-humanize](https://github.com/dustin/go-humanize)
- [gofeed](https://github.com/mmcdole/gofeed)
- [clipboard](https://github.com/atotto/clipboard)
- [termenv](https://github.com/muesli/termenv)

## License
This project is licensed under the GPL v3.0. See the [LICENSE](./LICENSE) file for details.
2 changes: 2 additions & 0 deletions THANKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
* Anas Mohamed (@amohamed11)
* David Jimenez (@dvejmz)
* Michael McDonagh (@m-mcdonagh)
* mooff (@awfulcooking)
* Josias (@justjosias)
39 changes: 32 additions & 7 deletions amfora.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"

"github.com/makeworld-the-better-one/amfora/bookmarks"
"github.com/makeworld-the-better-one/amfora/client"
"github.com/makeworld-the-better-one/amfora/config"
"github.com/makeworld-the-better-one/amfora/display"
"github.com/makeworld-the-better-one/amfora/logger"
"github.com/makeworld-the-better-one/amfora/subscriptions"
)

Expand All @@ -20,10 +22,15 @@ var (
)

func main() {
// err := logger.Init()
// if err != nil {
// panic(err)
// }
log, err := logger.GetLogger()
if err != nil {
panic(err)
}

debugModeEnabled := os.Getenv("AMFORA_DEBUG") == "1"
if debugModeEnabled {
log.Println("Debug mode enabled")
}

if len(os.Args) > 1 {
if os.Args[1] == "--version" || os.Args[1] == "-v" {
Expand All @@ -42,7 +49,7 @@ func main() {
}
}

err := config.Init()
err = config.Init()
if err != nil {
fmt.Fprintf(os.Stderr, "Config error: %v\n", err)
os.Exit(1)
Expand All @@ -67,11 +74,29 @@ func main() {

// Initialize Amfora's settings
display.Init(version, commit, builtBy)
display.NewTab()

// Load a URL, file, or render from stdin
if len(os.Args[1:]) > 0 {
display.URL(os.Args[1])
url := os.Args[1]
if !strings.Contains(url, "://") || strings.HasPrefix(url, "../") || strings.HasPrefix(url, "./") {
fileName := url
if _, err := os.Stat(fileName); err == nil {
if !strings.HasPrefix(fileName, "/") {
cwd, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "error getting working directory path: %v\n", err)
os.Exit(1)
}
fileName = filepath.Join(cwd, fileName)
}
url = "file://" + fileName
}
}
display.NewTabWithURL(url)
} else if !isStdinEmpty() {
renderFromStdin()
} else {
display.NewTab()
}

// Start
Expand Down
1 change: 0 additions & 1 deletion bookmarks/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func Init() error {

err = os.Remove(config.OldBkmkPath)
if err != nil {
//nolint:goerr113
return fmt.Errorf(
"couldn't delete old bookmarks file (%s), you must delete it yourself to prevent duplicate bookmarks: %w",
config.OldBkmkPath,
Expand Down
3 changes: 1 addition & 2 deletions client/tofu.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func loadTofuEntry(domain string, port string) (string, time.Time, error) {
return id, expiry, nil
}

//nolint:errcheck
// certID returns a generic string representing a cert or domain.
func certID(cert *x509.Certificate) string {
h := sha256.New()
Expand All @@ -73,7 +72,7 @@ func certID(cert *x509.Certificate) string {
// origCertID uses cert.Raw, which was used in v1.0.0 of the app.
func origCertID(cert *x509.Certificate) string {
h := sha256.New()
h.Write(cert.Raw) //nolint:errcheck
h.Write(cert.Raw)
return fmt.Sprintf("%X", h.Sum(nil))
}

Expand Down
39 changes: 25 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/gdamore/tcell/v2"
"github.com/makeworld-the-better-one/amfora/cache"
homedir "github.com/mitchellh/go-homedir"
"github.com/muesli/termenv"
"github.com/rkoesters/xdg/basedir"
"github.com/rkoesters/xdg/userdirs"
"github.com/spf13/viper"
Expand Down Expand Up @@ -59,9 +60,16 @@ var MediaHandlers = make(map[string]MediaHandler)
// Defaults to ScrollBarAuto on an invalid value
var ScrollBar cview.ScrollBarVisibility

// Whether the user's terminal is dark or light
// Defaults to dark, but is determined in Init()
// Used to prevent white text on a white background with the default theme
var hasDarkTerminalBackground bool

func Init() error {

// *** Set paths ***
// Windows uses paths under APPDATA, Unix systems use XDG paths
// Windows systems use XDG paths if variables are defined, see #255

home, err := homedir.Dir()
if err != nil {
Expand All @@ -78,10 +86,10 @@ func Init() error {
}

// Store config directory and file paths
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && os.Getenv("XDG_CONFIG_HOME") == "" {
configDir = amforaAppData
} else {
// Unix / POSIX system
// Unix / POSIX system, or Windows with XDG_CONFIG_HOME defined
configDir = filepath.Join(basedir.ConfigHome, "amfora")
}
configPath = filepath.Join(configDir, "config.toml")
Expand All @@ -94,7 +102,7 @@ func Init() error {
}

// Store TOFU db directory and file paths
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && os.Getenv("XDG_CACHE_HOME") == "" {
// Windows just stores it in APPDATA along with other stuff
tofuDBDir = amforaAppData
} else {
Expand All @@ -104,7 +112,7 @@ func Init() error {
tofuDBPath = filepath.Join(tofuDBDir, "tofu.toml")

// Store bookmarks dir and path
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && os.Getenv("XDG_DATA_HOME") == "" {
// Windows just keeps it in APPDATA along with other Amfora files
bkmkDir = amforaAppData
} else {
Expand All @@ -115,18 +123,12 @@ func Init() error {
BkmkPath = filepath.Join(bkmkDir, "bookmarks.xml")

// Feeds dir and path
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && os.Getenv("XDG_DATA_HOME") == "" {
// In APPDATA beside other Amfora files
subscriptionDir = amforaAppData
} else {
// XDG data dir on POSIX systems
xdg_data, ok := os.LookupEnv("XDG_DATA_HOME")
if ok && strings.TrimSpace(xdg_data) != "" {
subscriptionDir = filepath.Join(xdg_data, "amfora")
} else {
// Default to ~/.local/share/amfora
subscriptionDir = filepath.Join(home, ".local", "share", "amfora")
}
subscriptionDir = filepath.Join(basedir.DataHome, "amfora")
}
SubscriptionPath = filepath.Join(subscriptionDir, "subscriptions.json")

Expand Down Expand Up @@ -203,6 +205,7 @@ func Init() error {
viper.SetDefault("a-general.page_max_size", 2097152)
viper.SetDefault("a-general.page_max_time", 10)
viper.SetDefault("a-general.scrollbar", "auto")
viper.SetDefault("a-general.underline", true)
viper.SetDefault("commands.command1", "")
viper.SetDefault("commands.command2", "")
viper.SetDefault("commands.command3", "")
Expand Down Expand Up @@ -281,7 +284,7 @@ func Init() error {
viper.SetDefault("keybindings.bind_beginning", []string{"Home", "g"})
viper.SetDefault("keybindings.bind_end", []string{"End", "G"})
viper.SetDefault("keybindings.shift_numbers", "")
viper.SetDefault("url-handlers.other", "off")
viper.SetDefault("url-handlers.other", "default")
viper.SetDefault("cache.max_size", 0)
viper.SetDefault("cache.max_pages", 20)
viper.SetDefault("cache.timeout", 1800)
Expand Down Expand Up @@ -398,7 +401,15 @@ func Init() error {
}
if viper.GetBool("a-general.color") {
cview.Styles.PrimitiveBackgroundColor = GetColor("bg")
} // Otherwise it's black by default
} else {
// No colors allowed, set background to black instead of default
themeMu.Lock()
theme["bg"] = tcell.ColorBlack
cview.Styles.PrimitiveBackgroundColor = tcell.ColorBlack
themeMu.Unlock()
}

hasDarkTerminalBackground = termenv.HasDarkBackground()

// Parse HTTP command
HTTPCommand = viper.GetStringSlice("a-general.http")
Expand Down
Loading

0 comments on commit 6873997

Please sign in to comment.