server: add link to news posts back to original article

This commit is contained in:
2024-08-12 21:14:32 -07:00
parent c5def6c0e3
commit 8a237bf8e1
2 changed files with 26 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ use crate::{
compute_offset_limit,
error::ServerError,
graphql::{Body, Email, Html, Message, Tag, Thread, ThreadSummary},
EscapeHtml, InlineStyle, SanitizeHtml, StripHtml, Transformer,
AddOutlink, EscapeHtml, InlineStyle, SanitizeHtml, StripHtml, Transformer,
};
pub fn is_newsreader_search(query: &str) -> bool {
@@ -191,7 +191,8 @@ pub async fn thread(pool: &PgPool, thread_id: String) -> Result<Thread, ServerEr
// TODO: add site specific cleanups. For example:
// * Grafana does <div class="image-wrapp"><img class="lazyload>"<img src="/media/...>"</img></div>
// * Some sites appear to be HTML encoded, unencode them, i.e. imperialviolent
let body_tranformers: Vec<Box<dyn Transformer>> = vec![
let mut body_tranformers: Vec<Box<dyn Transformer>> = vec![
Box::new(AddOutlink(link.clone())),
Box::new(EscapeHtml),
Box::new(InlineStyle),
Box::new(SanitizeHtml {