modify osdd
This commit is contained in:
parent
f23bec11fb
commit
f83d13c588
6 changed files with 17 additions and 27 deletions
|
@ -104,7 +104,6 @@ public abstract class FessSearchAction extends FessBaseAction {
|
|||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("osddLink", openSearchHelper.hasOpenSearchFile());
|
||||
runtime.registerData("helpPage", viewHelper.getPagePath("common/help"));
|
||||
|
||||
final List<Map<String, String>> labelTypeItems = labelTypeHelper.getLabelTypeItemList();
|
||||
runtime.registerData("labelTypeItems", labelTypeItems);
|
||||
|
|
|
@ -46,6 +46,7 @@ public class HelpAction extends FessSearchAction {
|
|||
});
|
||||
}).renderWith(data -> {
|
||||
buildInitParams();
|
||||
data.register("helpPage", viewHelper.getPagePath("common/help"));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@ package org.codelibs.fess.app.web.osdd;
|
|||
|
||||
import org.codelibs.fess.app.web.base.FessSearchAction;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
import org.lastaflute.web.response.StreamResponse;
|
||||
|
||||
public class OsddAction extends FessSearchAction {
|
||||
|
||||
|
@ -39,10 +38,9 @@ public class OsddAction extends FessSearchAction {
|
|||
// ==============
|
||||
|
||||
@Execute
|
||||
public HtmlResponse index() {
|
||||
public StreamResponse index() {
|
||||
searchAvailable();
|
||||
openSearchHelper.write(LaResponseUtil.getResponse());
|
||||
return null;
|
||||
return openSearchHelper.asStream();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,17 +16,15 @@
|
|||
package org.codelibs.fess.helper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.codelibs.core.io.FileUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.lastaflute.web.exception.ForcedRequest404NotFoundException;
|
||||
import org.lastaflute.web.response.StreamResponse;
|
||||
import org.lastaflute.web.util.LaServletContextUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -67,21 +65,15 @@ public class OpenSearchHelper {
|
|||
return osddFile != null;
|
||||
}
|
||||
|
||||
public void write(final HttpServletResponse response) {
|
||||
public StreamResponse asStream() {
|
||||
if (osddFile == null) {
|
||||
throw new FessSystemException("Unsupported OpenSearch response.");
|
||||
}
|
||||
|
||||
response.setContentType(contentType + "; charset=" + encoding);
|
||||
ServletOutputStream os = null;
|
||||
try {
|
||||
os = response.getOutputStream();
|
||||
os.write(FileUtil.readBytes(osddFile));
|
||||
} catch (final IOException e) {
|
||||
throw new FessSystemException("Failed to write OpenSearch response.", e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
throw new ForcedRequest404NotFoundException("Unsupported OpenSearch response.");
|
||||
}
|
||||
|
||||
return new StreamResponse(osddFile.getName()).contentType(contentType + "; charset=" + encoding).stream(out -> {
|
||||
try (InputStream ins = new FileInputStream(osddFile)) {
|
||||
out.write(ins);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<dl>
|
||||
<dt>Add To Browser Search Engines</dt>
|
||||
<dd>
|
||||
Click <a href="#" onclick='window.external.AddSearchProvider("http://localhost:8080/fess/osdd");return false;'>here</a>
|
||||
Click <a href="#" onclick='window.external.AddSearchProvider("/osdd/");return false;'>here</a>
|
||||
to add a search engine list for your browser.
|
||||
</dd>
|
||||
</dl>
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<dt>ブラウザの検索エンジンに追加</dt>
|
||||
<dd>
|
||||
ご利用のブラウザの検索エンジン一覧に追加するためには
|
||||
<a href="#" onclick='window.external.AddSearchProvider("http://localhost:8080/fess/osdd");return false;'>ここ</a>をクリックしてください。
|
||||
<a href="#" onclick='window.external.AddSearchProvider("/osdd/");return false;'>ここ</a>をクリックしてください。
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue