mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Fixed issues serving static image content for banners/posters and misc other static images, improves overall performance of webui as well.
This commit is contained in:
parent
3a2a5f9d70
commit
efc2aad782
@ -444,7 +444,7 @@ $myShowList.sort(lambda x, y: cmp(x.name, y.name))
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th rowspan="1" colspan="1" align="center"><a href="$sbRoot/home/addShows/#">Add Show</a></th>
|
||||
<th rowspan="1" colspan="1" align="center"><a href="$sbRoot/home/addShows/">Add Show</a></th>
|
||||
<th rowspan="1" colspan="6"></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -103,7 +103,7 @@
|
||||
\$("#SubMenu a:contains('General')").addClass('btn').html('<span class="ui-icon ui-icon-gear pull-left"></span> General');
|
||||
\$("#SubMenu a:contains('Episode Status')").addClass('btn').html('<span class="ui-icon ui-icon-transferthick-e-w pull-left"></span> Episode Status Management');
|
||||
\$("#SubMenu a:contains('Missed Subtitle')").addClass('btn').html('<span class="ui-icon ui-icon-transferthick-e-w pull-left"></span> Missed Subtitles');
|
||||
\$("#SubMenu a[href$='/home/addShows/#']").addClass('btn').html('<span class="ui-icon ui-icon-video pull-left"></span> Add Show');
|
||||
\$("#SubMenu a[href$='/home/addShows/']").addClass('btn').html('<span class="ui-icon ui-icon-video pull-left"></span> Add Show');
|
||||
\$("#SubMenu a:contains('Processing')").addClass('btn').html('<span class="ui-icon ui-icon-folder-open pull-left"></span> Post-Processing');
|
||||
\$("#SubMenu a:contains('Manage Searches')").addClass('btn').html('<span class="ui-icon ui-icon-search pull-left"></span> Manage Searches');
|
||||
\$("#SubMenu a:contains('Manage Torrents')").addClass('btn').html('<span class="submenu-icon-bittorrent pull-left"></span> Manage Torrents');
|
||||
@ -146,9 +146,9 @@
|
||||
<li id="NAVhome" class="dropdown">
|
||||
<a href="$sbRoot/home/" class="dropdown-toggle" data-toggle="dropdown">Shows <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="$sbRoot/home/#"><i class="menu-icon-home"></i> Show List</a></li>
|
||||
<li><a href="$sbRoot/home/addShows/#"><i class="menu-icon-addshow"></i> Add Shows</a></li>
|
||||
<li><a href="$sbRoot/home/postprocess/#"><i class="menu-icon-postprocess"></i> Manual Post-Processing</a></li>
|
||||
<li><a href="$sbRoot/home/"><i class="menu-icon-home"></i> Show List</a></li>
|
||||
<li><a href="$sbRoot/home/addShows/"><i class="menu-icon-addshow"></i> Add Shows</a></li>
|
||||
<li><a href="$sbRoot/home/postprocess/"><i class="menu-icon-postprocess"></i> Manual Post-Processing</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
@ -142,7 +142,7 @@ class BaseHandler(RequestHandler):
|
||||
# handle 404 http errors
|
||||
if status_code == 404:
|
||||
index_url = sickbeard.WEB_ROOT
|
||||
url = self.request.uri.replace(index_url, '')
|
||||
url = self.request.uri[len(index_url):]
|
||||
|
||||
if url[:3] != 'api':
|
||||
self.redirect(url)
|
||||
@ -169,11 +169,7 @@ class BaseHandler(RequestHandler):
|
||||
</html>""" % (error, error,
|
||||
trace_info, request_info))
|
||||
|
||||
def redirect(self, url, permanent=False, status=None):
|
||||
if not url.endswith("/"):
|
||||
url = url + "/"
|
||||
permanent = True
|
||||
|
||||
def redirect(self, url, permanent=True, status=None):
|
||||
super(BaseHandler, self).redirect(sickbeard.WEB_ROOT + url, permanent, status)
|
||||
|
||||
def get_current_user(self, *args, **kwargs):
|
||||
@ -389,7 +385,8 @@ class WebRoot(WebHandler):
|
||||
else:
|
||||
default_image_name = 'banner.png'
|
||||
|
||||
image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name)
|
||||
#image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name)
|
||||
static_image_path = '/images/' + default_image_name
|
||||
if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)):
|
||||
cache_obj = image_cache.ImageCache()
|
||||
|
||||
@ -405,12 +402,8 @@ class WebRoot(WebHandler):
|
||||
|
||||
if ek.ek(os.path.isfile, image_file_name):
|
||||
image_path = image_file_name
|
||||
static_image_path = '/cache' + image_path.replace(sickbeard.CACHE_DIR, '')
|
||||
|
||||
# from mimetypes import MimeTypes
|
||||
#mime_type, encoding = MimeTypes().guess_type(image_path)
|
||||
#self.set_header('Content-Type', mime_type)
|
||||
|
||||
static_image_path = image_path.replace(sickbeard.CACHE_DIR, '')
|
||||
self.redirect(static_image_path)
|
||||
|
||||
def setHomeLayout(self, layout):
|
||||
|
@ -12,23 +12,6 @@ from tornado.httpserver import HTTPServer
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.routes import route
|
||||
|
||||
|
||||
class MultiStaticFileHandler(StaticFileHandler):
|
||||
def initialize(self, paths):
|
||||
self.paths = paths
|
||||
|
||||
def get(self, path, include_body=True):
|
||||
for staticPath in self.paths:
|
||||
try:
|
||||
super(MultiStaticFileHandler, self).initialize(staticPath)
|
||||
return super(MultiStaticFileHandler, self).get(path.strip('/')).result()
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
continue
|
||||
raise
|
||||
raise HTTPError(404)
|
||||
|
||||
|
||||
class SRWebServer(threading.Thread):
|
||||
def __init__(self, options={}, io_loop=None):
|
||||
threading.Thread.__init__(self)
|
||||
@ -89,37 +72,52 @@ class SRWebServer(threading.Thread):
|
||||
gzip=True,
|
||||
xheaders=sickbeard.HANDLE_REVERSE_PROXY,
|
||||
cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
|
||||
login_url=r'%s/login/' % self.options['web_root'],
|
||||
login_url=r'%s/login' % self.options['web_root'],
|
||||
)
|
||||
|
||||
# Main Handlers
|
||||
self.app.add_handlers('.*$', [
|
||||
# webapi handler
|
||||
(r'%s(/?)' % self.options['api_root'], ApiHandler),
|
||||
|
||||
# webapi key retrieval
|
||||
(r'%s/getkey(/?)' % self.options['web_root'], KeyHandler),
|
||||
|
||||
# webapi builder redirect
|
||||
(r'%s/api/builder' % self.options['web_root'], RedirectHandler, {"url": self.options['web_root'] + '/apibuilder'}),
|
||||
|
||||
# webui login/logout handlers
|
||||
(r'%s/login(/?)' % self.options['web_root'], LoginHandler),
|
||||
(r'%s/logout(/?)' % self.options['web_root'], LogoutHandler),
|
||||
|
||||
# webui handlers
|
||||
] + route.get_routes(self.options['web_root']))
|
||||
|
||||
# Static Handlers
|
||||
# Static File Handlers
|
||||
self.app.add_handlers(".*$", [
|
||||
(r'%s/(favicon\.ico)' % self.options['web_root'], MultiStaticFileHandler,
|
||||
{'paths': [os.path.join(self.options['data_root'], 'images/ico/favicon.ico')]}),
|
||||
(r'%s/%s(.*)(/?)' % (self.options['web_root'], 'images'), MultiStaticFileHandler,
|
||||
{'paths': [os.path.join(self.options['data_root'], 'images'),
|
||||
os.path.join(sickbeard.CACHE_DIR, 'images')]}),
|
||||
(r'%s/%s(.*)(/?)' % (self.options['web_root'], 'css'), MultiStaticFileHandler,
|
||||
{'paths': [os.path.join(self.options['data_root'], 'css')]}),
|
||||
(r'%s/%s(.*)(/?)' % (self.options['web_root'], 'js'), MultiStaticFileHandler,
|
||||
{'paths': [os.path.join(self.options['data_root'], 'js')]}),
|
||||
])
|
||||
# favicon
|
||||
(r'%s/(favicon\.ico)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": os.path.join(self.options['data_root'], 'images/ico/favicon.ico')}),
|
||||
|
||||
# Static Videos Path
|
||||
if self.video_root:
|
||||
self.app.add_handlers(".*$", [
|
||||
(r'%s/%s/(.*)' % (self.options['web_root'], 'videos'), MultiStaticFileHandler,
|
||||
{'paths': [self.video_root]}),
|
||||
])
|
||||
# images
|
||||
(r'%s/images/(.*)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": os.path.join(self.options['data_root'], 'images')}),
|
||||
|
||||
# cached images
|
||||
(r'%s/cache/images/(.*)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": os.path.join(sickbeard.CACHE_DIR, 'images')}),
|
||||
|
||||
# css
|
||||
(r'%s/css/(.*)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": os.path.join(self.options['data_root'], 'css')}),
|
||||
|
||||
# javascript
|
||||
(r'%s/js/(.*)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": os.path.join(self.options['data_root'], 'js')}),
|
||||
|
||||
# videos
|
||||
] + [(r'%s/videos/(.*)' % self.options['web_root'], StaticFileHandler,
|
||||
{"path": self.video_root})])
|
||||
|
||||
def run(self):
|
||||
if self.enable_https:
|
||||
|
Loading…
Reference in New Issue
Block a user