Fixed issues with this branch and recent commits to trunk

This commit is contained in:
Philip Ridout 2017-08-24 20:53:55 +01:00
parent 09a877002f
commit 0b91725a4f
5 changed files with 21 additions and 20 deletions

View File

@ -64,7 +64,7 @@ def controller_text(request):
elif current_item.is_image() and not frame.get('image', '') and Settings().value('api/thumbnails'): elif current_item.is_image() and not frame.get('image', '') and Settings().value('api/thumbnails'):
item['tag'] = str(index + 1) item['tag'] = str(index + 1)
thumbnail_path = os.path.join('images', 'thumbnails', frame['title']) thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
full_thumbnail_path = os.path.join(AppLocation.get_data_path(), thumbnail_path) full_thumbnail_path = str(AppLocation.get_data_path() / thumbnail_path)
# Create thumbnail if it doesn't exists # Create thumbnail if it doesn't exists
if not os.path.exists(full_thumbnail_path): if not os.path.exists(full_thumbnail_path):
create_thumb(current_item.get_frame_path(index), full_thumbnail_path, False) create_thumb(current_item.get_frame_path(index), full_thumbnail_path, False)
@ -82,7 +82,7 @@ def controller_text(request):
if current_item.is_capable(ItemCapabilities.HasThumbnails) and \ if current_item.is_capable(ItemCapabilities.HasThumbnails) and \
Settings().value('api/thumbnails'): Settings().value('api/thumbnails'):
# If the file is under our app directory tree send the portion after the match # If the file is under our app directory tree send the portion after the match
data_path = AppLocation.get_data_path() data_path = str(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):])
Registry().get('image_manager').add_image(frame['image'], frame['title'], None, 88, 88) Registry().get('image_manager').add_image(frame['image'], frame['title'], None, 88, 88)

View File

@ -125,12 +125,9 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli
file_name = urllib.parse.unquote(file_name) file_name = urllib.parse.unquote(file_name)
if '..' not in file_name: # no hacking please if '..' not in file_name: # no hacking please
if slide: if slide:
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name), full_path = str(AppLocation.get_section_data_path(controller_name) / 'thumbnails' / file_name / slide)
'thumbnails', file_name, slide))
else: else:
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name), full_path = str(AppLocation.get_section_data_path(controller_name) / 'thumbnails' / file_name)
'thumbnails', file_name))
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)
Registry().get('image_manager').add_image(full_path, just_file_name, None, width, height) Registry().get('image_manager').add_image(full_path, just_file_name, None, width, height)

View File

@ -68,11 +68,10 @@ class Endpoint(object):
""" """
Render a mako template Render a mako template
""" """
root = os.path.join(str(AppLocation.get_section_data_path('remotes'))) root = str(AppLocation.get_section_data_path('remotes'))
if not self.template_dir: if not self.template_dir:
raise Exception('No template directory specified') raise Exception('No template directory specified')
path = os.path.join(root, self.template_dir, filename) path = os.path.join(root, self.template_dir, filename)
# path = os.path.abspath(os.path.join(self.template_dir, filename))
if self.static_dir: if self.static_dir:
kwargs['static_url'] = '/{prefix}/static'.format(prefix=self.url_prefix) kwargs['static_url'] = '/{prefix}/static'.format(prefix=self.url_prefix)
kwargs['static_url'] = kwargs['static_url'].replace('//', '/') kwargs['static_url'] = kwargs['static_url'].replace('//', '/')

View File

@ -138,8 +138,12 @@ class WSGIApplication(object):
Add a static directory as a route Add a static directory as a route
""" """
if route not in self.static_routes: if route not in self.static_routes:
root = os.path.join(str(AppLocation.get_section_data_path('remotes'))) root = str(AppLocation.get_section_data_path('remotes'))
self.static_routes[route] = DirectoryApp(os.path.abspath(os.path.join(root, static_dir))) static_path = os.path.abspath(os.path.join(root, static_dir))
if not os.path.exists(static_path):
log.error('Static path "%s" does not exist. Skipping creating static route/', static_path)
return
self.static_routes[route] = DirectoryApp(static_path)
def dispatch(self, request): def dispatch(self, request):
""" """

View File

@ -59,21 +59,22 @@ class RemotesPlugin(Plugin, OpenLPMixin):
Create the internal file structure if it does not exist Create the internal file structure if it does not exist
:return: :return:
""" """
check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'assets')) check_directory_exists(AppLocation.get_section_data_path('remotes') / 'assets')
check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'images')) check_directory_exists(AppLocation.get_section_data_path('remotes') / 'images')
check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'static')) check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static')
check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'static', 'index')) check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static', 'index')
check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'templates')) check_directory_exists(AppLocation.get_section_data_path('remotes') / 'templates')
@staticmethod @staticmethod
def about(): def about():
""" """
Information about this plugin Information about this plugin
""" """
about_text = translate('RemotePlugin', '<strong>Web Interface</strong>' about_text = translate(
'<br />The web interface plugin provides the ability develop web based ' 'RemotePlugin',
'interfaces using openlp web services. \nPredefined interfaces can be ' '<strong>Web Interface</strong>'
'download as well as custom developed interfaces') '<br />The web interface plugin provides the ability to develop web based interfaces using OpenLP web '
'services.\nPredefined interfaces can be download as well as custom developed interfaces.')
return about_text return about_text
def set_plugin_text_strings(self): def set_plugin_text_strings(self):