Skip to content

Commit

Permalink
Pull bookmark favicons from cache if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwennerberg committed Sep 16, 2020
1 parent fe0fd78 commit 8747981
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion display/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package display

import (
"fmt"
"net/url"
"strconv"
"strings"

"github.com/gdamore/tcell"
"github.com/makeworld-the-better-one/amfora/bookmarks"
"github.com/makeworld-the-better-one/amfora/cache"
"github.com/makeworld-the-better-one/amfora/config"
"github.com/makeworld-the-better-one/amfora/renderer"
"github.com/makeworld-the-better-one/amfora/structs"
Expand Down Expand Up @@ -112,7 +114,16 @@ func Bookmarks(t *tab) {
rawContent := "# Bookmarks\r\n\r\n"
m, keys := bookmarks.All()
for i := range keys {
rawContent += fmt.Sprintf("=> %s %s\r\n", keys[i], m[keys[i]])
if viper.GetBool("a-general.emoji_favicons") {
parsed, _ := url.Parse(keys[i])
favIcon := cache.GetFavicon(parsed.Host)
if favIcon == "no" {
favIcon = ""
}
rawContent += fmt.Sprintf("=> %s %s %s\r\n", keys[i], favIcon, m[keys[i]])
} else {
rawContent += fmt.Sprintf("=> %s %s\r\n", keys[i], m[keys[i]])
}
}
// Render and display
content, links := renderer.RenderGemini(rawContent, textWidth(), leftMargin(), false)
Expand Down

0 comments on commit 8747981

Please sign in to comment.