6 private static void appendA(StringBuffer buf, String child, String href, String cl) {
7 buf.append("<a href='");
11 buf.append(" class='");
20 private static void appendDiv(StringBuffer buf, String child) {
23 buf.append("</div>\n");
26 private static void appendP(StringBuffer buf, String child) {
32 private static void append(StringBuffer buf, Article a) {
33 buf.append("<div class='article'>\n");
36 if (a.thumbnail != null) {
37 buf.append("<img class='left' src='");
38 buf.append(a.thumbnail);
41 appendA(buf, a.title, "redirect?url="+a.link, null);
42 buf.append("</h2>\n");
44 buf.append("<div class='article-info'>" + a.website + " - " + a.publicationDate + "</div>");
46 if (a.description != null) {
48 buf.append(a.description);
52 buf.append("</div>\n");
55 private static void appendMenu(StringBuffer buf, Category catActive) {
58 buf.append("<nav>\n");
61 for (Category cat: Category.values()) {
64 if (cat.equals(catActive))
69 appendA(buf, cat.getId(), cat.getId(), cl);
73 buf.append("</ul>\n");
74 buf.append("</nav>\n");
77 public static String toHTML(List<Article> articles, Category catActive) {
80 buf = new StringBuffer();
81 buf.append("<!DOCTYPE html>\n");
82 buf.append("<html lang='fr'>\n");
83 buf.append("<head>\n");
84 buf.append("<meta charset=\"UTF-8\">\n");
85 buf.append("<link rel='stylesheet' href='style.css' />\n");
86 buf.append("<title>PNews</title>\n");
87 buf.append("</head>\n");
88 buf.append("<body>\n");
90 appendMenu(buf, catActive);
92 for (Article e: articles)
95 buf.append("</body>\n");
96 buf.append("</html>\n");
98 return buf.toString();