X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=war%2Fsrc%2Fmain%2Fjava%2Fpnews%2Fservlet%2FHTML.java;h=d20d415c33c9a5894be6019c3a90b992c0cb09cd;hb=975f59a4767a4fc4f298b87abf2a5b415e988726;hp=89ce7c5970122ab643f240ad601f890437929931;hpb=56c07f5de3319eb61182b7100855801644538e6f;p=pnews.git diff --git a/war/src/main/java/pnews/servlet/HTML.java b/war/src/main/java/pnews/servlet/HTML.java index 89ce7c5..d20d415 100644 --- a/war/src/main/java/pnews/servlet/HTML.java +++ b/war/src/main/java/pnews/servlet/HTML.java @@ -66,7 +66,12 @@ public class HTML { buf.append("
\n"); if (a.description != null) { buf.append("

"); - buf.append(a.description); + if (a.description.length() < 512) { + buf.append(a.description); + } else { + buf.append(a.description.substring(0, 512)); + buf.append("[..]"); + } buf.append("

"); } buf.append("
\n"); @@ -105,11 +110,20 @@ public class HTML { buf.append("\n"); } - public static String toHTML(List
articles, Category catActive, Config cfg, ArticleProvider provider) { + 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; - Category[] cats; List entities; + String cl; buf = new StringBuffer(); buf.append("\n"); @@ -123,26 +137,29 @@ public class HTML { buf.append("\n"); buf.append("\n"); - cats = cfg.getCategories(); - appendMenu(buf, catActive, cfg); try { entities = provider.getEntityStats(catActive); if (entities.size() > 0) { - buf.append("Hot topics: "); + buf.append("\n"); } } catch (IllegalArgumentException | FeedException | IOException e2) { LOG.log(Level.SEVERE, "Failed to get entities", e2);