mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-14 05:52:53 +00:00
Proxy Thumbnails
This commit is contained in:
parent
759c9fc66b
commit
f33af75267
5 changed files with 22 additions and 20 deletions
13
src/post.rs
13
src/post.rs
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue