6 private static void appendA(StringBuffer buf, String child, String href) {
7 buf.append("<a href='");
14 private static void appendDiv(StringBuffer buf, String child) {
17 buf.append("</div>\n");
20 private static void appendP(StringBuffer buf, String child) {
26 private static void append(StringBuffer buf, Article entry) {
28 buf.append("<section>\n");
30 appendA(buf, entry.title, entry.link);
31 buf.append("</h2>\n");
33 buf.append("<img class='left' src='");
34 buf.append(entry.thumbnail);
38 buf.append(entry.description);
41 buf.append("</section>\n");
45 private static void appendMenu(StringBuffer buf) {
46 buf.append("<nav>\n");
49 for (Category cat: Category.values()) {
51 appendA(buf, cat.getId(), cat.getId() + ".html");
55 buf.append("</ul>\n");
56 buf.append("</nav>\n");
59 public static String toHTML(List<Article> articles) {
62 buf = new StringBuffer();
63 buf.append("<!DOCTYPE html>\n");
64 buf.append("<html lang='fr'>\n");
65 buf.append("<head>\n");
66 buf.append("<meta charset=\"UTF-8\">\n");
67 buf.append("<link rel='stylesheet' href='style.css' />\n");
68 buf.append("<title>PNews</title>\n");
69 buf.append("</head>\n");
70 buf.append("<body>\n");
74 for (Article e: articles)
77 buf.append("</body>\n");
78 buf.append("</html>\n");
80 return buf.toString();