Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Voormann2021-01-22 09:47:52 +0000
committerAndrey Loskutov2021-01-27 21:38:38 +0000
commitf9c2dd363c2ddff1f688d8895c32832385b75150 (patch)
tree1eb6833c7f702b336639fb77591e3523a4562f8a
parentf3152f41bbc201f34f85902e34d8e2343b2f2acb (diff)
downloadeclipse.platform.ua-f9c2dd363c2ddff1f688d8895c32832385b75150.tar.gz
eclipse.platform.ua-f9c2dd363c2ddff1f688d8895c32832385b75150.tar.xz
eclipse.platform.ua-f9c2dd363c2ddff1f688d8895c32832385b75150.zip
Bug 570260 - Improve modernized help UI prototype of Eclipse 4.19I20210127-1800
In "index.jsp" load modernized help UI cover page as bundle resource instead of from an URL with the same origin for security reasons and to avoid problems when having more than one infocenter with the same origin. This changes the activation to ("...=true" instead of "...=m/index.html"): -Dorg.eclipse.help.webapp.experimental.ui=true Change-Id: I3158e296fdd0bb2fbfa877a87538d41011b34bb1 Signed-off-by: Holger Voormann <eclipse@voormann.de>
-rw-r--r--org.eclipse.help.webapp/index.jsp16
-rw-r--r--org.eclipse.help.webapp/m/README.md11
2 files changed, 15 insertions, 12 deletions
diff --git a/org.eclipse.help.webapp/index.jsp b/org.eclipse.help.webapp/index.jsp
index 117fc46e0..7233954e2 100644
--- a/org.eclipse.help.webapp/index.jsp
+++ b/org.eclipse.help.webapp/index.jsp
@@ -14,6 +14,7 @@
<%@ page import="org.eclipse.help.internal.webapp.data.*" errorPage="/advanced/err.jsp" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.Scanner" %>
<%@ page import="java.net.URL" %>
+<%@ page import="org.eclipse.core.runtime.Platform" %>
<%
request.setCharacterEncoding("UTF-8");
ServerState.webappStarted(application,request, response);
@@ -42,17 +43,14 @@
if (request.getParameter("legacy") == null && experimentalUi != null) {
try {
// In a JSP forwarding to non JSP resources does not work
- // (page is shown, but "java.lang.IllegalStateException: STREAM" is thrown)
- // so read from URL instead:
- URL baseUrl = new URL(request.getRequestURL().toString());
- URL forwardUrl = new URL(baseUrl, experimentalUi);
- // Same-origin policy
- if (!baseUrl.getProtocol().equals(forwardUrl.getProtocol())
- || !baseUrl.getHost().equals(forwardUrl.getHost())
- || baseUrl.getPort() != forwardUrl.getPort()) throw new Exception();
+ // (page is shown, but "java.lang.IllegalStateException: STREAM" is thrown),
+ // so read it as plug-in resource instead:
+ String resource = experimentalUi.equalsIgnoreCase("true") ? "org.eclipse.help.webapp/m/index.html" : experimentalUi;
+ String[] bundleAndPath = resource.split("/", 2);
+ URL resourceAsUrl = Platform.getBundle(bundleAndPath[0]).getResource(bundleAndPath[1]);
// Read it as InputStream and convert it to a String
// (by using a Scanner with a delimiter that cannot be found: \A - start of input)
- Scanner scanAll = new Scanner(forwardUrl.openStream()).useDelimiter("\\A");
+ Scanner scanAll = new Scanner(resourceAsUrl.openStream()).useDelimiter("\\A");
response.getWriter().write(scanAll.hasNext() ? scanAll.next() : "");
} catch (Exception e) {
// Experimental UI resource not found, so fall back to legacy UI
diff --git a/org.eclipse.help.webapp/m/README.md b/org.eclipse.help.webapp/m/README.md
index 5f90459a8..30e66bfa8 100644
--- a/org.eclipse.help.webapp/m/README.md
+++ b/org.eclipse.help.webapp/m/README.md
@@ -29,7 +29,7 @@ Improvements compared to the legacy UI:
This prototype can be activated with the following Java property:
- -Dorg.eclipse.help.webapp.experimental.ui=m/index.html
+ -Dorg.eclipse.help.webapp.experimental.ui=true
To test, modify and/or customize this prototype, the files in this folder can
be put in a separate plugin (in `index.html` the links to the JavaScript and
@@ -38,7 +38,12 @@ CSS file have to be changed from `m/...` to something like
the plugin has the symbolic name `com.example.my_plugin`; using the raw
topic help link `rtopic/<plugin>/<optional-path>/<file>`):
- -Dorg.eclipse.help.webapp.experimental.ui=rtopic/com.example.my_plugin/index.html
+ -Dorg.eclipse.help.webapp.experimental.ui=<plugin>/<optional-path>/<file>
+
+For example, when the plugin has the symbolic name `com.example.my_plugin` with
+`index.html` in the folder `customized-help`:
+
+ -Dorg.eclipse.help.webapp.experimental.ui=com.example.my_plugin/customized-help/index.html
## Further development
@@ -54,7 +59,7 @@ buttons and bookmark support) and to determine the initial content page.
* Print chapter
* [`/advanced/print.jsp`](127.0.0.1:49999/help/advanced/print.jsp?topic=/../nav/0)
* Rest API to get the following as JSON instead of requesting and parsing the legacy UI
- * Search as you type and search term completion: currently, when typing `fo`, a search is executed for `fo*` (which means starts with `fo`), but this disables stemming like in the full search (which means when entering `logging`, pages containing `log` or `logs` are not found; ideally _starts with_ and stemming should be combined; the search term completion proposals are currently computed from the words contained in the results, for which there are better ways to do this on the server side
+ * Search as you type and search term completion: currently, when typing `fo`, a search is executed for `fo*` (which means starts with `fo`), but this disables stemming like in the full search (which means when entering `logging`, pages containing `log` or `logs` are not found; ideally _starts with_ and stemming should be combined; the search term completion proposals are currently computed from the words contained in the results, for which there are better ways to do this on the server side
* [`/advanced/searchView.jsp`](http://127.0.0.1:49999/help/advanced/searchView.jsp?showSearchCategories=false&searchWord=test*&maxHits=7)
* User-defined search scopes
* [`/advanced/workingSetManager.jsp`](http://127.0.0.1:49999/help/advanced/workingSetManager.jsp) - list of scopes

Back to the top