Added readable mode for article content

This commit is contained in:
2023-10-15 17:44:05 +02:00
parent 3d77c6f30f
commit ee80cbd53b
17 changed files with 151 additions and 53 deletions
+1 -38
View File
@@ -4,7 +4,6 @@ use crate::models::feed_item::rss_feed_item::FeedItem;
use crate::reader::structs::feed::FeedAggregate;
use crate::schema::feed_item::{feed_id, read};
use crate::{
auth::jwt::JwtToken,
database::establish_connection,
json_serialization::articles::Articles,
schema::feed::{self, user_id},
@@ -17,8 +16,6 @@ use super::structs::article::Article;
pub async fn get(path: web::Path<JsonUser>, req: HttpRequest) -> impl Responder {
let request = req.clone();
let _token: JwtToken = JwtToken::decode_from_request(req).unwrap();
let req_user_id = path.user_id;
log::info!("Received user_id: {}", req_user_id);
@@ -27,9 +24,6 @@ pub async fn get(path: web::Path<JsonUser>, req: HttpRequest) -> impl Responder
.filter(user_id.eq(req_user_id))
.load::<Feed>(&mut connection)
.unwrap();
// let feed = feeds::get_feed("https://www.heise.de/rss/heise-Rubrik-Wissen.rdf")
// .await
// .unwrap();
let mut feed_aggregates: Vec<FeedAggregate> = Vec::new();
for feed in feeds {
@@ -50,6 +44,7 @@ pub async fn get(path: web::Path<JsonUser>, req: HttpRequest) -> impl Responder
.map(|feed_item: FeedItem| Article {
title: feed_item.title,
content: feed_item.content,
url: feed_item.url,
})
.collect();
@@ -60,38 +55,6 @@ pub async fn get(path: web::Path<JsonUser>, req: HttpRequest) -> impl Responder
items: article_list,
})
}
// let feed_title: String = feed.title.clone();
// let feed_items: Vec<Article> = feed
// .into_items()
// .into_iter()
// .map(|item| {
// let title = item.title.unwrap();
// let frag = Html::parse_fragment(&item.content.unwrap());
// let mut content = "".to_string();
// let frag_clone = frag.clone();
// frag.tree.into_iter().for_each(|node| {
// let selector_img = Selector::parse("img").unwrap();
//
// for element in frag_clone.select(&selector_img) {
// if !content.starts_with("<img") {
// content.push_str(&element.html());
// content.push_str("<br>")
// }
// }
// if let scraper::node::Node::Text(text) = node {
// content.push_str(&text.text);
// }
// });
// Article { title, content }
// })
// .collect();
//
// let feed_aggregates = vec![
// (FeedAggregate {
// title: feed_title,
// items: feed_items,
// }),
// ];
let articles: Articles = Articles {
feeds: feed_aggregates,