diff --git a/Cargo.lock b/Cargo.lock
index 95a1340..583bf3a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -661,6 +661,21 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "futures"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-executor",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
[[package]]
name = "futures-channel"
version = "0.3.17"
@@ -668,6 +683,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888"
dependencies = [
"futures-core",
+ "futures-sink",
]
[[package]]
@@ -676,6 +692,36 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
+[[package]]
+name = "futures-executor"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-io"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
+
+[[package]]
+name = "futures-macro"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
+dependencies = [
+ "autocfg",
+ "proc-macro-hack",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "futures-sink"
version = "0.3.17"
@@ -695,11 +741,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
dependencies = [
"autocfg",
+ "futures-channel",
"futures-core",
+ "futures-io",
+ "futures-macro",
"futures-sink",
"futures-task",
+ "memchr",
"pin-project-lite",
"pin-utils",
+ "proc-macro-hack",
+ "proc-macro-nested",
+ "slab",
]
[[package]]
@@ -1038,6 +1091,7 @@ dependencies = [
"chrono",
"config",
"derive_more",
+ "futures",
"graphql_client",
"lazy_static",
"log",
@@ -1049,7 +1103,6 @@ dependencies = [
"serde_json",
"sled",
"url",
- "urlencoding",
]
[[package]]
@@ -1389,6 +1442,12 @@ version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
+[[package]]
+name = "proc-macro-nested"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
+
[[package]]
name = "proc-macro2"
version = "1.0.26"
@@ -2122,12 +2181,6 @@ dependencies = [
"percent-encoding",
]
-[[package]]
-name = "urlencoding"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
-
[[package]]
name = "vcpkg"
version = "0.2.15"
diff --git a/Cargo.toml b/Cargo.toml
index b2aca2e..304e1d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,4 +41,4 @@ chrono = "0.4.19"
sled = "0.34.7"
bincode = "1.3.3"
-urlencoding = "2.1.0"
+futures = "0.3.17"
diff --git a/src/proxy.rs b/src/proxy.rs
index ab80ff7..c252673 100644
--- a/src/proxy.rs
+++ b/src/proxy.rs
@@ -17,9 +17,9 @@
use std::ops::{Bound, RangeBounds};
use actix_web::{http::header, web, HttpResponse, Responder};
-use reqwest::header::{CONTENT_TYPE, USER_AGENT};
+use futures::future::join_all;
+use reqwest::header::CONTENT_TYPE;
use sailfish::TemplateOnce;
-use serde::{Deserialize, Serialize};
use crate::data::PostResp;
use crate::AppData;
@@ -31,7 +31,6 @@ pub mod routes {
pub index: &'static str,
pub page: &'static str,
pub asset: &'static str,
- pub gist: &'static str,
}
impl Proxy {
@@ -40,7 +39,6 @@ pub mod routes {
index: "/",
page: "/{username}/{post}",
asset: "/asset/medium/{name}",
- gist: "/asset/github-gist",
}
}
pub fn get_page(&self, username: &str, post: &str) -> String {
@@ -52,20 +50,12 @@ pub mod routes {
pub fn get_medium_asset(&self, asset_name: &str) -> String {
self.asset.replace("{name}", asset_name)
}
-
- pub fn get_gist(&self, url: &str) -> String {
- if let Some(gist_id) = url.split('/').last() {
- format!("{}?gist={}", self.gist, urlencoding::encode(gist_id))
- } else {
- url.to_owned()
- }
- }
}
}
// credits @carlomilanesi:
// https://users.rust-lang.org/t/how-to-get-a-substring-of-a-string/1351/11
-trait StringUtils {
+pub trait StringUtils {
fn substring(&self, start: usize, len: usize) -> &str;
fn slice(&self, range: impl RangeBounds <.= file.get_html_content() .>
-
- <.}.>
- See on GitHub
-
-
-
diff --git a/templates/gist_error.html b/templates/gist_error.html
deleted file mode 100644
index 6d9fedf..0000000
--- a/templates/gist_error.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- <.= file.get_html_content() .>
+<.}.>
+See gist on GitHub
diff --git a/templates/main.css b/templates/main.css
index 2c11008..d5c8112 100644
--- a/templates/main.css
+++ b/templates/main.css
@@ -63,9 +63,9 @@ code {
font-family: monospace;
font-size: 15px;
white-space: pre-wrap;
- background-color: #888;
- color: #fff;
+ display: block;
font-weight: 600;
+ line-height: 1rem;
}
iframe {
diff --git a/templates/post.html b/templates/post.html
index 1e2a314..4a0b31b 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -23,7 +23,7 @@
on <.= &date .> · <.= data.reading_time.floor() as usize .> min read