1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-19 19:25:24 +00:00

Support all text/* documents - fixes #12

This commit is contained in:
makeworld 2020-06-21 23:49:43 -04:00
parent 7ab1a2bda9
commit db69646dbd
3 changed files with 9 additions and 11 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Right margin for text (#1)
- Desktop entry file
- Option to continue anyway when cert doesn't match TOFU database
- Display all `text/*` documents, not just gemini and plain (#12)
### Changed
- Connection timeout is 15 seconds (was 5s)

View File

@ -21,7 +21,6 @@ var tabMap = make(map[int]*structs.Page) // Map of tab number to page
var tabViews = make(map[int]*cview.TextView)
var termW int
var termH int
// The user input and URL display bar at the bottom
var bottomBar = cview.NewInputField().
@ -80,9 +79,8 @@ var App = cview.NewApplication().
EnableMouse(false).
SetRoot(layout, true).
SetAfterResizeFunc(func(width int, height int) {
// Store width and height for calculations
// Store for calculations
termW = width
termH = height
// Shift new tabs created before app startup, when termW == 0
// XXX: This is hacky but works. The biggest issue is that there will sometimes be a tiny flash

View File

@ -34,7 +34,7 @@ func CanDisplay(res *gemini.Response) bool {
if err != nil {
return false
}
if mediatype != "text/gemini" && mediatype != "text/plain" {
if !strings.HasPrefix(mediatype, "text/") {
// Amfora doesn't support other filetypes
return false
}
@ -75,13 +75,6 @@ func MakePage(url string, res *gemini.Response, width int) (*structs.Page, error
}
}
if mediatype == "text/plain" {
return &structs.Page{
Url: url,
Content: utfText,
Links: []string{}, // Plaintext has no links
}, nil
}
if mediatype == "text/gemini" {
rendered, links := RenderGemini(utfText, width)
return &structs.Page{
@ -89,6 +82,12 @@ func MakePage(url string, res *gemini.Response, width int) (*structs.Page, error
Content: rendered,
Links: links,
}, nil
} else if strings.HasPrefix(mediatype, "text/") {
return &structs.Page{
Url: url,
Content: utfText,
Links: []string{}, // Non-gemini links are not supported
}, nil
}
return nil, errors.New("displayable mediatype is not handled in the code, implementation error")