git://git.nikiroo.be
/
gofetch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Small gopher client in SH
[gofetch.git]
/
src
/
be
/
nikiroo
/
gofetch
/
output
/
Html.java
diff --git
a/src/be/nikiroo/gofetch/output/Html.java
b/src/be/nikiroo/gofetch/output/Html.java
index cdc77a461056887ef1cafad7e6abf7d19019d1ab..385df8bf8da919416ccf672a623fa9288c0ab585 100644
(file)
--- a/
src/be/nikiroo/gofetch/output/Html.java
+++ b/
src/be/nikiroo/gofetch/output/Html.java
@@
-2,7
+2,8
@@
package be.nikiroo.gofetch.output;
import be.nikiroo.gofetch.data.Comment;
import be.nikiroo.gofetch.data.Story;
import be.nikiroo.gofetch.data.Comment;
import be.nikiroo.gofetch.data.Story;
-import be.nikiroo.gofetch.support.BasicSupport.Type;
+import be.nikiroo.gofetch.support.Type;
+import be.nikiroo.utils.StringUtils;
public class Html extends Output {
public Html(Type type, String hostname, String preselector, int port) {
public class Html extends Output {
public Html(Type type, String hostname, String preselector, int port) {
@@
-17,7
+18,7
@@
public class Html extends Output {
}
String gopherUrl = "gopher://" + hostname + sel + ":" + port;
}
String gopherUrl = "gopher://" + hostname + sel + ":" + port;
-
+
StringBuilder builder = new StringBuilder();
appendPre(builder);
StringBuilder builder = new StringBuilder();
appendPre(builder);
@@
-28,9
+29,9
@@
public class Html extends Output {
+ "</a>.</p>\n"//
+ "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
);
+ "</a>.</p>\n"//
+ "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
);
-
+
appendPost(builder);
appendPost(builder);
-
+
return builder.toString();
}
return builder.toString();
}
@@
-99,10
+100,14
@@
public class Html extends Output {
.append("<div class='comment' style='display: block; margin-left: 80px'>\n");
builder.append(space).append(" <h2>").append(comment.getTitle())
.append("</h2>\n");
.append("<div class='comment' style='display: block; margin-left: 80px'>\n");
builder.append(space).append(" <h2>").append(comment.getTitle())
.append("</h2>\n");
- builder.append(space).append(" <div class='by'>")
+ builder.append(space)
+ .append(" <div class='by' style='font-style: italic;'>")
.append(comment.getAuthor()).append("</div>\n");
.append(comment.getAuthor()).append("</div>\n");
- builder.append(space).append(" <div class='comment_content'>")
- .append(comment.getContent()).append("</div>\n");
+ builder.append(space).append(" <div class='comment_content'>");
+ for (String line : comment.getContentLines()) {
+ builder.append("<p>" + line + "</p>");
+ }
+ builder.append("</div>\n");
for (Comment subComment : comment) {
appendHtml(builder, subComment, space + " ");
}
for (Comment subComment : comment) {
appendHtml(builder, subComment, space + " ");
}
@@
-117,8
+122,14
@@
public class Html extends Output {
} else {
builder.append(" <h1>" + story.getTitle() + "</h1>\n");
}
} else {
builder.append(" <h1>" + story.getTitle() + "</h1>\n");
}
- builder.append(" <div class='details'>(" + story.getDetails()
- + ")</div>\n");
+
+ builder.append(" <div class='details'>");
+ if (story.getDetails() != null && !story.getDetails().isEmpty()) {
+ builder.append("(")
+ .append(StringUtils.xmlEscape(story.getDetails()))
+ .append(")");
+ }
+ builder.append("</div>\n");
builder.append(" <br/>\n");
if (!resume) {
builder.append(" <br/>\n");
if (!resume) {
@@
-135,9
+146,13
@@
public class Html extends Output {
builder.append(" <div class='content' style='text-align: justify'>\n");
if (resume) {
builder.append(" <div class='content' style='text-align: justify'>\n");
if (resume) {
- builder.append(" " + story.getContent() + "\n");
+ builder.append(" " + StringUtils.xmlEscape(story.getContent())
+ + "\n");
} else {
} else {
- builder.append(" " + story.getFullContent() + "\n");
+ builder.append(" "
+ + StringUtils.xmlEscape(story.getFullContent())
+ .replace("\n", "<br/>").replace("[ ", "<h2>")
+ .replace(" ]", "</h2>") + "\n");
}
builder.append(" </div>\n");
}
builder.append(" </div>\n");