forked from openlp/openlp
Fix bugs and lost images
This commit is contained in:
parent
be556248b8
commit
b1576d0819
@ -114,8 +114,8 @@ def controller_set(request):
|
||||
return {'results': {'success': True}}
|
||||
|
||||
|
||||
@api_controller_endpoint.route('/controller/{controller}/{action:next|previous}')
|
||||
@controller_endpoint.route('/{controller}/{action:next|previous}')
|
||||
@api_controller_endpoint.route('controller/{controller}/{action:next|previous}')
|
||||
@controller_endpoint.route('{action:next|previous}')
|
||||
@requires_auth
|
||||
def controller_direction(request, controller, action):
|
||||
"""
|
||||
|
@ -95,7 +95,7 @@ def service(request, plugin_name, log):
|
||||
return {'results': {'success': True}}
|
||||
|
||||
|
||||
def display_thumbnails(request, controller_name, log, dimensions, file_name, slide):
|
||||
def display_thumbnails(request, controller_name, log, dimensions, file_name, slide=None):
|
||||
"""
|
||||
Handles requests for adding a song to the service
|
||||
|
||||
@ -125,8 +125,13 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli
|
||||
if controller_name and file_name:
|
||||
file_name = urllib.parse.unquote(file_name)
|
||||
if '..' not in file_name: # no hacking please
|
||||
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
|
||||
'thumbnails', file_name, slide))
|
||||
if slide:
|
||||
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
|
||||
'thumbnails', file_name, slide))
|
||||
else:
|
||||
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
|
||||
|
||||
'thumbnails', file_name))
|
||||
if os.path.exists(full_path):
|
||||
path, just_file_name = os.path.split(full_path)
|
||||
Registry().get('image_manager').add_image(full_path, just_file_name, None, width, height)
|
||||
|
@ -143,10 +143,6 @@ class WSGIApplication(object):
|
||||
"""
|
||||
Find the appropriate URL and run the view function
|
||||
"""
|
||||
# First look to see if this is a static file request
|
||||
for route, static_app in self.static_routes.items():
|
||||
if re.match(route, request.path):
|
||||
return request.get_response(static_app)
|
||||
# If not a static route, try the views
|
||||
for route, views in self.route_map.items():
|
||||
match = re.match(route, request.path)
|
||||
@ -155,6 +151,10 @@ class WSGIApplication(object):
|
||||
log.debug('Found {method} {url}'.format(method=request.method, url=request.path))
|
||||
view_func = views[request.method.upper()]
|
||||
return _make_response(view_func(request, **kwargs))
|
||||
# Look to see if this is a static file request
|
||||
for route, static_app in self.static_routes.items():
|
||||
if re.match(route, request.path):
|
||||
return request.get_response(static_app)
|
||||
log.error('URL {url} - Not found'.format(url=request.path))
|
||||
raise NotFound()
|
||||
|
||||
|
@ -67,14 +67,14 @@ def images_service(request):
|
||||
return service(request, 'images', log)
|
||||
|
||||
|
||||
@images_endpoint.route('thumbnails/{dimensions}/{file_name}/{slide}')
|
||||
def images_thumbnails(request, dimensions, file_name, slide):
|
||||
# images/thumbnails/320x240/1.jpg
|
||||
@images_endpoint.route('thumbnails/{dimensions}/{file_name}')
|
||||
def images_thumbnails(request, dimensions, file_name):
|
||||
"""
|
||||
Return an image to a web page based on a URL
|
||||
:param request: Request object
|
||||
:param dimensions: the image size eg 88x88
|
||||
:param file_name: the file name of the image
|
||||
:param slide: the individual image name
|
||||
:param file_name: the individual image name
|
||||
:return:
|
||||
"""
|
||||
return display_thumbnails(request, 'images', log, dimensions, file_name, slide)
|
||||
return display_thumbnails(request, 'images', log, dimensions, file_name)
|
||||
|
Loading…
Reference in New Issue
Block a user