From 523ce6e894ca5da27214bf8cdf2a25c6446daba2 Mon Sep 17 00:00:00 2001
From: KNIX3 <69134168+KNIX3@users.noreply.github.com>
Date: Wed, 26 May 2021 23:01:52 -0400
Subject: [PATCH 1/5] Add iceberg theme (#239)
---
contrib/themes/README.md | 12 ++++
contrib/themes/iceberg.toml | 112 ++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+)
create mode 100644 contrib/themes/iceberg.toml
diff --git a/contrib/themes/README.md b/contrib/themes/README.md
index 3b9ff6f..fb548c8 100644
--- a/contrib/themes/README.md
+++ b/contrib/themes/README.md
@@ -115,6 +115,18 @@ Contributed by **[@thumb](https://github.com/thumbfighter)**.
![screenshot of add bookmark](https://user-images.githubusercontent.com/19327775/114432084-e8958200-9b85-11eb-9813-9982c3c0effa.png)
+## Iceberg Dark
+
+Contributed by **[@knix3](https://github.com/knix3)**
+
+![screenshot of Iceberg Dark theme](https://user-images.githubusercontent.com/69134168/118542790-7b938000-b721-11eb-81e1-ae45cdfbe546.png)
+
+More screenshots
+
+![screenshot of add bookmark](https://user-images.githubusercontent.com/69134168/118543243-07a5a780-b722-11eb-848a-95aa1de30044.png)
+![screenshot of error](https://user-images.githubusercontent.com/69134168/118543250-096f6b00-b722-11eb-9dca-d2b1bd6a8885.png)
+
+
## Yours?
Contribute your own theme by opening a PR.
diff --git a/contrib/themes/iceberg.toml b/contrib/themes/iceberg.toml
new file mode 100644
index 0000000..4baa260
--- /dev/null
+++ b/contrib/themes/iceberg.toml
@@ -0,0 +1,112 @@
+[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 = "#161821"
+tab_num = "#6b7089"
+tab_divider = "#e2a478"
+bottombar_label = "#6b7089"
+bottombar_text = "#89b8c2"
+bottombar_bg = "#161821"
+
+# 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 = "#c0ca8e"
+hdg_2 = "#e98989"
+hdg_3 = "#c6c8d1"
+amfora_link = "#6b7089"
+foreign_link = "#d2d4de"
+kink_number = "#95c4ce"
+regular_text = "#c6c8d1"
+quote_text = "#e98989"
+preformatted_text = "#c6c8d1"
+list_text = "#84a0c6"
+
+# btn_bg: The bg color for all modal buttons
+# btn_text: The text color for all modal buttons
+btn_bg = "#e27878"
+btn_text = "#d2d4de"
+
+# dl_choice_modal_bg
+# dl_choice_modal_text
+# dl_modal_bg
+# dl_modal_text
+# info_modal_bg
+# info_modal_text
+# error_modal_bg
+# error_modal_text
+# yesno_modal_bg
+# yesno_modal_text
+# tofu_modal_bg
+# tofu_modal_text
+# subscription_modal_bg
+# subscription_modal_text
+dl_choice_modal_bg = "#84a0c6"
+dl_choice_modal_text = "#161821"
+dl_modal_bg = "#84a0c6"
+dl_modal_text = "#161821"
+info_modal_bg = "#84a0c6"
+info_modal_text = "#161821"
+error_modal_bg = "#e98989"
+error_modal_text = "#161821"
+yesno_modal_bg = "#84a0c6"
+yesno_modal_text = "#161821"
+tofu_modal_bg = "#84a0c6"
+tofu_modal_text = "#161821"
+subscription_modal_bg = "#84a0c6"
+subscription_modal_text = "#161821"
+
+# 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 = "#161821"
+input_modal_text = "#c6c8d1"
+input_modal_field_bg = "#d2d4de"
+input_modal_field_text = "#6b7089"
+
+# bkmk_modal_bg
+# bkmk_modal_text
+# bkmk_modal_label
+# bkmk_modal_field_bg
+# bkmk_modal_field_text
+bkmk_modal_bg = "#161821"
+bkmk_modal_text = "#c6c8d1"
+bkmk_modal_label = "#c6c8d1"
+bkmk_modal_field_bg = "#d2d4de"
+bkmk_modal_field_text = "#6b7089"
From d0998128f9aacbf1d8e4b6c60bf035555111ef28 Mon Sep 17 00:00:00 2001
From: makeworld
Date: Sat, 29 May 2021 16:02:16 -0400
Subject: [PATCH 2/5] Update cview (bug fix) to simplify ANSI rendering
https://code.rocketnine.space/tslocum/cview/issues/47
---
go.mod | 4 ++--
go.sum | 20 ++++++++++----------
renderer/renderer.go | 19 +++++++++----------
3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/go.mod b/go.mod
index 61030ce..80a7f76 100644
--- a/go.mod
+++ b/go.mod
@@ -3,11 +3,11 @@ module github.com/makeworld-the-better-one/amfora
go 1.14
require (
- code.rocketnine.space/tslocum/cview v1.5.4
+ code.rocketnine.space/tslocum/cview v1.5.6-0.20210525194531-92dca67ac283
github.com/atotto/clipboard v0.1.4
github.com/dustin/go-humanize v1.0.0
github.com/fsnotify/fsnotify v1.4.9 // indirect
- github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3
+ github.com/gdamore/tcell/v2 v2.3.3
github.com/google/go-cmp v0.5.0 // indirect
github.com/makeworld-the-better-one/go-gemini v0.11.0
github.com/mitchellh/go-homedir v1.1.0
diff --git a/go.sum b/go.sum
index 1bf7c0b..8655c1f 100644
--- a/go.sum
+++ b/go.sum
@@ -12,8 +12,8 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
code.rocketnine.space/tslocum/cbind v0.1.5 h1:i6NkeLLNPNMS4NWNi3302Ay3zSU6MrqOT+yJskiodxE=
code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0SXBJtxBObbfBWo/M=
-code.rocketnine.space/tslocum/cview v1.5.4 h1:zBUFAanViudrAw8ZCqNxaufqrYL6a7F1AkkIClXIzYo=
-code.rocketnine.space/tslocum/cview v1.5.4/go.mod h1:JjgoZi3b528SaV923oQq14PGUCTE/g/6iggnDUxsChE=
+code.rocketnine.space/tslocum/cview v1.5.6-0.20210525194531-92dca67ac283 h1:5KBGXdQdfV09eYXOZuFTxqDujndqtRraXj+lyFcxlPk=
+code.rocketnine.space/tslocum/cview v1.5.6-0.20210525194531-92dca67ac283/go.mod h1:KBRxzIsj8bfgFpnMpkGVoxsrPUvnQsRnX29XJ2yzB6M=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -56,8 +56,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
-github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3 h1:PqyGpJlv98ynqEPq5MMiT+hcUPPvIomSS0Rnmy5Tl9A=
-github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
+github.com/gdamore/tcell/v2 v2.3.3 h1:RKoI6OcqYrr/Do8yHZklecdGzDTJH9ACKdfECbRdw3M=
+github.com/gdamore/tcell/v2 v2.3.3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@@ -144,8 +144,8 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
-github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
-github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
+github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
+github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@@ -313,14 +313,14 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210223095934-7937bea0104d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0=
-golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea h1:+WiDlPBBaO+h9vPNZi8uJ3k4BkKQB7Iow3aqwHVA5hI=
+golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 h1:EC6+IGYTjPpRfv9a2b/6Puw0W+hLtAhkV1tPsXhutqs=
-golang.org/x/term v0.0.0-20210317153231-de623e64d2a6/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
+golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
diff --git a/renderer/renderer.go b/renderer/renderer.go
index fa678c1..911f36e 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -25,11 +25,6 @@ func RenderANSI(s string) string {
s = cview.Escape(s)
if viper.GetBool("a-general.color") && viper.GetBool("a-general.ansi") {
s = cview.TranslateANSI(s)
- // The TranslateANSI function injects tags like [-:-:-]
- // but this will reset the background to use the user's terminal color.
- // These tags need to be replaced with resets that use the theme color.
- s = strings.ReplaceAll(s, "[-:-:-]",
- fmt.Sprintf("[-:%s:-]", config.GetColorString("bg")))
} else {
s = ansiRegex.ReplaceAllString(s, "")
}
@@ -300,11 +295,15 @@ func RenderGemini(s string, width int, proxied bool) (string, []string) {
// Support ANSI color codes in preformatted blocks - see #59
if viper.GetBool("a-general.color") && viper.GetBool("a-general.ansi") {
buf = cview.TranslateANSI(buf)
- // The TranslateANSI function injects tags like [-:-:-]
- // but this will reset the background to use the user's terminal color.
- // These tags need to be replaced with resets that use the theme color.
- buf = strings.ReplaceAll(buf, "[-:-:-]",
- fmt.Sprintf("[%s:%s:-]", config.GetColorString("preformatted_text"), config.GetColorString("bg")))
+ // The TranslateANSI function will reset the colors when it encounters
+ // an ANSI reset code, injecting a full reset tag: [-:-:-]
+ // This uses the default foreground and background colors of the
+ // application, but in this case we want it to use the preformatted text
+ // color as the foreground, as we're still in a preformat block.
+ buf = strings.ReplaceAll(
+ buf, "[-:-:-]",
+ fmt.Sprintf("[%s:-:-]", config.GetColorString("preformatted_text")),
+ )
} else {
buf = ansiRegex.ReplaceAllString(buf, "")
}
From 4480e2d54056b0b6bcc905d087d81fb61a846b76 Mon Sep 17 00:00:00 2001
From: David Jimenez
Date: Fri, 25 Jun 2021 04:59:14 +0100
Subject: [PATCH 3/5] Render stdin text as Gemtext (#205) (#242)
---
amfora.go | 21 +++++++++++++++++++++
display/display.go | 19 +++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/amfora.go b/amfora.go
index db53fbc..2f5f0ec 100644
--- a/amfora.go
+++ b/amfora.go
@@ -2,7 +2,9 @@ package main
import (
"fmt"
+ "io"
"os"
+ "strings"
"github.com/makeworld-the-better-one/amfora/bookmarks"
"github.com/makeworld-the-better-one/amfora/client"
@@ -68,6 +70,8 @@ func main() {
display.NewTab()
if len(os.Args[1:]) > 0 {
display.URL(os.Args[1])
+ } else if !isStdinEmpty() {
+ renderFromStdin()
}
// Start
@@ -75,3 +79,20 @@ func main() {
panic(err)
}
}
+
+func isStdinEmpty() bool {
+ stat, _ := os.Stdin.Stat()
+ return (stat.Mode() & os.ModeCharDevice) != 0
+}
+
+func renderFromStdin() {
+ stdinTextBuilder := new(strings.Builder)
+ _, err := io.Copy(stdinTextBuilder, os.Stdin)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error reading from standard input: %v\n", err)
+ os.Exit(1)
+ }
+
+ stdinText := stdinTextBuilder.String()
+ display.RenderFromString(stdinText)
+}
diff --git a/display/display.go b/display/display.go
index 0524443..fabfb14 100644
--- a/display/display.go
+++ b/display/display.go
@@ -529,6 +529,25 @@ func URL(u string) {
go goURL(t, fixUserURL(u))
}
+func RenderFromString(str string) {
+ t := tabs[curTab]
+ page, _ := renderPageFromString(str)
+ setPage(t, page)
+}
+
+func renderPageFromString(str string) (*structs.Page, bool) {
+ rendered, links := renderer.RenderGemini(str, textWidth(), false)
+ page := &structs.Page{
+ Mediatype: structs.TextGemini,
+ Raw: str,
+ Content: rendered,
+ Links: links,
+ TermWidth: termW,
+ }
+
+ return page, true
+}
+
func NumTabs() int {
return len(tabs)
}
From ff0f6d3812296a0e05f97213d3c1a3b9c0d9cc6a Mon Sep 17 00:00:00 2001
From: makeworld
Date: Fri, 25 Jun 2021 00:01:58 -0400
Subject: [PATCH 4/5] Doc for #242
---
CHANGELOG.md | 1 +
THANKS.md | 1 +
display/thanks.go | 1 +
3 files changed, 3 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c37d98..151300c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Configurable keybindings for scrolling on pages (#211, #222)
- Ability to save `about:` pages (#210, #236)
- `bind_beginning` and `bind_end` keybindings
+- Display gemtext from stdin (#205, #242)
### Changed
- Favicon support removed (#199)
diff --git a/THANKS.md b/THANKS.md
index b6d6366..b4da7cd 100644
--- a/THANKS.md
+++ b/THANKS.md
@@ -21,3 +21,4 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
* Himanshu (@singalhimanshu)
* @regr4
* Anas Mohamed (@amohamed11)
+* David Jimenez (@dvejmz)
diff --git a/display/thanks.go b/display/thanks.go
index e533c9b..8d090dc 100644
--- a/display/thanks.go
+++ b/display/thanks.go
@@ -25,4 +25,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
* Himanshu (@singalhimanshu)
* @regr4
* Anas Mohamed (@amohamed11)
+* David Jimenez (@dvejmz)
`)
From 4ef4d247d1a21ffcc1700a93603b5faec49d8302 Mon Sep 17 00:00:00 2001
From: makeworld
Date: Fri, 25 Jun 2021 00:32:47 -0400
Subject: [PATCH 5/5] Remove word from README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index bcccc20..4fe18cd 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ Amfora is packaged in many Linux distros. It's also on [Scoop](https://scoop.sh/
### Homebrew
-If you use [Homebrew](https://brew.sh/), you can install Amfora through the my personal tap.
+If you use [Homebrew](https://brew.sh/), you can install Amfora through my personal tap.
```
brew tap makeworld-the-better-one/tap
brew install amfora