chore: run prettier on all src/ files to fix formatting
Co-Authored-By: Justin Edmund <justin@jedmund.com>
This commit is contained in:
parent
d60eba6e90
commit
8cc5cedc9d
65 changed files with 1917 additions and 1681 deletions
|
|
@ -67,12 +67,21 @@ export async function request<TResponse = unknown, TBody = unknown>(
|
||||||
export const api = {
|
export const api = {
|
||||||
get: <T = unknown>(url: string, opts: Omit<RequestOptions, 'method' | 'body'> = {}) =>
|
get: <T = unknown>(url: string, opts: Omit<RequestOptions, 'method' | 'body'> = {}) =>
|
||||||
request<T>(url, { ...opts, method: 'GET' }),
|
request<T>(url, { ...opts, method: 'GET' }),
|
||||||
post: <T = unknown, B = unknown>(url: string, body: B, opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}) =>
|
post: <T = unknown, B = unknown>(
|
||||||
request<T, B>(url, { ...opts, method: 'POST', body }),
|
url: string,
|
||||||
put: <T = unknown, B = unknown>(url: string, body: B, opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}) =>
|
body: B,
|
||||||
request<T, B>(url, { ...opts, method: 'PUT', body }),
|
opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}
|
||||||
patch: <T = unknown, B = unknown>(url: string, body: B, opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}) =>
|
) => request<T, B>(url, { ...opts, method: 'POST', body }),
|
||||||
request<T, B>(url, { ...opts, method: 'PATCH', body }),
|
put: <T = unknown, B = unknown>(
|
||||||
|
url: string,
|
||||||
|
body: B,
|
||||||
|
opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}
|
||||||
|
) => request<T, B>(url, { ...opts, method: 'PUT', body }),
|
||||||
|
patch: <T = unknown, B = unknown>(
|
||||||
|
url: string,
|
||||||
|
body: B,
|
||||||
|
opts: Omit<RequestOptions<B>, 'method' | 'body'> = {}
|
||||||
|
) => request<T, B>(url, { ...opts, method: 'PATCH', body }),
|
||||||
delete: <T = unknown>(url: string, opts: Omit<RequestOptions, 'method' | 'body'> = {}) =>
|
delete: <T = unknown>(url: string, opts: Omit<RequestOptions, 'method' | 'body'> = {}) =>
|
||||||
request<T>(url, { ...opts, method: 'DELETE' })
|
request<T>(url, { ...opts, method: 'DELETE' })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,37 +127,53 @@ export function createListFilters<T>(
|
||||||
*/
|
*/
|
||||||
export const commonSorts = {
|
export const commonSorts = {
|
||||||
/** Sort by date field, newest first */
|
/** Sort by date field, newest first */
|
||||||
dateDesc: <T>(field: keyof T) => (a: T, b: T) =>
|
dateDesc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
new Date(b[field] as string).getTime() - new Date(a[field] as string).getTime(),
|
new Date(b[field] as string).getTime() - new Date(a[field] as string).getTime(),
|
||||||
|
|
||||||
/** Sort by date field, oldest first */
|
/** Sort by date field, oldest first */
|
||||||
dateAsc: <T>(field: keyof T) => (a: T, b: T) =>
|
dateAsc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
new Date(a[field] as string).getTime() - new Date(b[field] as string).getTime(),
|
new Date(a[field] as string).getTime() - new Date(b[field] as string).getTime(),
|
||||||
|
|
||||||
/** Sort by string field, A-Z */
|
/** Sort by string field, A-Z */
|
||||||
stringAsc: <T>(field: keyof T) => (a: T, b: T) =>
|
stringAsc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
String(a[field] || '').localeCompare(String(b[field] || '')),
|
String(a[field] || '').localeCompare(String(b[field] || '')),
|
||||||
|
|
||||||
/** Sort by string field, Z-A */
|
/** Sort by string field, Z-A */
|
||||||
stringDesc: <T>(field: keyof T) => (a: T, b: T) =>
|
stringDesc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
String(b[field] || '').localeCompare(String(a[field] || '')),
|
String(b[field] || '').localeCompare(String(a[field] || '')),
|
||||||
|
|
||||||
/** Sort by number field, ascending */
|
/** Sort by number field, ascending */
|
||||||
numberAsc: <T>(field: keyof T) => (a: T, b: T) =>
|
numberAsc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
Number(a[field]) - Number(b[field]),
|
Number(a[field]) - Number(b[field]),
|
||||||
|
|
||||||
/** Sort by number field, descending */
|
/** Sort by number field, descending */
|
||||||
numberDesc: <T>(field: keyof T) => (a: T, b: T) =>
|
numberDesc:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) =>
|
||||||
Number(b[field]) - Number(a[field]),
|
Number(b[field]) - Number(a[field]),
|
||||||
|
|
||||||
/** Sort by status field, published first */
|
/** Sort by status field, published first */
|
||||||
statusPublishedFirst: <T>(field: keyof T) => (a: T, b: T) => {
|
statusPublishedFirst:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) => {
|
||||||
if (a[field] === b[field]) return 0
|
if (a[field] === b[field]) return 0
|
||||||
return a[field] === 'published' ? -1 : 1
|
return a[field] === 'published' ? -1 : 1
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Sort by status field, draft first */
|
/** Sort by status field, draft first */
|
||||||
statusDraftFirst: <T>(field: keyof T) => (a: T, b: T) => {
|
statusDraftFirst:
|
||||||
|
<T>(field: keyof T) =>
|
||||||
|
(a: T, b: T) => {
|
||||||
if (a[field] === b[field]) return 0
|
if (a[field] === b[field]) return 0
|
||||||
return a[field] === 'draft' ? -1 : 1
|
return a[field] === 'draft' ? -1 : 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,8 @@
|
||||||
|
|
||||||
{#if searchError}
|
{#if searchError}
|
||||||
<div class="error-message">
|
<div class="error-message">
|
||||||
<strong>Error:</strong> {searchError}
|
<strong>Error:</strong>
|
||||||
|
{searchError}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
@ -152,13 +153,7 @@
|
||||||
<h3>Results</h3>
|
<h3>Results</h3>
|
||||||
|
|
||||||
<div class="result-tabs">
|
<div class="result-tabs">
|
||||||
<button
|
<button class="tab" class:active={true} onclick={() => {}}> Raw JSON </button>
|
||||||
class="tab"
|
|
||||||
class:active={true}
|
|
||||||
onclick={() => {}}
|
|
||||||
>
|
|
||||||
Raw JSON
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="copy-btn"
|
class="copy-btn"
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
|
|
@ -277,7 +272,8 @@
|
||||||
margin-bottom: $unit-half;
|
margin-bottom: $unit-half;
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select {
|
input,
|
||||||
|
select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
let isBlinking = $state(false)
|
let isBlinking = $state(false)
|
||||||
let isPlayingMusic = $state(forcePlayingMusic)
|
let isPlayingMusic = $state(forcePlayingMusic)
|
||||||
|
|
||||||
|
|
||||||
const scale = new Spring(1, {
|
const scale = new Spring(1, {
|
||||||
stiffness: 0.1,
|
stiffness: 0.1,
|
||||||
damping: 0.125
|
damping: 0.125
|
||||||
|
|
|
||||||
|
|
@ -51,18 +51,25 @@
|
||||||
connected = state.connected
|
connected = state.connected
|
||||||
|
|
||||||
// Flash indicator when update is received
|
// Flash indicator when update is received
|
||||||
if (state.lastUpdate && (!lastUpdate || state.lastUpdate.getTime() !== lastUpdate.getTime())) {
|
if (
|
||||||
|
state.lastUpdate &&
|
||||||
|
(!lastUpdate || state.lastUpdate.getTime() !== lastUpdate.getTime())
|
||||||
|
) {
|
||||||
updateFlash = true
|
updateFlash = true
|
||||||
setTimeout(() => updateFlash = false, 500)
|
setTimeout(() => (updateFlash = false), 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUpdate = state.lastUpdate
|
lastUpdate = state.lastUpdate
|
||||||
|
|
||||||
// Calculate smart interval based on track remaining time
|
// Calculate smart interval based on track remaining time
|
||||||
const nowPlayingAlbum = state.albums.find(a => a.isNowPlaying)
|
const nowPlayingAlbum = state.albums.find((a) => a.isNowPlaying)
|
||||||
if (nowPlayingAlbum?.nowPlayingTrack && nowPlayingAlbum.appleMusicData?.tracks && nowPlayingAlbum.lastScrobbleTime) {
|
if (
|
||||||
|
nowPlayingAlbum?.nowPlayingTrack &&
|
||||||
|
nowPlayingAlbum.appleMusicData?.tracks &&
|
||||||
|
nowPlayingAlbum.lastScrobbleTime
|
||||||
|
) {
|
||||||
const track = nowPlayingAlbum.appleMusicData.tracks.find(
|
const track = nowPlayingAlbum.appleMusicData.tracks.find(
|
||||||
t => t.name === nowPlayingAlbum.nowPlayingTrack
|
(t) => t.name === nowPlayingAlbum.nowPlayingTrack
|
||||||
)
|
)
|
||||||
|
|
||||||
if (track?.durationMs) {
|
if (track?.durationMs) {
|
||||||
|
|
@ -109,7 +116,7 @@
|
||||||
// Calculate initial remaining time
|
// Calculate initial remaining time
|
||||||
const calculateRemaining = () => {
|
const calculateRemaining = () => {
|
||||||
const elapsed = Date.now() - lastUpdate.getTime()
|
const elapsed = Date.now() - lastUpdate.getTime()
|
||||||
const remaining = (updateInterval * 1000) - elapsed
|
const remaining = updateInterval * 1000 - elapsed
|
||||||
return Math.max(0, Math.ceil(remaining / 1000))
|
return Math.max(0, Math.ceil(remaining / 1000))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +220,7 @@
|
||||||
|
|
||||||
{#if dev}
|
{#if dev}
|
||||||
<div class="debug-panel" class:minimized={isMinimized}>
|
<div class="debug-panel" class:minimized={isMinimized}>
|
||||||
<div class="debug-header" onclick={() => isMinimized = !isMinimized}>
|
<div class="debug-header" onclick={() => (isMinimized = !isMinimized)}>
|
||||||
<h3>Debug Panel</h3>
|
<h3>Debug Panel</h3>
|
||||||
<button class="minimize-btn" aria-label={isMinimized ? 'Expand' : 'Minimize'}>
|
<button class="minimize-btn" aria-label={isMinimized ? 'Expand' : 'Minimize'}>
|
||||||
{isMinimized ? '▲' : '▼'}
|
{isMinimized ? '▲' : '▼'}
|
||||||
|
|
@ -226,21 +233,21 @@
|
||||||
<button
|
<button
|
||||||
class="tab"
|
class="tab"
|
||||||
class:active={activeTab === 'nowplaying'}
|
class:active={activeTab === 'nowplaying'}
|
||||||
onclick={() => activeTab = 'nowplaying'}
|
onclick={() => (activeTab = 'nowplaying')}
|
||||||
>
|
>
|
||||||
Now Playing
|
Now Playing
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="tab"
|
class="tab"
|
||||||
class:active={activeTab === 'albums'}
|
class:active={activeTab === 'albums'}
|
||||||
onclick={() => activeTab = 'albums'}
|
onclick={() => (activeTab = 'albums')}
|
||||||
>
|
>
|
||||||
Albums
|
Albums
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="tab"
|
class="tab"
|
||||||
class:active={activeTab === 'cache'}
|
class:active={activeTab === 'cache'}
|
||||||
onclick={() => activeTab = 'cache'}
|
onclick={() => (activeTab = 'cache')}
|
||||||
>
|
>
|
||||||
Cache
|
Cache
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -251,13 +258,21 @@
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h4>Connection</h4>
|
<h4>Connection</h4>
|
||||||
<p class="status" class:connected>
|
<p class="status" class:connected>
|
||||||
Status: {#if connected}<CheckIcon class="icon status-icon success" /> Connected{:else}<XIcon class="icon status-icon error" /> Disconnected{/if}
|
Status: {#if connected}<CheckIcon class="icon status-icon success" /> Connected{:else}<XIcon
|
||||||
|
class="icon status-icon error"
|
||||||
|
/> Disconnected{/if}
|
||||||
</p>
|
</p>
|
||||||
<p class:flash={updateFlash}>
|
<p class:flash={updateFlash}>
|
||||||
Last Update: {lastUpdate ? lastUpdate.toLocaleTimeString() : 'Never'}
|
Last Update: {lastUpdate ? lastUpdate.toLocaleTimeString() : 'Never'}
|
||||||
</p>
|
</p>
|
||||||
<p>Next Update: {formatTime(nextUpdateIn)}</p>
|
<p>Next Update: {formatTime(nextUpdateIn)}</p>
|
||||||
<p>Interval: {updateInterval}s {trackRemainingTime > 0 ? `(smart mode)` : nowPlaying ? '(fast mode)' : '(normal)'}</p>
|
<p>
|
||||||
|
Interval: {updateInterval}s {trackRemainingTime > 0
|
||||||
|
? `(smart mode)`
|
||||||
|
: nowPlaying
|
||||||
|
? '(fast mode)'
|
||||||
|
: '(normal)'}
|
||||||
|
</p>
|
||||||
{#if trackRemainingTime > 0}
|
{#if trackRemainingTime > 0}
|
||||||
<p>Track Remaining: {formatTime(trackRemainingTime)}</p>
|
<p>Track Remaining: {formatTime(trackRemainingTime)}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -274,7 +289,10 @@
|
||||||
{/if}
|
{/if}
|
||||||
{#if nowPlaying.album.appleMusicData}
|
{#if nowPlaying.album.appleMusicData}
|
||||||
<p class="preview">
|
<p class="preview">
|
||||||
<span>Preview:</span> {#if nowPlaying.album.appleMusicData.previewUrl}<CheckIcon class="icon success" /> Available{:else}<XIcon class="icon error" /> Not found{/if}
|
<span>Preview:</span>
|
||||||
|
{#if nowPlaying.album.appleMusicData.previewUrl}<CheckIcon
|
||||||
|
class="icon success"
|
||||||
|
/> Available{:else}<XIcon class="icon error" /> Not found{/if}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -290,8 +308,16 @@
|
||||||
<div class="albums-list">
|
<div class="albums-list">
|
||||||
{#each albums as album}
|
{#each albums as album}
|
||||||
{@const albumId = `${album.artist.name}:${album.name}`}
|
{@const albumId = `${album.artist.name}:${album.name}`}
|
||||||
<div class="album-item" class:playing={album.isNowPlaying} class:expanded={expandedAlbumId === albumId}>
|
<div
|
||||||
<div class="album-header" onclick={() => expandedAlbumId = expandedAlbumId === albumId ? null : albumId}>
|
class="album-item"
|
||||||
|
class:playing={album.isNowPlaying}
|
||||||
|
class:expanded={expandedAlbumId === albumId}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="album-header"
|
||||||
|
onclick={() =>
|
||||||
|
(expandedAlbumId = expandedAlbumId === albumId ? null : albumId)}
|
||||||
|
>
|
||||||
<div class="album-content">
|
<div class="album-content">
|
||||||
<div class="album-info">
|
<div class="album-info">
|
||||||
<span class="name">{album.name}</span>
|
<span class="name">{album.name}</span>
|
||||||
|
|
@ -306,7 +332,9 @@
|
||||||
{album.appleMusicData.tracks?.length || 0} tracks
|
{album.appleMusicData.tracks?.length || 0} tracks
|
||||||
</span>
|
</span>
|
||||||
<span class="meta-item">
|
<span class="meta-item">
|
||||||
{#if album.appleMusicData.previewUrl}<CheckIcon class="icon success inline" /> Preview{:else}<XIcon class="icon error inline" /> No preview{/if}
|
{#if album.appleMusicData.previewUrl}<CheckIcon
|
||||||
|
class="icon success inline"
|
||||||
|
/> Preview{:else}<XIcon class="icon error inline" /> No preview{/if}
|
||||||
</span>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="meta-item">No Apple Music data</span>
|
<span class="meta-item">No Apple Music data</span>
|
||||||
|
|
@ -315,7 +343,10 @@
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="clear-cache-btn"
|
class="clear-cache-btn"
|
||||||
onclick={(e) => { e.stopPropagation(); clearAlbumCache(album) }}
|
onclick={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
clearAlbumCache(album)
|
||||||
|
}}
|
||||||
disabled={clearingAlbums.has(albumId)}
|
disabled={clearingAlbums.has(albumId)}
|
||||||
title="Clear Apple Music cache for this album"
|
title="Clear Apple Music cache for this album"
|
||||||
>
|
>
|
||||||
|
|
@ -333,9 +364,18 @@
|
||||||
{#if album.appleMusicData.searchMetadata}
|
{#if album.appleMusicData.searchMetadata}
|
||||||
<h5>Search Information</h5>
|
<h5>Search Information</h5>
|
||||||
<div class="search-metadata">
|
<div class="search-metadata">
|
||||||
<p><strong>Search Query:</strong> <code>{album.appleMusicData.searchMetadata.searchQuery}</code></p>
|
<p>
|
||||||
<p><strong>Search Time:</strong> {new Date(album.appleMusicData.searchMetadata.searchTime).toLocaleString()}</p>
|
<strong>Search Query:</strong>
|
||||||
<p><strong>Status:</strong>
|
<code>{album.appleMusicData.searchMetadata.searchQuery}</code>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Search Time:</strong>
|
||||||
|
{new Date(
|
||||||
|
album.appleMusicData.searchMetadata.searchTime
|
||||||
|
).toLocaleString()}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Status:</strong>
|
||||||
{#if album.appleMusicData.searchMetadata.found}
|
{#if album.appleMusicData.searchMetadata.found}
|
||||||
<CheckIcon class="icon success inline" /> Found
|
<CheckIcon class="icon success inline" /> Found
|
||||||
{:else}
|
{:else}
|
||||||
|
|
@ -343,14 +383,22 @@
|
||||||
{/if}
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
{#if album.appleMusicData.searchMetadata.error}
|
{#if album.appleMusicData.searchMetadata.error}
|
||||||
<p><strong>Error:</strong> <span class="error-text">{album.appleMusicData.searchMetadata.error}</span></p>
|
<p>
|
||||||
|
<strong>Error:</strong>
|
||||||
|
<span class="error-text"
|
||||||
|
>{album.appleMusicData.searchMetadata.error}</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if album.appleMusicData.appleMusicId}
|
{#if album.appleMusicData.appleMusicId}
|
||||||
<h5>Apple Music Details</h5>
|
<h5>Apple Music Details</h5>
|
||||||
<p><strong>Apple Music ID:</strong> {album.appleMusicData.appleMusicId}</p>
|
<p>
|
||||||
|
<strong>Apple Music ID:</strong>
|
||||||
|
{album.appleMusicData.appleMusicId}
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if album.appleMusicData.releaseDate}
|
{#if album.appleMusicData.releaseDate}
|
||||||
|
|
@ -366,7 +414,10 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if album.appleMusicData.previewUrl}
|
{#if album.appleMusicData.previewUrl}
|
||||||
<p><strong>Preview URL:</strong> <code>{album.appleMusicData.previewUrl}</code></p>
|
<p>
|
||||||
|
<strong>Preview URL:</strong>
|
||||||
|
<code>{album.appleMusicData.previewUrl}</code>
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if album.appleMusicData.tracks?.length}
|
{#if album.appleMusicData.tracks?.length}
|
||||||
|
|
@ -378,7 +429,11 @@
|
||||||
<span class="track-number">{i + 1}.</span>
|
<span class="track-number">{i + 1}.</span>
|
||||||
<span class="track-name">{track.name}</span>
|
<span class="track-name">{track.name}</span>
|
||||||
{#if track.durationMs}
|
{#if track.durationMs}
|
||||||
<span class="track-duration">{Math.floor(track.durationMs / 60000)}:{String(Math.floor((track.durationMs % 60000) / 1000)).padStart(2, '0')}</span>
|
<span class="track-duration"
|
||||||
|
>{Math.floor(track.durationMs / 60000)}:{String(
|
||||||
|
Math.floor((track.durationMs % 60000) / 1000)
|
||||||
|
).padStart(2, '0')}</span
|
||||||
|
>
|
||||||
{/if}
|
{/if}
|
||||||
{#if track.previewUrl}
|
{#if track.previewUrl}
|
||||||
<CheckIcon class="icon success inline" title="Has preview" />
|
<CheckIcon class="icon success inline" title="Has preview" />
|
||||||
|
|
@ -395,7 +450,9 @@
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<h5>No Apple Music Data</h5>
|
<h5>No Apple Music Data</h5>
|
||||||
<p class="no-data">This album was not searched in Apple Music or the search is pending.</p>
|
<p class="no-data">
|
||||||
|
This album was not searched in Apple Music or the search is pending.
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -426,11 +483,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cache-actions">
|
<div class="cache-actions">
|
||||||
<button
|
<button onclick={clearAllMusicCache} disabled={isClearing} class="clear-all-btn">
|
||||||
onclick={clearAllMusicCache}
|
|
||||||
disabled={isClearing}
|
|
||||||
class="clear-all-btn"
|
|
||||||
>
|
|
||||||
{isClearing ? 'Clearing...' : 'Clear All Music Cache'}
|
{isClearing ? 'Clearing...' : 'Clear All Music Cache'}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
@ -463,10 +516,7 @@
|
||||||
{isClearing ? 'Clearing...' : 'Clear Not Found Cache'}
|
{isClearing ? 'Clearing...' : 'Clear Not Found Cache'}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button onclick={() => searchModal?.open()} class="search-btn">
|
||||||
onclick={() => searchModal?.open()}
|
|
||||||
class="search-btn"
|
|
||||||
>
|
|
||||||
Test Apple Music Search
|
Test Apple Music Search
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -912,7 +962,8 @@
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: $unit;
|
gap: $unit;
|
||||||
|
|
||||||
.clear-all-btn, .clear-not-found-btn {
|
.clear-all-btn,
|
||||||
|
.clear-not-found-btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 140px;
|
min-width: 140px;
|
||||||
padding: $unit * 1.5;
|
padding: $unit * 1.5;
|
||||||
|
|
|
||||||
|
|
@ -250,8 +250,8 @@
|
||||||
background: $gray-95;
|
background: $gray-95;
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New',
|
font-family:
|
||||||
monospace;
|
'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
color: $text-color;
|
color: $text-color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,13 @@
|
||||||
|
|
||||||
let { album, getAlbumArtwork }: Props = $props()
|
let { album, getAlbumArtwork }: Props = $props()
|
||||||
|
|
||||||
const trackText = $derived(`${album.artist.name} — ${album.name}${
|
const trackText = $derived(
|
||||||
|
`${album.artist.name} — ${album.name}${
|
||||||
album.appleMusicData?.releaseDate
|
album.appleMusicData?.releaseDate
|
||||||
? ` (${new Date(album.appleMusicData.releaseDate).getFullYear()})`
|
? ` (${new Date(album.appleMusicData.releaseDate).getFullYear()})`
|
||||||
: ''
|
: ''
|
||||||
} — ${album.nowPlayingTrack || album.name}`)
|
} — ${album.nowPlayingTrack || album.name}`
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="now-playing-bar">
|
<nav class="now-playing-bar">
|
||||||
|
|
|
||||||
|
|
@ -229,8 +229,8 @@
|
||||||
.metadata-value {
|
.metadata-value {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: $gray-10;
|
color: $gray-10;
|
||||||
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New',
|
font-family:
|
||||||
monospace;
|
'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -275,10 +275,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
{#if !isLoading}
|
{#if !isLoading}
|
||||||
<AutoSaveStatus
|
<AutoSaveStatus status="idle" lastSavedAt={album?.updatedAt} />
|
||||||
status="idle"
|
|
||||||
lastSavedAt={album?.updatedAt}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,14 @@
|
||||||
ondelete?: (event: CustomEvent<{ album: Album; event: MouseEvent }>) => void
|
ondelete?: (event: CustomEvent<{ album: Album; event: MouseEvent }>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
let { album, isDropdownActive = false, ontoggledropdown, onedit, ontogglepublish, ondelete }: Props = $props()
|
let {
|
||||||
|
album,
|
||||||
|
isDropdownActive = false,
|
||||||
|
ontoggledropdown,
|
||||||
|
onedit,
|
||||||
|
ontogglepublish,
|
||||||
|
ondelete
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
function formatRelativeTime(dateString: string): string {
|
function formatRelativeTime(dateString: string): string {
|
||||||
const date = new Date(dateString)
|
const date = new Date(dateString)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
to { transform: rotate(360deg); }
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
<div class="draft-banner">
|
<div class="draft-banner">
|
||||||
<div class="draft-banner-content">
|
<div class="draft-banner-content">
|
||||||
<span class="draft-banner-text">
|
<span class="draft-banner-text">
|
||||||
Unsaved draft found{#if timeAgo} (saved {timeAgo}){/if}.
|
Unsaved draft found{#if timeAgo}
|
||||||
|
(saved {timeAgo}){/if}.
|
||||||
</span>
|
</span>
|
||||||
<div class="draft-banner-actions">
|
<div class="draft-banner-actions">
|
||||||
<button class="draft-banner-button" type="button" onclick={onRestore}>Restore</button>
|
<button class="draft-banner-button" type="button" onclick={onRestore}>Restore</button>
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,9 @@
|
||||||
let showDraftPrompt = $state(false)
|
let showDraftPrompt = $state(false)
|
||||||
let draftTimestamp = $state<number | null>(null)
|
let draftTimestamp = $state<number | null>(null)
|
||||||
let timeTicker = $state(0)
|
let timeTicker = $state(0)
|
||||||
const draftTimeText = $derived.by(() => (draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null))
|
const draftTimeText = $derived.by(() =>
|
||||||
|
draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null
|
||||||
|
)
|
||||||
|
|
||||||
function buildPayload() {
|
function buildPayload() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -65,7 +67,8 @@ function buildPayload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autosave store (edit mode only)
|
// Autosave store (edit mode only)
|
||||||
let autoSave = mode === 'edit' && postId
|
let autoSave =
|
||||||
|
mode === 'edit' && postId
|
||||||
? createAutoSaveStore({
|
? createAutoSaveStore({
|
||||||
debounceMs: 2000,
|
debounceMs: 2000,
|
||||||
getPayload: () => (hasLoaded ? buildPayload() : null),
|
getPayload: () => (hasLoaded ? buildPayload() : null),
|
||||||
|
|
@ -126,7 +129,12 @@ $effect(() => {
|
||||||
|
|
||||||
// Trigger autosave when form data changes
|
// Trigger autosave when form data changes
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
title; slug; status; content; tags; activeTab
|
title
|
||||||
|
slug
|
||||||
|
status
|
||||||
|
content
|
||||||
|
tags
|
||||||
|
activeTab
|
||||||
if (hasLoaded && autoSave) {
|
if (hasLoaded && autoSave) {
|
||||||
autoSave.schedule()
|
autoSave.schedule()
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +319,6 @@ $effect(() => {
|
||||||
isSaving = false
|
isSaving = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AdminPage>
|
<AdminPage>
|
||||||
|
|
@ -341,7 +348,8 @@ $effect(() => {
|
||||||
<div class="draft-banner">
|
<div class="draft-banner">
|
||||||
<div class="draft-banner-content">
|
<div class="draft-banner-content">
|
||||||
<span class="draft-banner-text">
|
<span class="draft-banner-text">
|
||||||
Unsaved draft found{#if draftTimeText} (saved {draftTimeText}){/if}.
|
Unsaved draft found{#if draftTimeText}
|
||||||
|
(saved {draftTimeText}){/if}.
|
||||||
</span>
|
</span>
|
||||||
<div class="draft-banner-actions">
|
<div class="draft-banner-actions">
|
||||||
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
||||||
|
|
@ -381,11 +389,7 @@ $effect(() => {
|
||||||
|
|
||||||
<Input label="Slug" bind:value={slug} placeholder="essay-url-slug" />
|
<Input label="Slug" bind:value={slug} placeholder="essay-url-slug" />
|
||||||
|
|
||||||
<DropdownSelectField
|
<DropdownSelectField label="Status" bind:value={status} options={statusOptions} />
|
||||||
label="Status"
|
|
||||||
bind:value={status}
|
|
||||||
options={statusOptions}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="tags-field">
|
<div class="tags-field">
|
||||||
<label class="input-label">Tags</label>
|
<label class="input-label">Tags</label>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from './Button.svelte'
|
import Button from './Button.svelte'
|
||||||
import { formatFileSize, getFileType, isVideoFile, formatDuration, formatBitrate } from '$lib/utils/mediaHelpers'
|
import {
|
||||||
|
formatFileSize,
|
||||||
|
getFileType,
|
||||||
|
isVideoFile,
|
||||||
|
formatDuration,
|
||||||
|
formatBitrate
|
||||||
|
} from '$lib/utils/mediaHelpers'
|
||||||
import type { Media } from '@prisma/client'
|
import type { Media } from '@prisma/client'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@
|
||||||
let showDraftPrompt = $state(false)
|
let showDraftPrompt = $state(false)
|
||||||
let draftTimestamp = $state<number | null>(null)
|
let draftTimestamp = $state<number | null>(null)
|
||||||
let timeTicker = $state(0)
|
let timeTicker = $state(0)
|
||||||
const draftTimeText = $derived.by(() => (draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null))
|
const draftTimeText = $derived.by(() =>
|
||||||
|
draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null
|
||||||
|
)
|
||||||
|
|
||||||
function buildPayload() {
|
function buildPayload() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -68,7 +70,8 @@ function buildPayload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autosave store (edit mode only)
|
// Autosave store (edit mode only)
|
||||||
let autoSave = mode === 'edit' && postId
|
let autoSave =
|
||||||
|
mode === 'edit' && postId
|
||||||
? createAutoSaveStore({
|
? createAutoSaveStore({
|
||||||
debounceMs: 2000,
|
debounceMs: 2000,
|
||||||
getPayload: () => (hasLoaded ? buildPayload() : null),
|
getPayload: () => (hasLoaded ? buildPayload() : null),
|
||||||
|
|
@ -101,7 +104,11 @@ let autoSave = mode === 'edit' && postId
|
||||||
|
|
||||||
// Trigger autosave when form data changes
|
// Trigger autosave when form data changes
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
title; status; content; featuredImage; tags
|
title
|
||||||
|
status
|
||||||
|
content
|
||||||
|
featuredImage
|
||||||
|
tags
|
||||||
if (hasLoaded && autoSave) {
|
if (hasLoaded && autoSave) {
|
||||||
autoSave.schedule()
|
autoSave.schedule()
|
||||||
}
|
}
|
||||||
|
|
@ -397,7 +404,8 @@ $effect(() => {
|
||||||
<div class="draft-banner">
|
<div class="draft-banner">
|
||||||
<div class="draft-banner-content">
|
<div class="draft-banner-content">
|
||||||
<span class="draft-banner-text">
|
<span class="draft-banner-text">
|
||||||
Unsaved draft found{#if draftTimeText} (saved {draftTimeText}){/if}.
|
Unsaved draft found{#if draftTimeText}
|
||||||
|
(saved {draftTimeText}){/if}.
|
||||||
</span>
|
</span>
|
||||||
<div class="draft-banner-actions">
|
<div class="draft-banner-actions">
|
||||||
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="dropdown-container" use:clickOutside={{ enabled: isOpen }} onclickoutside={handleClickOutside}>
|
<div
|
||||||
|
class="dropdown-container"
|
||||||
|
use:clickOutside={{ enabled: isOpen }}
|
||||||
|
onclickoutside={handleClickOutside}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
bind:this={buttonRef}
|
bind:this={buttonRef}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
|
|
||||||
|
|
@ -165,9 +165,7 @@
|
||||||
|
|
||||||
{#if isDropdownOpen}
|
{#if isDropdownOpen}
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<button class="dropdown-item" type="button" onclick={handleEdit}>
|
<button class="dropdown-item" type="button" onclick={handleEdit}> Edit post </button>
|
||||||
Edit post
|
|
||||||
</button>
|
|
||||||
<button class="dropdown-item" type="button" onclick={handleTogglePublish}>
|
<button class="dropdown-item" type="button" onclick={handleTogglePublish}>
|
||||||
{post.status === 'published' ? 'Unpublish' : 'Publish'} post
|
{post.status === 'published' ? 'Unpublish' : 'Publish'} post
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,9 @@
|
||||||
const hasFeaturedImage = $derived(
|
const hasFeaturedImage = $derived(
|
||||||
!!(formData.featuredImage && featuredImageMedia) || !!featuredImageMedia
|
!!(formData.featuredImage && featuredImageMedia) || !!featuredImageMedia
|
||||||
)
|
)
|
||||||
const hasBackgroundColor = $derived(!!(formData.backgroundColor && formData.backgroundColor?.trim()))
|
const hasBackgroundColor = $derived(
|
||||||
|
!!(formData.backgroundColor && formData.backgroundColor?.trim())
|
||||||
|
)
|
||||||
const hasLogo = $derived(!!(formData.logoUrl && logoMedia) || !!logoMedia)
|
const hasLogo = $derived(!!(formData.logoUrl && logoMedia) || !!logoMedia)
|
||||||
|
|
||||||
// Auto-disable toggles when content is removed
|
// Auto-disable toggles when content is removed
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@
|
||||||
const draftKey = $derived(mode === 'edit' && project ? makeDraftKey('project', project.id) : null)
|
const draftKey = $derived(mode === 'edit' && project ? makeDraftKey('project', project.id) : null)
|
||||||
|
|
||||||
// Autosave (edit mode only)
|
// Autosave (edit mode only)
|
||||||
const autoSave = mode === 'edit'
|
const autoSave =
|
||||||
|
mode === 'edit'
|
||||||
? createAutoSaveStore({
|
? createAutoSaveStore({
|
||||||
debounceMs: 2000,
|
debounceMs: 2000,
|
||||||
getPayload: () => (hasLoaded ? formStore.buildPayload() : null),
|
getPayload: () => (hasLoaded ? formStore.buildPayload() : null),
|
||||||
|
|
@ -89,7 +90,8 @@
|
||||||
// Trigger autosave when formData changes (edit mode)
|
// Trigger autosave when formData changes (edit mode)
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
// Establish dependencies on fields
|
// Establish dependencies on fields
|
||||||
formStore.fields; activeTab
|
formStore.fields
|
||||||
|
activeTab
|
||||||
if (mode === 'edit' && hasLoaded && autoSave) {
|
if (mode === 'edit' && hasLoaded && autoSave) {
|
||||||
autoSave.schedule()
|
autoSave.schedule()
|
||||||
}
|
}
|
||||||
|
|
@ -143,9 +145,9 @@
|
||||||
|
|
||||||
let savedProject: Project
|
let savedProject: Project
|
||||||
if (mode === 'edit') {
|
if (mode === 'edit') {
|
||||||
savedProject = await api.put(`/api/projects/${project?.id}`, payload) as Project
|
savedProject = (await api.put(`/api/projects/${project?.id}`, payload)) as Project
|
||||||
} else {
|
} else {
|
||||||
savedProject = await api.post('/api/projects', payload) as Project
|
savedProject = (await api.post('/api/projects', payload)) as Project
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.dismiss(loadingToastId)
|
toast.dismiss(loadingToastId)
|
||||||
|
|
@ -168,8 +170,6 @@
|
||||||
isSaving = false
|
isSaving = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AdminPage>
|
<AdminPage>
|
||||||
|
|
@ -225,7 +225,11 @@
|
||||||
handleSave()
|
handleSave()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProjectMetadataForm bind:formData={formStore.fields} validationErrors={formStore.validationErrors} onSave={handleSave} />
|
<ProjectMetadataForm
|
||||||
|
bind:formData={formStore.fields}
|
||||||
|
validationErrors={formStore.validationErrors}
|
||||||
|
onSave={handleSave}
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -239,7 +243,11 @@
|
||||||
handleSave()
|
handleSave()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProjectBrandingForm bind:formData={formStore.fields} validationErrors={formStore.validationErrors} onSave={handleSave} />
|
<ProjectBrandingForm
|
||||||
|
bind:formData={formStore.fields}
|
||||||
|
validationErrors={formStore.validationErrors}
|
||||||
|
onSave={handleSave}
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,7 @@
|
||||||
|
|
||||||
{#if isDropdownOpen}
|
{#if isDropdownOpen}
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<button class="dropdown-item" type="button" onclick={handleEdit}>
|
<button class="dropdown-item" type="button" onclick={handleEdit}> Edit project </button>
|
||||||
Edit project
|
|
||||||
</button>
|
|
||||||
<button class="dropdown-item" type="button" onclick={handleTogglePublish}>
|
<button class="dropdown-item" type="button" onclick={handleTogglePublish}>
|
||||||
{project.status === 'published' ? 'Unpublish' : 'Publish'} project
|
{project.status === 'published' ? 'Unpublish' : 'Publish'} project
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,9 @@ const draftKey = $derived(makeDraftKey('post', postId ?? 'new'))
|
||||||
let showDraftPrompt = $state(false)
|
let showDraftPrompt = $state(false)
|
||||||
let draftTimestamp = $state<number | null>(null)
|
let draftTimestamp = $state<number | null>(null)
|
||||||
let timeTicker = $state(0)
|
let timeTicker = $state(0)
|
||||||
const draftTimeText = $derived.by(() => (draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null))
|
const draftTimeText = $derived.by(() =>
|
||||||
|
draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null
|
||||||
|
)
|
||||||
|
|
||||||
function buildPayload() {
|
function buildPayload() {
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
|
|
@ -82,7 +84,8 @@ function buildPayload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autosave store (edit mode only)
|
// Autosave store (edit mode only)
|
||||||
let autoSave = mode === 'edit' && postId
|
let autoSave =
|
||||||
|
mode === 'edit' && postId
|
||||||
? createAutoSaveStore({
|
? createAutoSaveStore({
|
||||||
debounceMs: 2000,
|
debounceMs: 2000,
|
||||||
getPayload: () => (hasLoaded ? buildPayload() : null),
|
getPayload: () => (hasLoaded ? buildPayload() : null),
|
||||||
|
|
@ -115,7 +118,11 @@ $effect(() => {
|
||||||
|
|
||||||
// Trigger autosave when form data changes
|
// Trigger autosave when form data changes
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
status; content; linkUrl; linkDescription; title
|
status
|
||||||
|
content
|
||||||
|
linkUrl
|
||||||
|
linkDescription
|
||||||
|
title
|
||||||
if (hasLoaded && autoSave) {
|
if (hasLoaded && autoSave) {
|
||||||
autoSave.schedule()
|
autoSave.schedule()
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +343,8 @@ $effect(() => {
|
||||||
<div class="draft-banner">
|
<div class="draft-banner">
|
||||||
<div class="draft-banner-content">
|
<div class="draft-banner-content">
|
||||||
<span class="draft-banner-text">
|
<span class="draft-banner-text">
|
||||||
Unsaved draft found{#if draftTimeText} (saved {draftTimeText}){/if}.
|
Unsaved draft found{#if draftTimeText}
|
||||||
|
(saved {draftTimeText}){/if}.
|
||||||
</span>
|
</span>
|
||||||
<div class="draft-banner-actions">
|
<div class="draft-banner-actions">
|
||||||
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,7 @@
|
||||||
>
|
>
|
||||||
<span class="status-dot"></span>
|
<span class="status-dot"></span>
|
||||||
<span class="status-label">{currentConfig.label}</span>
|
<span class="status-label">{currentConfig.label}</span>
|
||||||
<svg
|
<svg class="chevron" class:open={isOpen} width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||||
class="chevron"
|
|
||||||
class:open={isOpen}
|
|
||||||
width="12"
|
|
||||||
height="12"
|
|
||||||
viewBox="0 0 12 12"
|
|
||||||
fill="none"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
d="M3 4.5L6 7.5L9 4.5"
|
d="M3 4.5L6 7.5L9 4.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
|
|
@ -96,12 +89,7 @@
|
||||||
|
|
||||||
{#if viewUrl && currentStatus === 'published'}
|
{#if viewUrl && currentStatus === 'published'}
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a
|
<a href={viewUrl} target="_blank" rel="noopener noreferrer" class="dropdown-item view-link">
|
||||||
href={viewUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="dropdown-item view-link"
|
|
||||||
>
|
|
||||||
View on site
|
View on site
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,6 @@
|
||||||
// Short delay to prevent flicker
|
// Short delay to prevent flicker
|
||||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||||
|
|
||||||
|
|
||||||
let url = `/api/media?page=${page}&limit=24`
|
let url = `/api/media?page=${page}&limit=24`
|
||||||
|
|
||||||
if (filterType !== 'all') {
|
if (filterType !== 'all') {
|
||||||
|
|
|
||||||
|
|
@ -375,10 +375,7 @@
|
||||||
const afterPos = nodePos + actualNode.nodeSize
|
const afterPos = nodePos + actualNode.nodeSize
|
||||||
|
|
||||||
// Insert the duplicated node
|
// Insert the duplicated node
|
||||||
editor.chain()
|
editor.chain().focus().insertContentAt(afterPos, nodeCopy).run()
|
||||||
.focus()
|
|
||||||
.insertContentAt(afterPos, nodeCopy)
|
|
||||||
.run()
|
|
||||||
|
|
||||||
isMenuOpen = false
|
isMenuOpen = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@ export async function adminFetch(
|
||||||
let detail: string | undefined
|
let detail: string | undefined
|
||||||
try {
|
try {
|
||||||
const json = await response.clone().json()
|
const json = await response.clone().json()
|
||||||
detail = typeof json === 'object' && json !== null && 'error' in json ? String(json.error) : undefined
|
detail =
|
||||||
|
typeof json === 'object' && json !== null && 'error' in json
|
||||||
|
? String(json.error)
|
||||||
|
: undefined
|
||||||
} catch {
|
} catch {
|
||||||
try {
|
try {
|
||||||
detail = await response.clone().text()
|
detail = await response.clone().text()
|
||||||
|
|
|
||||||
|
|
@ -340,11 +340,14 @@ export async function findAlbum(artist: string, album: string): Promise<AppleMus
|
||||||
|
|
||||||
// Log all songs for debugging
|
// Log all songs for debugging
|
||||||
songs.forEach((s, index) => {
|
songs.forEach((s, index) => {
|
||||||
logger.music('debug', `Song ${index + 1}: "${s.attributes?.name}" by "${s.attributes?.artistName}" on "${s.attributes?.albumName}"`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Song ${index + 1}: "${s.attributes?.name}" by "${s.attributes?.artistName}" on "${s.attributes?.albumName}"`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Find matching song
|
// Find matching song
|
||||||
const matchingSong = songs.find(s => {
|
const matchingSong = songs.find((s) => {
|
||||||
const songName = s.attributes?.name || ''
|
const songName = s.attributes?.name || ''
|
||||||
const artistName = s.attributes?.artistName || ''
|
const artistName = s.attributes?.artistName || ''
|
||||||
const albumName = s.attributes?.albumName || ''
|
const albumName = s.attributes?.albumName || ''
|
||||||
|
|
@ -357,7 +360,8 @@ export async function findAlbum(artist: string, album: string): Promise<AppleMus
|
||||||
const artistSearchLower = artist.toLowerCase()
|
const artistSearchLower = artist.toLowerCase()
|
||||||
|
|
||||||
// Check if the song name matches what we're looking for
|
// Check if the song name matches what we're looking for
|
||||||
const songMatches = songNameLower === albumSearchLower ||
|
const songMatches =
|
||||||
|
songNameLower === albumSearchLower ||
|
||||||
songNameLower.includes(albumSearchLower) ||
|
songNameLower.includes(albumSearchLower) ||
|
||||||
albumSearchLower.includes(songNameLower)
|
albumSearchLower.includes(songNameLower)
|
||||||
|
|
||||||
|
|
@ -365,7 +369,8 @@ export async function findAlbum(artist: string, album: string): Promise<AppleMus
|
||||||
const artistNameNormalized = artistNameLower.replace(/\s+/g, '')
|
const artistNameNormalized = artistNameLower.replace(/\s+/g, '')
|
||||||
const artistSearchNormalized = artistSearchLower.replace(/\s+/g, '')
|
const artistSearchNormalized = artistSearchLower.replace(/\s+/g, '')
|
||||||
|
|
||||||
const artistMatches = artistNameLower === artistSearchLower ||
|
const artistMatches =
|
||||||
|
artistNameLower === artistSearchLower ||
|
||||||
artistNameNormalized === artistSearchNormalized ||
|
artistNameNormalized === artistSearchNormalized ||
|
||||||
artistNameLower.includes(artistSearchLower) ||
|
artistNameLower.includes(artistSearchLower) ||
|
||||||
artistSearchLower.includes(artistNameLower) ||
|
artistSearchLower.includes(artistNameLower) ||
|
||||||
|
|
@ -373,7 +378,10 @@ export async function findAlbum(artist: string, album: string): Promise<AppleMus
|
||||||
artistSearchNormalized.includes(artistNameNormalized)
|
artistSearchNormalized.includes(artistNameNormalized)
|
||||||
|
|
||||||
if (songMatches && artistMatches) {
|
if (songMatches && artistMatches) {
|
||||||
logger.music('debug', `Found matching song: "${songName}" by "${artistName}" on album "${albumName}"`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Found matching song: "${songName}" by "${artistName}" on album "${albumName}"`
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -397,7 +405,10 @@ export async function findAlbum(artist: string, album: string): Promise<AppleMus
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no album found, create a synthetic album from the song
|
// If no album found, create a synthetic album from the song
|
||||||
logger.music('debug', `Creating synthetic album from single: "${matchingSong.attributes?.name}"`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Creating synthetic album from single: "${matchingSong.attributes?.name}"`
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
id: `single-${matchingSong.id}`,
|
id: `single-${matchingSong.id}`,
|
||||||
type: 'albums' as const,
|
type: 'albums' as const,
|
||||||
|
|
@ -449,11 +460,13 @@ export async function transformAlbumData(appleMusicAlbum: AppleMusicAlbum) {
|
||||||
if ((attributes as any).isSingle && (attributes as any)._singleSongPreview) {
|
if ((attributes as any).isSingle && (attributes as any)._singleSongPreview) {
|
||||||
logger.music('debug', 'Processing synthetic single album')
|
logger.music('debug', 'Processing synthetic single album')
|
||||||
previewUrl = (attributes as any)._singleSongPreview
|
previewUrl = (attributes as any)._singleSongPreview
|
||||||
tracks = [{
|
tracks = [
|
||||||
|
{
|
||||||
name: attributes.name,
|
name: attributes.name,
|
||||||
previewUrl: (attributes as any)._singleSongPreview,
|
previewUrl: (attributes as any)._singleSongPreview,
|
||||||
durationMs: undefined // We'd need to fetch the song details for duration
|
durationMs: undefined // We'd need to fetch the song details for duration
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
// Always fetch tracks to get preview URLs
|
// Always fetch tracks to get preview URLs
|
||||||
else if (appleMusicAlbum.id) {
|
else if (appleMusicAlbum.id) {
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,38 @@ export interface CacheConfig {
|
||||||
|
|
||||||
export class CacheManager {
|
export class CacheManager {
|
||||||
private static cacheTypes: Map<string, CacheConfig> = new Map([
|
private static cacheTypes: Map<string, CacheConfig> = new Map([
|
||||||
['lastfm-recent', { prefix: 'lastfm:recent:', defaultTTL: 30, description: 'Last.fm recent tracks' }],
|
[
|
||||||
['lastfm-album', { prefix: 'lastfm:albuminfo:', defaultTTL: 3600, description: 'Last.fm album info' }],
|
'lastfm-recent',
|
||||||
['apple-album', { prefix: 'apple:album:', defaultTTL: 86400, description: 'Apple Music album data' }],
|
{ prefix: 'lastfm:recent:', defaultTTL: 30, description: 'Last.fm recent tracks' }
|
||||||
['apple-notfound', { prefix: 'notfound:apple-music:', defaultTTL: 3600, description: 'Apple Music not found records' }],
|
],
|
||||||
['apple-failure', { prefix: 'failure:apple-music:', defaultTTL: 86400, description: 'Apple Music API failures' }],
|
[
|
||||||
['apple-ratelimit', { prefix: 'ratelimit:apple-music:', defaultTTL: 3600, description: 'Apple Music rate limit state' }]
|
'lastfm-album',
|
||||||
|
{ prefix: 'lastfm:albuminfo:', defaultTTL: 3600, description: 'Last.fm album info' }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'apple-album',
|
||||||
|
{ prefix: 'apple:album:', defaultTTL: 86400, description: 'Apple Music album data' }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'apple-notfound',
|
||||||
|
{
|
||||||
|
prefix: 'notfound:apple-music:',
|
||||||
|
defaultTTL: 3600,
|
||||||
|
description: 'Apple Music not found records'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'apple-failure',
|
||||||
|
{ prefix: 'failure:apple-music:', defaultTTL: 86400, description: 'Apple Music API failures' }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'apple-ratelimit',
|
||||||
|
{
|
||||||
|
prefix: 'ratelimit:apple-music:',
|
||||||
|
defaultTTL: 3600,
|
||||||
|
description: 'Apple Music rate limit state'
|
||||||
|
}
|
||||||
|
]
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -118,7 +144,10 @@ export class CacheManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.music('info', `Cleared ${totalDeleted} cache entries for album "${album}" by "${artist}"`)
|
logger.music(
|
||||||
|
'info',
|
||||||
|
`Cleared ${totalDeleted} cache entries for album "${album}" by "${artist}"`
|
||||||
|
)
|
||||||
return totalDeleted
|
return totalDeleted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,14 +181,21 @@ export class CacheManager {
|
||||||
export const cache = {
|
export const cache = {
|
||||||
lastfm: {
|
lastfm: {
|
||||||
getRecent: (username: string) => CacheManager.get('lastfm-recent', username),
|
getRecent: (username: string) => CacheManager.get('lastfm-recent', username),
|
||||||
setRecent: (username: string, data: string) => CacheManager.set('lastfm-recent', username, data),
|
setRecent: (username: string, data: string) =>
|
||||||
getAlbum: (artist: string, album: string) => CacheManager.get('lastfm-album', `${artist}:${album}`),
|
CacheManager.set('lastfm-recent', username, data),
|
||||||
setAlbum: (artist: string, album: string, data: string) => CacheManager.set('lastfm-album', `${artist}:${album}`, data)
|
getAlbum: (artist: string, album: string) =>
|
||||||
|
CacheManager.get('lastfm-album', `${artist}:${album}`),
|
||||||
|
setAlbum: (artist: string, album: string, data: string) =>
|
||||||
|
CacheManager.set('lastfm-album', `${artist}:${album}`, data)
|
||||||
},
|
},
|
||||||
apple: {
|
apple: {
|
||||||
getAlbum: (artist: string, album: string) => CacheManager.get('apple-album', `${artist}:${album}`),
|
getAlbum: (artist: string, album: string) =>
|
||||||
setAlbum: (artist: string, album: string, data: string, ttl?: number) => CacheManager.set('apple-album', `${artist}:${album}`, data, ttl),
|
CacheManager.get('apple-album', `${artist}:${album}`),
|
||||||
isNotFound: (artist: string, album: string) => CacheManager.get('apple-notfound', `${artist}:${album}`),
|
setAlbum: (artist: string, album: string, data: string, ttl?: number) =>
|
||||||
markNotFound: (artist: string, album: string, ttl?: number) => CacheManager.set('apple-notfound', `${artist}:${album}`, '1', ttl)
|
CacheManager.set('apple-album', `${artist}:${album}`, data, ttl),
|
||||||
|
isNotFound: (artist: string, album: string) =>
|
||||||
|
CacheManager.get('apple-notfound', `${artist}:${album}`),
|
||||||
|
markNotFound: (artist: string, album: string, ttl?: number) =>
|
||||||
|
CacheManager.set('apple-notfound', `${artist}:${album}`, '1', ttl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,8 +95,8 @@ export async function uploadFileLocally(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract video metadata
|
// Extract video metadata
|
||||||
const videoStream = metadata.streams.find(s => s.codec_type === 'video')
|
const videoStream = metadata.streams.find((s) => s.codec_type === 'video')
|
||||||
const audioStream = metadata.streams.find(s => s.codec_type === 'audio')
|
const audioStream = metadata.streams.find((s) => s.codec_type === 'audio')
|
||||||
|
|
||||||
if (videoStream) {
|
if (videoStream) {
|
||||||
width = videoStream.width || 0
|
width = videoStream.width || 0
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ function createMusicStream() {
|
||||||
nowPlaying: nowPlayingAlbum
|
nowPlaying: nowPlayingAlbum
|
||||||
? `${nowPlayingAlbum.artist.name} - ${nowPlayingAlbum.name}`
|
? `${nowPlayingAlbum.artist.name} - ${nowPlayingAlbum.name}`
|
||||||
: 'none',
|
: 'none',
|
||||||
albums: albums.map(a => ({
|
albums: albums.map((a) => ({
|
||||||
name: a.name,
|
name: a.name,
|
||||||
artist: a.artist.name,
|
artist: a.artist.name,
|
||||||
isNowPlaying: a.isNowPlaying,
|
isNowPlaying: a.isNowPlaying,
|
||||||
|
|
@ -144,11 +144,13 @@ function createMusicStream() {
|
||||||
albums: derived({ subscribe }, ($state) => $state.albums) as Readable<Album[]>,
|
albums: derived({ subscribe }, ($state) => $state.albums) as Readable<Album[]>,
|
||||||
// Helper to check if any album is playing
|
// Helper to check if any album is playing
|
||||||
nowPlaying: derived({ subscribe }, ($state) => {
|
nowPlaying: derived({ subscribe }, ($state) => {
|
||||||
const playing = $state.albums.find(a => a.isNowPlaying)
|
const playing = $state.albums.find((a) => a.isNowPlaying)
|
||||||
return playing ? {
|
return playing
|
||||||
|
? {
|
||||||
album: playing,
|
album: playing,
|
||||||
track: playing.nowPlayingTrack
|
track: playing.nowPlayingTrack
|
||||||
} : null
|
}
|
||||||
|
: null
|
||||||
}) as Readable<{ album: Album; track?: string } | null>
|
}) as Readable<{ album: Album; track?: string } | null>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,7 @@ export function createProjectFormStore(initialProject?: Project | null) {
|
||||||
let original = $state<ProjectFormData | null>(null)
|
let original = $state<ProjectFormData | null>(null)
|
||||||
|
|
||||||
// Derived state using $derived rune
|
// Derived state using $derived rune
|
||||||
const isDirty = $derived(
|
const isDirty = $derived(original ? JSON.stringify(fields) !== JSON.stringify(original) : false)
|
||||||
original ? JSON.stringify(fields) !== JSON.stringify(original) : false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Initialize from project if provided
|
// Initialize from project if provided
|
||||||
if (initialProject) {
|
if (initialProject) {
|
||||||
|
|
@ -96,7 +94,8 @@ export function createProjectFormStore(initialProject?: Project | null) {
|
||||||
role: fields.role,
|
role: fields.role,
|
||||||
projectType: fields.projectType,
|
projectType: fields.projectType,
|
||||||
externalUrl: fields.externalUrl,
|
externalUrl: fields.externalUrl,
|
||||||
featuredImage: fields.featuredImage && fields.featuredImage !== '' ? fields.featuredImage : null,
|
featuredImage:
|
||||||
|
fields.featuredImage && fields.featuredImage !== '' ? fields.featuredImage : null,
|
||||||
logoUrl: fields.logoUrl && fields.logoUrl !== '' ? fields.logoUrl : null,
|
logoUrl: fields.logoUrl && fields.logoUrl !== '' ? fields.logoUrl : null,
|
||||||
backgroundColor: fields.backgroundColor,
|
backgroundColor: fields.backgroundColor,
|
||||||
highlightColor: fields.highlightColor,
|
highlightColor: fields.highlightColor,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,10 @@ export class LastfmStreamManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for now playing updates for non-recent albums
|
// Check for now playing updates for non-recent albums
|
||||||
const nowPlayingUpdates = await this.getNowPlayingUpdatesForNonRecentAlbums(enrichedAlbums, freshData)
|
const nowPlayingUpdates = await this.getNowPlayingUpdatesForNonRecentAlbums(
|
||||||
|
enrichedAlbums,
|
||||||
|
freshData
|
||||||
|
)
|
||||||
if (nowPlayingUpdates.length > 0) {
|
if (nowPlayingUpdates.length > 0) {
|
||||||
update.nowPlayingUpdates = nowPlayingUpdates
|
update.nowPlayingUpdates = nowPlayingUpdates
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,19 @@ export class NowPlayingDetector {
|
||||||
for (const track of tracks) {
|
for (const track of tracks) {
|
||||||
if (track.nowPlaying) {
|
if (track.nowPlaying) {
|
||||||
hasOfficialNowPlaying = true
|
hasOfficialNowPlaying = true
|
||||||
logger.music('debug', `Last.fm reports "${track.name}" by ${track.artist.name} as now playing`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Last.fm reports "${track.name}" by ${track.artist.name} as now playing`
|
||||||
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasOfficialNowPlaying) {
|
if (!hasOfficialNowPlaying) {
|
||||||
logger.music('debug', 'No official now playing from Last.fm, will use duration-based detection')
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
'No official now playing from Last.fm, will use duration-based detection'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process all tracks
|
// Process all tracks
|
||||||
|
|
@ -230,8 +236,11 @@ export class NowPlayingDetector {
|
||||||
this.updateRecentTracks(newRecentTracks)
|
this.updateRecentTracks(newRecentTracks)
|
||||||
|
|
||||||
// Log summary
|
// Log summary
|
||||||
const nowPlayingCount = Array.from(albums.values()).filter(a => a.isNowPlaying).length
|
const nowPlayingCount = Array.from(albums.values()).filter((a) => a.isNowPlaying).length
|
||||||
logger.music('debug', `Detected ${nowPlayingCount} album(s) as now playing out of ${albums.size} recent albums`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Detected ${nowPlayingCount} album(s) as now playing out of ${albums.size} recent albums`
|
||||||
|
)
|
||||||
|
|
||||||
// Ensure only one album is marked as now playing
|
// Ensure only one album is marked as now playing
|
||||||
return this.ensureSingleNowPlaying(albums, newRecentTracks)
|
return this.ensureSingleNowPlaying(albums, newRecentTracks)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,10 @@ export class SimpleLastfmStreamManager {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
extended: true
|
extended: true
|
||||||
})
|
})
|
||||||
logger.music('debug', `📊 Got ${recentTracksResponse.tracks?.length || 0} tracks from Last.fm`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`📊 Got ${recentTracksResponse.tracks?.length || 0} tracks from Last.fm`
|
||||||
|
)
|
||||||
|
|
||||||
// Cache for other uses but always use fresh for now playing
|
// Cache for other uses but always use fresh for now playing
|
||||||
await this.albumEnricher.cacheRecentTracks(this.username, recentTracksResponse)
|
await this.albumEnricher.cacheRecentTracks(this.username, recentTracksResponse)
|
||||||
|
|
@ -64,7 +67,7 @@ export class SimpleLastfmStreamManager {
|
||||||
|
|
||||||
// Check if anything changed
|
// Check if anything changed
|
||||||
const currentState = JSON.stringify(
|
const currentState = JSON.stringify(
|
||||||
enrichedAlbums.map(a => ({
|
enrichedAlbums.map((a) => ({
|
||||||
key: `${a.artist.name}:${a.name}`,
|
key: `${a.artist.name}:${a.name}`,
|
||||||
isNowPlaying: a.isNowPlaying,
|
isNowPlaying: a.isNowPlaying,
|
||||||
track: a.nowPlayingTrack
|
track: a.nowPlayingTrack
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ export class SimpleNowPlayingDetector {
|
||||||
|
|
||||||
const isPlaying = elapsed >= 0 && elapsed <= maxPlayTime
|
const isPlaying = elapsed >= 0 && elapsed <= maxPlayTime
|
||||||
|
|
||||||
logger.music('debug', `Track playing check: elapsed=${Math.round(elapsed/1000)}s, duration=${Math.round(durationMs/1000)}s, maxPlay=${Math.round(maxPlayTime/1000)}s, isPlaying=${isPlaying}`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Track playing check: elapsed=${Math.round(elapsed / 1000)}s, duration=${Math.round(durationMs / 1000)}s, maxPlay=${Math.round(maxPlayTime / 1000)}s, isPlaying=${isPlaying}`
|
||||||
|
)
|
||||||
|
|
||||||
// Track is playing if we're within the duration + buffer
|
// Track is playing if we're within the duration + buffer
|
||||||
return isPlaying
|
return isPlaying
|
||||||
|
|
@ -30,16 +33,22 @@ export class SimpleNowPlayingDetector {
|
||||||
recentTracks: any[],
|
recentTracks: any[],
|
||||||
appleMusicDataLookup: (artistName: string, albumName: string) => Promise<any>
|
appleMusicDataLookup: (artistName: string, albumName: string) => Promise<any>
|
||||||
): Promise<Album[]> {
|
): Promise<Album[]> {
|
||||||
logger.music('debug', `Processing ${albums.length} albums with ${recentTracks.length} recent tracks`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Processing ${albums.length} albums with ${recentTracks.length} recent tracks`
|
||||||
|
)
|
||||||
|
|
||||||
// First check if Last.fm reports anything as officially playing
|
// First check if Last.fm reports anything as officially playing
|
||||||
const officialNowPlaying = recentTracks.find(track => track.nowPlaying)
|
const officialNowPlaying = recentTracks.find((track) => track.nowPlaying)
|
||||||
|
|
||||||
if (officialNowPlaying) {
|
if (officialNowPlaying) {
|
||||||
// Trust Last.fm's official now playing status
|
// Trust Last.fm's official now playing status
|
||||||
logger.music('debug', `✅ Last.fm official now playing: "${officialNowPlaying.name}" by ${officialNowPlaying.artist.name}`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`✅ Last.fm official now playing: "${officialNowPlaying.name}" by ${officialNowPlaying.artist.name}`
|
||||||
|
)
|
||||||
|
|
||||||
return albums.map(album => ({
|
return albums.map((album) => ({
|
||||||
...album,
|
...album,
|
||||||
isNowPlaying:
|
isNowPlaying:
|
||||||
album.name === officialNowPlaying.album.name &&
|
album.name === officialNowPlaying.album.name &&
|
||||||
|
|
@ -74,14 +83,17 @@ export class SimpleNowPlayingDetector {
|
||||||
if (!mostRecentTrack) {
|
if (!mostRecentTrack) {
|
||||||
// No recent tracks, nothing is playing
|
// No recent tracks, nothing is playing
|
||||||
logger.music('debug', '❌ No recent tracks found, nothing is playing')
|
logger.music('debug', '❌ No recent tracks found, nothing is playing')
|
||||||
return albums.map(album => ({
|
return albums.map((album) => ({
|
||||||
...album,
|
...album,
|
||||||
isNowPlaying: false,
|
isNowPlaying: false,
|
||||||
nowPlayingTrack: undefined
|
nowPlayingTrack: undefined
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.music('debug', `Most recent track: "${mostRecentTrack.name}" by ${mostRecentTrack.artist.name} from ${mostRecentTrack.album.name}`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Most recent track: "${mostRecentTrack.name}" by ${mostRecentTrack.artist.name} from ${mostRecentTrack.album.name}`
|
||||||
|
)
|
||||||
logger.music('debug', `Scrobbled at: ${mostRecentTrack.date}`)
|
logger.music('debug', `Scrobbled at: ${mostRecentTrack.date}`)
|
||||||
|
|
||||||
// Check if the most recent track is still playing
|
// Check if the most recent track is still playing
|
||||||
|
|
@ -112,28 +124,39 @@ export class SimpleNowPlayingDetector {
|
||||||
logger.music('debug', `⚠️ No duration found for track "${mostRecentTrack.name}"`)
|
logger.music('debug', `⚠️ No duration found for track "${mostRecentTrack.name}"`)
|
||||||
// Fallback: assume track is playing if scrobbled within last 5 minutes
|
// Fallback: assume track is playing if scrobbled within last 5 minutes
|
||||||
const timeSinceScrobble = Date.now() - mostRecentTrack.date.getTime()
|
const timeSinceScrobble = Date.now() - mostRecentTrack.date.getTime()
|
||||||
if (timeSinceScrobble < 5 * 60 * 1000) { // 5 minutes
|
if (timeSinceScrobble < 5 * 60 * 1000) {
|
||||||
|
// 5 minutes
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
playingTrack = mostRecentTrack.name
|
playingTrack = mostRecentTrack.name
|
||||||
logger.music('debug', `⏰ Using time-based fallback: track scrobbled ${Math.round(timeSinceScrobble/1000)}s ago, assuming still playing`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`⏰ Using time-based fallback: track scrobbled ${Math.round(timeSinceScrobble / 1000)}s ago, assuming still playing`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error checking track duration:', error as Error, undefined, 'music')
|
logger.error('Error checking track duration:', error as Error, undefined, 'music')
|
||||||
logger.music('debug', `❌ Failed to get Apple Music data for ${mostRecentTrack.artist.name} - ${mostRecentTrack.album.name}`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`❌ Failed to get Apple Music data for ${mostRecentTrack.artist.name} - ${mostRecentTrack.album.name}`
|
||||||
|
)
|
||||||
|
|
||||||
// Fallback when Apple Music lookup fails
|
// Fallback when Apple Music lookup fails
|
||||||
const timeSinceScrobble = Date.now() - mostRecentTrack.date.getTime()
|
const timeSinceScrobble = Date.now() - mostRecentTrack.date.getTime()
|
||||||
if (timeSinceScrobble < 5 * 60 * 1000) { // 5 minutes
|
if (timeSinceScrobble < 5 * 60 * 1000) {
|
||||||
|
// 5 minutes
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
playingTrack = mostRecentTrack.name
|
playingTrack = mostRecentTrack.name
|
||||||
logger.music('debug', `⏰ Using time-based fallback after Apple Music error: track scrobbled ${Math.round(timeSinceScrobble/1000)}s ago`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`⏰ Using time-based fallback after Apple Music error: track scrobbled ${Math.round(timeSinceScrobble / 1000)}s ago`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update albums with the result
|
// Update albums with the result
|
||||||
return albums.map(album => {
|
return albums.map((album) => {
|
||||||
const key = `${album.artist.name}:${album.name}`
|
const key = `${album.artist.name}:${album.name}`
|
||||||
const isThisAlbumPlaying = isPlaying && key === albumKey
|
const isThisAlbumPlaying = isPlaying && key === albumKey
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="error-container">
|
<div class="error-container">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
import { fail, redirect } from '@sveltejs/kit'
|
import { fail, redirect } from '@sveltejs/kit'
|
||||||
import type { Actions, PageServerLoad } from './$types'
|
import type { Actions, PageServerLoad } from './$types'
|
||||||
import { clearSessionCookie, setSessionCookie, validateAdminPassword } from '$lib/server/admin/session'
|
import {
|
||||||
|
clearSessionCookie,
|
||||||
|
setSessionCookie,
|
||||||
|
validateAdminPassword
|
||||||
|
} from '$lib/server/admin/session'
|
||||||
|
|
||||||
export const load = (async ({ cookies }) => {
|
export const load = (async ({ cookies }) => {
|
||||||
// Ensure we start with a clean session when hitting the login page
|
// Ensure we start with a clean session when hitting the login page
|
||||||
|
|
|
||||||
|
|
@ -454,11 +454,7 @@
|
||||||
>
|
>
|
||||||
Manage Albums
|
Manage Albums
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button onclick={handleBulkDelete} class="btn btn-danger btn-small" disabled={isDeleting}>
|
||||||
onclick={handleBulkDelete}
|
|
||||||
class="btn btn-danger btn-small"
|
|
||||||
disabled={isDeleting}
|
|
||||||
>
|
|
||||||
{isDeleting
|
{isDeleting
|
||||||
? 'Deleting...'
|
? 'Deleting...'
|
||||||
: `Delete ${selectedMediaIds.size} file${selectedMediaIds.size > 1 ? 's' : ''}`}
|
: `Delete ${selectedMediaIds.size} file${selectedMediaIds.size > 1 ? 's' : ''}`}
|
||||||
|
|
@ -533,9 +529,7 @@
|
||||||
Alt
|
Alt
|
||||||
</span>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="indicator-pill no-alt-text" title="No description">
|
<span class="indicator-pill no-alt-text" title="No description"> No Alt </span>
|
||||||
No Alt
|
|
||||||
</span>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span class="filesize">{formatFileSize(item.size)}</span>
|
<span class="filesize">{formatFileSize(item.size)}</span>
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@
|
||||||
let showCleanupModal = $state(false)
|
let showCleanupModal = $state(false)
|
||||||
let cleaningUp = $state(false)
|
let cleaningUp = $state(false)
|
||||||
|
|
||||||
const allSelected = $derived(auditData && selectedFiles.size >= Math.min(20, auditData.orphanedFiles.length))
|
const allSelected = $derived(
|
||||||
|
auditData && selectedFiles.size >= Math.min(20, auditData.orphanedFiles.length)
|
||||||
|
)
|
||||||
const hasSelection = $derived(selectedFiles.size > 0)
|
const hasSelection = $derived(selectedFiles.size > 0)
|
||||||
const selectedSize = $derived(
|
const selectedSize = $derived(
|
||||||
auditData?.orphanedFiles
|
auditData?.orphanedFiles
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
function addFiles(newFiles: File[]) {
|
function addFiles(newFiles: File[]) {
|
||||||
// Filter for supported file types (images and videos)
|
// Filter for supported file types (images and videos)
|
||||||
const supportedFiles = newFiles.filter((file) =>
|
const supportedFiles = newFiles.filter(
|
||||||
file.type.startsWith('image/') || file.type.startsWith('video/')
|
(file) => file.type.startsWith('image/') || file.type.startsWith('video/')
|
||||||
)
|
)
|
||||||
|
|
||||||
if (supportedFiles.length !== newFiles.length) {
|
if (supportedFiles.length !== newFiles.length) {
|
||||||
|
|
@ -305,7 +305,9 @@
|
||||||
</div>
|
</div>
|
||||||
<h3>Drop media files here</h3>
|
<h3>Drop media files here</h3>
|
||||||
<p>or click to browse and select files</p>
|
<p>or click to browse and select files</p>
|
||||||
<p class="upload-hint">Images: JPG, PNG, GIF, WebP, SVG | Videos: WebM, MP4, OGG, MOV, AVI</p>
|
<p class="upload-hint">
|
||||||
|
Images: JPG, PNG, GIF, WebP, SVG | Videos: WebM, MP4, OGG, MOV, AVI
|
||||||
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="compact-content">
|
<div class="compact-content">
|
||||||
<svg
|
<svg
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,7 @@ const statusFilterOptions = [
|
||||||
<AdminPage>
|
<AdminPage>
|
||||||
<AdminHeader title="Universe" slot="header">
|
<AdminHeader title="Universe" slot="header">
|
||||||
{#snippet actions()}
|
{#snippet actions()}
|
||||||
<Button variant="primary" buttonSize="medium" onclick={handleNewEssay}>
|
<Button variant="primary" buttonSize="medium" onclick={handleNewEssay}>New Essay</Button>
|
||||||
New Essay
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</AdminHeader>
|
</AdminHeader>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ const draftKey = $derived(makeDraftKey('post', $page.params.id))
|
||||||
let showDraftPrompt = $state(false)
|
let showDraftPrompt = $state(false)
|
||||||
let draftTimestamp = $state<number | null>(null)
|
let draftTimestamp = $state<number | null>(null)
|
||||||
let timeTicker = $state(0)
|
let timeTicker = $state(0)
|
||||||
const draftTimeText = $derived.by(() => (draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null))
|
const draftTimeText = $derived.by(() =>
|
||||||
|
draftTimestamp ? (timeTicker, timeAgo(draftTimestamp)) : null
|
||||||
|
)
|
||||||
|
|
||||||
const postTypeConfig = {
|
const postTypeConfig = {
|
||||||
post: { icon: '💭', label: 'Post', showTitle: false, showContent: true },
|
post: { icon: '💭', label: 'Post', showTitle: false, showContent: true },
|
||||||
|
|
@ -353,7 +355,13 @@ onMount(async () => {
|
||||||
// Trigger autosave when form data changes
|
// Trigger autosave when form data changes
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
// Establish dependencies
|
// Establish dependencies
|
||||||
title; slug; status; content; tags; excerpt; postType
|
title
|
||||||
|
slug
|
||||||
|
status
|
||||||
|
content
|
||||||
|
tags
|
||||||
|
excerpt
|
||||||
|
postType
|
||||||
if (hasLoaded) {
|
if (hasLoaded) {
|
||||||
autoSave.schedule()
|
autoSave.schedule()
|
||||||
}
|
}
|
||||||
|
|
@ -521,7 +529,8 @@ $effect(() => {
|
||||||
<div class="draft-banner">
|
<div class="draft-banner">
|
||||||
<div class="draft-banner-content">
|
<div class="draft-banner-content">
|
||||||
<span class="draft-banner-text">
|
<span class="draft-banner-text">
|
||||||
Unsaved draft found{#if draftTimeText} (saved {draftTimeText}){/if}.
|
Unsaved draft found{#if draftTimeText}
|
||||||
|
(saved {draftTimeText}){/if}.
|
||||||
</span>
|
</span>
|
||||||
<div class="draft-banner-actions">
|
<div class="draft-banner-actions">
|
||||||
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
<button class="draft-banner-button" onclick={restoreDraft}>Restore</button>
|
||||||
|
|
|
||||||
|
|
@ -114,11 +114,7 @@
|
||||||
<AdminPage>
|
<AdminPage>
|
||||||
<AdminHeader title="Work" slot="header">
|
<AdminHeader title="Work" slot="header">
|
||||||
{#snippet actions()}
|
{#snippet actions()}
|
||||||
<Button
|
<Button variant="primary" buttonSize="medium" onclick={() => goto('/admin/projects/new')}>
|
||||||
variant="primary"
|
|
||||||
buttonSize="medium"
|
|
||||||
onclick={() => goto('/admin/projects/new')}
|
|
||||||
>
|
|
||||||
New project
|
New project
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,14 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Apple Music search error:', error)
|
console.error('Apple Music search error:', error)
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
error: error instanceof Error ? error.message : 'Unknown error'
|
error: error instanceof Error ? error.message : 'Unknown error'
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
status: 500,
|
status: 500,
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,13 +36,16 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
deleted = await redis.del(key)
|
deleted = await redis.del(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
deleted,
|
deleted,
|
||||||
key: key || pattern
|
key: key || pattern
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Failed to clear cache:', error as Error)
|
logger.error('Failed to clear cache:', error as Error)
|
||||||
return new Response('Internal server error', { status: 500 })
|
return new Response('Internal server error', { status: 500 })
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,16 @@ export const GET: RequestHandler = async ({ url }) => {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
total: keys.length,
|
total: keys.length,
|
||||||
showing: keysWithValues.length,
|
showing: keysWithValues.length,
|
||||||
keys: keysWithValues
|
keys: keysWithValues
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get Redis keys:', error)
|
console.error('Failed to get Redis keys:', error)
|
||||||
return new Response('Internal server error', { status: 500 })
|
return new Response('Internal server error', { status: 500 })
|
||||||
|
|
|
||||||
|
|
@ -14,20 +14,26 @@ export const GET: RequestHandler = async ({ url }) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await findAlbum(artist, album)
|
const result = await findAlbum(artist, album)
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
artist,
|
artist,
|
||||||
album,
|
album,
|
||||||
found: !!result,
|
found: !!result,
|
||||||
result
|
result
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
error: error instanceof Error ? error.message : 'Unknown error'
|
error: error instanceof Error ? error.message : 'Unknown error'
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
status: 500,
|
status: 500,
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,36 +20,45 @@ export const GET: RequestHandler = async () => {
|
||||||
const jpSongs = jpResults.results?.songs?.data || []
|
const jpSongs = jpResults.results?.songs?.data || []
|
||||||
const usSongs = usResults.results?.songs?.data || []
|
const usSongs = usResults.results?.songs?.data || []
|
||||||
|
|
||||||
const hachiko = [...jpSongs, ...usSongs].find(s =>
|
const hachiko = [...jpSongs, ...usSongs].find(
|
||||||
|
(s) =>
|
||||||
s.attributes?.name?.toLowerCase() === 'hachikō' &&
|
s.attributes?.name?.toLowerCase() === 'hachikō' &&
|
||||||
s.attributes?.artistName?.includes('藤井')
|
s.attributes?.artistName?.includes('藤井')
|
||||||
)
|
)
|
||||||
|
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
searchQuery,
|
searchQuery,
|
||||||
jpSongsFound: jpSongs.length,
|
jpSongsFound: jpSongs.length,
|
||||||
usSongsFound: usSongs.length,
|
usSongsFound: usSongs.length,
|
||||||
hachikoFound: !!hachiko,
|
hachikoFound: !!hachiko,
|
||||||
hachikoDetails: hachiko ? {
|
hachikoDetails: hachiko
|
||||||
|
? {
|
||||||
name: hachiko.attributes?.name,
|
name: hachiko.attributes?.name,
|
||||||
artist: hachiko.attributes?.artistName,
|
artist: hachiko.attributes?.artistName,
|
||||||
album: hachiko.attributes?.albumName,
|
album: hachiko.attributes?.albumName,
|
||||||
preview: hachiko.attributes?.previews?.[0]?.url
|
preview: hachiko.attributes?.previews?.[0]?.url
|
||||||
} : null,
|
}
|
||||||
allSongs: [...jpSongs, ...usSongs].map(s => ({
|
: null,
|
||||||
|
allSongs: [...jpSongs, ...usSongs].map((s) => ({
|
||||||
name: s.attributes?.name,
|
name: s.attributes?.name,
|
||||||
artist: s.attributes?.artistName,
|
artist: s.attributes?.artistName,
|
||||||
album: s.attributes?.albumName
|
album: s.attributes?.albumName
|
||||||
}))
|
}))
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return new Response(JSON.stringify({
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
error: error instanceof Error ? error.message : 'Unknown error'
|
error: error instanceof Error ? error.message : 'Unknown error'
|
||||||
}), {
|
}),
|
||||||
|
{
|
||||||
status: 500,
|
status: 500,
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,12 @@ async function searchAppleMusicForAlbum(album: Album): Promise<Album> {
|
||||||
searchMetadata,
|
searchMetadata,
|
||||||
error: true
|
error: true
|
||||||
}
|
}
|
||||||
await redis.set(`apple:album:${album.artist.name}:${album.name}`, JSON.stringify(errorData), 'EX', 1800)
|
await redis.set(
|
||||||
|
`apple:album:${album.artist.name}:${album.name}`,
|
||||||
|
JSON.stringify(errorData),
|
||||||
|
'EX',
|
||||||
|
1800
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return album with search metadata if Apple Music search fails
|
// Return album with search metadata if Apple Music search fails
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ export const GET: RequestHandler = async ({ request }) => {
|
||||||
let remainingMs = 0
|
let remainingMs = 0
|
||||||
if (nowPlayingAlbum?.nowPlayingTrack && nowPlayingAlbum.appleMusicData?.tracks) {
|
if (nowPlayingAlbum?.nowPlayingTrack && nowPlayingAlbum.appleMusicData?.tracks) {
|
||||||
const track = nowPlayingAlbum.appleMusicData.tracks.find(
|
const track = nowPlayingAlbum.appleMusicData.tracks.find(
|
||||||
t => t.name === nowPlayingAlbum.nowPlayingTrack
|
(t) => t.name === nowPlayingAlbum.nowPlayingTrack
|
||||||
)
|
)
|
||||||
|
|
||||||
if (track?.durationMs && nowPlayingAlbum.lastScrobbleTime) {
|
if (track?.durationMs && nowPlayingAlbum.lastScrobbleTime) {
|
||||||
|
|
@ -68,7 +68,7 @@ export const GET: RequestHandler = async ({ request }) => {
|
||||||
? `${nowPlayingAlbum.artist.name} - ${nowPlayingAlbum.name}`
|
? `${nowPlayingAlbum.artist.name} - ${nowPlayingAlbum.name}`
|
||||||
: 'none',
|
: 'none',
|
||||||
remainingMs: remainingMs,
|
remainingMs: remainingMs,
|
||||||
albumsWithStatus: update.albums.map(a => ({
|
albumsWithStatus: update.albums.map((a) => ({
|
||||||
name: a.name,
|
name: a.name,
|
||||||
artist: a.artist.name,
|
artist: a.artist.name,
|
||||||
isNowPlaying: a.isNowPlaying,
|
isNowPlaying: a.isNowPlaying,
|
||||||
|
|
@ -100,7 +100,10 @@ export const GET: RequestHandler = async ({ request }) => {
|
||||||
// Apply new interval if it changed significantly (more than 1 second difference)
|
// Apply new interval if it changed significantly (more than 1 second difference)
|
||||||
if (Math.abs(targetInterval - currentInterval) > 1000) {
|
if (Math.abs(targetInterval - currentInterval) > 1000) {
|
||||||
currentInterval = targetInterval
|
currentInterval = targetInterval
|
||||||
logger.music('debug', `Adjusting interval to ${currentInterval}ms (playing: ${isPlaying}, remaining: ${Math.round(remainingMs/1000)}s)`)
|
logger.music(
|
||||||
|
'debug',
|
||||||
|
`Adjusting interval to ${currentInterval}ms (playing: ${isPlaying}, remaining: ${Math.round(remainingMs / 1000)}s)`
|
||||||
|
)
|
||||||
|
|
||||||
// Reset interval with new timing
|
// Reset interval with new timing
|
||||||
if (intervalId) {
|
if (intervalId) {
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,10 @@ export const POST: RequestHandler = async (event) => {
|
||||||
const allowedTypes = [...allowedImageTypes, ...allowedVideoTypes]
|
const allowedTypes = [...allowedImageTypes, ...allowedVideoTypes]
|
||||||
|
|
||||||
if (!allowedTypes.includes(file.type)) {
|
if (!allowedTypes.includes(file.type)) {
|
||||||
return errorResponse('Invalid file type. Allowed types: Images (JPEG, PNG, WebP, GIF, SVG) and Videos (WebM, MP4, OGG, MOV, AVI)', 400)
|
return errorResponse(
|
||||||
|
'Invalid file type. Allowed types: Images (JPEG, PNG, WebP, GIF, SVG) and Videos (WebM, MP4, OGG, MOV, AVI)',
|
||||||
|
400
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate file size - different limits for images and videos
|
// Validate file size - different limits for images and videos
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,8 @@ export const PATCH: RequestHandler = async (event) => {
|
||||||
if (data.content !== undefined) updateData.content = data.content
|
if (data.content !== undefined) updateData.content = data.content
|
||||||
if (data.featuredImage !== undefined) updateData.featuredImage = data.featuredImage
|
if (data.featuredImage !== undefined) updateData.featuredImage = data.featuredImage
|
||||||
if (data.attachedPhotos !== undefined)
|
if (data.attachedPhotos !== undefined)
|
||||||
updateData.attachments = data.attachedPhotos && data.attachedPhotos.length > 0 ? data.attachedPhotos : null
|
updateData.attachments =
|
||||||
|
data.attachedPhotos && data.attachedPhotos.length > 0 ? data.attachedPhotos : null
|
||||||
if (data.tags !== undefined) updateData.tags = data.tags
|
if (data.tags !== undefined) updateData.tags = data.tags
|
||||||
if (data.publishedAt !== undefined) updateData.publishedAt = data.publishedAt
|
if (data.publishedAt !== undefined) updateData.publishedAt = data.publishedAt
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,10 @@
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
const viewport = document.querySelector('meta[name="viewport"]')
|
const viewport = document.querySelector('meta[name="viewport"]')
|
||||||
if (viewport) {
|
if (viewport) {
|
||||||
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes')
|
viewport.setAttribute(
|
||||||
|
'content',
|
||||||
|
'width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@ export const GET: RequestHandler = async (event) => {
|
||||||
section: 'universe',
|
section: 'universe',
|
||||||
id: post.id.toString(),
|
id: post.id.toString(),
|
||||||
title:
|
title:
|
||||||
post.title || new Date(post.publishedAt || post.createdAt).toLocaleDateString('en-US', {
|
post.title ||
|
||||||
|
new Date(post.publishedAt || post.createdAt).toLocaleDateString('en-US', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric'
|
day: 'numeric'
|
||||||
|
|
@ -177,7 +178,7 @@ ${
|
||||||
item.type === 'album' && item.coverPhoto
|
item.type === 'album' && item.coverPhoto
|
||||||
? `
|
? `
|
||||||
<enclosure url="${item.coverPhoto.url.startsWith('http') ? item.coverPhoto.url : event.url.origin + item.coverPhoto.url}" type="image/jpeg" length="${item.coverPhoto.size || 0}"/>
|
<enclosure url="${item.coverPhoto.url.startsWith('http') ? item.coverPhoto.url : event.url.origin + item.coverPhoto.url}" type="image/jpeg" length="${item.coverPhoto.size || 0}"/>
|
||||||
<media:thumbnail url="${(item.coverPhoto.thumbnailUrl || item.coverPhoto.url).startsWith('http') ? (item.coverPhoto.thumbnailUrl || item.coverPhoto.url) : event.url.origin + (item.coverPhoto.thumbnailUrl || item.coverPhoto.url)}"/>
|
<media:thumbnail url="${(item.coverPhoto.thumbnailUrl || item.coverPhoto.url).startsWith('http') ? item.coverPhoto.thumbnailUrl || item.coverPhoto.url : event.url.origin + (item.coverPhoto.thumbnailUrl || item.coverPhoto.url)}"/>
|
||||||
<media:content url="${item.coverPhoto.url.startsWith('http') ? item.coverPhoto.url : event.url.origin + item.coverPhoto.url}" type="image/jpeg"/>`
|
<media:content url="${item.coverPhoto.url.startsWith('http') ? item.coverPhoto.url : event.url.origin + item.coverPhoto.url}" type="image/jpeg"/>`
|
||||||
: item.type === 'post' && item.featuredImage
|
: item.type === 'post' && item.featuredImage
|
||||||
? `
|
? `
|
||||||
|
|
@ -215,9 +216,9 @@ ${item.location ? `<category domain="location">${escapeXML(item.location)}</cate
|
||||||
'Content-Type': 'application/rss+xml; charset=utf-8',
|
'Content-Type': 'application/rss+xml; charset=utf-8',
|
||||||
'Cache-Control': 'public, max-age=300, s-maxage=600, stale-while-revalidate=86400',
|
'Cache-Control': 'public, max-age=300, s-maxage=600, stale-while-revalidate=86400',
|
||||||
'Last-Modified': lastBuildDate,
|
'Last-Modified': lastBuildDate,
|
||||||
'ETag': etag,
|
ETag: etag,
|
||||||
'X-Content-Type-Options': 'nosniff',
|
'X-Content-Type-Options': 'nosniff',
|
||||||
'Vary': 'Accept-Encoding',
|
Vary: 'Accept-Encoding',
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
|
'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
|
||||||
'Access-Control-Max-Age': '86400'
|
'Access-Control-Max-Age': '86400'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue