Merge branch 'master' into feeds

This commit is contained in:
makeworld 2020-12-06 22:11:05 -05:00
commit d0c8184cc0
11 changed files with 368 additions and 26 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Opening local files with `file://` URIs (#103, #117)
- `show_link` option added in config to optionally see the URL (#133)
### Changed
- Updated [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) to v0.9.3

View File

@ -5,7 +5,6 @@
<h6>Image modified from: amphora by Alvaro Cabrera from the Noun Project</h6>
</center>
[![travis build status](https://img.shields.io/travis/com/makeworld-the-better-one/amfora/master?label=master)](https://travis-ci.com/github/makeworld-the-better-one/amfora)
[![go reportcard](https://goreportcard.com/badge/github.com/makeworld-the-better-one/amfora)](https://goreportcard.com/report/github.com/makeworld-the-better-one/amfora)
[![license GPLv3](https://img.shields.io/github/license/makeworld-the-better-one/amfora)](https://www.gnu.org/licenses/gpl-3.0.en.html)
@ -61,6 +60,10 @@ brew upgrade amfora
```
### From Source
<details>
<summary>Click to expand</summary>
This section is for advanced users who want to install the latest (possibly unstable) version of Amfora.
**Requirements:**
@ -90,17 +93,8 @@ You can update it with:
brew upgrade --fetch-HEAD amfora
```
## Usage
</details>
Just call `amfora` or `amfora <url>` on the terminal. On Windows it might be `amfora.exe` instead.
To determine the version, you can run `amfora --version` or `amfora -v`.
The project keeps many standard terminal keybindings and is intuitive. Press <kbd>?</kbd> inside the application to pull up the help menu with a list of all the keybindings, and <kbd>Esc</kbd> to leave it. If you have used Bombadillo you will find it similar.
It is designed with large terminals in mind, but should look and work well at any reasonable terminal size.
It was tested with left-to-right languages, and will likely not work as well with right-to-left languages like Arabic.
## Features / Roadmap
Features in *italics* are in the master branch, but not in the latest release.
@ -133,22 +127,14 @@ Features in *italics* are in the master branch, but not in the latest release.
- So is tracking a page, to know when its content changes
- [ ] Stream support
- [ ] Table of contents for pages
- [ ] History browser
- [ ] Search in pages with <kbd>Ctrl-F</kbd>
- [ ] Support Markdown rendering
- [ ] Persistent history
## Configuration
The config file is written in the intuitive [TOML](https://github.com/toml-lang/toml) file format. See [default-config.toml](./default-config.toml) for details. By default this file is available at `~/.config/amfora/config.toml`, or `$XDG_CONFIG_HOME/amfora/config.toml`, if that variable is set.
On Windows, the file is in `%APPDATA%\amfora\config.toml`, which usually expands to `C:\Users\<username>\AppData\Roaming\amfora\config.toml`.
## Usage & Configuration
Please see [the wiki](https://github.com/makeworld-the-better-one/amfora/wiki) for an introduction on how to use Amfora and configure it.
## Client Certificates
Amfora has early support for client certs. Eventually Amfora will be able to generate them itself, but for you can do it by using OpenSSL:
```shell
openssl req -new -subj "/CN=username" -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -days 1825 -nodes -out cert.pem -keyout key.pem
```
This will create a certificate and key file, that can be renamed and moved as you like. See the configuration section above for how to edit your config file to tell Amfora about them.
## Known Bugs

View File

@ -224,6 +224,7 @@ func Init() error {
viper.SetDefault("a-general.color", true)
viper.SetDefault("a-general.ansi", true)
viper.SetDefault("a-general.bullets", true)
viper.SetDefault("a-general.show_link", false)
viper.SetDefault("a-general.left_margin", 0.15)
viper.SetDefault("a-general.max_width", 100)
viper.SetDefault("a-general.downloads", "")

View File

@ -50,6 +50,9 @@ ansi = true
# Whether to replace list asterisks with unicode bullets
bullets = true
# Whether to show link after link text
show_link = false
# A number from 0 to 1, indicating what percentage of the terminal width the left margin should take up.
left_margin = 0.15

View File

@ -21,6 +21,43 @@ Contributed by **[@crdpa](https://github.com/crdpa)**.
![screenshot of dracula theme](https://user-images.githubusercontent.com/61637474/99983210-53d2e900-2d8a-11eb-9ab7-12dc10c2933a.png)
</details>
## Gruvbox
Contributed by **[@Skraylet](https://github.com/Skraylet)**.
![screenshot of gruvbox theme](https://user-images.githubusercontent.com/26380693/100381730-4768bd80-3022-11eb-83ae-bcd0495f2ae9.png)
<details>
<summary>Another screenshot</summary>
![screenshot of gruvbox theme](https://user-images.githubusercontent.com/26380693/100381734-4a63ae00-3022-11eb-9531-a635df310052.png)
</details>
## Solarized
Contributed by **[@bnthor](https://github.com/bnthor)**.
### Dark
![screenshot of solarized dark theme](https://user-images.githubusercontent.com/798657/100597218-77071680-32fd-11eb-8e0d-593ff95b7129.png)
<details>
<summary>Another screenshot</summary>
![screenshot of solarized dark theme](https://user-images.githubusercontent.com/798657/100597236-7b333400-32fd-11eb-8844-b92601da52c7.png)
</details>
### Light
![screenshot of solarized light theme](https://user-images.githubusercontent.com/798657/100597327-9aca5c80-32fd-11eb-8c91-fe3e324d8959.png)
<details>
<summary>Another screenshot</summary>
![screenshot of solarized light theme](https://user-images.githubusercontent.com/798657/100597349-a453c480-32fd-11eb-866e-10b0587228f6.png)
</details>
## Yours?
Contribute your own theme by opening a PR.

101
contrib/themes/gruvbox.toml Normal file
View File

@ -0,0 +1,101 @@
[theme]
# This section is for changing the COLORS used in Amfora.
# These colors only apply if 'color' is enabled above.
# Colors can be set using a W3C color name, or a hex value such as "#ffffff".
# Note that not all colors will work on terminals that do not have truecolor support.
# If you want to stick to the standard 16 or 256 colors, you can get
# a list of those here: https://jonasjacek.github.io/colors/
# DO NOT use the names from that site, just the hex codes.
# Definitions:
# bg = background
# fg = foreground
# dl = download
# btn = button
# hdg = heading
# bkmk = bookmark
# modal = a popup window/box in the middle of the screen
bg = "#1d2021"
fg = "#ebdbb2"
tab_num = "#928374"
tab_divider = "#928374"
bottombar_bg = "#1d2021"
bottombar_text = "#ebdbb2"
bottombar_label = "#ebdbb2"
# EXAMPLES:
# hdg_1 = "green"
# hdg_2 = "#5f0000"
# Available keys to set:
# bg: background for pages, tab row, app in general
# tab_num: The number/highlight of the tabs at the top
# tab_divider: The color of the divider character between tab numbers: |
# bottombar_label: The color of the prompt that appears when you press space
# bottombar_text: The color of the text you type
# bottombar_bg
# hdg_1
# hdg_2
# hdg_3
# amfora_link: A link that Amfora supports viewing. For now this is only gemini://
# foreign_link: HTTP(S), Gopher, etc
# link_number: The silver number that appears to the left of a link
# regular_text: Normal gemini text, and plaintext documents
# quote_text
# preformatted_text
# list_text
hdg_1 = "#b8bb26"
hdg_2 = "#8ec07c"
hdg_3 = "#689d6a"
amfora_link = "#ebdbb2"
foreign_link = "#bdae93"
link_number = "#83a598"
regular_text = "#ebdbb2"
quote_text = "#928374"
preformatted_text = "#ebdbb2"
list_text = "#ebdbb2"
# btn_bg: The bg color for all modal buttons
# btn_text: The text color for all modal buttons
btn_bg = "#3c3836"
btn_text = "#ebdbb2"
dl_choice_modal_bg = "#3c3836"
dl_choice_modal_text = "#ebdbb2"
dl_modal_bg = "#3c3836"
dl_modal_text = "#ebdbb2"
info_modal_bg = "#3c3836"
info_modal_text = "#ebdbb2"
error_modal_bg = "#3c3836"
error_modal_text = "#fb4934"
yesno_modal_bg = "#3c3836"
yesno_modal_text = "#ebdbb2"
tofu_modal_bg = "#3c3836"
tofu_modal_text = "#ebdbb2"
# input_modal_bg
# input_modal_text
# input_modal_field_bg: The bg of the input field, where you type the text
# input_modal_field_text: The color of the text you type
input_modal_bg = "#3c3836"
input_modal_text = "#ebdbb2"
input_modal_field_bg = "#1d2021"
input_modal_field_text = "#ebdbb2"
# bkmk_modal_bg
# bkmk_modal_text
# bkmk_modal_label
# bkmk_modal_field_bg
# bkmk_modal_field_text
bkmk_modal_bg = "#3c3836"
bkmk_modal_text = "#ebdbb2"
bkmk_modal_label = "#ebdbb2"
bkmk_modal_field_bg = "#1d2021"
bkmk_modal_field_text = "#f8f8f2"

View File

@ -0,0 +1,102 @@
[theme]
# This section is for changing the COLORS used in Amfora.
# These colors only apply if 'color' is enabled above.
# Colors can be set using a W3C color name, or a hex value such as "#ffffff".
# Note that not all colors will work on terminals that do not have truecolor support.
# If you want to stick to the standard 16 or 256 colors, you can get
# a list of those here: https://jonasjacek.github.io/colors/
# DO NOT use the names from that site, just the hex codes.
# Definitions:
# bg = background
# fg = foreground
# dl = download
# btn = button
# hdg = heading
# bkmk = bookmark
# modal = a popup window/box in the middle of the screen
# EXAMPLES:
# hdg_1 = "green"
# hdg_2 = "#5f0000"
# Available keys to set:
# bg: background for pages, tab row, app in general
# tab_num: The number/highlight of the tabs at the top
# tab_divider: The color of the divider character between tab numbers: |
# bottombar_label: The color of the prompt that appears when you press space
# bottombar_text: The color of the text you type
# bottombar_bg
bg = "#002b36"
fg = "#EDE8D5"
tab_num = "#3889D2"
tab_divider = "#0F3642"
bottombar_bg = "#0F3642"
bottombar_text = "#93a1a1"
bottombar_label = "#3ea197"
# hdg_1
# hdg_2
# hdg_3
# amfora_link: A link that Amfora supports viewing. For now this is only gemini://
# foreign_link: HTTP(S), Gopher, etc
# link_number: The silver number that appears to the left of a link
# regular_text: Normal gemini text, and plaintext documents
# quote_text
# preformatted_text
# list_text
hdg_1 = "#3EA197"
hdg_2 = "#3889D2"
hdg_3 = "#6D6EC4"
amfora_link = "#94A1A1"
foreign_link = "#849496"
link_number = "#869B00"
regular_text = "#EDE8D5"
quote_text = "#EDE8D5"
preformatted_text = "#EDE8D5"
list_text = "#EDE8D5"
# btn_bg: The bg color for all modal buttons
# btn_text: The text color for all modal buttons
btn_bg = "#3889D2"
btn_text = "#FCF6E3"
dl_choice_modal_bg = "#073642"
dl_choice_modal_text = "#93a1a1"
dl_modal_bg = "#073642"
dl_modal_text = "#94a1a1"
info_modal_bg = "#073642"
info_modal_text = "#94a1a1"
error_modal_bg = "#073642"
error_modal_text = "#D53234"
yesno_modal_bg = "#073642"
yesno_modal_text = "#94a1a1"
tofu_modal_bg = "#073642"
tofu_modal_text = "#94a1a1"
# input_modal_bg
# input_modal_text
# input_modal_field_bg: The bg of the input field, where you type the text
# input_modal_field_text: The color of the text you type
input_modal_bg = "#073642"
input_modal_text = "#94a1a1"
input_modal_field_bg = "#062B36"
input_modal_field_text ="#94a1a1"
# bkmk_modal_bg
# bkmk_modal_text
# bkmk_modal_label
# bkmk_modal_field_bg
# bkmk_modal_field_text
bkmk_modal_bg = "#073642"
bkmk_modal_text = "#94a1a1"
bkmk_modal_label = "#3ea197"
bkmk_modal_field_bg = "#062B36"
bkmk_modal_field_text = "#94a1a1"

View File

@ -0,0 +1,102 @@
[theme]
# This section is for changing the COLORS used in Amfora.
# These colors only apply if 'color' is enabled above.
# Colors can be set using a W3C color name, or a hex value such as "#ffffff".
# Note that not all colors will work on terminals that do not have truecolor support.
# If you want to stick to the standard 16 or 256 colors, you can get
# a list of those here: https://jonasjacek.github.io/colors/
# DO NOT use the names from that site, just the hex codes.
# Definitions:
# bg = background
# fg = foreground
# dl = download
# btn = button
# hdg = heading
# bkmk = bookmark
# modal = a popup window/box in the middle of the screen
# EXAMPLES:
# hdg_1 = "green"
# hdg_2 = "#5f0000"
# Available keys to set:
# bg: background for pages, tab row, app in general
# tab_num: The number/highlight of the tabs at the top
# tab_divider: The color of the divider character between tab numbers: |
# bottombar_label: The color of the prompt that appears when you press space
# bottombar_text: The color of the text you type
# bottombar_bg
bg = "#FCF6E3"
fg = "#5A6E75"
tab_num = "#3889D2"
tab_divider = "#EDE8D5"
bottombar_bg = "#EDE8D5"
bottombar_text = "#5A6E75"
bottombar_label = "#3ea197"
# hdg_1
# hdg_2
# hdg_3
# amfora_link: A link that Amfora supports viewing. For now this is only gemini://
# foreign_link: HTTP(S), Gopher, etc
# link_number: The silver number that appears to the left of a link
# regular_text: Normal gemini text, and plaintext documents
# quote_text
# preformatted_text
# list_text
hdg_1 = "#3EA197"
hdg_2 = "#3889D2"
hdg_3 = "#6D6EC4"
amfora_link = "#5A6E75"
foreign_link = "#677B83"
link_number = "#CC3283"
regular_text = "#0F3642"
quote_text = "#0F3642"
preformatted_text = "#0F3642"
list_text = "#0F3642"
# btn_bg: The bg color for all modal buttons
# btn_text: The text color for all modal buttons
btn_bg = "#3889D2"
btn_text = "#FCF6E3"
dl_choice_modal_bg = "#EDE8D5"
dl_choice_modal_text = "#0F3642"
dl_modal_bg = "#EDE8D5"
dl_modal_text = "#0F3642"
info_modal_bg = "#EDE8D5"
info_modal_text = "#0F3642"
error_modal_bg = "#EDE8D5"
error_modal_text = "#D53234"
yesno_modal_bg = "#EDE8D5"
yesno_modal_text = "#0F3642"
tofu_modal_bg = "#EDE8D5"
tofu_modal_text = "#0F3642"
# input_modal_bg
# input_modal_text
# input_modal_field_bg: The bg of the input field, where you type the text
# input_modal_field_text: The color of the text you type
input_modal_bg = "#EDE8D5"
input_modal_text = "#0F3642"
input_modal_field_bg = "#FCF6E3"
input_modal_field_text ="#0F3642"
# bkmk_modal_bg
# bkmk_modal_text
# bkmk_modal_label
# bkmk_modal_field_bg
# bkmk_modal_field_text
bkmk_modal_bg = "#EDE8D5"
bkmk_modal_text = "#0F3642"
bkmk_modal_label = "#3ea197"
bkmk_modal_field_bg = "#FCF6E3"
bkmk_modal_field_text = "#0F3642"

View File

@ -47,6 +47,9 @@ ansi = true
# Whether to replace list asterisks with unicode bullets
bullets = true
# Whether to show link after link text
show_link = false
# A number from 0 to 1, indicating what percentage of the terminal width the left margin should take up.
left_margin = 0.15

View File

@ -69,8 +69,11 @@ func MakePage(url string, res *gemini.Response, width, leftMargin int, proxied b
// Content was larger than max size
return nil, ErrTooLarge
} else if err != io.EOF {
if errors.Is(err, os.ErrDeadlineExceeded) {
// Timed out
if os.IsTimeout(err) {
// I would use
// errors.Is(err, os.ErrDeadlineExceeded)
// but that isn't supported before Go 1.15.
return nil, ErrTimedOut
}
// Some other error

View File

@ -134,6 +134,9 @@ func convertRegularGemini(s string, numLinks, width int, proxied bool) (string,
// There is link text
url = lines[i][:delim]
linkText = strings.Trim(lines[i][delim:], " \t")
if viper.GetBool("a-general.show_link") {
linkText += " (" + url + ")"
}
}
if strings.TrimSpace(lines[i]) == "" || strings.TrimSpace(url) == "" {