mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
WebUI: add headers to RSS entry viewer
Introduced Author, 'Open link' headers. Note that the Author and 'Open link' are not mandatory fields in RSS/Atom feeds. So these headers will only be displayed when the feed includes them. PR #22503.
This commit is contained in:
parent
72e8b3272b
commit
f0b9a17566
1 changed files with 66 additions and 24 deletions
|
@ -60,12 +60,15 @@
|
||||||
|
|
||||||
#rssTorrentDetailsName {
|
#rssTorrentDetailsName {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
font-weight: bold;
|
||||||
background-color: var(--color-background-blue);
|
background-color: var(--color-background-blue);
|
||||||
padding: 0;
|
padding: 0;
|
||||||
color: var(--color-text-white);
|
color: var(--color-text-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
#rssTorrentDetailsDate {
|
#rssTorrentDetailsAuthor,
|
||||||
|
#rssTorrentDetailsDate,
|
||||||
|
#rssTorrentDetailsLink {
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
background-color: var(--color-background-default);
|
background-color: var(--color-background-default);
|
||||||
}
|
}
|
||||||
|
@ -429,15 +432,23 @@
|
||||||
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
|
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
|
||||||
clearDetails();
|
clearDetails();
|
||||||
|
|
||||||
const article = feedData[feedUid].filter((article) => article.id === articleID)[0];
|
const article = feedData[feedUid].find((article) => (article.id === articleID));
|
||||||
if (article) {
|
if (article === undefined)
|
||||||
$("rssDetailsView").append((() => {
|
return;
|
||||||
|
|
||||||
|
const detailsView = document.getElementById("rssDetailsView");
|
||||||
|
|
||||||
|
const articleTitle = article.title;
|
||||||
|
if (articleTitle !== undefined) {
|
||||||
const torrentName = document.createElement("p");
|
const torrentName = document.createElement("p");
|
||||||
torrentName.textContent = article.title;
|
torrentName.textContent = articleTitle;
|
||||||
torrentName.id = "rssTorrentDetailsName";
|
torrentName.id = "rssTorrentDetailsName";
|
||||||
return torrentName;
|
|
||||||
})());
|
detailsView.append(torrentName);
|
||||||
$("rssDetailsView").append((() => {
|
}
|
||||||
|
|
||||||
|
const articleDate = article.date;
|
||||||
|
if (articleDate !== undefined) {
|
||||||
const torrentDate = document.createElement("div");
|
const torrentDate = document.createElement("div");
|
||||||
torrentDate.id = "rssTorrentDetailsDate";
|
torrentDate.id = "rssTorrentDetailsDate";
|
||||||
|
|
||||||
|
@ -446,16 +457,47 @@
|
||||||
torrentDate.append(torrentDateDesc);
|
torrentDate.append(torrentDateDesc);
|
||||||
|
|
||||||
const torrentDateData = document.createElement("span");
|
const torrentDateData = document.createElement("span");
|
||||||
torrentDateData.textContent = new Date(article.date).toLocaleString();
|
torrentDateData.textContent = new Date(articleDate).toLocaleString();
|
||||||
torrentDate.append(torrentDateData);
|
torrentDate.append(torrentDateData);
|
||||||
|
|
||||||
return torrentDate;
|
detailsView.append(torrentDate);
|
||||||
})());
|
}
|
||||||
|
|
||||||
|
const articleAuthor = article.author;
|
||||||
|
if (articleAuthor !== undefined) {
|
||||||
|
const divElement = document.createElement("div");
|
||||||
|
divElement.id = "rssTorrentDetailsAuthor";
|
||||||
|
|
||||||
|
const header = document.createElement("b");
|
||||||
|
header.textContent = "QBT_TR(Author: )QBT_TR[CONTEXT=RSSWidget]";
|
||||||
|
divElement.append(header);
|
||||||
|
|
||||||
|
const span = document.createElement("span");
|
||||||
|
span.textContent = articleAuthor;
|
||||||
|
divElement.append(span);
|
||||||
|
|
||||||
|
detailsView.append(divElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
const articleLink = article.link;
|
||||||
|
if (articleLink !== undefined) {
|
||||||
|
const divElement = document.createElement("div");
|
||||||
|
divElement.id = "rssTorrentDetailsLink";
|
||||||
|
|
||||||
|
const anchorElement = document.createElement("a");
|
||||||
|
anchorElement.href = articleLink;
|
||||||
|
anchorElement.textContent = "QBT_TR(Open link)QBT_TR[CONTEXT=RSSWidget]";
|
||||||
|
anchorElement.target = "_blank";
|
||||||
|
anchorElement.style = "font-weight: bold;";
|
||||||
|
divElement.append(anchorElement);
|
||||||
|
|
||||||
|
detailsView.append(divElement);
|
||||||
|
}
|
||||||
|
|
||||||
// Place in iframe with sandbox attribute to prevent js execution
|
// Place in iframe with sandbox attribute to prevent js execution
|
||||||
const torrentDescription = document.createRange().createContextualFragment('<iframe sandbox id="rssDescription"></iframe>');
|
const torrentDescription = document.createRange().createContextualFragment('<iframe sandbox id="rssDescription"></iframe>');
|
||||||
$("rssDetailsView").append(torrentDescription);
|
$("rssDetailsView").append(torrentDescription);
|
||||||
document.getElementById("rssDescription").srcdoc = `<html><head><link rel="stylesheet" type="text/css" href="css/style.css"></head><body>${article.description}</body></html>`;
|
document.getElementById("rssDescription").srcdoc = `<html><head><link rel="stylesheet" type="text/css" href="css/style.css"></head><body>${article.description}</body></html>`;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateRssFeedList = () => {
|
const updateRssFeedList = () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue