mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
✨ Support all text/* documents - fixes #12
This commit is contained in:
parent
7ab1a2bda9
commit
db69646dbd
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Right margin for text (#1)
|
- Right margin for text (#1)
|
||||||
- Desktop entry file
|
- Desktop entry file
|
||||||
- Option to continue anyway when cert doesn't match TOFU database
|
- Option to continue anyway when cert doesn't match TOFU database
|
||||||
|
- Display all `text/*` documents, not just gemini and plain (#12)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Connection timeout is 15 seconds (was 5s)
|
- Connection timeout is 15 seconds (was 5s)
|
||||||
|
@ -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 tabViews = make(map[int]*cview.TextView)
|
||||||
|
|
||||||
var termW int
|
var termW int
|
||||||
var termH int
|
|
||||||
|
|
||||||
// The user input and URL display bar at the bottom
|
// The user input and URL display bar at the bottom
|
||||||
var bottomBar = cview.NewInputField().
|
var bottomBar = cview.NewInputField().
|
||||||
@ -80,9 +79,8 @@ var App = cview.NewApplication().
|
|||||||
EnableMouse(false).
|
EnableMouse(false).
|
||||||
SetRoot(layout, true).
|
SetRoot(layout, true).
|
||||||
SetAfterResizeFunc(func(width int, height int) {
|
SetAfterResizeFunc(func(width int, height int) {
|
||||||
// Store width and height for calculations
|
// Store for calculations
|
||||||
termW = width
|
termW = width
|
||||||
termH = height
|
|
||||||
|
|
||||||
// Shift new tabs created before app startup, when termW == 0
|
// 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
|
// XXX: This is hacky but works. The biggest issue is that there will sometimes be a tiny flash
|
||||||
|
@ -34,7 +34,7 @@ func CanDisplay(res *gemini.Response) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if mediatype != "text/gemini" && mediatype != "text/plain" {
|
if !strings.HasPrefix(mediatype, "text/") {
|
||||||
// Amfora doesn't support other filetypes
|
// Amfora doesn't support other filetypes
|
||||||
return false
|
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" {
|
if mediatype == "text/gemini" {
|
||||||
rendered, links := RenderGemini(utfText, width)
|
rendered, links := RenderGemini(utfText, width)
|
||||||
return &structs.Page{
|
return &structs.Page{
|
||||||
@ -89,6 +82,12 @@ func MakePage(url string, res *gemini.Response, width int) (*structs.Page, error
|
|||||||
Content: rendered,
|
Content: rendered,
|
||||||
Links: links,
|
Links: links,
|
||||||
}, nil
|
}, 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")
|
return nil, errors.New("displayable mediatype is not handled in the code, implementation error")
|
||||||
|
Loading…
Reference in New Issue
Block a user