T-011: Login-Flow in der App (AudibleClient-Trait, Auth- Erkennung über ~/.audible, Terminal-Login, Minimale Bibliothek; spec-Abweichung: kein Kopieren nach ~/.config, app nutzt audible-cli-pfad)
This commit is contained in:
@ -21,7 +21,7 @@ Abnahme M0: Ein gekauftes Buch läuft lokal mit Kapiteln.
|
|||||||
| ID | Titel | Status |
|
| ID | Titel | Status |
|
||||||
|----|-------|--------|
|
|----|-------|--------|
|
||||||
| T-010 | Tauri-Projekt aufsetzen (Rust-Backend, Svelte-Frontend) | fertig |
|
| T-010 | Tauri-Projekt aufsetzen (Rust-Backend, Svelte-Frontend) | fertig |
|
||||||
| T-011 | Login-Flow in der App (Auth-Datei sicher unter ~/.config speichern) | offen |
|
| T-011 | Login-Flow in der App (Auth-Datei sicher unter ~/.config speichern) | fertig |
|
||||||
| T-012 | Bibliotheksansicht mit Covern, Suche, Sortierung | offen |
|
| T-012 | Bibliotheksansicht mit Covern, Suche, Sortierung | offen |
|
||||||
| T-013 | Download-Manager (Queue, Fortschritt, Abbruch) | offen |
|
| T-013 | Download-Manager (Queue, Fortschritt, Abbruch) | offen |
|
||||||
| T-014 | Entschlüsseln nach dem Download, Ablage als .m4b mit Kapiteln und Cover | offen |
|
| T-014 | Entschlüsseln nach dem Download, Ablage als .m4b mit Kapiteln und Cover | offen |
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>hw-vite</title>
|
<title>Hörwerk</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
292
src-tauri/src/audible.rs
Normal file
292
src-tauri/src/audible.rs
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// Status der Anmeldung beim Audible-Konto.
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct AuthStatus {
|
||||||
|
pub logged_in: bool,
|
||||||
|
pub profiles: Vec<String>,
|
||||||
|
pub auth_dir: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ein Buch aus der Audible-Bibliothek (Export-JSON, Felder nach Spike).
|
||||||
|
#[derive(Debug, Deserialize, Clone, Serialize)]
|
||||||
|
pub struct Book {
|
||||||
|
pub asin: String,
|
||||||
|
pub title: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub authors: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub narrators: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub runtime_length_min: i64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub cover_url: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub percent_complete: f64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub is_finished: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Zugriffsschicht auf Audible — hinter diesem Trait kapseln, damit
|
||||||
|
/// `audible-cli` später austauschbar bleibt (spec E-02).
|
||||||
|
pub trait AudibleClient: Send + Sync {
|
||||||
|
fn auth_status(&self) -> Result<AuthStatus, String>;
|
||||||
|
/// Startet die interaktive Anmeldung (audible quickstart) im Terminal.
|
||||||
|
/// true = Terminal gestartet, der Nutzer meldet sich dort an; dann
|
||||||
|
/// `auth_status` erneut prüfen.
|
||||||
|
fn start_login(&self) -> Result<bool, String>;
|
||||||
|
fn library(&self) -> Result<Vec<Book>, String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CliAudibleClient {
|
||||||
|
auth_dir: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CliAudibleClient {
|
||||||
|
/// Standard: `~/.audible` (audible-cli-Standardpfad), per
|
||||||
|
/// `HOERWERK_AUDIBLE_DIR` überschreibbar (z. B. für KT-010).
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::with_auth_dir(default_auth_dir())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_auth_dir(dir: PathBuf) -> Self {
|
||||||
|
Self { auth_dir: dir }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Findet die audible-CLI: bevorzugt `~/.local/bin/audible` (pipx),
|
||||||
|
/// sonst `$PATH`. Übergabe als Argumentliste, nie über eine Shell.
|
||||||
|
fn audible_binary(&self) -> Result<PathBuf, String> {
|
||||||
|
if let Some(home) = home_dir() {
|
||||||
|
let p = home.join(".local/bin/audible");
|
||||||
|
if p.is_file() {
|
||||||
|
return Ok(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(path) = env::var("PATH") {
|
||||||
|
for dir in env::split_paths(&path) {
|
||||||
|
let p = dir.join("audible");
|
||||||
|
if p.is_file() {
|
||||||
|
return Ok(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err("audible-cli nicht gefunden — Installation: pipx install audible-cli".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CliAudibleClient {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn home_dir() -> Option<PathBuf> {
|
||||||
|
env::var("HOME").ok().map(PathBuf::from)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_auth_dir() -> PathBuf {
|
||||||
|
home_dir()
|
||||||
|
.map(|h| h.join(".audible"))
|
||||||
|
.unwrap_or_else(|| PathBuf::from("."))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AudibleClient for CliAudibleClient {
|
||||||
|
fn auth_status(&self) -> Result<AuthStatus, String> {
|
||||||
|
let mut profiles = Vec::new();
|
||||||
|
let entries = fs::read_dir(&self.auth_dir).map_err(|e| {
|
||||||
|
format!(
|
||||||
|
"Auth-Verzeichnis nicht lesbar ({}): {e}",
|
||||||
|
self.auth_dir.display()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
let p = entry.path();
|
||||||
|
let is_json = p
|
||||||
|
.extension()
|
||||||
|
.and_then(|e| e.to_str())
|
||||||
|
.map(|e| e.eq_ignore_ascii_case("json"))
|
||||||
|
.unwrap_or(false);
|
||||||
|
if is_json {
|
||||||
|
if let Some(stem) = p.file_stem().and_then(|s| s.to_str()) {
|
||||||
|
profiles.push(stem.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(AuthStatus {
|
||||||
|
logged_in: !profiles.is_empty(),
|
||||||
|
profiles,
|
||||||
|
auth_dir: self.auth_dir.display().to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_login(&self) -> Result<bool, String> {
|
||||||
|
let bin = self.audible_binary()?;
|
||||||
|
let Some((term, needs_e)) = find_terminal() else {
|
||||||
|
return Err("kein unterstütztes Terminal gefunden — bitte in deiner Shell ausführen: audible quickstart".to_string());
|
||||||
|
};
|
||||||
|
// Argumentliste, keine Shell und kein zusammengesetzter String (spec).
|
||||||
|
let mut cmd = Command::new(term);
|
||||||
|
if needs_e {
|
||||||
|
cmd.arg("-e");
|
||||||
|
}
|
||||||
|
cmd.arg(&bin).arg("quickstart");
|
||||||
|
cmd.spawn()
|
||||||
|
.map_err(|e| format!("Terminal konnte nicht gestartet werden: {e}"))?;
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn library(&self) -> Result<Vec<Book>, String> {
|
||||||
|
let bin = self.audible_binary()?;
|
||||||
|
let out = env::temp_dir().join(format!("hoerwerk-library-{}.json", std::process::id()));
|
||||||
|
let exported = Command::new(&bin)
|
||||||
|
.args(["library", "export", "-f", "json", "-o"])
|
||||||
|
.arg(&out)
|
||||||
|
.output()
|
||||||
|
.map_err(|e| format!("audible library export fehlgeschlagen: {e}"))?;
|
||||||
|
let stderr = String::from_utf8_lossy(&exported.stderr);
|
||||||
|
if !exported.status.success() {
|
||||||
|
let _ = fs::remove_file(&out);
|
||||||
|
return Err(reduce_noise(&stderr));
|
||||||
|
}
|
||||||
|
let content = match fs::read_to_string(&out) {
|
||||||
|
Ok(c) => c,
|
||||||
|
Err(e) => {
|
||||||
|
return Err(format!("Export-Datei nicht lesbar: {e}"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let _ = fs::remove_file(&out);
|
||||||
|
parse_library(&content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wandelt den Bibliotheks-Export in `Book`s (separat getestet).
|
||||||
|
pub fn parse_library(content: &str) -> Result<Vec<Book>, String> {
|
||||||
|
serde_json::from_str(content).map_err(|e| format!("Bibliothek-JSON nicht parsebar: {e}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Taugt stderr von audible-cli: Warnungen und Passwort-Prompts raus,
|
||||||
|
/// echte Fehlertexte bleiben.
|
||||||
|
fn reduce_noise(s: &str) -> String {
|
||||||
|
let lower = |l: &str| l.to_lowercase();
|
||||||
|
let kept: Vec<&str> = s
|
||||||
|
.lines()
|
||||||
|
.filter(|l| {
|
||||||
|
let l = lower(l);
|
||||||
|
!(l.contains("userwarning")
|
||||||
|
|| l.contains("warning: password input")
|
||||||
|
|| l.contains("please enter")
|
||||||
|
|| l.contains("getpass")
|
||||||
|
|| l.contains("passwd =")
|
||||||
|
|| l.contains("press enter"))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let joined = kept.join("\n");
|
||||||
|
if joined.trim().is_empty() {
|
||||||
|
"audible-cli meldete keinen Fehler, aber der Befehl schlug fehl.".to_string()
|
||||||
|
} else {
|
||||||
|
joined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_terminal() -> Option<(&'static str, bool)> {
|
||||||
|
// (Programm, heißt „-e Programm Args“)
|
||||||
|
const CANDIDATES: [(&str, bool); 5] = [
|
||||||
|
("konsole", true),
|
||||||
|
("kitty", true),
|
||||||
|
("alacritty", true),
|
||||||
|
("foot", false),
|
||||||
|
("xterm", true),
|
||||||
|
];
|
||||||
|
for (name, needs_e) in CANDIDATES {
|
||||||
|
if is_in_path(name) {
|
||||||
|
return Some((name, needs_e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_in_path(name: &str) -> bool {
|
||||||
|
if let Ok(path) = env::var("PATH") {
|
||||||
|
for dir in env::split_paths(&path) {
|
||||||
|
if dir.join(name).is_file() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn temp_dir() -> PathBuf {
|
||||||
|
let d = env::temp_dir().join(format!(
|
||||||
|
"hoerwerk-test-{}-{}",
|
||||||
|
std::process::id(),
|
||||||
|
chrono_len()
|
||||||
|
));
|
||||||
|
fs::create_dir_all(&d).unwrap();
|
||||||
|
d
|
||||||
|
}
|
||||||
|
|
||||||
|
fn chrono_len() -> String {
|
||||||
|
// kleiner uniq-Suffix ohne chrono: nanos seit Start via std
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
let n = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||||
|
format!("{}", n.subsec_nanos())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn logged_in_wenn_auth_datei_vorhanden() {
|
||||||
|
let d = temp_dir();
|
||||||
|
fs::write(d.join("testprof.json"), "{}").unwrap();
|
||||||
|
let c = CliAudibleClient::with_auth_dir(d.clone());
|
||||||
|
let s = c.auth_status().unwrap();
|
||||||
|
assert!(s.logged_in);
|
||||||
|
assert_eq!(s.profiles, vec!["testprof".to_string()]);
|
||||||
|
fs::remove_dir_all(d).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ausgeloggt_wenn_nichts_da() {
|
||||||
|
let d = temp_dir();
|
||||||
|
let c = CliAudibleClient::with_auth_dir(d);
|
||||||
|
let s = c.auth_status().unwrap();
|
||||||
|
assert!(!s.logged_in);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn json_nur_fuer_auth_dateien() {
|
||||||
|
let d = temp_dir();
|
||||||
|
fs::write(d.join("a.json"), "{}").unwrap();
|
||||||
|
fs::write(d.join("config.toml"), "").unwrap();
|
||||||
|
fs::write(d.join("txt.txt"), "{}").unwrap();
|
||||||
|
let c = CliAudibleClient::with_auth_dir(d);
|
||||||
|
let s = c.auth_status().unwrap();
|
||||||
|
assert_eq!(s.profiles.len(), 1);
|
||||||
|
assert!(s.profiles[0] == "a");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_library_nimmt_pfelder() {
|
||||||
|
let json = r#"[{"asin":"B08L4WJMDM","title":"Elfe 2"}]"#;
|
||||||
|
let books = parse_library(json).unwrap();
|
||||||
|
assert_eq!(books.len(), 1);
|
||||||
|
assert_eq!(books[0].asin, "B08L4WJMDM");
|
||||||
|
assert_eq!(books[0].runtime_length_min, 0);
|
||||||
|
assert!(!books[0].is_finished);
|
||||||
|
assert!(parse_library("kaputt").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn noise_wird_gefiltert() {
|
||||||
|
let s = "UserWarning: legace\nerror: 401\nPlease enter the auth-file password";
|
||||||
|
assert_eq!(reduce_noise(s), "error: 401");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,28 @@
|
|||||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
mod audible;
|
||||||
|
|
||||||
|
use audible::{AudibleClient, AuthStatus, Book, CliAudibleClient};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn greet(name: &str) -> String {
|
fn auth_status(client: tauri::State<CliAudibleClient>) -> Result<AuthStatus, String> {
|
||||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
client.auth_status()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn start_login(client: tauri::State<CliAudibleClient>) -> Result<bool, String> {
|
||||||
|
client.start_login()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn get_library(client: tauri::State<CliAudibleClient>) -> Result<Vec<Book>, String> {
|
||||||
|
client.library()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
.invoke_handler(tauri::generate_handler![greet])
|
.manage(CliAudibleClient::new())
|
||||||
|
.invoke_handler(tauri::generate_handler![auth_status, start_login, get_library])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|||||||
209
src/App.svelte
209
src/App.svelte
@ -1,89 +1,126 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import svelteLogo from './assets/svelte.svg'
|
import { authStatus, startLogin, getLibrary, type Book } from './lib/audible'
|
||||||
import viteLogo from './assets/vite.svg'
|
|
||||||
import heroImg from './assets/hero.png'
|
type View = 'loading' | 'login' | 'library'
|
||||||
import Counter from './lib/Counter.svelte'
|
|
||||||
|
let view = $state<View>('loading')
|
||||||
|
let error = $state('')
|
||||||
|
let info = $state('')
|
||||||
|
let books = $state<Book[]>([])
|
||||||
|
let starting = $state(false)
|
||||||
|
let checking = $state(false)
|
||||||
|
let pollTimer = $state<ReturnType<typeof setInterval> | null>(null)
|
||||||
|
|
||||||
|
function clearPoll() {
|
||||||
|
if (pollTimer !== null) {
|
||||||
|
clearInterval(pollTimer)
|
||||||
|
pollTimer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadLibrary(): Promise<void> {
|
||||||
|
checking = true
|
||||||
|
error = ''
|
||||||
|
try {
|
||||||
|
books = await getLibrary()
|
||||||
|
view = 'library'
|
||||||
|
} catch (e) {
|
||||||
|
error = String(e)
|
||||||
|
} finally {
|
||||||
|
checking = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkAuth(): Promise<void> {
|
||||||
|
checking = true
|
||||||
|
error = ''
|
||||||
|
try {
|
||||||
|
const s = await authStatus()
|
||||||
|
if (s.logged_in) {
|
||||||
|
clearPoll()
|
||||||
|
await loadLibrary()
|
||||||
|
} else if (view === 'library') {
|
||||||
|
view = 'login'
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = String(e)
|
||||||
|
} finally {
|
||||||
|
checking = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doLogin(): Promise<void> {
|
||||||
|
starting = true
|
||||||
|
error = ''
|
||||||
|
info = ''
|
||||||
|
try {
|
||||||
|
await startLogin()
|
||||||
|
info = 'Anmeldung läuft im Terminal. Danach hier „Jetzt prüfen“ oder kurz warten.'
|
||||||
|
clearPoll()
|
||||||
|
pollTimer = setInterval(checkAuth, 3000)
|
||||||
|
} catch (e) {
|
||||||
|
error = String(e)
|
||||||
|
} finally {
|
||||||
|
starting = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Beim Start prüfen: angemeldet → Bibliothek; sonst Login-Screen.
|
||||||
|
$effect(() => {
|
||||||
|
checkAuth()
|
||||||
|
return clearPoll
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section id="center">
|
{#if view === 'loading'}
|
||||||
<div class="hero">
|
<main class="center">
|
||||||
<img src={heroImg} class="base" width="170" height="179" alt="" />
|
<h1>Hörwerk</h1>
|
||||||
<img src={svelteLogo} class="framework" alt="Svelte logo" />
|
<p class="muted">Prüfe Anmeldung…</p>
|
||||||
<img src={viteLogo} class="vite" alt="Vite logo" />
|
</main>
|
||||||
</div>
|
{:else if view === 'login'}
|
||||||
<div>
|
<main class="center">
|
||||||
<h1>Get started</h1>
|
<h1>Hörwerk</h1>
|
||||||
<p>Edit <code>src/App.svelte</code> and save to test <code>HMR</code></p>
|
<p class="muted">
|
||||||
</div>
|
Melden dich mit deinem Audible-Konto an. Die Anmeldung läuft über
|
||||||
<Counter />
|
<code>audible-cli</code> im Terminal. Nur dein eigenes, gekauftes Konto —
|
||||||
</section>
|
keine Daten gehen über die App hinaus.
|
||||||
|
</p>
|
||||||
|
<button class="primary" onclick={() => doLogin()} disabled={starting}>
|
||||||
|
{starting ? 'Starte…' : 'Anmeldung starten'}
|
||||||
|
</button>
|
||||||
|
<button class="ghost" onclick={() => checkAuth()} disabled={checking}>
|
||||||
|
{checking ? 'Prüfe…' : 'Jetzt prüfen'}
|
||||||
|
</button>
|
||||||
|
{#if info}<p class="info">{info}</p>{/if}
|
||||||
|
{#if error}<p class="error">{error}</p>{/if}
|
||||||
|
</main>
|
||||||
|
{:else if view === 'library'}
|
||||||
|
<main>
|
||||||
|
<header class="bar">
|
||||||
|
<h1>Hörwerk</h1>
|
||||||
|
<span class="muted">{books.length} Titel</span>
|
||||||
|
<button class="ghost" onclick={() => checkAuth()} disabled={checking}>Aushang prüfen</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
<div class="ticks"></div>
|
{#if error}
|
||||||
|
<p class="error">{error}</p>
|
||||||
<section id="next-steps">
|
{:else}
|
||||||
<div id="docs">
|
<table>
|
||||||
<svg class="icon" role="presentation" aria-hidden="true">
|
<thead>
|
||||||
<use href="/icons.svg#documentation-icon"></use>
|
<tr><th>Titel</th><th>Autor</th><th>Sprecher</th><th class="num">Min</th></tr>
|
||||||
</svg>
|
</thead>
|
||||||
<h2>Documentation</h2>
|
<tbody>
|
||||||
<p>Your questions, answered</p>
|
{#each books as b (b.asin)}
|
||||||
<ul>
|
<tr>
|
||||||
<li>
|
<td>{b.title}</td>
|
||||||
<a href="https://vite.dev/" target="_blank" rel="noreferrer">
|
<td>{b.authors}</td>
|
||||||
<img class="logo" src={viteLogo} alt="" />
|
<td>{b.narrators}</td>
|
||||||
Explore Vite
|
<td class="num">{b.runtime_length_min}</td>
|
||||||
</a>
|
</tr>
|
||||||
</li>
|
{/each}
|
||||||
<li>
|
</tbody>
|
||||||
<a href="https://svelte.dev/" target="_blank" rel="noreferrer">
|
</table>
|
||||||
<img class="button-icon" src={svelteLogo} alt="" />
|
<p class="muted footnote">Bibliotheksansicht minimal (T-012: Cover, Suche, Sortierung, Status).</p>
|
||||||
Learn more
|
{/if}
|
||||||
</a>
|
</main>
|
||||||
</li>
|
{/if}
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div id="social">
|
|
||||||
<svg class="icon" role="presentation" aria-hidden="true">
|
|
||||||
<use href="/icons.svg#social-icon"></use>
|
|
||||||
</svg>
|
|
||||||
<h2>Connect with us</h2>
|
|
||||||
<p>Join the Vite community</p>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/vitejs/vite" target="_blank" rel="noreferrer">
|
|
||||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
|
||||||
<use href="/icons.svg#github-icon"></use>
|
|
||||||
</svg>
|
|
||||||
GitHub
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://chat.vite.dev/" target="_blank" rel="noreferrer">
|
|
||||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
|
||||||
<use href="/icons.svg#discord-icon"></use>
|
|
||||||
</svg>
|
|
||||||
Discord
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://x.com/vite_js" target="_blank" rel="noreferrer">
|
|
||||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
|
||||||
<use href="/icons.svg#x-icon"></use>
|
|
||||||
</svg>
|
|
||||||
X.com
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://bsky.app/profile/vite.dev" target="_blank" rel="noreferrer">
|
|
||||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
|
||||||
<use href="/icons.svg#bluesky-icon"></use>
|
|
||||||
</svg>
|
|
||||||
Bluesky
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="ticks"></div>
|
|
||||||
<section id="spacer"></section>
|
|
||||||
|
|||||||
349
src/app.css
349
src/app.css
@ -1,296 +1,113 @@
|
|||||||
:root {
|
:root {
|
||||||
--text: #6b6375;
|
color-scheme: dark;
|
||||||
--text-h: #08060d;
|
--bg: #16181d;
|
||||||
--bg: #fff;
|
--bg-card: #1e2127;
|
||||||
--border: #e5e4e7;
|
--fg: #e8e6e3;
|
||||||
--code-bg: #f4f3ec;
|
--fg-muted: #9aa0a8;
|
||||||
--accent: #aa3bff;
|
--accent: #c2762f;
|
||||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
--error: #d4645c;
|
||||||
--accent-border: rgba(170, 59, 255, 0.5);
|
--border: #2a2e36;
|
||||||
--social-bg: rgba(244, 243, 236, 0.5);
|
|
||||||
--shadow:
|
|
||||||
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
|
|
||||||
|
|
||||||
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
|
|
||||||
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
|
|
||||||
--mono: ui-monospace, Consolas, monospace;
|
|
||||||
|
|
||||||
font: 18px/145% var(--sans);
|
|
||||||
letter-spacing: 0.18px;
|
|
||||||
color-scheme: light dark;
|
|
||||||
color: var(--text);
|
|
||||||
background: var(--bg);
|
|
||||||
font-synthesis: none;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
:root {
|
|
||||||
--text: #9ca3af;
|
|
||||||
--text-h: #f3f4f6;
|
|
||||||
--bg: #16171d;
|
|
||||||
--border: #2e303a;
|
|
||||||
--code-bg: #1f2028;
|
|
||||||
--accent: #c084fc;
|
|
||||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
|
||||||
--accent-border: rgba(192, 132, 252, 0.5);
|
|
||||||
--social-bg: rgba(47, 48, 58, 0.5);
|
|
||||||
--shadow:
|
|
||||||
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#social .button-icon {
|
|
||||||
filter: invert(1) brightness(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--fg);
|
||||||
|
font-family: system-ui, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
main.center {
|
||||||
h2 {
|
display: flex;
|
||||||
font-family: var(--heading);
|
flex-direction: column;
|
||||||
font-weight: 500;
|
gap: 0.9rem;
|
||||||
color: var(--text-h);
|
max-width: 34rem;
|
||||||
|
margin: 9vh auto;
|
||||||
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 56px;
|
font-size: 1.4rem;
|
||||||
letter-spacing: -1.68px;
|
font-weight: 600;
|
||||||
margin: 32px 0;
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
font-size: 36px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 118%;
|
|
||||||
letter-spacing: -0.24px;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
code,
|
.muted {
|
||||||
.counter {
|
color: var(--fg-muted);
|
||||||
font-family: var(--mono);
|
line-height: 1.5;
|
||||||
display: inline-flex;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: var(--text-h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
.bar {
|
||||||
font-size: 15px;
|
|
||||||
line-height: 135%;
|
|
||||||
padding: 4px 8px;
|
|
||||||
background: var(--code-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.counter {
|
|
||||||
font-size: 16px;
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
color: var(--accent);
|
|
||||||
background: var(--accent-bg);
|
|
||||||
border: 2px solid transparent;
|
|
||||||
transition: border-color 0.3s;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--accent-border);
|
|
||||||
}
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 2px solid var(--accent);
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.base,
|
|
||||||
.framework,
|
|
||||||
.vite {
|
|
||||||
inset-inline: 0;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.base {
|
|
||||||
width: 170px;
|
|
||||||
position: relative;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.framework,
|
|
||||||
.vite {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.framework {
|
|
||||||
z-index: 1;
|
|
||||||
top: 34px;
|
|
||||||
height: 28px;
|
|
||||||
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
|
|
||||||
scale(1.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.vite {
|
|
||||||
z-index: 0;
|
|
||||||
top: 107px;
|
|
||||||
height: 26px;
|
|
||||||
width: auto;
|
|
||||||
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
|
|
||||||
scale(0.8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#app {
|
|
||||||
width: 1126px;
|
|
||||||
max-width: 100%;
|
|
||||||
margin: 0 auto;
|
|
||||||
text-align: center;
|
|
||||||
border-inline: 1px solid var(--border);
|
|
||||||
min-height: 100svh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
gap: 1rem;
|
||||||
|
padding: 0.8rem 1.2rem;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: var(--bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#center {
|
.bar .muted {
|
||||||
display: flex;
|
flex: 1;
|
||||||
flex-direction: column;
|
|
||||||
gap: 25px;
|
|
||||||
place-content: center;
|
|
||||||
place-items: center;
|
|
||||||
flex-grow: 1;
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
padding: 32px 20px 24px;
|
|
||||||
gap: 18px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#next-steps {
|
button {
|
||||||
display: flex;
|
border: 1px solid var(--border);
|
||||||
border-top: 1px solid var(--border);
|
border-radius: 6px;
|
||||||
|
padding: 0.45rem 0.9rem;
|
||||||
|
background: var(--bg-card);
|
||||||
|
color: var(--fg);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover:enabled {
|
||||||
|
filter: brightness(1.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary {
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.ghost {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: calc(100% - 2.4rem);
|
||||||
|
margin: 1rem 1.2rem;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
padding: 0.4rem 0.6rem;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
& > div {
|
|
||||||
flex: 1 1 0;
|
|
||||||
padding: 32px;
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
padding: 24px 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
flex-direction: column;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#docs {
|
th.num,
|
||||||
border-right: 1px solid var(--border);
|
td.num {
|
||||||
|
text-align: right;
|
||||||
@media (max-width: 1024px) {
|
|
||||||
border-right: none;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#next-steps ul {
|
.footnote {
|
||||||
list-style: none;
|
margin: 0.6rem 1.2rem 2rem;
|
||||||
padding: 0;
|
font-size: 0.85rem;
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
margin: 32px 0 0;
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
height: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: var(--text-h);
|
|
||||||
font-size: 16px;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: var(--social-bg);
|
|
||||||
display: flex;
|
|
||||||
padding: 6px 12px;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: box-shadow 0.3s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
}
|
|
||||||
.button-icon {
|
|
||||||
height: 18px;
|
|
||||||
width: 18px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
margin-top: 20px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
li {
|
|
||||||
flex: 1 1 calc(50% - 8px);
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: center;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#spacer {
|
.info {
|
||||||
height: 88px;
|
color: #7fa9d4;
|
||||||
border-top: 1px solid var(--border);
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
height: 48px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ticks {
|
.error {
|
||||||
position: relative;
|
color: var(--error);
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&::before,
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: -4.5px;
|
|
||||||
border: 5px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
left: 0;
|
|
||||||
border-left-color: var(--border);
|
|
||||||
}
|
|
||||||
&::after {
|
|
||||||
right: 0;
|
|
||||||
border-right-color: var(--border);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="26.6" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 308"><path fill="#FF3E00" d="M239.682 40.707C211.113-.182 154.69-12.301 113.895 13.69L42.247 59.356a82.198 82.198 0 0 0-37.135 55.056a86.566 86.566 0 0 0 8.536 55.576a82.425 82.425 0 0 0-12.296 30.719a87.596 87.596 0 0 0 14.964 66.244c28.574 40.893 84.997 53.007 125.787 27.016l71.648-45.664a82.182 82.182 0 0 0 37.135-55.057a86.601 86.601 0 0 0-8.53-55.577a82.409 82.409 0 0 0 12.29-30.718a87.573 87.573 0 0 0-14.963-66.244"></path><path fill="#FFF" d="M106.889 270.841c-23.102 6.007-47.497-3.036-61.103-22.648a52.685 52.685 0 0 1-9.003-39.85a49.978 49.978 0 0 1 1.713-6.693l1.35-4.115l3.671 2.697a92.447 92.447 0 0 0 28.036 14.007l2.663.808l-.245 2.659a16.067 16.067 0 0 0 2.89 10.656a17.143 17.143 0 0 0 18.397 6.828a15.786 15.786 0 0 0 4.403-1.935l71.67-45.672a14.922 14.922 0 0 0 6.734-9.977a15.923 15.923 0 0 0-2.713-12.011a17.156 17.156 0 0 0-18.404-6.832a15.78 15.78 0 0 0-4.396 1.933l-27.35 17.434a52.298 52.298 0 0 1-14.553 6.391c-23.101 6.007-47.497-3.036-61.101-22.649a52.681 52.681 0 0 1-9.004-39.849a49.428 49.428 0 0 1 22.34-33.114l71.664-45.677a52.218 52.218 0 0 1 14.563-6.398c23.101-6.007 47.497 3.036 61.101 22.648a52.685 52.685 0 0 1 9.004 39.85a50.559 50.559 0 0 1-1.713 6.692l-1.35 4.116l-3.67-2.693a92.373 92.373 0 0 0-28.037-14.013l-2.664-.809l.246-2.658a16.099 16.099 0 0 0-2.89-10.656a17.143 17.143 0 0 0-18.398-6.828a15.786 15.786 0 0 0-4.402 1.935l-71.67 45.674a14.898 14.898 0 0 0-6.73 9.975a15.9 15.9 0 0 0 2.709 12.012a17.156 17.156 0 0 0 18.404 6.832a15.841 15.841 0 0 0 4.402-1.935l27.345-17.427a52.147 52.147 0 0 1 14.552-6.397c23.101-6.006 47.497 3.037 61.102 22.65a52.681 52.681 0 0 1 9.003 39.848a49.453 49.453 0 0 1-22.34 33.12l-71.664 45.673a52.218 52.218 0 0 1-14.563 6.398"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.9 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 8.5 KiB |
@ -1,10 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
let count: number = $state(0)
|
|
||||||
const increment = () => {
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button type="button" class="counter" onclick={increment}>
|
|
||||||
Count is {count}
|
|
||||||
</button>
|
|
||||||
22
src/lib/audible.ts
Normal file
22
src/lib/audible.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
|
export interface AuthStatus {
|
||||||
|
logged_in: boolean
|
||||||
|
profiles: string[]
|
||||||
|
auth_dir: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Book {
|
||||||
|
asin: string
|
||||||
|
title: string
|
||||||
|
authors: string
|
||||||
|
narrators: string
|
||||||
|
runtime_length_min: number
|
||||||
|
cover_url: string
|
||||||
|
percent_complete: number
|
||||||
|
is_finished: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const authStatus = () => invoke<AuthStatus>('auth_status')
|
||||||
|
export const startLogin = () => invoke<boolean>('start_login')
|
||||||
|
export const getLibrary = () => invoke<Book[]>('get_library')
|
||||||
Reference in New Issue
Block a user