Remove Gemini test

This lives as an external program.
This commit is contained in:
Emery Hemingway 2021-12-25 20:17:43 +01:00
parent cd042fbf44
commit 0018f122a5
1 changed files with 0 additions and 58 deletions

View File

@ -1,58 +0,0 @@
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/[asyncdispatch, os, parseopt, strutils, tables, xmltree]
import preserves, preserves/xmlhooks
import syndicate, syndicate/[actors, capabilities, relay]
import parsegemini
import gemclient
import nimsvg
import svui
import eris
type Svui = svui.Svui[Ref]
proc main() =
proc quitHook() {.noconv.} = quit()
setControlCHook(quitHook)
waitFor runActor("client") do (turn: var Turn):
let cap = mint()
connectUnix(turn, "/run/syndicate/ds", cap) do (turn: var Turn; a: Assertion) -> TurnAction:
let ds = unembed a
let client = newGeminiClient()
for kind, arg, _ in getopt():
if kind == cmdArgument and arg.startsWith"gemini":
var
nodes: seq[Nodes]
p: GeminiParser
let resp = client.fetch(arg)
open(p, resp.bodyStream)
# TODO: append to a text block until running into verbatim text,
# then push the current text and open a new block
while true:
p.next()
case p.kind
of gmiEof: break
else:
let n = buildSvg:
t: xmltree.escape p.text
nodes.add n
close(p)
let doc = buildSvg:
svg(viewBox="0 0 600 800", `font-family` = "Gentium Plus", `font-size`="20"):
g(fill="white"):
text(fill="black"):
for n in nodes: embed n
let
buf = render doc
bs = if buf.len < (16 shl 10): bs1k else: bs32k
capPr = toPreserve($erisCap(buf, bs), Ref)
discard publish(turn, ds, Svui(attrs: toTable {"urn": capPr}, svg: buf))
stderr.writeLine "done"
main()