Put HTML generation into its own method.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Mar 2013 06:21:11 +0000 (07:21 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Mar 2013 06:21:11 +0000 (07:21 +0100)
src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java

index 45c290f..1b64c5b 100644 (file)
@@ -121,16 +121,28 @@ public class NewComicTrigger implements Trigger {
                html.append("<body>");
 
                for (Comic newComic : newComics) {
-                       html.append("<h1>").append(StringEscapeUtils.escapeHtml4(newComic.title())).append("</h1>\n");
-                       for (Strip strip : newComic) {
-                               html.append("<div><img src=\"").append(StringEscapeUtils.escapeHtml4(strip.imageUrl()));
-                               html.append("\" alt=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
-                               html.append("\" title=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
-                               html.append("\"></div>\n");
-                       }
+                       generateComicHtml(html, newComic);
                }
 
                return html.append("</body>").toString();
        }
 
+       /**
+        * Generates the HTML for a single comic.
+        *
+        * @param html
+        *              The string builder to append the HTML to
+        * @param comic
+        *              The comic to render
+        */
+       private void generateComicHtml(StringBuilder html, Comic comic) {
+               html.append("<h1>").append(StringEscapeUtils.escapeHtml4(comic.title())).append("</h1>\n");
+               for (Strip strip : comic) {
+                       html.append("<div><img src=\"").append(StringEscapeUtils.escapeHtml4(strip.imageUrl()));
+                       html.append("\" alt=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
+                       html.append("\" title=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
+                       html.append("\"></div>\n");
+               }
+       }
+
 }