import java.util.List;
-import com.rometools.rome.feed.synd.SyndEntry;
-import com.rometools.rome.feed.synd.SyndFeed;
-
public class HTML {
private static void appendA(StringBuffer buf, String child, String href) {
buf.append("<a href='");
buf.append("</div>\n");
}
- private static void append(StringBuffer buf, SyndEntry entry) {
- buf.append("<div>");
- appendA(buf, entry.getTitle(), entry.getLink());
- buf.append("</div>\n");
+ private static void appendP(StringBuffer buf, String child) {
+ buf.append("<p>");
+ buf.append(child);
+ buf.append("</p>\n");
+ }
+
+ private static void append(StringBuffer buf, Article entry) {
+
+ buf.append("<section>\n");
+ buf.append("<h2>");
+ appendA(buf, entry.title, entry.link);
+ buf.append("</h2>\n");
+
+ buf.append("<img class='left' src='");
+ buf.append(entry.thumbnail);
+ buf.append("'/>\n");
+
+ buf.append("<p>");
+ buf.append(entry.description);
+ buf.append("</p>");
+
+ buf.append("</section>\n");
- appendDiv(buf, entry.getPublishedDate().toString());
- appendDiv(buf, entry.getDescription().getValue());
}
- public static void append(StringBuffer buf, SyndFeed feed) {
- for (SyndEntry e: feed.getEntries()) {
- append(buf, e);
+ private static void appendMenu(StringBuffer buf) {
+ buf.append("<nav>\n");
+ buf.append("<ul>\n");
+
+ for (Category cat: Category.values()) {
+ buf.append("<li>");
+ appendA(buf, cat.getId(), cat.getId() + ".html");
+ buf.append("</li>");
}
+
+ buf.append("</ul>\n");
+ buf.append("</nav>\n");
}
- public static String toHTML(List<SyndFeed> feeds) {
+ public static String toHTML(List<Article> articles) {
StringBuffer buf;
buf = new StringBuffer();
buf.append("<!DOCTYPE html>\n");
- buf.append("<html>\n");
+ buf.append("<html lang='fr'>\n");
buf.append("<head>\n");
buf.append("<meta charset=\"UTF-8\">\n");
+ buf.append("<link rel='stylesheet' href='style.css' />\n");
+ buf.append("<title>PNews</title>\n");
buf.append("</head>\n");
buf.append("<body>\n");
- for (SyndFeed e: feeds)
+ appendMenu(buf);
+
+ for (Article e: articles)
append(buf, e);
buf.append("</body>\n");