gemenon

[ACTIVE] The Safari of the Gemini ecosystem
git clone git://git.figbert.com/gemenon.git
Log | Files | Refs

commit 76840d1177bb344ef55d366e0dad30bcf5bbe418
parent ae75fdc68bc1d151c093d2e1cc2743044486417b
Author: FIGBERT <figbert@figbert.com>
Date:   Mon, 17 Oct 2022 13:17:08 -0700

Add support for images and plain text responses

Diffstat:
MShared/CapsuleView.swift | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Shared/CapsuleView.swift b/Shared/CapsuleView.swift @@ -40,9 +40,18 @@ struct SuccessView: View { ScrollView { HStack { Spacer() - if data.tab.response?.body?.gemtext != nil { - VStack(alignment: .leading, spacing: 10) { - renderGemtext((data.tab.response?.body?.gemtext)!, url: data.tab.url) + if case .MIME(let mime) = data.tab.response?.header { + if mime.hasPrefix("text/") { + if mime.hasPrefix("text/gemini") { + VStack(alignment: .leading, spacing: 10) { + renderGemtext((data.tab.response?.body?.gemtext)!, url: data.tab.url) + } + } else { + Text(data.tab.response?.body?.text ?? "error") + .monospaced(true).font(.system(size: 14)) + } + } else if mime.hasPrefix("image/") { + Image(nsImage: NSImage(data: data.tab.response?.body?.raw ?? Data()) ?? NSImage()) } } Spacer()