Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Dec 12, 2024
2 parents 172cbf4 + f5fb364 commit ad57049
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 64 deletions.
9 changes: 6 additions & 3 deletions movie_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
USE_NEXT_BUTTON = True
PLEX_AVAILABLE = False
JELLYFIN_AVAILABLE = False
MOBILE_TRUNCATION = False

# Other globals
all_plex_unwatched_movies = []
Expand All @@ -69,7 +70,7 @@ def load_settings():
global FEATURE_SETTINGS, CLIENT_SETTINGS, APPLE_TV_SETTINGS
global LG_TV_SETTINGS, PLEX_SETTINGS, JELLYFIN_SETTINGS
global HOMEPAGE_MODE, USE_LINKS, USE_FILTER, USE_WATCH_BUTTON, USE_NEXT_BUTTON
global PLEX_AVAILABLE, JELLYFIN_AVAILABLE
global PLEX_AVAILABLE, JELLYFIN_AVAILABLE, MOBILE_TRUNCATION

# Load all settings first
FEATURE_SETTINGS = settings.get('features', {})
Expand All @@ -85,6 +86,7 @@ def load_settings():
USE_FILTER = FEATURE_SETTINGS.get('use_filter', True)
USE_WATCH_BUTTON = FEATURE_SETTINGS.get('use_watch_button', True)
USE_NEXT_BUTTON = FEATURE_SETTINGS.get('use_next_button', True)
MOBILE_TRUNCATION = FEATURE_SETTINGS.get('mobile_truncation', False)

# Update service availability flags
PLEX_AVAILABLE = (
Expand Down Expand Up @@ -501,6 +503,7 @@ def index():
use_filter=USE_FILTER,
use_watch_button=USE_WATCH_BUTTON,
use_next_button=USE_NEXT_BUTTON,
mobile_truncation=MOBILE_TRUNCATION,
settings_disabled=settings.get('system', {}).get('disable_settings', False)
)

Expand Down Expand Up @@ -1198,8 +1201,8 @@ def get_plex_token():

# Store in global dict
_plex_pin_logins[client_id] = pin_login

logger.info(f"Plex auth initiated with PIN: {pin_login.pin}")
logger.info("Plex auth initiated with PIN: ****")

return jsonify({
"auth_url": "https://plex.tv/link",
Expand Down
128 changes: 96 additions & 32 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,35 @@ document.addEventListener('DOMContentLoaded', async function() {
setupEventListeners();
checkAndLoadCache();
try {
// Check current client configuration
const response = await fetch('/devices');
const devices = await response.json();
const powerButton = document.getElementById("btn_power");
if (powerButton) {
powerButton.style.display = devices.length > 0 ? 'flex' : 'none';
}
// Check current client configuration
const response = await fetch('/devices');
const devices = await response.json();
const powerButton = document.getElementById("btn_power");
const nextButton = document.getElementById("btn_next_movie");

if (powerButton && nextButton) {
if (devices.length > 0) {
powerButton.style.display = 'flex';
nextButton.style.flex = '';
} else {
powerButton.style.display = 'none';
if (window.matchMedia('(max-width: 767px)').matches) {
nextButton.style.flex = '0 0 100%';
nextButton.style.marginRight = '0';
}
}
}
} catch (error) {
console.error("Error checking devices:", error);
const powerButton = document.getElementById("btn_power");
if (powerButton) {
console.error("Error checking devices:", error);
const powerButton = document.getElementById("btn_power");
const nextButton = document.getElementById("btn_next_movie");
if (powerButton && nextButton) {
powerButton.style.display = 'none';
}
if (window.matchMedia('(max-width: 767px)').matches) {
nextButton.style.flex = '0 0 100%';
nextButton.style.marginRight = '0';
}
}
}
await syncTraktWatched(false);
startVersionChecker();
Expand Down Expand Up @@ -500,7 +516,7 @@ function updateMovieDisplay(movieData) {
return;
}

console.log('Movie data received:', movieData);
// console.log('Movie data received:', movieData);

hideMessage();

Expand Down Expand Up @@ -1093,44 +1109,92 @@ class ExpandableText {
}

reset() {
if (!this.element) return;
this.element.removeEventListener('click', this.boundToggle);
this.element.classList.remove('truncated', 'expanded');
this.element.style.webkitLineClamp = '1';
this.element.style.display = '-webkit-box';
this.element.style.maxHeight = '';
this.element.style.cursor = 'default';
this.state.expanded = false;
if (!this.element) return;
this.element.removeEventListener('click', this.boundToggle);
this.element.classList.remove('truncated', 'expanded');

// Check for mobile and truncation setting
const isMobileOrPWA = window.matchMedia('(max-width: 767px)').matches;
if (isMobileOrPWA) {
// On mobile, respect the MOBILE_TRUNCATION setting
if (window.MOBILE_TRUNCATION) {
this.element.style.webkitLineClamp = '1';
this.element.style.display = '-webkit-box';
} else {
this.element.style.webkitLineClamp = 'unset';
this.element.style.display = 'block';
}
} else {
// On desktop, always use truncation
this.element.style.webkitLineClamp = '1';
this.element.style.display = '-webkit-box';
}

this.element.style.maxHeight = '';
this.element.style.cursor = 'default';
this.state.expanded = false;
}

checkTruncation() {
if (!this.element) return;
if (!this.element) return;

requestAnimationFrame(() => {
requestAnimationFrame(() => {
void this.element.offsetHeight;

const isMobileOrPWA = window.matchMedia('(max-width: 767px)').matches;

// If on mobile and truncation is disabled, don't truncate
if (isMobileOrPWA && !window.MOBILE_TRUNCATION) {
this.state.truncated = false;
this.element.classList.remove('truncated');
this.element.style.cursor = 'default';
return;
}

const truncated = this.element.scrollHeight > this.element.clientHeight;
this.state.truncated = truncated;

if (truncated) {
this.element.classList.add('truncated');
this.element.style.cursor = 'pointer';
this.element.classList.add('truncated');
this.element.style.cursor = 'pointer';
}

console.log('Truncation check:', {
scrollHeight: this.element.scrollHeight,
clientHeight: this.element.clientHeight,
isTruncated: truncated,
text: this.element.textContent.substring(0, 50) + '...'
});
});
});
}

bindEvents() {
if (!this.element) return;
this.element.addEventListener('click', this.boundToggle);
}

checkTruncation() {
if (!this.element) return;

requestAnimationFrame(() => {
void this.element.offsetHeight;

// Add check for mobile and truncation setting
const isMobileOrPWA = window.matchMedia('(max-width: 768px)').matches || window.navigator.standalone;
const shouldTruncate = !isMobileOrPWA || window.MOBILE_TRUNCATION;

const truncated = shouldTruncate && this.element.scrollHeight > this.element.clientHeight;
this.state.truncated = truncated;

if (truncated) {
this.element.classList.add('truncated');
this.element.style.cursor = 'pointer';
}

console.log('Truncation check:', {
scrollHeight: this.element.scrollHeight,
clientHeight: this.element.clientHeight,
isTruncated: truncated,
isMobile: isMobileOrPWA,
truncationEnabled: window.MOBILE_TRUNCATION,
text: this.element.textContent.substring(0, 50) + '...'
});
});
}

toggle(e) {
if (e) e.stopPropagation();
if (!this.state.truncated || !this.element) return;
Expand Down
25 changes: 16 additions & 9 deletions static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ document.addEventListener('DOMContentLoaded', function() {
}

function renderSettingsSection(title, settings, envOverrides, fields) {
console.log('Current envOverrides:', envOverrides);
const section = document.createElement('div');
section.className = 'settings-section';

Expand All @@ -427,6 +426,13 @@ document.addEventListener('DOMContentLoaded', function() {
label.textContent = field.label;
fieldContainer.appendChild(label);

if (field.description) {
const description = document.createElement('div');
description.className = 'setting-description';
description.innerHTML = field.description;
fieldContainer.appendChild(description);
}

if (field.key === 'trakt.connect') {
createTraktIntegration(fieldContainer);
section.appendChild(fieldContainer);
Expand Down Expand Up @@ -490,11 +496,7 @@ document.addEventListener('DOMContentLoaded', function() {
const value = getNestedValue(settings, field.key);
let isOverridden = getNestedValue(envOverrides, field.key);

console.log(`Field ${field.key}:`, {
value,
isOverridden,
envOverrides: envOverrides
});
console.log(`Field ${field.key}: configured`);

const isIntegrationToggle = (
field.key === 'overseerr.enabled' ||
Expand Down Expand Up @@ -851,7 +853,13 @@ document.addEventListener('DOMContentLoaded', function() {
{ key: 'features.use_filter', label: 'Enable Filters', type: 'switch' },
{ key: 'features.use_watch_button', label: 'Enable Watch Button', type: 'switch' },
{ key: 'features.use_next_button', label: 'Enable Next Button', type: 'switch' },
{ key: 'features.homepage_mode', label: 'Homepage Mode', type: 'switch' }
{ key: 'features.mobile_truncation', label: 'Enable Mobile Description Truncation', type: 'switch' },
{
key: 'features.homepage_mode',
label: 'Homepage Mode',
type: 'switch',
description: 'Provides a simplified, non-interactive display format ideal for <a href="https://gethomepage.dev" target="_blank" rel="noopener noreferrer">Homepage</a> iframe integration. Removes buttons, links, and keeps movie descriptions fully expanded.'
}
]
},
{
Expand Down Expand Up @@ -1637,7 +1645,6 @@ document.addEventListener('DOMContentLoaded', function() {
}

const data = await response.json();
console.log("Auth data received:", data);

const authWindow = window.open(
data.auth_url,
Expand Down Expand Up @@ -1669,7 +1676,7 @@ document.addEventListener('DOMContentLoaded', function() {
const statusResponse = await fetch(`/api/plex/check_auth/${data.client_id}`);
const statusData = await statusResponse.json();

console.log("Status check:", statusData);
console.log("Auth status check completed");

if (statusData.token) {
clearInterval(checkAuth);
Expand Down
19 changes: 19 additions & 0 deletions static/style/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -930,3 +930,22 @@
width: 20px;
height: 20px;
}

.setting-description {
font-size: 0.9em;
color: #EAEAEC;
margin: 4px 0 8px 0;
opacity: 0.8;
line-height: 1.4;
}

.setting-description a {
color: #E5A00D;
text-decoration: none;
transition: color 0.2s;
}

.setting-description a:hover {
color: #F8D68B;
text-decoration: underline;
}
30 changes: 14 additions & 16 deletions static/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,15 @@ main {
flex: 0 0 calc(50% - 5px);
}

#btn_next_movie {
margin-right: 10px; /* Space between the buttons */
#btn_power[style*="display: none"] ~ #btn_next_movie,
#btn_power.hidden ~ #btn_next_movie {
flex: 0 0 100% !important;
max-width: 100% !important;
margin-right: 0 !important;
}

#btn_power {
margin-right: 0;
#btn_next_movie {
margin-right: 10px; /* Space between the buttons */
}

#switch_service {
Expand All @@ -1125,12 +1128,6 @@ main {
justify-content: center !important;
}

/* #switch_service .switch-icon {
margin-left: 8px !important;
width: 20px !important;
height: 20px !important;
} */

#switch_service .switch-icon {
position: absolute;
right: 12px;
Expand Down Expand Up @@ -1187,7 +1184,7 @@ main {
}

/* Description Adjustments */
#description {
body.homepage-mode #description {
display: block !important;
-webkit-line-clamp: unset !important;
-webkit-box-orient: unset !important;
Expand All @@ -1196,9 +1193,10 @@ main {
padding-right: 0 !important;
}

#description.truncated::after {
body.homepage-mode #description.truncated::after {
display: none !important;
}

}

/* PWA Specific Styles */
Expand Down Expand Up @@ -1277,12 +1275,12 @@ body.in-iframe .main-nav {
}

body.in-iframe main {
padding-top: 0;
padding-top: 0;
}

@media all and (display-mode: standalone) {
body.in-iframe main {
padding-top: 0;
padding-top: 0;
}
}

Expand Down Expand Up @@ -2438,12 +2436,12 @@ body.homepage-mode #description.truncated::after {
.trakt-confirm-dialog .dialog-content p,
.trakt-confirm-dialog .version-info {
color: #EAEAEC;
font-weight: 300;
font-weight: 300;
}

.trakt-confirm-dialog .changelog-content {
color: #EAEAEC;
font-weight: 300;
font-weight: 300;
white-space: pre-line;
line-height: 1.6;
}
2 changes: 1 addition & 1 deletion utils/fetch_movie_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def initialize_services():

# Initialize Plex
plex = PlexServer(plex_url, plex_token)
logger.info(f"Plex initialized with URL: {plex_url}, Libraries: {PLEX_MOVIE_LIBRARIES}")
logger.info(f"Plex initialized with URL: {plex_url}, Libraries: [REDACTED]")
except Exception as e:
logger.error(f"Error initializing Plex: {e}")
PLEX_AVAILABLE = False
Expand Down
Loading

0 comments on commit ad57049

Please sign in to comment.