fix #2784 Added functionality to set Content-Disposition to inline based on MIME types configuration
This commit is contained in:
parent
5bbf18084c
commit
e35c04d8c6
4 changed files with 20 additions and 5 deletions
|
@ -83,7 +83,6 @@ import org.lastaflute.web.response.ActionResponse;
|
|||
import org.lastaflute.web.response.StreamResponse;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
import org.lastaflute.web.util.LaServletContextUtil;
|
||||
import org.opensearch.core.common.text.Text;
|
||||
import org.opensearch.search.fetch.subphase.highlight.HighlightField;
|
||||
|
@ -211,6 +210,9 @@ public class ViewHelper {
|
|||
textFragmentPrefixLength = fessConfig.getQueryHighlightTextFragmentPrefixLengthAsInteger();
|
||||
textFragmentSuffixLength = fessConfig.getQueryHighlightTextFragmentSuffixLengthAsInteger();
|
||||
textFragmentSize = fessConfig.getQueryHighlightTextFragmentSizeAsInteger();
|
||||
|
||||
split(fessConfig.getResponseInlineMimetypes(), ",")
|
||||
.of(stream -> stream.map(String::trim).filter(StringUtil::isNotEmpty).forEach(inlineMimeTypeSet::add));
|
||||
}
|
||||
|
||||
public String getContentTitle(final Map<String, Object> document) {
|
||||
|
@ -759,7 +761,7 @@ public class ViewHelper {
|
|||
return;
|
||||
}
|
||||
if (mimeType.startsWith("text/")) {
|
||||
final String charset = LaResponseUtil.getResponse().getCharacterEncoding();
|
||||
final String charset = responseData.getCharSet();
|
||||
if (charset != null) {
|
||||
response.contentType(mimeType + "; charset=" + charset);
|
||||
return;
|
||||
|
|
|
@ -673,6 +673,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. true */
|
||||
String RESPONSE_HIGHLIGHT_content_title_ENABLED = "response.highlight.content_title.enabled";
|
||||
|
||||
/** The key of the configuration. e.g. application/pdf,text/plain */
|
||||
String RESPONSE_INLINE_MIMETYPES = "response.inline.mimetypes";
|
||||
|
||||
/** The key of the configuration. e.g. fess.search */
|
||||
String INDEX_DOCUMENT_SEARCH_INDEX = "index.document.search.index";
|
||||
|
||||
|
@ -3881,6 +3884,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
boolean isResponseHighlightContentTitleEnabled();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'response.inline.mimetypes'. <br>
|
||||
* The value is, e.g. application/pdf,text/plain <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getResponseInlineMimetypes();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.document.search.index'. <br>
|
||||
* The value is, e.g. fess.search <br>
|
||||
|
@ -8774,6 +8784,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return is(FessConfig.RESPONSE_HIGHLIGHT_content_title_ENABLED);
|
||||
}
|
||||
|
||||
public String getResponseInlineMimetypes() {
|
||||
return get(FessConfig.RESPONSE_INLINE_MIMETYPES);
|
||||
}
|
||||
|
||||
public String getIndexDocumentSearchIndex() {
|
||||
return get(FessConfig.INDEX_DOCUMENT_SEARCH_INDEX);
|
||||
}
|
||||
|
@ -10990,6 +11004,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.RESPONSE_MAX_TITLE_LENGTH, "50");
|
||||
defaultMap.put(FessConfig.RESPONSE_MAX_SITE_PATH_LENGTH, "100");
|
||||
defaultMap.put(FessConfig.RESPONSE_HIGHLIGHT_content_title_ENABLED, "true");
|
||||
defaultMap.put(FessConfig.RESPONSE_INLINE_MIMETYPES, "application/pdf,text/plain");
|
||||
defaultMap.put(FessConfig.INDEX_DOCUMENT_SEARCH_INDEX, "fess.search");
|
||||
defaultMap.put(FessConfig.INDEX_DOCUMENT_UPDATE_INDEX, "fess.update");
|
||||
defaultMap.put(FessConfig.INDEX_DOCUMENT_SUGGEST_INDEX, "fess");
|
||||
|
|
|
@ -56,9 +56,6 @@
|
|||
</postConstruct>
|
||||
</component>
|
||||
<component name="viewHelper" class="org.codelibs.fess.helper.ViewHelper">
|
||||
<postConstruct name="addInlineMimeType">
|
||||
<arg>"application/pdf"</arg>
|
||||
</postConstruct>
|
||||
</component>
|
||||
<component name="userAgentHelper" class="org.codelibs.fess.helper.UserAgentHelper">
|
||||
</component>
|
||||
|
|
|
@ -337,6 +337,7 @@ response.field.site_path=site_path
|
|||
response.max.title.length=50
|
||||
response.max.site.path.length=100
|
||||
response.highlight.content_title.enabled=true
|
||||
response.inline.mimetypes=application/pdf,text/plain
|
||||
|
||||
# document index
|
||||
index.document.search.index=fess.search
|
||||
|
|
Loading…
Add table
Reference in a new issue