1 package be
.nikiroo
.gofetch
.output
;
3 import be
.nikiroo
.gofetch
.data
.Comment
;
4 import be
.nikiroo
.gofetch
.data
.Story
;
5 import be
.nikiroo
.gofetch
.support
.BasicSupport
.Type
;
7 public class Html
extends Output
{
8 public Html(Type type
, String hostname
, String preselector
, int port
) {
9 super(type
, hostname
, preselector
, port
);
13 public String
getIndexHeader() {
14 String sel
= preselector
;
19 String gopherUrl
= "gopher://" + hostname
+ sel
+ ":" + port
;
21 return "<h1>News</h1>\n"//
22 + "<p>You will find here a few pages full of news, mirroring <a href='"
26 + "<p>They are simply scrapped from their associated webpage and updated a few times a day.</p>\n"//
31 public String
getIndexFooter() {
36 public String
exportHeader(Story story
) {
37 StringBuilder builder
= new StringBuilder();
41 builder
.append("<div class='story-header'>\n");
42 appendHtml(builder
, story
, true);
43 builder
.append("<hr/>\n");
44 builder
.append("</div>\n");
48 return builder
.toString();
52 public String
export(Story story
) {
53 StringBuilder builder
= new StringBuilder();
56 builder
.append("<div class='story'>\n");
57 appendHtml(builder
, story
, false);
58 builder
.append("<hr/>\n");
60 if (story
.getComments() != null) {
61 for (Comment comment
: story
.getComments()) {
62 appendHtml(builder
, comment
, " ");
66 builder
.append("</div>\n");
70 return builder
.toString();
73 private void appendPre(StringBuilder builder
) {
74 builder
.append("<!DOCTYPE html>\n");
75 builder
.append("<html>\n");
76 builder
.append("<head>\n");
77 builder
.append(" <meta http-equiv='content-type' content='text/html; charset=utf-8'>\n");
78 builder
.append(" <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n");
79 builder
.append("</head>\n");
80 builder
.append("<body>\n");
83 private void appendPost(StringBuilder builder
) {
84 builder
.append("</body>\n");
87 private void appendHtml(StringBuilder builder
, Comment comment
, String space
) {
89 .append("<div class='comment' style='display: block; margin-left: 80px'>\n");
90 builder
.append(space
).append(" <h2>").append(comment
.getTitle())
92 builder
.append(space
).append(" <div class='by'>")
93 .append(comment
.getAuthor()).append("</div>\n");
94 builder
.append(space
).append(" <div class='comment_content'>")
95 .append(comment
.getContent()).append("</div>\n");
96 for (Comment subComment
: comment
) {
97 appendHtml(builder
, subComment
, space
+ " ");
99 builder
.append(space
).append("</div>\n");
102 private StringBuilder
appendHtml(StringBuilder builder
, Story story
,
105 builder
.append(" <h1><a href='" + story
.getId() + ".html'>"
106 + story
.getTitle() + "</a></h1>\n");
108 builder
.append(" <h1>" + story
.getTitle() + "</h1>\n");
110 builder
.append(" <div class='details'>(" + story
.getDetails()
112 builder
.append(" <br/>\n");
115 builder
.append(" <ul>\n");
116 builder
.append(" <li>News link: <a href='"
117 + story
.getUrlInternal() + "'>" + story
.getUrlInternal()
119 builder
.append(" <li>Source link: <a href='"
120 + story
.getUrlExternal() + "'>" + story
.getUrlExternal()
122 builder
.append(" </ul>\n");
123 builder
.append(" <br/>\n");
126 builder
.append(" <div class='content'>\n");
128 builder
.append(" " + story
.getContent() + "\n");
130 builder
.append(" " + story
.getFullContent() + "\n");
132 builder
.append(" </div>\n");