blob: 87c21194a0d2f72431345a578eb1f0597b9ea5dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.doc.internal.linkchecker;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.help.internal.webapp.servlet.FilterHTMLHeadOutputStream;
import org.eclipse.help.internal.webapp.servlet.FilterUtils;
import org.eclipse.help.webapp.IFilter;
/**
* This class inserts a CSSs for narrow and disabled CSSs when called from the
* dynamic help view.
*/
public class AddScriptFilter implements IFilter {
/*
* @see IFilter#filter(HttpServletRequest, OutputStream)
*/
@Override
public OutputStream filter(HttpServletRequest req, OutputStream out) {
String relativePath = FilterUtils.getRelativePathPrefix(req);
StringBuffer script = new StringBuffer();
script.append("\n<script type=\"text/javascript\" src=\"");
script.append(relativePath);
script.append("content/org.eclipse.ua.tests.doc/checkdoc.js\"> </script>"); //$NON-NLS-1$
try {
return new FilterHTMLHeadOutputStream(
out,
script.toString().getBytes("ASCII")); //$NON-NLS-1$
} catch (UnsupportedEncodingException uee) {
return out;
}
}
}
|