Fix download order and comments/content storing
[gofetch.git] / src / be / nikiroo / gofetch / output / Html.java
index c087ef24d91ced582827d5cac32f9dcf8574424f..b0ef7e2e834698b66791fdbf6784ece99d935200 100644 (file)
@@ -1,7 +1,5 @@
 package be.nikiroo.gofetch.output;
 
-import java.util.List;
-
 import be.nikiroo.gofetch.data.Comment;
 import be.nikiroo.gofetch.data.Story;
 import be.nikiroo.gofetch.support.BasicSupport.Type;
@@ -13,16 +11,19 @@ public class Html extends Output {
 
        @Override
        public String getIndexHeader() {
-               String gopherUrl = "gopher://" + hostname + preselector + ":" + port;
+               String sel = preselector;
+               if (!sel.isEmpty()) {
+                       sel = "/1" + sel;
+               }
+
+               String gopherUrl = "gopher://" + hostname + sel + ":" + port;
 
                return "<h1>News</h1>\n"//
                                + "<p>You will find here a few pages full of news, mirroring <a href='"
                                + gopherUrl + "'>"
                                + gopherUrl
                                + "</a>.</p>\n"//
-                               + "<br/>\n"//
                                + "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
-                               + "<br/>\n"//
                ;
        }
 
@@ -32,7 +33,7 @@ public class Html extends Output {
        }
 
        @Override
-       public String export(Story story) {
+       public String exportHeader(Story story) {
                StringBuilder builder = new StringBuilder();
 
                builder.append("<div class='story-header'>\n");
@@ -44,15 +45,15 @@ public class Html extends Output {
        }
 
        @Override
-       public String export(Story story, List<Comment> comments) {
+       public String export(Story story) {
                StringBuilder builder = new StringBuilder();
 
                builder.append("<div class='story'>\n");
                appendHtml(builder, story, false);
                builder.append("<hr/>\n");
 
-               if (comments != null) {
-                       for (Comment comment : comments) {
+               if (story.getComments() != null) {
+                       for (Comment comment : story.getComments()) {
                                appendHtml(builder, comment, "  ");
                        }
                }
@@ -103,7 +104,11 @@ public class Html extends Output {
                }
 
                builder.append("        <div class='content'>\n");
-               builder.append("                " + story.getContent() + "\n");
+               if (resume) {
+                       builder.append("                " + story.getContent() + "\n");
+               } else {
+                       builder.append("                " + story.getFullContent() + "\n");
+               }
                builder.append("        </div>\n");
 
                return builder;