X-Git-Url: https://wpitchoune.net/gitweb/?a=blobdiff_plain;f=war%2Fsrc%2Fmain%2Fjava%2Fpnews%2Fservlet%2FHTML.java;h=72f0b4b3b514573f650f09701220c0b7b73ec241;hb=511fe72ae8bad61a60f738c01819af58510ae9d3;hp=ad0c24a6266737065289e7e9c1b63b495fc46508;hpb=25efa841b409dc33c640f1baac14e46fb1ef3b3b;p=pnews.git
diff --git a/war/src/main/java/pnews/servlet/HTML.java b/war/src/main/java/pnews/servlet/HTML.java
index ad0c24a..72f0b4b 100644
--- a/war/src/main/java/pnews/servlet/HTML.java
+++ b/war/src/main/java/pnews/servlet/HTML.java
@@ -1,13 +1,18 @@
package pnews.servlet;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.rometools.rome.io.FeedException;
+
import pnews.Article;
import pnews.Category;
+import pnews.EntityStat;
+import pnews.Language;
public class HTML {
private static final String CLASS_NAME= HTML.class.getName();
@@ -71,13 +76,16 @@ public class HTML {
buf.append("\n");
}
- private static void appendMenu(StringBuffer buf, Category catActive, Category[] cats) {
+ private static void appendMenu(StringBuffer buf, Category catActive, Config cfg) {
String cl;
buf.append("\n");
}
- public static String toHTML(List articles, Category catActive, Category[] cats) {
+ private static String toURL(Category catActive, String entity) {
+ try {
+ return catActive.getURL() + "?entity=" + URLEncoder.encode(entity, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ LOG.log(Level.SEVERE, "Failed to generate link to entity " + entity, e);
+ return catActive.getURL();
+ }
+ }
+
+ public static String toHTML(List articles, Category catActive, String entityActive, Config cfg, ArticleProvider provider) {
StringBuffer buf;
int i;
+ List entities;
+ String cl;
buf = new StringBuffer();
buf.append("\n");
@@ -109,7 +132,33 @@ public class HTML {
buf.append("\n");
buf.append("\n");
- appendMenu(buf, catActive, cats);
+ appendMenu(buf, catActive, cfg);
+
+ try {
+ entities = provider.getEntityStats(catActive);
+
+ if (entities.size() > 0) {
+ buf.append("\n");
+ }
+ } catch (IllegalArgumentException | FeedException | IOException e2) {
+ LOG.log(Level.SEVERE, "Failed to get entities", e2);
+ }
i = 0;
for (Article e: articles) {