fix: control rendering behavior based on routing

This commit is contained in:
Matthew Esposito 2025-02-09 17:10:12 -05:00
parent ebc682da2d
commit bb20190555
3 changed files with 5 additions and 4 deletions

View file

@ -8,6 +8,7 @@ use crate::utils::{
};
use crate::{client::json, server::RequestExt, server::ResponseExt};
use cookie::Cookie;
use htmlescape::decode_html;
use hyper::{Body, Request, Response};
use log::debug;
use rinja::Template;
@ -623,7 +624,7 @@ pub async fn rss(req: Request<Body>) -> Result<Response<Body>, String> {
title: Some(post.title.to_string()),
link: Some(format_url(&utils::get_post_url(&post))),
author: Some(post.author.name),
content: Some(rewrite_urls(&post.body)),
content: Some(rewrite_urls(&decode_html(&post.body).unwrap())),
pub_date: Some(DateTime::from_timestamp(post.created_ts as i64, 0).unwrap_or_default().to_rfc2822()),
description: Some(format!(
"<a href='{}{}'>Comments</a>",

View file

@ -6,6 +6,7 @@ use crate::server::RequestExt;
use crate::utils::{error, filter_posts, format_url, get_filters, nsfw_landing, param, setting, template, Post, Preferences, User};
use crate::{config, utils};
use chrono::DateTime;
use htmlescape::decode_html;
use hyper::{Body, Request, Response};
use rinja::Template;
use time::{macros::format_description, OffsetDateTime};
@ -167,7 +168,7 @@ pub async fn rss(req: Request<Body>) -> Result<Response<Body>, String> {
link: Some(format_url(&utils::get_post_url(&post))),
author: Some(post.author.name),
pub_date: Some(DateTime::from_timestamp(post.created_ts as i64, 0).unwrap_or_default().to_rfc2822()),
content: Some(rewrite_urls(&post.body)),
content: Some(rewrite_urls(&decode_html(&post.body).unwrap())),
..Default::default()
})
.collect::<Vec<_>>(),

View file

@ -7,7 +7,6 @@ use crate::config::{self, get_setting};
//
use crate::{client::json, server::RequestExt};
use cookie::Cookie;
use htmlescape::decode_html;
use hyper::{Body, Request, Response};
use libflate::deflate::{Decoder, Encoder};
use log::error;
@ -388,7 +387,7 @@ impl Post {
let awards = Awards::parse(&data["all_awardings"]);
// selftext_html is set for text posts when browsing.
let mut body = rewrite_urls(&decode_html(&val(post, "selftext_html")).unwrap());
let mut body = rewrite_urls(&val(post, "selftext_html"));
if body.is_empty() {
body = rewrite_urls(&val(post, "body_html"));
}