forked from openlp/openlp
Change image_manager to a property
Fix path using appropriate function call pathname2url
This commit is contained in:
parent
08682a3bd2
commit
cc4e393966
@ -405,18 +405,14 @@ class HttpRouter(object):
|
|||||||
if controller_name in supported_controllers:
|
if controller_name in supported_controllers:
|
||||||
full_path = urllib.parse.unquote(file_name)
|
full_path = urllib.parse.unquote(file_name)
|
||||||
if not '..' in full_path: # no hacking please
|
if not '..' in full_path: # no hacking please
|
||||||
full_path = os.path.normpath(os.path.join(
|
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
|
||||||
AppLocation.get_section_data_path(controller_name),
|
|
||||||
'thumbnails/' + full_path))
|
'thumbnails/' + full_path))
|
||||||
if os.path.exists(full_path):
|
if os.path.exists(full_path):
|
||||||
path, just_file_name = os.path.split(full_path)
|
path, just_file_name = os.path.split(full_path)
|
||||||
image_manager = Registry().get('image_manager')
|
self.image_manager.add_image(full_path, just_file_name, None, dimensions)
|
||||||
image_manager.add_image(full_path, just_file_name, None,
|
|
||||||
dimensions)
|
|
||||||
ext, content_type = self.get_content_type(full_path)
|
ext, content_type = self.get_content_type(full_path)
|
||||||
content = image_to_byte(
|
image = self.image_manager.get_image(full_path, just_file_name, dimensions)
|
||||||
image_manager.get_image(full_path,
|
content = image_to_byte(image, False)
|
||||||
just_file_name, dimensions), False)
|
|
||||||
if len(content)==0:
|
if len(content)==0:
|
||||||
return self.do_not_found()
|
return self.do_not_found()
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
@ -520,7 +516,7 @@ class HttpRouter(object):
|
|||||||
# portion after the match
|
# portion after the match
|
||||||
dataPath = AppLocation.get_data_path()
|
dataPath = AppLocation.get_data_path()
|
||||||
if frame['image'][0:len(dataPath)] == dataPath:
|
if frame['image'][0:len(dataPath)] == dataPath:
|
||||||
item['img'] = frame['image'][len(dataPath):]
|
item['img'] = urllib.request.pathname2url(frame['image'][len(dataPath):])
|
||||||
item['text'] = str(frame['title'])
|
item['text'] = str(frame['title'])
|
||||||
item['html'] = str(frame['title'])
|
item['html'] = str(frame['title'])
|
||||||
item['selected'] = (self.live_controller.selected_row == index)
|
item['selected'] = (self.live_controller.selected_row == index)
|
||||||
@ -689,3 +685,13 @@ class HttpRouter(object):
|
|||||||
return self._alerts_manager
|
return self._alerts_manager
|
||||||
|
|
||||||
alerts_manager = property(_get_alerts_manager)
|
alerts_manager = property(_get_alerts_manager)
|
||||||
|
|
||||||
|
def _get_image_manager(self):
|
||||||
|
"""
|
||||||
|
Adds the image manager to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, '_image_manager'):
|
||||||
|
self._image_manager = Registry().get('image_manager')
|
||||||
|
return self._image_manager
|
||||||
|
|
||||||
|
image_manager = property(_get_image_manager)
|
Loading…
Reference in New Issue
Block a user