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
generated is better than vendor in this case
[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 5b022d1f8789224a1ea11514bc55ac42da01b47f..a4452643ccf055d6584d74781771370b7c1c8e58 100644
(file)
--- a/
src/be/nikiroo/gofetch/output/Html.java
+++ b/
src/be/nikiroo/gofetch/output/Html.java
@@
-2,7
+2,9
@@
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.BasicSupport;
+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) {
@@
-10,7
+12,7
@@
public class Html extends Output {
}
@Override
}
@Override
- public String getIndexHeader() {
+ public String get
Main
IndexHeader() {
String sel = preselector;
if (!sel.isEmpty()) {
sel = "/1" + sel;
String sel = preselector;
if (!sel.isEmpty()) {
sel = "/1" + sel;
@@
-18,17
+20,34
@@
public class Html extends Output {
String gopherUrl = "gopher://" + hostname + sel + ":" + port;
String gopherUrl = "gopher://" + hostname + sel + ":" + port;
- return "<h1>News</h1>\n"//
+ StringBuilder builder = new StringBuilder();
+ appendPre(builder);
+
+ builder.append("<h2>News</h2>\n"//
+ "<p>You will find here a few pages full of news, mirroring <a href='"
+ gopherUrl + "'>"
+ gopherUrl
+ "</a>.</p>\n"//
+ "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
+ "<p>You will find here a few pages full of news, mirroring <a href='"
+ gopherUrl + "'>"
+ gopherUrl
+ "</a>.</p>\n"//
+ "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
- ;
+ );
+
+ appendPost(builder);
+
+ return builder.toString();
}
@Override
}
@Override
- public String getIndexFooter() {
+ public String getMainIndexFooter() {
+ return "";
+ }
+
+ @Override
+ public String getIndexHeader(BasicSupport support) {
+ return "<h1>" + support.getDescription() + "</h1>\n<br/><br/>";
+ }
+
+ @Override
+ public String getIndexFooter(BasicSupport support) {
return "";
}
return "";
}
@@
-76,6
+95,9
@@
public class Html extends Output {
builder.append("<head>\n");
builder.append(" <meta http-equiv='content-type' content='text/html; charset=utf-8'>\n");
builder.append(" <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n");
builder.append("<head>\n");
builder.append(" <meta http-equiv='content-type' content='text/html; charset=utf-8'>\n");
builder.append(" <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n");
+ builder.append(" <style type='text/css'>\n");
+ builder.append(" body { margin: 1em 15%; }\n");
+ builder.append(" </style>\n");
builder.append("</head>\n");
builder.append("<body>\n");
}
builder.append("</head>\n");
builder.append("<body>\n");
}
@@
-87,12
+109,16
@@
public class Html extends Output {
private void appendHtml(StringBuilder builder, Comment comment, String space) {
builder.append(space)
.append("<div class='comment' style='display: block; margin-left: 80px'>\n");
private void appendHtml(StringBuilder builder, Comment comment, String space) {
builder.append(space)
.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(" <h3>").append(comment.getTitle())
+ .append("</h3>\n");
+ 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 + " ");
}
@@
-102,17
+128,25
@@
public class Html extends Output {
private StringBuilder appendHtml(StringBuilder builder, Story story,
boolean resume) {
if (resume) {
private StringBuilder appendHtml(StringBuilder builder, Story story,
boolean resume) {
if (resume) {
- builder.append(" <h
1
><a href='" + story.getId() + ".html'>"
- + story.getTitle() + "</a></h
1
>\n");
+ builder.append(" <h
2
><a href='" + story.getId() + ".html'>"
+ + story.getTitle() + "</a></h
2
>\n");
} else {
} else {
- builder.append(" <h1>" + story.getTitle() + "</h1>\n");
+ builder.append(" <h2>" + story.getTitle() + "</h2>\n");
+ }
+
+ builder.append(" <div class='details'>");
+ if (story.getDetails() != null && !story.getDetails().isEmpty()) {
+ builder.append("(")
+ .append(StringUtils.xmlEscape(story.getDetails()))
+ .append(")");
}
}
- builder.append(" <div class='details'>(" + story.getDetails()
- + ")</div>\n");
+ builder.append("</div>\n");
builder.append(" <br/>\n");
if (!resume) {
builder.append(" <ul>\n");
builder.append(" <br/>\n");
if (!resume) {
builder.append(" <ul>\n");
+ builder.append(" <li>Reference: <a href=''>" + story.getId()
+ + "</a></li>\n");
builder.append(" <li>News link: <a href='"
+ story.getUrlInternal() + "'>" + story.getUrlInternal()
+ "</a></li>\n");
builder.append(" <li>News link: <a href='"
+ story.getUrlInternal() + "'>" + story.getUrlInternal()
+ "</a></li>\n");
@@
-123,11
+157,16
@@
public class Html extends Output {
builder.append(" <br/>\n");
}
builder.append(" <br/>\n");
}
- builder.append(" <div class='content'>\n");
+ builder.append(" <div class='content'
style='text-align: justify'
>\n");
if (resume) {
if (resume) {
- builder.append(" " + story.getContent() + "\n");
+ builder.append(" "
+ + StringUtils.xmlEscape(story.getContent()).replace("\n",
+ "<br/>") + "\n");
} else {
} else {
- builder.append(" " + story.getFullContent() + "\n");
+ builder.append(" "
+ + StringUtils.xmlEscape(story.getFullContent())
+ .replace("\n", "<br/>").replace("[ ", "<h3>")
+ .replace(" ]", "</h3>") + "\n");
}
builder.append(" </div>\n");
}
builder.append(" </div>\n");