From 3ffe19b85cb6f2c1d26922eb61ca73a42096e8e9 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 29 Oct 2014 17:23:58 +0100 Subject: [PATCH] replaced old /api/table_p.xml servlet with /Tables_p.xml to avoid double code --- htroot/Tables_p.html | 9 +++++---- htroot/Tables_p.java | 24 ++++++++++++++++++++---- htroot/api/table_p.html | 41 ----------------------------------------- htroot/api/table_p.xml | 24 ------------------------ 4 files changed, 25 insertions(+), 73 deletions(-) delete mode 100644 htroot/api/table_p.html delete mode 100644 htroot/api/table_p.xml diff --git a/htroot/Tables_p.html b/htroot/Tables_p.html index a7e7e725d..efbeb3530 100644 --- a/htroot/Tables_p.html +++ b/htroot/Tables_p.html @@ -26,17 +26,18 @@ - + + #%env/templates/header.template%# + #%env/templates/submenuConfig.template%# + - #%env/templates/header.template%# - #%env/templates/submenuConfig.template%# #(showselection)#::

Table Administration

diff --git a/htroot/Tables_p.java b/htroot/Tables_p.java index 1f6a5ac05..4cf3025fe 100644 --- a/htroot/Tables_p.java +++ b/htroot/Tables_p.java @@ -36,10 +36,14 @@ import net.yacy.server.serverSwitch; public class Tables_p { - public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) { + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); + final String ext = header.get("EXT", ""); + final boolean json = ext.equals("json"); + final boolean xml = ext.equals("xml"); + prop.put("showtable", 0); prop.put("showedit", 0); prop.put("showselection", 0); @@ -164,6 +168,7 @@ public class Tables_p { Tables.Row row; boolean dark = true; byte[] cell; + prop.putXML("showtable_" + count + "_table", table); // only used in XML while (mapIterator.hasNext() && count < maxcount) { row = mapIterator.next(); if (row == null) continue; @@ -173,9 +178,20 @@ public class Tables_p { prop.put("showtable_list_" + count + "_pk", UTF8.String(row.getPK())); prop.put("showtable_list_" + count + "_count", count); prop.put("showtable_list_" + count + "_table", table); // tablename for edit link - for (int i = 0; i < columns.size(); i++) { - cell = row.get(columns.get(i)); - prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cell == null ? "" : UTF8.String(cell)); + String col; + if (xml) { + for (int i = 0; i < columns.size(); i++) { + col = columns.get(i); + cell = row.get(col); + prop.putXML("showtable_list_" + count + "_columns_" + i + "_cell", cell == null ? "" : UTF8.String(cell)); + prop.putXML("showtable_list_" + count + "_columns_" + i + "_col", col); + } + } else { + for (int i = 0; i < columns.size(); i++) { + col = columns.get(i); + cell = row.get(col); + prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cell == null ? "" : UTF8.String(cell)); + } } prop.put("showtable_list_" + count + "_columns", columns.size()); count++; diff --git a/htroot/api/table_p.html b/htroot/api/table_p.html deleted file mode 100644 index 0d1e76b66..000000000 --- a/htroot/api/table_p.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - YaCy '#[clientname]#': Table Viewer - #(showtable)#:: - - #(/showtable)# - #%env/templates/metas.template%# - - - - #(showtable)#:: - -
- - - - #(showpk)#::#(/showpk)# - #{columns}# - - #{/columns}# - - #{list}# - - #(showpk)#::#(/showpk)# - #{columns}# - - #{/columns}# - - #{/list}# -
PK#[header]#
#[pk]##[cell]#
-

- - - -

-
-
- #(/showtable)# - - diff --git a/htroot/api/table_p.xml b/htroot/api/table_p.xml deleted file mode 100644 index 2d447b287..000000000 --- a/htroot/api/table_p.xml +++ /dev/null @@ -1,24 +0,0 @@ - -#(showtable)# - #{tables}# - - #{/tables}# -:: -
- - #{columns}# - - #{/columns}# - - - #{list}# - - #{columns}# - #[cell]# - #{/columns}# - - #{/list}# - -
-#(/showtable)# -
\ No newline at end of file