Refactor page helper functions

This commit is contained in:
JonnyWong16 2020-02-20 09:00:10 -08:00
commit 5fad0a1d97
20 changed files with 254 additions and 232 deletions

View file

@ -53,7 +53,7 @@ DOCUMENTATION :: END
</%doc>
<%!
from plexpy.helpers import cast_to_int, pms_image_proxy
from plexpy.helpers import cast_to_int, page
# Human readable duration
def hd(seconds):
@ -73,7 +73,7 @@ DOCUMENTATION :: END
<div class="dashboard-stats-container">
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
<% fallback = 'art-live' if row0['live'] else 'art' %>
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${pms_image_proxy(row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
% elif stat_id == 'top_platforms':
<div id="stats-background-${stat_id}" class="dashboard-stats-background platform-${row0['platform_name']}-rgba no-image">
% else:
@ -82,7 +82,7 @@ DOCUMENTATION :: END
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
<div class="dashboard-stats-poster-container hidden-xs">
% if stat_id in ('top_music', 'popular_music'):
<div id="stats-thumb-${stat_id}-bg" class="dashboard-stats-poster" style="background-image: url(${pms_image_proxy(row0['thumb'], row0['rating_key'], 300, 300, 60, '282828', 3, fallback='cover')});"></div>
<div id="stats-thumb-${stat_id}-bg" class="dashboard-stats-poster" style="background-image: url(${page('pms_image_proxy', row0['thumb'], row0['rating_key'], 300, 300, 60, '282828', 3, fallback='cover')});"></div>
% endif
<%
height, fallback = ('450', 'poster')
@ -98,7 +98,7 @@ DOCUMENTATION :: END
href += '&source=history'
%>
<a id="stats-thumb-url-${stat_id}" href="${href}" title="${row0['title']}">
<div id="stats-thumb-${stat_id}" class="dashboard-stats-${fallback.split('-')[0]}" style="background-image: url(${pms_image_proxy(row0['thumb'], row0['rating_key'], 300, height, fallback=fallback)});"></div>
<div id="stats-thumb-${stat_id}" class="dashboard-stats-${fallback.split('-')[0]}" style="background-image: url(${page('pms_image_proxy', row0['thumb'], row0['rating_key'], 300, height, fallback=fallback)});"></div>
</a>
</div>
% elif stat_id == 'top_users':
@ -222,9 +222,9 @@ DOCUMENTATION :: END
}
}
$('#stats-thumb-url-' + stat_id).attr('href', href).prop('title', $(elem).data('title'));
$('#stats-background-' + stat_id).css('background-image', 'url(' + pms_image_proxy(art, rating_key, 500, 280, 40, '282828', 3, fallback_art) + ')');
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + pms_image_proxy(thumb, rating_key, 300, height, null, null, null, fallback_poster) + ')');
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(' + pms_image_proxy(thumb, rating_key, 300, height, 60, '282828', 3, fallback_poster) + ')');
$('#stats-background-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', art, rating_key, 500, 280, 40, '282828', 3, fallback_art) + ')');
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', thumb, rating_key, 300, height, null, null, null, fallback_poster) + ')');
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(' + page('pms_image_proxy', thumb, rating_key, 300, height, 60, '282828', 3, fallback_poster) + ')');
}
}