public void enlistImage(final Picture picture,
final DirectoryMetadata parentDirectoryMetadata) {
try {
-
- final Dimension imageSize = picture.getDimensions();
-
- final List<Dimension> recommendedDimensions = Picture
- .getThumbnailDimensions(imageSize);
-
- Dimension listingDimension = new Dimension(1500, 450);
-
- if (listingDimension.width > imageSize.width)
- if (listingDimension.height > imageSize.height)
- listingDimension = imageSize;
-
- final String listingThumbnailUrl = indexer.getThumbnailUrl(picture,
- listingDimension, indexingContext);
-
- filesHtml.append("<div style=\"float:left; margin: 10px;\">");
- filesHtml.append("<a href=\""
- + indexingContext.getGlobalUrl()
- + UrlParamEncoder.encode(indexingContext.getLocalUrl()
- + "/" + picture.fileName) + "\">\n");
-
- filesHtml.append("<img border=\"0\" src=\"" + listingThumbnailUrl
- + "\"/></a>\n");
- filesHtml.append("<br/><b>"
- + FilePathParser
- .getFileNameWithoutExtension(picture.fileName)
- + "</b><br/>(");
-
- int count = 0;
- for (final Dimension dimension : recommendedDimensions) {
- count++;
- if (count > 1)
- filesHtml.append(", ");
- filesHtml.append("<a href=\""
- + indexer.getThumbnailUrl(picture, dimension,
- indexingContext) + "\">");
- filesHtml.append(dimension.width + "x" + dimension.height);
- filesHtml.append("</a>");
- }
-
- filesHtml.append(")\n");
- filesHtml.append("</div>");
-
+ enlistImageInternal(picture);
} catch (final Exception e) {
logger.error(
"Error generating thumbnails for image file: "
}
}
+ private String enlistImageDimensions(final Picture picture) {
+ final StringBuilder html = new StringBuilder();
+
+ final List<Dimension> recommendedDimensions = Picture
+ .getThumbnailDimensions(picture.getDimensions());
+
+ int count = 0;
+ for (final Dimension dimension : recommendedDimensions) {
+ count++;
+ if (count > 1)
+ html.append(", ");
+ html.append("<a href=\""
+ + indexer.getThumbnailUrl(picture, dimension,
+ indexingContext) + "\">");
+ html.append(dimension.width + "x" + dimension.height);
+ html.append("</a>");
+ }
+
+ return html.toString();
+ }
+
+ private void enlistImageInternal(final Picture picture) {
+
+ filesHtml.append("<div style=\"float:left; margin: 10px;\">");
+
+ // clickable image thumbnail
+ filesHtml.append("<a href=\""
+ + indexingContext.getGlobalUrl()
+ + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+ + picture.fileName) + "\">\n");
+ filesHtml.append("<img border=\"0\" src=\""
+ + getImageThumbnailUrl(picture) + "\"/></a><br/>\n");
+
+ // file name
+ filesHtml.append("<b>"
+ + FilePathParser.getFileNameWithoutExtension(picture.fileName)
+ + "</b><br/>");
+
+ // links to thumbnails of various sizes
+ filesHtml.append("(" + enlistImageDimensions(picture) + ")\n");
+
+ filesHtml.append("</div>");
+ }
+
/** {@inheritDoc} */
@Override
public void enlistOgv(final AbstractFile abstractFile,
final GeneralFile file = (GeneralFile) abstractFile;
+ filesHtml.append("<div style=\"margin: 30px; clear: both;\">");
+
+ // watchable video
filesHtml
- .append("<div style=\"margin: 30px; clear: both;\">"
- + "<video preload=\"metadata\" controls=\"controls\" tabindex=\"0\">\n");
+ .append("<video preload=\"metadata\" controls=\"controls\" tabindex=\"0\">\n");
filesHtml
.append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
+ indexingContext.getGlobalUrl()
+ UrlParamEncoder.encode(indexingContext.getLocalUrl()
+ "/" + file.fileName) + "\">\n");
filesHtml.append("</source>\n");
-
filesHtml.append("</video>\n");
-
filesHtml.append("<br/>\n");
+ // video title
filesHtml
.append("Video: <b>"
+ FilePathParser
.getFileNameWithoutExtension(file.fileName)
+ "<b/> ");
+
+ // video download link
filesHtml.append("<a href=\""
+ indexingContext.getGlobalUrl()
+ UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
- + file.fileName) + "\">download as OGV</a></div>\n");
+ + file.fileName) + "\">download as OGV</a>");
+
+ filesHtml.append("</div>\n");
filesHtml.append("\n");
return finalHtml.toString();
}
+ private String getImageThumbnailUrl(final Picture picture) {
+ final Dimension imageSize = picture.getDimensions();
+
+ Dimension listingDimension = new Dimension(1500, 450);
+
+ if (listingDimension.width > imageSize.width)
+ if (listingDimension.height > imageSize.height)
+ listingDimension = imageSize;
+
+ return indexer.getThumbnailUrl(picture, listingDimension,
+ indexingContext);
+ }
+
@Override
public void init(final String galleryTitle, final List<String> path,
final AbstractIndexer indexer, final IndexingContext indexingContext) {