-- Leo's gemini proxy

-- Connecting to typed-hole.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

commit 4062a3618e8c033b850abe69143ae600b9bba2c1

Author: Julien Blanchard <julien@sideburns.eu>

Date: Tue Nov 26 19:05:29 2019 +0100


WIP: decide between webview or textview


diff --git a/Cargo.lock b/Cargo.lock

index e06c3ba..0c950c4 100644

--- a/Cargo.lock

+++ b/Cargo.lock

@@ -1,6 +1,14 @@

This file is automatically @generated by Cargo.

It is not intended for manual editing.

[[package]]

+name = "aho-corasick"

+version = "0.7.6"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "arrayref"

version = "0.3.5"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -88,6 +96,14 @@ version = "1.3.2"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "c2-chacha"

+version = "0.2.3"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "cairo-rs"

version = "0.7.1"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -115,6 +131,7 @@ dependencies = [

name = "castor"

version = "0.1.0"

dependencies = [

+ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",

"gdk 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",

"gdk-pixbuf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

"gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

@@ -122,10 +139,14 @@ dependencies = [

"glib-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",

"gtk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

"json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",

+ "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",

+ "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",

"relm 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",

"relm-derive 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",

"simplelog 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",

+ "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

"uhttp_uri 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",

+ "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

"webkit2gtk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",

]


@@ -163,6 +184,20 @@ version = "0.1.4"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "core-foundation"

+version = "0.6.4"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "core-foundation-sys"

+version = "0.6.2"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "crossbeam-utils"

version = "0.6.6"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -212,6 +247,19 @@ dependencies = [

]


[[package]]

+name = "foreign-types"

+version = "0.3.2"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "foreign-types-shared"

+version = "0.1.1"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "fragile"

version = "0.3.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -282,6 +330,16 @@ dependencies = [

]


[[package]]

+name = "getrandom"

+version = "0.1.13"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "gio"

version = "0.7.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -382,6 +440,16 @@ dependencies = [

]


[[package]]

+name = "idna"

+version = "0.2.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",

+ "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",

+ "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "javascriptcore-rs"

version = "0.8.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -422,6 +490,33 @@ dependencies = [

]


[[package]]

+name = "matches"

+version = "0.1.8"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

+name = "memchr"

+version = "2.2.1"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

+name = "native-tls"

+version = "0.2.3"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",

+ "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)",

+ "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)",

+ "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",

+ "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",

+ "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",

+ "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "num-integer"

version = "0.1.41"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -439,6 +534,36 @@ dependencies = [

]


[[package]]

+name = "openssl"

+version = "0.10.26"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",

+ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",

+ "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "openssl-probe"

+version = "0.1.2"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

+name = "openssl-sys"

+version = "0.9.53"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",

+ "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",

+ "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "pango"

version = "0.7.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -464,11 +589,21 @@ dependencies = [

]


[[package]]

+name = "percent-encoding"

+version = "2.1.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "pkg-config"

version = "0.3.17"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "ppv-lite86"

+version = "0.2.6"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "proc-macro2"

version = "0.4.30"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -501,6 +636,27 @@ dependencies = [

]


[[package]]

+name = "rand"

+version = "0.7.2"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",

+ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",

+ "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "rand_chacha"

+version = "0.2.1"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",

+ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "rand_core"

version = "0.3.1"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -514,6 +670,22 @@ version = "0.4.2"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "rand_core"

+version = "0.5.1"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "rand_hc"

+version = "0.2.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "rand_os"

version = "0.1.3"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -551,6 +723,22 @@ dependencies = [

]


[[package]]

+name = "regex"

+version = "1.3.1"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",

+ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",

+ "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",

+ "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "regex-syntax"

+version = "0.6.12"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "relm"

version = "0.18.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -578,6 +766,14 @@ dependencies = [

]


[[package]]

+name = "remove_dir_all"

+version = "0.5.2"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "rust-argon2"

version = "0.5.1"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -593,6 +789,34 @@ version = "0.1.16"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "schannel"

+version = "0.1.16"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",

+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "security-framework"

+version = "0.3.4"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",

+ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "security-framework-sys"

+version = "0.3.3"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "simplelog"

version = "0.7.4"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -603,6 +827,11 @@ dependencies = [

]


[[package]]

+name = "smallvec"

+version = "1.0.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "soup-sys"

version = "0.9.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -647,6 +876,19 @@ dependencies = [

]


[[package]]

+name = "tempfile"

+version = "3.1.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",

+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",

+ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",

+ "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",

+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "term"

version = "0.6.1"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -656,6 +898,14 @@ dependencies = [

]


[[package]]

+name = "thread_local"

+version = "0.3.6"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "time"

version = "0.1.42"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -671,6 +921,22 @@ version = "0.5.1"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "unicode-bidi"

+version = "0.3.4"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "unicode-normalization"

+version = "0.1.11"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

name = "unicode-xid"

version = "0.1.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -681,6 +947,26 @@ version = "0.2.0"

source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

+name = "url"

+version = "2.1.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+dependencies = [

+ "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",

+ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",

+ "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

+]

+

+[[package]]

+name = "vcpkg"

+version = "0.2.7"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

+name = "wasi"

+version = "0.7.0"

+source = "registry+https://github.com/rust-lang/crates.io-index"

+

+[[package]]

name = "webkit2gtk"

version = "0.8.0"

source = "registry+https://github.com/rust-lang/crates.io-index"

@@ -742,6 +1028,7 @@ version = "0.4.0"

source = "registry+https://github.com/rust-lang/crates.io-index"


[metadata]

+"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"

"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"

"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"

"checksum atk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "86b7499272acf036bb5820c6e346bbfb5acc5dceb104bc2c4fd7e6e33dfcde6a"

@@ -753,6 +1040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"

"checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0"

"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"

+"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"

"checksum cairo-rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e05db47de3b0f09a222fa4bba2eab957d920d4243962a86b2d77ab401e4a359c"

"checksum cairo-sys-rs 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90a1ec04603a78c111886a385edcec396dbfbc57ea26b9e74aeea6a1fe55dcca"

"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8"

@@ -760,17 +1048,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01"

"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"

"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"

+"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"

+"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"

"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"

"checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"

"checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"

"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"

"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"

+"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"

+"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"

"checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9"

"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"

"checksum gdk 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6243e995f41f3a61a31847e54cc719edce93dd9140c89dca3b9919be1cfe22d5"

"checksum gdk-pixbuf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9726408ee1bbada83094326a99b9c68fea275f9dbb515de242a69e72051f4fcc"

"checksum gdk-pixbuf-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1d6778abf5764b9080a9345a16c5d16289426a3b3edd808a29a9061d431c465"

"checksum gdk-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebe06357212127f50575b535bdb04638f5d375bb41062287abc6c94e5b8067b"

+"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"

"checksum gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6261b5d34c30c2d59f879e643704cf54cb44731f3a2038000b68790c03e360e3"

"checksum gio-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "778b856a70a32e2cc5dd5cc7fa1b0c4b6df924fdf5c82984bc28f30565657cfe"

"checksum glib 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "be27232841baa43e0fd5ae003f7941925735b2f733a336dc75f07b9eff415e7b"

@@ -778,41 +1071,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

"checksum gobject-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61d55bc9202447ca776f6ad0048c36e3312010f66f82ab478e97513e93f3604b"

"checksum gtk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "709f1074259d4685b96133f92b75c7f35b504715b0fcdc96ec95de2607296a60"

"checksum gtk-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbd9395497ae1d1915d1d6e522d51ae8745bf613906c34ac191c411250fc4025"

+"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"

"checksum javascriptcore-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8b1f9f98eacacf8fd0430b92aebb9fba475928da5f8b77eb4269ceb298c3d15"

"checksum javascriptcore-rs-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f46ada8a08dcd75a10afae872fbfb51275df4a8ae0d46b8cc7c708f08dd2998"

"checksum json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3ca41abbeb7615d56322a984e63be5e5d0a117dfaca86c14393e32a762ccac1"

"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"

"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"

+"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"

+"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"

+"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e"

"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"

"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4"

+"checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585"

+"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"

+"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f"

"checksum pango 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393fa071b144f8ffb83ede273758983cf414ca3c0b1d2a5a9ce325b3ba3dd786"

"checksum pango-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ee97abcad820f9875e032656257ad1c790e7b11a0e6ce2516a8f5b0d8f8213f"

+"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"

"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"

+"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"

"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"

"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"

"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"

"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"

+"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"

+"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"

"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"

"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"

+"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"

+"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"

"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"

"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"

"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"

"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d"

+"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"

+"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"

"checksum relm 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4127341a75eb96dc99ba39b87a2783bb011b20fbdbafc25ed2f58216d2ff714"

"checksum relm-derive 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec66397054dc1ea6c658159866b9978add6a90655aba5dd4a90c34d2e63f9d69"

+"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"

"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf"

"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"

+"checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021"

+"checksum security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df"

+"checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895"

"checksum simplelog 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "05a3e303ace6adb0a60a9e9e2fbc6a33e1749d1e43587e2125f7efa9c5e107c5"

+"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86"

"checksum soup-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48a2f246b51c81d4baa1ce611240c2f6e0323ae75f3b6cc9d2d2911e0567962c"

"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"

"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"

"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"

+"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"

"checksum term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5"

+"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"

"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"

"checksum uhttp_uri 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9b600e6da808f63a440874d633b22fa04abc9c3b08212ee7292512aec62805b"

+"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"

+"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf"

"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"

"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"

+"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61"

+"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95"

+"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"

"checksum webkit2gtk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad2b3e0b64094b0bbaa81bd73c56f992414e8d02fa763fbebc6f9911c1b36735"

"checksum webkit2gtk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f438a797e617deaa635e482f0beb29abb3bbe1540709cc20a572cac499b2f980"

"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"

diff --git a/Cargo.toml b/Cargo.toml

index a2373e6..77fdd49 100644

--- a/Cargo.toml

+++ b/Cargo.toml

@@ -19,3 +19,8 @@ uhttp_uri = "*"

relm = "*"

relm-derive = "*"

webkit2gtk = "*"

+regex = "*"

+native-tls = "*"

+url = "*"

+tempfile = "*"

+dirs = "*"

diff --git a/src/absolute.rs b/src/absolute.rs

new file mode 100644

index 0000000..7e5bfcf

--- /dev/null

+++ b/src/absolute.rs

@@ -0,0 +1,89 @@

+use url::Url;

+

+pub fn make(url: &str) -> Result<url::Url, url::ParseError> {

+ // Creates an absolute link if needed

+ match super::history::get_current_host() {

+ Some(host) => {

+ if url.starts_with("gemini://") {

+ Url::parse(url)

+ } else if url.starts_with("//") {

+ Url::parse(&format!("gemini:{}", url))

+ } else if url.starts_with('/') {

+ Url::parse(&format!("gemini://{}{}", host, url))

+ } else {

+ let current_host_path = super::history::get_current_url().unwrap();

+ Url::parse(&format!("{}{}", current_host_path, url))

+ }

+ }

+ None => {

+ if url.starts_with("gemini://") {

+ Url::parse(url)

+ } else if url.starts_with("//") {

+ Url::parse(&format!("gemini:{}", url))

+ } else {

+ Url::parse(&format!("gemini://{}", url))

+ }

+ }

+ }

+}

+

+#[test]

+fn test_make_absolute_full_url() {

+ super::history::append("gemini://typed-hole.org");

+ let url = "gemini://typed-hole.org/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_full_url_no_protocol() {

+ super::history::append("gemini://typed-hole.org");

+ let url = "//typed-hole.org/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_slash_path() {

+ super::history::append("gemini://typed-hole.org");

+ let url = "/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_just_path() {

+ super::history::append("gemini://typed-hole.org");

+ let url = "foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_full_url_no_current_host() {

+ let url = "gemini://typed-hole.org/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_full_url_no_protocol_no_current_host() {

+ let url = "//typed-hole.org/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_slash_path_no_current_host() {

+ let url = "/foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

+#[test]

+fn test_make_absolute_just_path_no_current_host() {

+ let url = "foo";

+ let expected_url = Url::parse("gemini://typed-hole.org/foo").unwrap();

+ let absolute_url = make(&url).unwrap();

+ assert_eq!(expected_url, absolute_url);

+}

diff --git a/src/content.rs b/src/content.rs

new file mode 100644

index 0000000..6e8be18

--- /dev/null

+++ b/src/content.rs

@@ -0,0 +1,65 @@

+use std::io::{Read, Write};

+use tempfile::NamedTempFile;

+

+use native_tls::TlsConnector;

+use std::net::{TcpStream, ToSocketAddrs};

+use std::time::Duration;

+

+pub fn get_data(url: &url::Url) -> Result<(Vec<u8>, Vec<u8>), String> {

+ let host = url.host_str().unwrap();

+ let urlf = format!("{}:1965", host);

+

+ let mut builder = TlsConnector::builder();

+ builder.danger_accept_invalid_hostnames(true);

+ builder.danger_accept_invalid_certs(true);

+ let connector = builder.build().unwrap();

+

+ match urlf.to_socket_addrs() {

+ Ok(mut addrs_iter) => match addrs_iter.next() {

+ Some(socket_addr) => {

+ let stream = TcpStream::connect_timeout(&socket_addr, Duration::new(5, 0));

+

+ match stream {

+ Ok(stream) => {

+ let mstream = connector.connect(&host, stream);

+

+ match mstream {

+ Ok(mut stream) => {

+ let url = format!("{}\r\n", url);

+ stream.write_all(url.as_bytes()).unwrap();

+ let mut res = vec![];

+ stream.read_to_end(&mut res).unwrap();

+

+ let clrf_idx = find_clrf(&res);

+ let content = res.split_off(clrf_idx.unwrap() + 2);

+

+ Ok((res, content))

+ }

+ Err(e) => Err(format!("Could not connect to {}\n{}", urlf, e)),

+ }

+ }

+ Err(e) => Err(format!("Could not connect to {}\n{}", urlf, e)),

+ }

+ }

+ None => Err(format!("Could not connect to {}", urlf)),

+ },

+ Err(e) => Err(format!("Could not connect to {}\n{}", urlf, e)),

+ }

+}

+

+// pub fn download(content: Vec<u8>) {

+// let path = write_tmp_file(content);

+// open::that(path).unwrap();

+// }

+

+fn write_tmp_file(content: Vec<u8>) -> std::path::PathBuf {

+ let mut tmp_file = NamedTempFile::new().unwrap();

+ tmp_file.write_all(&content).unwrap();

+ let (_file, path) = tmp_file.keep().unwrap();

+ path

+}

+

+fn find_clrf(data: &[u8]) -> Option<usize> {

+ let clrf = b"\r\n";

+ data.windows(clrf.len()).position(|window| window == clrf)

+}

diff --git a/src/main.rs b/src/main.rs

index 3c1a916..8081cf4 100644

--- a/src/main.rs

+++ b/src/main.rs

@@ -1,13 +1,30 @@

+use std::fs::File;

+use std::io::prelude::*;

+use std::io::{BufRead, BufReader};

+

use gtk::Orientation::{Horizontal, Vertical};

-use gtk::{ButtonExt, EntryExt, Inhibit, OrientableExt, WidgetExt};

+use gtk::{ButtonExt, EntryExt, Inhibit, OrientableExt, TextBufferExt, TextViewExt, WidgetExt};

use relm::Widget;

use relm_derive::{widget, Msg};

-use webkit2gtk::WebViewExt;

+use webkit2gtk::{WebContext, WebContextExt, WebViewExt};

+

+extern crate regex;

+use regex::Regex;

+

+use url::Url;

+mod content;

+

+const LINK_REGEX: &str = r"^=>\s*(\S*)\s*(.*)?$";

+const H1_REGEX: &str = r"^#\s+(.*)$";

+const H2_REGEX: &str = r"^##\s+(.*)$";

+const H3_REGEX: &str = r"^###\s+(.*)$";

+const UL_REGEX: &str = r"^\s*\*\s+(.*)$";


use self::Msg::*;


pub struct Model {

- counter: i32,

+ current_url: String,

+ current_host: String,

}


@@ -22,19 +39,47 @@ pub enum Msg {

impl Widget for Win {

fn init_view(&mut self) {

- // self.webview.load_uri("https://crates.io/");

+ // self.webview.load_uri("gemini://gemini.circumlunar.space");

}


fn model() -> Model {

- Model { counter: 0 }

+ Model {

+ current_url: String::from(""),

+ current_host: String::from(""),

+ }

}


fn update(&mut self, event: Msg) {

match event {

Back => (),

Go(url) => {

- println!("{:?}", url);

- self.webview.load_uri(&url);

+ let new_url = Url::parse(&url).unwrap();

+ let data = content::get_data(&new_url);

+ self.model.current_url = new_url.to_string();

+ self.model.current_host = new_url.host().unwrap().to_string();

+ match data {

+ Ok((meta, new_content)) => {

+ clear_buffer(&self.webview);

+ let content_str = String::from_utf8_lossy(&new_content).to_string();

+ // let content = gemini2html(content_str, self.model.current_url.clone());

+ // self.webview.load_html(&content, None);

+ let content = parse_gemini(

+ &content_str,

+ self.model.current_url.clone(),

+ self.model.current_host.clone(),

+ self.webview.get_buffer().unwrap(),

+ );

+

+ let (start, end) = content.get_bounds();

+ // content.delete(&mut start, &mut end);

+ // let (start, end) = content.get_bounds();

+ content.set_text(&content.get_text(&start, &end, false).unwrap());

+ }

+ Err(_) => {

+ let content = "ERROR";

+ self.webview.get_buffer().unwrap().set_text(&content);

+ }

+ }

}

Quit => gtk::main_quit(),

Next => (),

@@ -66,16 +111,29 @@ impl Widget for Win {

gtk::Entry {

activate(url_bar) => {

let url = url_bar.get_text().expect("get_text failed").to_string();

- Go(url)

+ if url.starts_with("gemini://") {

+ Go(url)

+ } else {

+ Go(format!("gemini://{}", url))

+ }

},

placeholder_text: Some("Enter a URL"),

width_chars: 40,

},

},

- #[name="webview"]

- webkit2gtk::WebView {

- vexpand: true,

- },

+ gtk::ScrolledWindow {

+ #[name="webview"]

+ gtk::TextView {

+ vexpand: true,

+ editable: false,

+ },

+ }

+ // webkit2gtk::WebView {

+ // vexpand: true,

+ // // decide_policy(_, policy_decision, policy_decision_type) with (open_in_new_window, relm) =>

+ // // return WebView::decide_policy(&policy_decision, &policy_decision_type, &open_in_new_window, &relm),

+ // // permission_request(_, request) => (PermissionRequest(request.clone()), true),

+ // },

},

delete_event(_, _) => (Quit, Inhibit(false)),

}

@@ -83,5 +141,158 @@ impl Widget for Win {

}


fn main() {

+ // let context = WebContext::get_default().unwrap();

+ // context.register_uri_scheme("gemini", visit_link);

Win::run(()).expect("Win::run failed");

}

+

+fn visit_link(url: &str) -> String {

+ let new_url = Url::parse(url).unwrap();

+ let data = content::get_data(&new_url);

+ match data {

+ Ok((meta, new_content)) => String::from_utf8_lossy(&new_content).to_string(),

+ Err(_) => String::from("ERROR"),

+ }

+}

+

+fn clear_buffer(view: &gtk::TextView) {

+ match view.get_buffer() {

+ Some(buffer) => {

+ let (mut start, mut end) = buffer.get_bounds();

+ buffer.delete(&mut start, &mut end);

+ }

+ None => (),

+ }

+}

+

+// fn gemini2html(content: String, current_url: String) -> String {

+// let link_regexp = Regex::new(LINK_REGEX).unwrap();

+// let h1_regexp = Regex::new(H1_REGEX).unwrap();

+// let h2_regexp = Regex::new(H2_REGEX).unwrap();

+// let h3_regexp = Regex::new(H3_REGEX).unwrap();

+// let ul_regexp = Regex::new(UL_REGEX).unwrap();

+

+// let mut html = String::from("<!DOCTYPE html><html><body>");

+

+// for line in content.lines() {

+// if link_regexp.is_match(line) {

+// let caps = link_regexp.captures(&line).unwrap();

+// let dest = caps.get(1).map_or("", |m| m.as_str());

+// let label = caps.get(2).map_or("", |m| m.as_str());

+// html.push_str(&format!(

+// "<a href={}>{}</a><br/>",

+// make_absolute(dest, &current_url),

+// label

+// ));

+// } else if h1_regexp.is_match(line) {

+// let caps = h1_regexp.captures(&line).unwrap();

+// let header = caps.get(1).map_or("", |m| m.as_str());

+// html.push_str(&format!("<h1>{}</h1>", header));

+// } else if h2_regexp.is_match(line) {

+// let caps = h2_regexp.captures(&line).unwrap();

+// let header = caps.get(1).map_or("", |m| m.as_str());

+// html.push_str(&format!("<h2>{}</h2>", header));

+// } else if h3_regexp.is_match(line) {

+// let caps = h3_regexp.captures(&line).unwrap();

+// let header = caps.get(1).map_or("", |m| m.as_str());

+// html.push_str(&format!("<h3>{}</h3>", header));

+// } else if ul_regexp.is_match(line) {

+// let caps = ul_regexp.captures(&line).unwrap();

+// let header = caps.get(1).map_or("", |m| m.as_str());

+// html.push_str(&format!("<ul><li>{}</li></ul>", header));

+// } else if line.is_empty() {

+// html.push_str("<br/>");

+// } else {

+// html.push_str(&format!("{}<br/>", line));

+// }

+// }

+

+// let html_end = "</body></html>";

+// println!("{}{}", html, html_end);

+// format!("{}{}", html, html_end)

+// }

+

+fn parse_gemini(

+ content: &String,

+ current_url: String,

+ current_host: String,

+ buffer: gtk::TextBuffer,

+) -> gtk::TextBuffer {

+ let link_regexp = Regex::new(LINK_REGEX).unwrap();

+ let h1_regexp = Regex::new(H1_REGEX).unwrap();

+ let h2_regexp = Regex::new(H2_REGEX).unwrap();

+ let h3_regexp = Regex::new(H3_REGEX).unwrap();

+ let ul_regexp = Regex::new(UL_REGEX).unwrap();

+

+ for line in content.lines() {

+ if link_regexp.is_match(line) {

+ let caps = link_regexp.captures(&line).unwrap();

+ let dest = caps.get(1).map_or("", |m| m.as_str());

+ let label = caps.get(2).map_or("", |m| m.as_str());

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(

+ &mut end_iter,

+ &format!(

+ "Link: {} -> {}\n",

+ label,

+ make_absolute(dest, &current_url, &current_host)

+ ),

+ );

+ } else if h1_regexp.is_match(line) {

+ let caps = h1_regexp.captures(&line).unwrap();

+ let header = caps.get(1).map_or("", |m| m.as_str());

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, &format!("Header 1: {}\n", header));

+ } else if h2_regexp.is_match(line) {

+ let caps = h2_regexp.captures(&line).unwrap();

+ let header = caps.get(1).map_or("", |m| m.as_str());

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, &format!("Header 2: {}\n", header));

+ } else if h3_regexp.is_match(line) {

+ let caps = h3_regexp.captures(&line).unwrap();

+ let header = caps.get(1).map_or("", |m| m.as_str());

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, &format!("Header 3: {}\n", header));

+ } else if ul_regexp.is_match(line) {

+ let caps = ul_regexp.captures(&line).unwrap();

+ let header = caps.get(1).map_or("", |m| m.as_str());

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, &format!("List item: {}\n", header));

+ } else if line.is_empty() {

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, "\n");

+ } else {

+ let mut end_iter = buffer.get_end_iter();

+ buffer.insert(&mut end_iter, &format!("{}\n", line));

+ }

+ }

+ buffer

+}

+

+fn make_absolute(url: &str, current_host: &str, current_url: &str) -> String {

+ if url.starts_with("gopher://") {

+ String::from(url)

+ } else if url.starts_with("http://") {

+ String::from(url)

+ } else if url.starts_with("https://") {

+ String::from(url)

+ } else if !current_host.is_empty() {

+ if url.starts_with("gemini://") {

+ String::from(url)

+ } else if url.starts_with("//") {

+ format!("gemini:{}", url)

+ } else if url.starts_with('/') {

+ format!("{}{}", current_host, url)

+ } else {

+ format!("{}{}", current_url, url)

+ }

+ } else {

+ if url.starts_with("gemini://") {

+ String::from(url)

+ } else if url.starts_with("//") {

+ format!("gemini:{}", url)

+ } else {

+ format!("gemini://{}", url)

+ }

+ }

+}



---

Served by Pollux Gemini Server.

-- Response ended

-- Page fetched on Sun May 19 06:33:26 2024