move ai python server into seperate repo
This commit is contained in:
17
src/assets/migrations/20250102152758_article.sql
Normal file
17
src/assets/migrations/20250102152758_article.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE articles (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
sourceUrl VARCHAR(255) NOT NULL UNIQUE,
|
||||
author VARCHAR(255) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
publishDate TIMESTAMP NOT NULL,
|
||||
fetchDate TIMESTAMP NOT NULL
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS articles;
|
||||
-- +goose StatementEnd
|
||||
15
src/assets/migrations/20250102232127_article_fts.sql
Normal file
15
src/assets/migrations/20250102232127_article_fts.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE articles
|
||||
ADD COLUMN fts_vector tsvector GENERATED ALWAYS AS (
|
||||
to_tsvector('german', coalesce(title, '') || ' ' || coalesce(content, '') || ' ' || coalesce(author, ''))
|
||||
) STORED;
|
||||
|
||||
CREATE INDEX articles_fts_idx ON articles USING gin(fts_vector);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP INDEX IF EXISTS articles_fts_idx;
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
|
||||
-- +goose StatementEnd
|
||||
13
src/assets/migrations/20250103140557_response_cache.sql
Normal file
13
src/assets/migrations/20250103140557_response_cache.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE responses (
|
||||
url VARCHAR(255) NOT NULL UNIQUE PRIMARY KEY,
|
||||
content BYTEA NOT NULL,
|
||||
fetchDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS responses;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE responses ADD COLUMN processed BOOLEAN DEFAULT false;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE responses DROP COLUMN IF EXISTS processed;
|
||||
-- +goose StatementEnd
|
||||
14
src/assets/migrations/20250107091120_remove_responses.sql
Normal file
14
src/assets/migrations/20250107091120_remove_responses.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS responses;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE responses (
|
||||
url VARCHAR(255) NOT NULL UNIQUE PRIMARY KEY,
|
||||
content BYTEA NOT NULL,
|
||||
fetchDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
processed BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
36
src/assets/migrations/20250107104609_drop_column_author.sql
Normal file
36
src/assets/migrations/20250107104609_drop_column_author.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS articles_fts_idx;
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
|
||||
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS author;
|
||||
|
||||
ALTER TABLE articles
|
||||
ADD COLUMN fts_vector tsvector GENERATED ALWAYS AS (
|
||||
to_tsvector('german', coalesce(title, '') || ' ' || coalesce(content, ''))
|
||||
) STORED;
|
||||
CREATE INDEX articles_fts_idx ON articles USING gin(fts_vector);
|
||||
|
||||
COMMIT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE articles ADD COLUMN author VARCHAR(255) DEFAULT '';
|
||||
|
||||
DROP INDEX IF EXISTS articles_fts_idx;
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
|
||||
|
||||
ALTER TABLE articles
|
||||
ADD COLUMN fts_vector tsvector GENERATED ALWAYS AS (
|
||||
to_tsvector('german', coalesce(title, '') || ' ' || coalesce(content, '') || ' ' || coalesce(author, ''))
|
||||
) STORED;
|
||||
|
||||
CREATE INDEX articles_fts_idx ON articles USING gin(fts_vector);
|
||||
|
||||
COMMIT;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE articles ADD COLUMN aisummary TEXT DEFAULT '';
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS aisummary;
|
||||
-- +goose StatementEnd
|
||||
75
src/assets/static/index.html
Normal file
75
src/assets/static/index.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dark Mode Article Previews</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background-color: #121212;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.article-preview {
|
||||
background-color: #1e1e1e;
|
||||
border: 1px solid #2c2c2c;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0d6efd;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
p {
|
||||
color: white
|
||||
}
|
||||
|
||||
h5 {
|
||||
color: white
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container py-5">
|
||||
<h1 class="text-center mb-auto">Article Previews</h1>
|
||||
<div class="column">
|
||||
<!-- Article 1 -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card article-preview p-3">
|
||||
<h5 class="card-title">Article Title 1</h5>
|
||||
<p class="card-text">This is a short preview of the article content. It provides a quick summary to entice readers to click and read more.</p>
|
||||
<a href="#" class="stretched-link">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Article 2 -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card article-preview p-3">
|
||||
<h5 class="card-title">Article Title 2</h5>
|
||||
<p class="card-text">This is another preview of an article. It gives a brief overview to encourage users to explore further.</p>
|
||||
<a href="#" class="stretched-link">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Article 3 -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card article-preview p-3">
|
||||
<h5 class="card-title">Article Title 3</h5>
|
||||
<p class="card-text">A concise description of the article to pique interest and direct readers to the full content.</p>
|
||||
<a href="#" class="stretched-link">Read More</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS Bundle -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
23
src/assets/templates/article.html
Normal file
23
src/assets/templates/article.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{{ define "content" }}
|
||||
|
||||
<div class="content max-w-screen-lg mx-auto">
|
||||
|
||||
{{ range . }}
|
||||
<div tabindex="0" class="collapse bg-base-200 shadow mb-4">
|
||||
<div class="collapse-title font-medium">{{ .Title }}</div>
|
||||
<div class="collapse-content">
|
||||
<p class="pb-2">
|
||||
<span class="badge badge-outline">{{ .ShortSource }}</span>
|
||||
<span class="badge badge-outline">{{ .PublishDate }}</span>
|
||||
{{if .AiSummarized}}
|
||||
<span class="badge badge-outline">ai summary</span>
|
||||
{{end}}
|
||||
</p>
|
||||
<p class="card-text">{{ .Summary }}</p>
|
||||
<a href="{{ .SourceUrl }}" class="link">Link</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
{{ end }}
|
||||
62
src/assets/templates/layout.html
Normal file
62
src/assets/templates/layout.html
Normal file
@@ -0,0 +1,62 @@
|
||||
{{ define "base" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="de" data-theme="dark">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/unpoly@3.9.5/unpoly.min.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.23/dist/full.min.css" rel="stylesheet" type="text/css" />
|
||||
<body>
|
||||
|
||||
<nav class="fixed top-0 z-50 w-full p-4">
|
||||
<div class="navbar bg-base-300 rounded-box drop-shadow-md">
|
||||
|
||||
{{/* Logo with navigation */}}
|
||||
|
||||
<div class="flex-1">
|
||||
<a href="/" tabindex="0" class="btn btn-ghost text-xl">crowsnest</a>
|
||||
<ul class="menu menu-horizontal hidden sm:flex">
|
||||
<li><a tabindex="0" class="active">Artikel</a></li>
|
||||
<li><a tabindex="0">Themen</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{{/* Search field for normal sized screen */}}
|
||||
|
||||
<div class="hidden sm:flex flex-none pe-4">
|
||||
<form role="search" method="post" action="/up/search" up-submit up-autosubmit up-target=".content">
|
||||
<label class="input input-bordered input-sm flex items-center gap-2">
|
||||
<input name="search" type="search" class="grow" placeholder="Suche" />
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"
|
||||
class="h-4 w-4 opacity-70">
|
||||
<path fill-rule="evenodd" d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{/* Dropdown for small screens */}}
|
||||
|
||||
<div class="dropdown dropdown-end sm:hidden">
|
||||
<div tabindex="0" role="button" class="btn btn-ghost">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
|
||||
class="h-6 w-6 opacity-70">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5M12 17.25h8.25" />
|
||||
</svg>
|
||||
</div>
|
||||
<ul class="menu dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow">
|
||||
<li><a tabindex="0" class="active">Artikel</a></li>
|
||||
<li><a tabindex="0">Themen</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mx-auto px-4 mt-28">
|
||||
{{ template "content" . }}
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/unpoly@3.9.5/unpoly.min.js"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user