From 2692f5a73ac90ae90fbe75e57c0abbf9343a0e4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 5 Dec 2025 20:52:15 +0100 Subject: [PATCH] =?utf8?q?=E2=9E=96=20Remove=20commons-lang3=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - .../filters/comics/KevinAndKellComicFilter.java | 3 +- .../rhynodge/states/TorrentState.java | 82 +++++++++++++--------- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/build.gradle b/build.gradle index aebd2e3..a34a665 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,6 @@ dependencies { implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.5.1' implementation group: "org.jsoup", name: "jsoup", version: "1.16.1" implementation group: "javax.mail", name: "mail", version: "1.4.6-rc1" - implementation group: "org.apache.commons", name: "commons-lang3", version: "3.1" implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.16.1" implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.16.1' implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: '2.16.1' diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/comics/KevinAndKellComicFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/comics/KevinAndKellComicFilter.java index 1b98739..3b0e657 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/comics/KevinAndKellComicFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/comics/KevinAndKellComicFilter.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Optional; import net.pterodactylus.rhynodge.filters.ComicSiteFilter; -import org.apache.commons.lang3.StringEscapeUtils; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; @@ -38,7 +37,7 @@ public class KevinAndKellComicFilter extends ComicSiteFilter { @Override protected Optional extractTitle(Document document) { Elements captionElements = document.select("#comicstripCaption"); - return Optional.ofNullable(StringEscapeUtils.unescapeHtml4(captionElements.text())); + return Optional.of(captionElements.text()); } @Override diff --git a/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java b/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java index 658986e..4c30d45 100644 --- a/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java +++ b/src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java @@ -33,12 +33,23 @@ import net.pterodactylus.rhynodge.State; import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringEscapeUtils; import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.net.WWWFormCodec; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; +import static kotlinx.html.Gen_consumer_tagsKt.html; +import static kotlinx.html.Gen_tag_groupsKt.table; +import static kotlinx.html.Gen_tag_unionsKt.a; +import static kotlinx.html.Gen_tags_hKt.body; +import static kotlinx.html.Gen_tags_tKt.caption; +import static kotlinx.html.Gen_tags_tKt.tbody; +import static kotlinx.html.Gen_tags_tKt.td; +import static kotlinx.html.Gen_tags_tKt.th; +import static kotlinx.html.Gen_tags_tKt.thead; +import static kotlinx.html.Gen_tags_tKt.tr; +import static kotlinx.html.stream.StreamKt.createHTML; +import static net.pterodactylus.util.dom.KotlinXHtml.wrapper; /** * {@link State} that contains information about an arbitrary number of torrent @@ -137,40 +148,41 @@ public class TorrentState extends AbstractState implements Iterable @Override protected String htmlText() { - StringBuilder htmlBuilder = new StringBuilder(); - htmlBuilder.append("\n"); - htmlBuilder.append("\n\n"); - htmlBuilder.append("\n"); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append("\n"); - htmlBuilder.append("\n"); - htmlBuilder.append("\n"); - for (TorrentFile torrentFile : files.stream().sorted(sortNewFirst()).toList()) { - if (newTorrentFiles.contains(torrentFile)) { - htmlBuilder.append(""); - } else { - htmlBuilder.append(""); - } - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append(""); - htmlBuilder.append("\n"); - } - htmlBuilder.append("\n"); - htmlBuilder.append("
All Known Torrents
FilenameSizeFile(s)SeedsLeechersMagnetDownload
").append(StringEscapeUtils.escapeHtml4(torrentFile.name())).append("").append(StringEscapeUtils.escapeHtml4(torrentFile.size())).append("").append(torrentFile.fileCount()).append("").append(torrentFile.seedCount()).append("").append(torrentFile.leechCount()).append("LinkLink
\n"); - htmlBuilder.append("\n"); - return htmlBuilder.toString(); + var tagConsumer = createHTML(true, true); + return html(tagConsumer, null, wrapper(html -> { + body(html, null, wrapper(body -> { + table(body, null, wrapper(table -> { + caption(table, null, wrapper(caption -> caption.text("All Known Torrents"))); + thead(table, null, wrapper(thead -> { + tr(thead, null, wrapper(tr -> { + th(tr, null, null, wrapper(th -> th.text("Filename"))); + th(tr, null, null, wrapper(th -> th.text("Size"))); + th(tr, null, null, wrapper(th -> th.text("File(s)"))); + th(tr, null, null, wrapper(th -> th.text("Seeds"))); + th(tr, null, null, wrapper(th -> th.text("Leechers"))); + th(tr, null, null, wrapper(th -> th.text("Magnets"))); + th(tr, null, null, wrapper(th -> th.text("Download"))); + })); + })); + tbody(table, null, wrapper(tbody -> { + for (TorrentFile torrentFile : files.stream().sorted(sortNewFirst()).toList()) { + tr(tbody, null, wrapper(tr -> { + if (newTorrentFiles.contains(torrentFile)) { + tr.getAttributes().put("style", "color: #008000; font-weight: bold;"); + } + td(tr, null, wrapper(td -> td.text(torrentFile.name()))); + td(tr, null, wrapper(td -> td.text(torrentFile.size()))); + td(tr, null, wrapper(td -> td.text(torrentFile.fileCount()))); + td(tr, null, wrapper(td -> td.text(torrentFile.seedCount()))); + td(tr, null, wrapper(td -> td.text(torrentFile.leechCount()))); + td(tr, null, wrapper(td -> a(td, torrentFile.magnetUri(), null, null, wrapper(a -> a.text("Link"))))); + td(tr, null, wrapper(td -> a(td, torrentFile.downloadUri(), null, null, wrapper(a -> a.text("Link"))))); + })); + } + })); + })); + })); + })); } /** -- 2.7.4