add thumbnail to fess-ss
This commit is contained in:
parent
3c1d58dd90
commit
3e486e531e
7 changed files with 59 additions and 11 deletions
|
@ -10,7 +10,7 @@
|
|||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.25.0",
|
||||
"babel-loader": "^7.0.0",
|
||||
"babel-loader": "^7.1.1",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-stage-0": "^6.24.1",
|
||||
|
|
|
@ -5,6 +5,7 @@ export default class {
|
|||
this.FessView = FessView;
|
||||
this.FessModel = FessModel;
|
||||
this.fessUrl = FessJQuery('script#fess-ss').attr('fess-url');
|
||||
this.fessContextPath = this.fessUrl.slice(0, this.fessUrl.indexOf('/json'));
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -70,7 +71,7 @@ export default class {
|
|||
this.FessModel.search(this.fessUrl, params).then(function(data){
|
||||
var response = data.response;
|
||||
if (response.record_count > 0) {
|
||||
$cls.FessView.renderResult(data.response, params);
|
||||
$cls.FessView.renderResult($cls.fessContextPath, data.response, params);
|
||||
$fessResult.css('display', 'block');
|
||||
$cls._bindPagination(data.response);
|
||||
} else {
|
||||
|
|
|
@ -248,8 +248,6 @@
|
|||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
|
|
@ -25,13 +25,24 @@
|
|||
<div class="media-body">
|
||||
<h3 class="title ellipsis media-heading">
|
||||
<a class="link" href="{{url}}" data-uri="{{url}}" data-order="0">
|
||||
{{title}}
|
||||
{{content_title}}
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="description">
|
||||
{{{content_description}}}
|
||||
<div>
|
||||
<div class="thumbnailBox media-left hidden-xs-down">
|
||||
<a class="link" href="{{url}}" data-uri="{{url}}" data-id="b4acd0fd3e244f57a1d08580f5ac6ee6"
|
||||
data-order="1"
|
||||
>
|
||||
<img src="{{../context_path}}/images/blank.png"
|
||||
data-src="{{../context_path}}/thumbnail/?docId={{doc_id}}&queryId={{../query_id}}" class="thumbnail"
|
||||
>
|
||||
</a>
|
||||
</div>
|
||||
<div class="media-body description">
|
||||
{{{content_description}}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="site ellipsis">
|
||||
<cite>{{site}}</cite>
|
||||
|
|
|
@ -6,6 +6,8 @@ import noResultTemplate from '!handlebars-loader!./templates/fess-no-result.hbs'
|
|||
export default class {
|
||||
constructor(FessMessages) {
|
||||
this.FessMessages = FessMessages;
|
||||
this.IMG_LOADING_DELAY = 200;
|
||||
this.IMG_LOADING_MAX = 0;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
@ -54,13 +56,15 @@ export default class {
|
|||
$fessForm.html(this.FessMessages.render(html, {}));
|
||||
}
|
||||
|
||||
renderResult(response, params) {
|
||||
renderResult(contextPath, response, params) {
|
||||
response['context_path'] = contextPath;
|
||||
var $fessResult = FessJQuery('.fessWrapper .fessResult');
|
||||
var html = resultTemplate(response);
|
||||
$fessResult.html(this.FessMessages.render(html, response));
|
||||
var $pagination = this._createPagination(response.record_count, response.page_size, response.page_number, params);
|
||||
FessJQuery('.fessWrapper .paginationNav').append($pagination);
|
||||
FessJQuery('.fessWrapper select.sort').val(params.sort);
|
||||
this._loadThumbnail(contextPath);
|
||||
}
|
||||
|
||||
renderNoResult(response, params) {
|
||||
|
@ -132,4 +136,30 @@ export default class {
|
|||
return $pagination;
|
||||
}
|
||||
|
||||
_loadThumbnail(contextPath) {
|
||||
var $cls = this;
|
||||
var loadImage = function(img, url, limit) {
|
||||
var imgData = new Image();
|
||||
imgData.onload = function() {
|
||||
FessJQuery(img).css('background-image', '');
|
||||
FessJQuery(img).attr('src', url);
|
||||
};
|
||||
imgData.onerror = function() {
|
||||
if (limit > 0) {
|
||||
setTimeout(function() {
|
||||
loadImage(img, url, --limit);
|
||||
}, $cls.IMG_LOADING_DELAY);
|
||||
} else {
|
||||
FessJQuery(img).attr('src', contextPath + "/images/noimage.png");
|
||||
}
|
||||
imgData = null;
|
||||
};
|
||||
imgData.src = url;
|
||||
};
|
||||
|
||||
FessJQuery('img.thumbnail').each(function() {
|
||||
FessJQuery(this).css('background-image', 'url("' + contextPath + '/images/loading.gif")');
|
||||
loadImage(this, FessJQuery(this).attr('data-src'), $cls.IMG_LOADING_MAX);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.codelibs.fess.helper.RelatedQueryHelper;
|
|||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.helper.UserInfoHelper;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.thumbnail.ThumbnailManager;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.DocumentUtil;
|
||||
import org.codelibs.fess.util.FacetResponse;
|
||||
|
@ -285,6 +286,13 @@ public class JsonApiManager extends BaseJsonApiManager {
|
|||
buf.append(']');
|
||||
}
|
||||
}
|
||||
|
||||
if (fessConfig.isThumbnailEnabled()) {
|
||||
final UserInfoHelper userInfoHelper = ComponentUtil.getComponent(UserInfoHelper.class);
|
||||
final ThumbnailManager thumbnailManager = ComponentUtil.getComponent(ThumbnailManager.class);
|
||||
userInfoHelper.storeQueryId(queryId, documentItems);
|
||||
thumbnailManager.storeRequest(queryId, documentItems);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
status = 1;
|
||||
err = e;
|
||||
|
|
6
src/main/webapp/js/ss/fess-ss.min.js
vendored
6
src/main/webapp/js/ss/fess-ss.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue