replaced old /api/table_p.xml servlet with /Tables_p.xml to avoid double

code
This commit is contained in:
orbiter 2014-10-29 17:23:58 +01:00
parent 856da2712b
commit 3ffe19b85c
4 changed files with 25 additions and 73 deletions

View File

@ -26,17 +26,18 @@
<script type="text/javascript" src="js/sorttable.js"></script> <script type="text/javascript" src="js/sorttable.js"></script>
</head> </head>
<body id="Tables"> <body id="Tables">
#%env/templates/header.template%#
#%env/templates/submenuConfig.template%#
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
if (window.location.search.length > 1) { if (window.location.search.length > 1) {
document.write("<div id=\"api\">\<a href=\"api/table_p.xml" + window.location.search + "\"\><img src=\"env/grafics/api.png\" width=\"60\" height=\"40\" alt=\"API\"/></a></div>"); document.write("<div id=\"api\"><a href=\"/Tables_p.xml" + window.location.search + "\"\ id=\"apilink\"><img src=\"env/grafics/api.png\" width=\"60\" height=\"40\" alt=\"API\"/></a></div>");
} }
//]]> //]]>
</script> </script>
#%env/templates/header.template%#
#%env/templates/submenuConfig.template%#
#(showselection)#:: #(showselection)#::
<h2>Table Administration</h2> <h2>Table Administration</h2>
<form action="Tables_p.html" method="get" accept-charset="UTF-8"> <form action="Tables_p.html" method="get" accept-charset="UTF-8">

View File

@ -36,10 +36,14 @@ import net.yacy.server.serverSwitch;
public class Tables_p { 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 Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects(); 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("showtable", 0);
prop.put("showedit", 0); prop.put("showedit", 0);
prop.put("showselection", 0); prop.put("showselection", 0);
@ -164,6 +168,7 @@ public class Tables_p {
Tables.Row row; Tables.Row row;
boolean dark = true; boolean dark = true;
byte[] cell; byte[] cell;
prop.putXML("showtable_" + count + "_table", table); // only used in XML
while (mapIterator.hasNext() && count < maxcount) { while (mapIterator.hasNext() && count < maxcount) {
row = mapIterator.next(); row = mapIterator.next();
if (row == null) continue; 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 + "_pk", UTF8.String(row.getPK()));
prop.put("showtable_list_" + count + "_count", count); prop.put("showtable_list_" + count + "_count", count);
prop.put("showtable_list_" + count + "_table", table); // tablename for edit link prop.put("showtable_list_" + count + "_table", table); // tablename for edit link
for (int i = 0; i < columns.size(); i++) { String col;
cell = row.get(columns.get(i)); if (xml) {
prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cell == null ? "" : UTF8.String(cell)); 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()); prop.put("showtable_list_" + count + "_columns", columns.size());
count++; count++;

View File

@ -1,41 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaCy '#[clientname]#': Table Viewer</title>
#(showtable)#::
<link rel="alternate" type="application/xml" title="Table" href="table_p.xml?table=#[table]#&pk=" />
#(/showtable)#
#%env/templates/metas.template%#
</head>
<script type="text/javascript" src="/js/sorttable.js"></script>
<body id="Table">
#(showtable)#::
<form action="/Tables_p.html" method="post" target="_parent" enctype="multipart/form-data" accept-charset="UTF-8" name="tablelisting">
<fieldset>
<legend><label for="table">Table: '#[table]#'</label></legend>
<table class="sortable" border="0">
<tr class="TableHeader" valign="bottom">
#(showpk)#::<td>PK</td>#(/showpk)#
#{columns}#
<td>#[header]#</td>
#{/columns}#
</tr>
#{list}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
#(showpk)#::<td>#[pk]#</td>#(/showpk)#
#{columns}#
<td align="left">#[cell]#</td>
#{/columns}#
</tr>
#{/list}#
</table>
<p>
<input type="hidden" name="table" value="#[table]#" />
<input type="hidden" name="num" value="#[num]#" />
<input type="submit" name="edittable" value="Edit Table" class="btn btn-primary"/>
</p>
</fieldset>
</form>
#(/showtable)#
</body>
</html>

View File

@ -1,24 +0,0 @@
<tables count="#[tablecount]#">
#(showtable)#
#{tables}#
<table name="#[table]#" count="#[num]#"/>
#{/tables}#
::
<table name="#[table]#" count="#[num]#">
<columns>
#{columns}#
<column name="#[header]#" />
#{/columns}#
</columns>
<rows>
#{list}#
<row#(showpk)#:: key="#[pk]#"#(/showpk)#>
#{columns}#
<column name="#[column]#">#[cell]#</column>
#{/columns}#
</row>
#{/list}#
</rows>
</table>
#(/showtable)#
</tables>