This commit is contained in:
2025-10-20 12:50:03 +02:00
commit 561a91d023
13 changed files with 396 additions and 0 deletions

47
templates/index.html Normal file
View File

@@ -0,0 +1,47 @@
<!doctype html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vyhledávání Google — Inzio</title>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body class="bg-light d-flex min-vh-100">
<main class="container my-auto py-5">
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<div class="text-center mb-4">
<h1 class="fw-semibold">Inzio Web Search</h1>
<p class="text-muted mb-0">Jednoduché vyhledávání na Googlu</p>
</div>
{% if error %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %}
<div class="card shadow-sm">
<div class="card-body p-4">
<form action="/search" method="POST" class="d-flex flex-column gap-3">
<div>
<label for="q" class="form-label">Hledaný dotaz</label>
<input type="text" class="form-control form-control-lg" id="q" name="q" placeholder="Zadejte dotaz…" required>
</div>
<div class="d-grid d-sm-flex gap-2">
<button type="submit" class="btn btn-primary btn-lg">Hledat</button>
</div>
</form>
</div>
<div class="card-footer bg-white text-muted small">
Výsledky poskytuje <a href="https://developers.google.com/custom-search/v1/overview#search_engine_id" target="_blank" rel="noopener">Google Custom Search JSON API</a> · limit: 1 požadavek / 5&nbsp;s
</div>
</div>
</div>
</div>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>

90
templates/results.html Normal file
View File

@@ -0,0 +1,90 @@
<!doctype html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Výsledky pro "{{ query }}" - vontor.cz</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script>
function download(fmt) {
const payload = { format: fmt, results: JSON.parse(document.getElementById('json-data').textContent) };
fetch('/export', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(payload)
}).then(r => {
if (r.ok) return r.blob();
return r.json().then(j=>{throw j});
}).then(blob=>{
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'results.' + fmt;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}).catch(e=>{ alert('Export failed: ' + JSON.stringify(e));});
}
</script>
</head>
<body class="bg-light min-vh-100 d-flex">
<main class="container my-auto py-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Výsledky pro "{{ query }}"</h1>
<a class="btn btn-outline-secondary" href="/">Nové hledání</a>
</div>
{% if notice %}
<div class="alert alert-warning" role="alert">
{{ notice }}
</div>
{% endif %}
<div class="card shadow-sm mb-3">
<div class="card-body">
<div class="d-flex flex-wrap gap-2 justify-content-between align-items-center">
<div class="text-muted">Počet výsledků: <strong>{{ results|length }}</strong></div>
<div class="d-flex gap-2">
<button class="btn btn-sm btn-outline-primary" onclick="download('json')">Stáhnout JSON</button>
</div>
</div>
</div>
</div>
{% if results and results|length > 0 %}
<ol class="list-group list-group-numbered">
{% for item in results %}
<li class="list-group-item">
<div class="d-flex gap-3 align-items-start">
{% if item.icon %}
<img src="{{ item.icon }}" alt="" width="20" height="20" class="rounded mt-1" onerror="this.style.display='none'">
{% endif %}
<div class="flex-grow-1">
<a class="fw-semibold" href="{{ item.link }}" target="_blank" rel="noopener noreferrer">{{ item.title }}</a>
{% if r.snippet %}
<small class="text-muted d-block">{{ r.snippet }}</small>
{% endif %}
<small class="text-break text-secondary">{{ r.link }}</small>
</div>
</div>
</li>
{% endfor %}
</ol>
{% else %}
<div class="alert alert-info" role="alert">
Žádné položky k zobrazení.
</div>
{% endif %}
<script id="json-data" type="application/json">{{ results|tojson }}</script>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>