Proxy Thumbnails

This commit is contained in:
spikecodes 2020-11-30 21:10:08 -08:00
parent 759c9fc66b
commit f33af75267
5 changed files with 22 additions and 20 deletions

View file

@ -1,13 +1,10 @@
// CRATES
use crate::utils::{request, val, Comment, ErrorTemplate, Flair, Params, Post};
use crate::utils::{format_url, request, val, Comment, ErrorTemplate, Flair, Params, Post};
use actix_web::{get, http::StatusCode, web, HttpResponse, Result};
use askama::Template;
use chrono::{TimeZone, Utc};
use pulldown_cmark::{html, Options, Parser};
#[cfg(feature = "proxy")]
use base64::encode;
// STRUCTS
#[derive(Template)]
#[template(path = "post.html", escape = "none")]
@ -69,14 +66,6 @@ async fn page(web::Path((_sub, id)): web::Path<(String, String)>, params: web::Q
}
}
async fn format_url(url: &str) -> String {
#[cfg(feature = "proxy")]
return "/imageproxy/".to_string() + encode(url).as_str();
#[cfg(not(feature = "proxy"))]
return url.to_string();
}
// UTILITIES
async fn media(data: &serde_json::Value) -> (String, String) {
let post_type: &str;