➖ Remove commons-lang3 dependency
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Dec 2025 19:52:15 +0000 (20:52 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 7 Dec 2025 17:43:20 +0000 (18:43 +0100)
build.gradle
src/main/java/net/pterodactylus/rhynodge/filters/comics/KevinAndKellComicFilter.java
src/main/java/net/pterodactylus/rhynodge/states/TorrentState.java

index aebd2e3..a34a665 100644 (file)
@@ -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'
index 1b98739..3b0e657 100644 (file)
@@ -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<String> extractTitle(Document document) {
                Elements captionElements = document.select("#comicstripCaption");
-               return Optional.ofNullable(StringEscapeUtils.unescapeHtml4(captionElements.text()));
+               return Optional.of(captionElements.text());
        }
 
        @Override
index 658986e..4c30d45 100644 (file)
@@ -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<TorrentFile>
 
        @Override
        protected String htmlText() {
-               StringBuilder htmlBuilder = new StringBuilder();
-               htmlBuilder.append("<html><body>\n");
-               htmlBuilder.append("<table>\n<caption>All Known Torrents</caption>\n");
-               htmlBuilder.append("<thead>\n");
-               htmlBuilder.append("<tr>");
-               htmlBuilder.append("<th>Filename</th>");
-               htmlBuilder.append("<th>Size</th>");
-               htmlBuilder.append("<th>File(s)</th>");
-               htmlBuilder.append("<th>Seeds</th>");
-               htmlBuilder.append("<th>Leechers</th>");
-               htmlBuilder.append("<th>Magnet</th>");
-               htmlBuilder.append("<th>Download</th>");
-               htmlBuilder.append("</tr>\n");
-               htmlBuilder.append("</thead>\n");
-               htmlBuilder.append("<tbody>\n");
-               for (TorrentFile torrentFile : files.stream().sorted(sortNewFirst()).toList()) {
-                       if (newTorrentFiles.contains(torrentFile)) {
-                               htmlBuilder.append("<tr style=\"color: #008000; font-weight: bold;\">");
-                       } else {
-                               htmlBuilder.append("<tr>");
-                       }
-                       htmlBuilder.append("<td>").append(StringEscapeUtils.escapeHtml4(torrentFile.name())).append("</td>");
-                       htmlBuilder.append("<td>").append(StringEscapeUtils.escapeHtml4(torrentFile.size())).append("</td>");
-                       htmlBuilder.append("<td>").append(torrentFile.fileCount()).append("</td>");
-                       htmlBuilder.append("<td>").append(torrentFile.seedCount()).append("</td>");
-                       htmlBuilder.append("<td>").append(torrentFile.leechCount()).append("</td>");
-                       htmlBuilder.append("<td><a href=\"").append(StringEscapeUtils.escapeHtml4(torrentFile.magnetUri())).append("\">Link</a></td>");
-                       htmlBuilder.append("<td><a href=\"").append(StringEscapeUtils.escapeHtml4(torrentFile.downloadUri())).append("\">Link</a></td>");
-                       htmlBuilder.append("</tr>\n");
-               }
-               htmlBuilder.append("</tbody>\n");
-               htmlBuilder.append("</table>\n");
-               htmlBuilder.append("</body></html>\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")))));
+                                                       }));
+                                               }
+                                       }));
+                               }));
+                       }));
+               }));
        }
 
        /**