feat: add thumbnail spec
This commit is contained in:
@@ -42,7 +42,6 @@ pub async fn get_repos(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r| r.id)
|
.map(|r| r.id)
|
||||||
.collect::<HashSet<String>>();
|
.collect::<HashSet<String>>();
|
||||||
println!("{added_ids:?}");
|
|
||||||
let data = response
|
let data = response
|
||||||
.json::<Vec<Repository>>()
|
.json::<Vec<Repository>>()
|
||||||
.await?
|
.await?
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ pub async fn proxy_file(
|
|||||||
.bearer_auth(token)
|
.bearer_auth(token)
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
response.error_for_status_ref()?;
|
response
|
||||||
|
.error_for_status_ref()
|
||||||
|
.map_err(|_| crate::error::Error::NotFound)?;
|
||||||
|
|
||||||
let bytes = response.bytes().await?;
|
let bytes = response.bytes().await?;
|
||||||
let mime = mime_guess::from_path(&path.file)
|
let mime = mime_guess::from_path(&path.file)
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ impl ResponseError for Error {
|
|||||||
Error::ValidationFailed(msg) => {
|
Error::ValidationFailed(msg) => {
|
||||||
HttpResponse::BadRequest().json(ErrorResponse { error: msg.clone() })
|
HttpResponse::BadRequest().json(ErrorResponse { error: msg.clone() })
|
||||||
}
|
}
|
||||||
Error::NotFound => HttpResponse::NotFound().finish(),
|
Error::NotFound => HttpResponse::NotFound().json(ErrorResponse {
|
||||||
|
error: "not found".to_string(),
|
||||||
|
}),
|
||||||
_ => HttpResponse::InternalServerError().finish(),
|
_ => HttpResponse::InternalServerError().finish(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
type ImageStatus = 'loading' | 'loaded' | 'error';
|
type ImageStatus = 'loading' | 'loaded' | 'error';
|
||||||
import type { HTMLImgAttributes } from 'svelte/elements';
|
import type { HTMLImgAttributes } from 'svelte/elements';
|
||||||
|
|
||||||
let { src, ...props }: HTMLImgAttributes = $props();
|
let { src, fallback, ...props }: HTMLImgAttributes & { fallback?: string } = $props();
|
||||||
let status: ImageStatus = $state('loading');
|
let status: ImageStatus = $state('loading');
|
||||||
|
let useFallback = $state(false);
|
||||||
|
|
||||||
|
const currentSrc = $derived(useFallback && fallback ? fallback : src);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if status === 'loading'}
|
{#if status === 'loading'}
|
||||||
@@ -11,11 +14,18 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<img
|
<img
|
||||||
{src}
|
src={currentSrc}
|
||||||
hidden={status === 'loading'}
|
hidden={status === 'loading'}
|
||||||
onload={() => {
|
onload={() => {
|
||||||
status = 'loaded';
|
status = 'loaded';
|
||||||
}}
|
}}
|
||||||
onerror={() => (status = 'error')}
|
onerror={() => {
|
||||||
|
if (!useFallback && fallback) {
|
||||||
|
useFallback = true;
|
||||||
|
status = 'loading';
|
||||||
|
} else {
|
||||||
|
status = 'error';
|
||||||
|
}
|
||||||
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -44,7 +44,8 @@
|
|||||||
>
|
>
|
||||||
<div class="relative aspect-video overflow-hidden">
|
<div class="relative aspect-video overflow-hidden">
|
||||||
<Image
|
<Image
|
||||||
src={'https://picsum.photos/seed/yama/400/225'}
|
src={`/api/v0/repos/${project.id}/files/thumbnail.webp`}
|
||||||
|
fallback={`https://picsum.photos/seed/${project.id}/400/225`}
|
||||||
alt={project.full_name}
|
alt={project.full_name}
|
||||||
class="min-h-56.5 w-full min-w-100 object-cover transition-transform duration-300 group-hover:scale-105"
|
class="min-h-56.5 w-full min-w-100 object-cover transition-transform duration-300 group-hover:scale-105"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -115,7 +115,6 @@
|
|||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<GitBranch class="h-6 w-6 text-icon" />
|
<GitBranch class="h-6 w-6 text-icon" />
|
||||||
<h2 class="text-xl font-semibold text-text-primary">Import Git Repository</h2>
|
<h2 class="text-xl font-semibold text-text-primary">Import Git Repository</h2>
|
||||||
<span class="text-xs text-text-muted">repo must be public</span>
|
|
||||||
</div>
|
</div>
|
||||||
<Button.Root
|
<Button.Root
|
||||||
class="flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-hover hover:text-text-primary"
|
class="flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-hover hover:text-text-primary"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={containerRef}
|
bind:this={containerRef}
|
||||||
class="relative w-full max-w-6xl overflow-hidden rounded-md bg-black shadow-2xl ring-1 ring-gray-700/80"
|
class="relative mt-2 w-full max-w-6xl overflow-hidden rounded-md bg-black shadow-2xl ring-1 ring-gray-700/80"
|
||||||
class:max-w-none={isFullscreen}
|
class:max-w-none={isFullscreen}
|
||||||
class:h-screen={isFullscreen}
|
class:h-screen={isFullscreen}
|
||||||
class:rounded-none={isFullscreen}
|
class:rounded-none={isFullscreen}
|
||||||
|
|||||||
Reference in New Issue
Block a user