Added support for showing thumbnails of images in webinterface

This commit is contained in:
Tomas Groth 2014-07-14 14:41:27 +02:00
parent 06110df08b
commit 8fa23ac95d
5 changed files with 14 additions and 5 deletions

View File

@ -317,6 +317,8 @@ class ServiceItem(RegistryProperties):
:param path: The title of the slide in the service item. :param path: The title of the slide in the service item.
:param file_name: The title of the slide in the service item. :param file_name: The title of the slide in the service item.
:param image: The command of/for the slide. :param image: The command of/for the slide.
:param display_title: Title to show in gui/webinterface, optional.
:param notes: Notes to show in the webinteface, optional.
""" """
self.service_item_type = ServiceItemType.Command self.service_item_type = ServiceItemType.Command
self._raw_frames.append({'title': file_name, 'image': image, 'path': path, self._raw_frames.append({'title': file_name, 'image': image, 'path': path,

View File

@ -551,6 +551,7 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.CanLoop) service_item.add_capability(ItemCapabilities.CanLoop)
service_item.add_capability(ItemCapabilities.CanAppend) service_item.add_capability(ItemCapabilities.CanAppend)
service_item.add_capability(ItemCapabilities.CanEditTitle) service_item.add_capability(ItemCapabilities.CanEditTitle)
service_item.add_capability(ItemCapabilities.HasThumbnails)
# force a nonexistent theme # force a nonexistent theme
service_item.theme = -1 service_item.theme = -1
missing_items_file_names = [] missing_items_file_names = []

View File

@ -295,6 +295,7 @@ class PresentationMediaItem(MediaManagerItem):
i += 1 i += 1
image_file = 'mainslide%03d.png' % i image_file = 'mainslide%03d.png' % i
image = os.path.join(doc.get_temp_folder(), image_file) image = os.path.join(doc.get_temp_folder(), image_file)
service_item.add_capability(ItemCapabilities.HasThumbnails)
doc.close_presentation() doc.close_presentation()
return True return True
else: else:

View File

@ -111,7 +111,7 @@ window.OpenLP = {
} }
// use thumbnail if available // use thumbnail if available
if (slide["img"]) { if (slide["img"]) {
text += "<br /><img src='" + slide["img"] + "'><br />"; text += "<br /><img src='" + slide["img"].replace("/thumbnails/", "/thumbnails320x240/") + "'><br />";
} }
// use notes if available // use notes if available
if (slide["notes"]) { if (slide["notes"]) {

View File

@ -159,7 +159,7 @@ class HttpRouter(RegistryProperties):
('^/(stage)$', {'function': self.serve_file, 'secure': False}), ('^/(stage)$', {'function': self.serve_file, 'secure': False}),
('^/(main)$', {'function': self.serve_file, 'secure': False}), ('^/(main)$', {'function': self.serve_file, 'secure': False}),
(r'^/files/(.*)$', {'function': self.serve_file, 'secure': False}), (r'^/files/(.*)$', {'function': self.serve_file, 'secure': False}),
(r'^/(.*)/thumbnails([^/]+)?/(.*)$', {'function': self.serve_thumbnail, 'secure': False}), (r'^/(\w+)/thumbnails([^/]+)?/(.*)$', {'function': self.serve_thumbnail, 'secure': False}),
(r'^/api/poll$', {'function': self.poll, 'secure': False}), (r'^/api/poll$', {'function': self.poll, 'secure': False}),
(r'^/main/poll$', {'function': self.main_poll, 'secure': False}), (r'^/main/poll$', {'function': self.main_poll, 'secure': False}),
(r'^/main/image$', {'function': self.main_image, 'secure': False}), (r'^/main/image$', {'function': self.main_image, 'secure': False}),
@ -387,7 +387,7 @@ class HttpRouter(RegistryProperties):
Serve an image file. If not found return 404. Serve an image file. If not found return 404.
""" """
log.debug('serve thumbnail %s/thumbnails%s/%s' % (controller_name, dimensions, file_name)) log.debug('serve thumbnail %s/thumbnails%s/%s' % (controller_name, dimensions, file_name))
supported_controllers = ['presentations'] supported_controllers = ['presentations', 'images']
if not dimensions: if not dimensions:
dimensions = '' dimensions = ''
content = '' content = ''
@ -496,6 +496,12 @@ class HttpRouter(RegistryProperties):
item['tag'] = str(index + 1) item['tag'] = str(index + 1)
item['text'] = str(frame['text']) item['text'] = str(frame['text'])
item['html'] = str(frame['html']) item['html'] = str(frame['html'])
elif current_item.is_image():
item['tag'] = str(index + 1)
thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title'])
item['img'] = urllib.request.pathname2url(thumbnail_path)
item['text'] = str(frame['title'])
item['html'] = str(frame['title'])
else: else:
item['tag'] = str(index + 1) item['tag'] = str(index + 1)
if current_item.is_capable(ItemCapabilities.HasDisplayTitle): if current_item.is_capable(ItemCapabilities.HasDisplayTitle):
@ -503,8 +509,7 @@ class HttpRouter(RegistryProperties):
if current_item.is_capable(ItemCapabilities.HasNotes): if current_item.is_capable(ItemCapabilities.HasNotes):
item['notes'] = str(frame['notes']) item['notes'] = str(frame['notes'])
if current_item.is_capable(ItemCapabilities.HasThumbnails): if current_item.is_capable(ItemCapabilities.HasThumbnails):
# If the file is under our app directory tree send the # If the file is under our app directory tree send the portion after the match
# portion after the match
data_path = AppLocation.get_data_path() data_path = AppLocation.get_data_path()
if frame['image'][0:len(data_path)] == data_path: if frame['image'][0:len(data_path)] == data_path:
item['img'] = urllib.request.pathname2url(frame['image'][len(data_path):]) item['img'] = urllib.request.pathname2url(frame['image'][len(data_path):])