read config from json. Many refactoring to prepare multi language support
[pnews.git] / war / src / main / java / pnews / servlet / HTML.java
index 7b7b142..e9aae26 100644 (file)
@@ -53,7 +53,7 @@ public class HTML {
                buf.append("<div class='article-content'>\n");
 
                buf.append("<div class='article-title'>\n");
-               appendA(buf, a.title, "redirect?url=" + URLEncoder.encode(a.link, "UTF-8"), null);
+               appendA(buf, a.title, "/redirect?url=" + URLEncoder.encode(a.link, "UTF-8"), null);
                buf.append("</div>\n");
                
                buf.append("<div class='article-info'>" + a.website + " - " + a.publicationDate + "</div>");
@@ -71,13 +71,13 @@ public class HTML {
                buf.append("</div>\n");         
        }
        
-       private static void appendMenu(StringBuffer buf, Category catActive) {
+       private static void appendMenu(StringBuffer buf, Category catActive, Category[] cats) {
                String cl;
                
                buf.append("<nav>\n");
                buf.append("<ul>\n");
 
-               for (Category cat: Category.values()) {
+               for (Category cat: cats) {
                        buf.append("<li>");
                        
                        if (cat.equals(catActive))
@@ -85,7 +85,7 @@ public class HTML {
                        else
                                cl = null;
                        
-                       appendA(buf, cat.getId(), cat.getId(), cl);
+                       appendA(buf, cat.getName(), cat.getURL(), cl);
                        buf.append("</li>");
                }
                
@@ -93,7 +93,7 @@ public class HTML {
                buf.append("</nav>\n");
        }
        
-       public static String toHTML(List<Article> articles, Category catActive) {
+       public static String toHTML(List<Article> articles, Category catActive, Category[] cats) {
                StringBuffer buf;
                int i;
                
@@ -102,14 +102,14 @@ public class HTML {
                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("<link rel='stylesheet' href='/style.css' />\n");
                buf.append("<title>");
                buf.append(catActive.getTitle());
                buf.append(" - PNews</title>\n");
                buf.append("</head>\n");
                buf.append("<body>\n");
                
-               appendMenu(buf, catActive);
+               appendMenu(buf, catActive, cats);
                
                i = 0;
                for (Article e: articles) {