feat(sidebar): узкое меню, субменю историй с hover, эффект text-fade
- Сужено боковое меню (56px), убрана иконка Home - Субменю историй при наведении: полная высота, на всю ширину, z-9999 - Класс text-fade для плавного обрезания длинного текста - Убраны скругления в субменю - Chatwoot, изменения в posts-mcs и прочие обновления Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,4 +22,7 @@ LLM_EMBEDDING_MODEL=nomic-embed-text
|
|||||||
# Запустите свой: docker run -d -p 4000:8080 searxng/searxng
|
# Запустите свой: docker run -d -p 4000:8080 searxng/searxng
|
||||||
# SEARXNG_API_URL=http://localhost:4000
|
# SEARXNG_API_URL=http://localhost:4000
|
||||||
# SEARXNG_FALLBACK_URL= # через запятую, если основной недоступен
|
# SEARXNG_FALLBACK_URL= # через запятую, если основной недоступен
|
||||||
|
# Ghost — вкладка Dooseek. Локально: port 2369 (или 2368)
|
||||||
|
# GHOST_URL=http://localhost:2369
|
||||||
|
# GHOST_CONTENT_API_KEY=ключ из Admin → Integrations
|
||||||
# DATA_DIR=./data
|
# DATA_DIR=./data
|
||||||
|
|||||||
31
apps/chatwoot/.env.example
Normal file
31
apps/chatwoot/.env.example
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Chatwoot — минимальная конфигурация
|
||||||
|
# Скопируйте в .env и заполните обязательные поля
|
||||||
|
|
||||||
|
# === Обязательно ===
|
||||||
|
# Сгенерировать: openssl rand -hex 64
|
||||||
|
SECRET_KEY_BASE=
|
||||||
|
|
||||||
|
# Пароль PostgreSQL (обязательно)
|
||||||
|
POSTGRES_PASSWORD=
|
||||||
|
|
||||||
|
# URL фронтенда (где открывать Chatwoot)
|
||||||
|
FRONTEND_URL=http://localhost:3001
|
||||||
|
|
||||||
|
# === PostgreSQL ===
|
||||||
|
POSTGRES_HOST=postgres
|
||||||
|
POSTGRES_USERNAME=postgres
|
||||||
|
RAILS_ENV=production
|
||||||
|
|
||||||
|
# === Redis ===
|
||||||
|
REDIS_URL=redis://redis:6379
|
||||||
|
# Для production задайте REDIS_PASSWORD и REDIS_URL=redis://:пароль@redis:6379
|
||||||
|
REDIS_PASSWORD=
|
||||||
|
|
||||||
|
# === Опционально ===
|
||||||
|
# Регистрация новых аккаунтов (true/false)
|
||||||
|
ENABLE_ACCOUNT_SIGNUP=true
|
||||||
|
|
||||||
|
# SMTP — для локальной разработки используйте MailHog (docker compose включает его)
|
||||||
|
# SMTP_ADDRESS=mailhog
|
||||||
|
# SMTP_PORT=1025
|
||||||
|
# MAILER_SENDER_EMAIL=chatwoot@localhost
|
||||||
50
apps/chatwoot/README.md
Normal file
50
apps/chatwoot/README.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Chatwoot — self-hosted live chat
|
||||||
|
|
||||||
|
Live chat для клиентской поддержки. Данные на вашем сервере.
|
||||||
|
|
||||||
|
## Быстрый старт
|
||||||
|
|
||||||
|
### 1. Подготовка
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd chatwoot
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Заполнить .env
|
||||||
|
|
||||||
|
Обязательно задать:
|
||||||
|
|
||||||
|
- **SECRET_KEY_BASE** — сгенерировать: `openssl rand -hex 64`
|
||||||
|
- **POSTGRES_PASSWORD** — пароль для PostgreSQL
|
||||||
|
|
||||||
|
### 3. Запуск
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Инициализация БД (выполнить один раз)
|
||||||
|
docker compose run --rm rails bundle exec rails db:chatwoot_prepare
|
||||||
|
|
||||||
|
# Запуск
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Доступ
|
||||||
|
|
||||||
|
- **Интерфейс:** http://localhost:3001
|
||||||
|
- Создайте аккаунт при первом входе (если `ENABLE_ACCOUNT_SIGNUP=true`)
|
||||||
|
|
||||||
|
## Встраивание виджета
|
||||||
|
|
||||||
|
После создания инбокса в панели Chatwoot скопируйте код виджета и вставьте на сайт перед `</body>`.
|
||||||
|
|
||||||
|
## Полезные команды
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Остановить
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
# Обновить до новой версии
|
||||||
|
docker compose pull
|
||||||
|
docker compose run --rm rails bundle exec rails db:chatwoot_prepare
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
78
apps/chatwoot/docker-compose.yaml
Normal file
78
apps/chatwoot/docker-compose.yaml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Chatwoot — self-hosted live chat
|
||||||
|
# Документация: https://developers.chatwoot.com/self-hosted
|
||||||
|
|
||||||
|
x-app: &app
|
||||||
|
image: chatwoot/chatwoot:latest
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- storage_data:/app/storage
|
||||||
|
|
||||||
|
services:
|
||||||
|
rails:
|
||||||
|
<<: *app
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- redis
|
||||||
|
- mailhog
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:3001:3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- RAILS_ENV=production
|
||||||
|
- INSTALLATION_ENV=docker
|
||||||
|
entrypoint: docker/entrypoints/rails.sh
|
||||||
|
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
sidekiq:
|
||||||
|
<<: *app
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- redis
|
||||||
|
- mailhog
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- RAILS_ENV=production
|
||||||
|
- INSTALLATION_ENV=docker
|
||||||
|
command: ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: pgvector/pgvector:pg16
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=chatwoot
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD required}
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
mailhog:
|
||||||
|
image: mailhog/mailhog:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "1025:1025"
|
||||||
|
- "8025:8025"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
command: ["sh", "-c", "redis-server $${REDIS_PASSWORD:+--requirepass \"$$REDIS_PASSWORD\"}"]
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
storage_data:
|
||||||
|
postgres_data:
|
||||||
|
redis_data:
|
||||||
@@ -2,14 +2,34 @@ import { searchSearxng, type SearxngSearchResult } from '@/lib/searxng';
|
|||||||
import configManager from '@/lib/config';
|
import configManager from '@/lib/config';
|
||||||
import { getSearxngURL } from '@/lib/config/serverRegistry';
|
import { getSearxngURL } from '@/lib/config/serverRegistry';
|
||||||
|
|
||||||
|
const GHOST_URL = process.env.GHOST_URL?.trim() ?? '';
|
||||||
|
const GHOST_CONTENT_API_KEY = process.env.GHOST_CONTENT_API_KEY?.trim() ?? '';
|
||||||
|
const PLACEHOLDER_IMAGE = 'https://placehold.co/400x225/e5e7eb/6b7280?text=Post';
|
||||||
|
|
||||||
type Region = 'america' | 'eu' | 'russia' | 'china';
|
type Region = 'america' | 'eu' | 'russia' | 'china';
|
||||||
type Topic = 'tech' | 'finance' | 'art' | 'sports' | 'entertainment';
|
type Topic = 'tech' | 'finance' | 'art' | 'sports' | 'entertainment' | 'gooseek';
|
||||||
|
|
||||||
|
interface GhostPost {
|
||||||
|
title: string;
|
||||||
|
excerpt?: string | null;
|
||||||
|
custom_excerpt?: string | null;
|
||||||
|
meta_description?: string | null;
|
||||||
|
plaintext?: string | null;
|
||||||
|
html?: string | null;
|
||||||
|
feature_image?: string | null;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stripHtml(html: string): string {
|
||||||
|
return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
||||||
|
}
|
||||||
|
|
||||||
const SOURCES_BY_REGION: Record<
|
const SOURCES_BY_REGION: Record<
|
||||||
Region,
|
Region,
|
||||||
Record<Topic, { query: string[]; links: string[] }>
|
Record<Topic, { query: string[]; links: string[] }>
|
||||||
> = {
|
> = {
|
||||||
america: {
|
america: {
|
||||||
|
gooseek: { query: [], links: [] },
|
||||||
tech: {
|
tech: {
|
||||||
query: ['technology news', 'latest tech', 'AI', 'science and innovation'],
|
query: ['technology news', 'latest tech', 'AI', 'science and innovation'],
|
||||||
links: ['techcrunch.com', 'wired.com', 'theverge.com', 'arstechnica.com'],
|
links: ['techcrunch.com', 'wired.com', 'theverge.com', 'arstechnica.com'],
|
||||||
@@ -32,6 +52,7 @@ const SOURCES_BY_REGION: Record<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
eu: {
|
eu: {
|
||||||
|
gooseek: { query: [], links: [] },
|
||||||
tech: {
|
tech: {
|
||||||
query: ['technology news', 'tech', 'AI', 'innovation'],
|
query: ['technology news', 'tech', 'AI', 'innovation'],
|
||||||
links: ['techcrunch.com', 'bbc.com', 'theguardian.com', 'reuters.com', 'euronews.com'],
|
links: ['techcrunch.com', 'bbc.com', 'theguardian.com', 'reuters.com', 'euronews.com'],
|
||||||
@@ -54,6 +75,7 @@ const SOURCES_BY_REGION: Record<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
russia: {
|
russia: {
|
||||||
|
gooseek: { query: [], links: [] },
|
||||||
tech: {
|
tech: {
|
||||||
query: ['technology news', 'tech', 'IT', 'innovation'],
|
query: ['technology news', 'tech', 'IT', 'innovation'],
|
||||||
links: ['tass.com', 'ria.ru', 'interfax.com', 'kommersant.ru', 'vedomosti.ru'],
|
links: ['tass.com', 'ria.ru', 'interfax.com', 'kommersant.ru', 'vedomosti.ru'],
|
||||||
@@ -76,6 +98,7 @@ const SOURCES_BY_REGION: Record<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
china: {
|
china: {
|
||||||
|
gooseek: { query: [], links: [] },
|
||||||
tech: {
|
tech: {
|
||||||
query: ['technology news', 'tech', 'AI', 'innovation'],
|
query: ['technology news', 'tech', 'AI', 'innovation'],
|
||||||
links: ['scmp.com', 'xinhuanet.com', 'chinadaily.com.cn', 'reuters.com'],
|
links: ['scmp.com', 'xinhuanet.com', 'chinadaily.com.cn', 'reuters.com'],
|
||||||
@@ -137,8 +160,91 @@ const COUNTRY_TO_REGION: Record<string, Region> = {
|
|||||||
DK: 'eu',
|
DK: 'eu',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function fetchDooseekPosts(): Promise<
|
||||||
|
{ title: string; content: string; url: string; thumbnail: string }[]
|
||||||
|
> {
|
||||||
|
if (!GHOST_URL || !GHOST_CONTENT_API_KEY) {
|
||||||
|
throw new Error(
|
||||||
|
'Ghost не настроен. Укажите GHOST_URL и GHOST_CONTENT_API_KEY в .env',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const base = GHOST_URL.replace(/\/$/, '');
|
||||||
|
const apiUrl = `${base}/ghost/api/content/posts/?key=${GHOST_CONTENT_API_KEY}&limit=50&fields=title,excerpt,custom_excerpt,meta_description,html,feature_image,url&formats=html`;
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 15_000);
|
||||||
|
try {
|
||||||
|
const res = await fetch(apiUrl, {
|
||||||
|
signal: controller.signal,
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
});
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
if (!res.ok) {
|
||||||
|
if (res.status === 401) {
|
||||||
|
throw new Error(
|
||||||
|
'Неверный Ghost Content API Key. Получите ключ в Ghost Admin → Settings → Integrations → Add custom integration.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw new Error(`Ghost API: HTTP ${res.status}`);
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
const posts: GhostPost[] = data.posts ?? [];
|
||||||
|
return posts.map((p) => {
|
||||||
|
const excerpt =
|
||||||
|
p.custom_excerpt?.trim() ||
|
||||||
|
p.meta_description?.trim() ||
|
||||||
|
p.excerpt?.trim() ||
|
||||||
|
p.plaintext?.trim() ||
|
||||||
|
(p.html ? stripHtml(p.html) : '');
|
||||||
|
const content = excerpt
|
||||||
|
? excerpt.slice(0, 300) + (excerpt.length > 300 ? '…' : '')
|
||||||
|
: (p.title ? `${p.title}. Читать далее →` : 'Читать далее →');
|
||||||
|
return {
|
||||||
|
title: p.title || 'Без названия',
|
||||||
|
content,
|
||||||
|
url: p.url,
|
||||||
|
thumbnail: p.feature_image?.trim() || PLACEHOLDER_IMAGE,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const GET = async (req: Request) => {
|
export const GET = async (req: Request) => {
|
||||||
try {
|
try {
|
||||||
|
const params = new URL(req.url).searchParams;
|
||||||
|
|
||||||
|
const mode: 'normal' | 'preview' =
|
||||||
|
(params.get('mode') as 'normal' | 'preview') || 'normal';
|
||||||
|
const topic: Topic = (params.get('topic') as Topic) || 'tech';
|
||||||
|
|
||||||
|
if (topic === 'gooseek') {
|
||||||
|
try {
|
||||||
|
const blogs = await fetchDooseekPosts();
|
||||||
|
return Response.json({ blogs }, { status: 200 });
|
||||||
|
} catch (e) {
|
||||||
|
const msg =
|
||||||
|
e instanceof Error ? e.message : String(e);
|
||||||
|
const isConnect =
|
||||||
|
msg.includes('ECONNREFUSED') ||
|
||||||
|
msg.includes('fetch failed') ||
|
||||||
|
msg.includes('Failed to fetch') ||
|
||||||
|
msg.includes('AbortError');
|
||||||
|
return Response.json(
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
!GHOST_URL || !GHOST_CONTENT_API_KEY
|
||||||
|
? 'Ghost не настроен. Укажите GHOST_URL и GHOST_CONTENT_API_KEY в .env'
|
||||||
|
: isConnect
|
||||||
|
? 'Не удалось подключиться к Ghost. Проверьте GHOST_URL и доступность сайта.'
|
||||||
|
: `Ошибка загрузки постов: ${msg}`,
|
||||||
|
},
|
||||||
|
{ status: isConnect ? 503 : 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const searxngURL = getSearxngURL();
|
const searxngURL = getSearxngURL();
|
||||||
if (!searxngURL?.trim()) {
|
if (!searxngURL?.trim()) {
|
||||||
return Response.json(
|
return Response.json(
|
||||||
@@ -149,12 +255,6 @@ export const GET = async (req: Request) => {
|
|||||||
{ status: 503 },
|
{ status: 503 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = new URL(req.url).searchParams;
|
|
||||||
|
|
||||||
const mode: 'normal' | 'preview' =
|
|
||||||
(params.get('mode') as 'normal' | 'preview') || 'normal';
|
|
||||||
const topic: Topic = (params.get('topic') as Topic) || 'tech';
|
|
||||||
const regionParam = params.get('region') as Region | null;
|
const regionParam = params.get('region') as Region | null;
|
||||||
|
|
||||||
let region: Region = 'america';
|
let region: Region = 'america';
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ const Page = () => {
|
|||||||
throw new Error(data.message || 'Failed to load articles');
|
throw new Error(data.message || 'Failed to load articles');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (topic !== 'gooseek') {
|
||||||
data.blogs = data.blogs.filter((blog: Discover) => blog.thumbnail);
|
data.blogs = data.blogs.filter((blog: Discover) => blog.thumbnail);
|
||||||
|
}
|
||||||
|
|
||||||
setDiscover(data.blogs);
|
setDiscover(data.blogs);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
@@ -131,9 +133,7 @@ const Page = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeTopic === 'gooseek') {
|
if (activeTopic === 'gooseek') {
|
||||||
setLoading(false);
|
fetchArticles('gooseek');
|
||||||
setDiscover(null);
|
|
||||||
setSetupRequired(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchArticles(activeTopic);
|
fetchArticles(activeTopic);
|
||||||
@@ -170,26 +170,95 @@ const Page = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="flex flex-row items-center justify-center min-h-screen">
|
<div className="flex flex-col gap-4 pb-28 pt-5 lg:pb-8 w-full">
|
||||||
<svg
|
{/* Mobile: SmallNewsCard — rounded-3xl, aspect-video, p-4, h3 mb-2 + p */}
|
||||||
aria-hidden="true"
|
<div className="block lg:hidden">
|
||||||
className="w-8 h-8 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]"
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
viewBox="0 0 100 101"
|
{[1, 2, 3, 4].map((i) => (
|
||||||
fill="none"
|
<div
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
key={i}
|
||||||
|
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
|
||||||
>
|
>
|
||||||
<path
|
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
d="M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z"
|
<div className="p-4">
|
||||||
fill="currentColor"
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
/>
|
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
<path
|
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
d="M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z"
|
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
|
||||||
fill="currentFill"
|
</div>
|
||||||
/>
|
</div>
|
||||||
</svg>
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Desktop: точно как реальный layout — 1st Major isLeft=false (текст слева, картинка справа) */}
|
||||||
|
<div className="hidden lg:block space-y-0">
|
||||||
|
{/* 1st MajorNewsCard isLeft=FALSE: content LEFT, image RIGHT */}
|
||||||
|
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
|
||||||
|
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
|
||||||
|
<div className="h-8 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
|
||||||
|
{/* 3× SmallNewsCard */}
|
||||||
|
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4">
|
||||||
|
{[1, 2, 3].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
|
||||||
|
>
|
||||||
|
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="p-4">
|
||||||
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
|
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
|
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
|
||||||
|
{/* 2nd MajorNewsCard isLeft=TRUE: image LEFT, content RIGHT */}
|
||||||
|
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
|
||||||
|
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
|
||||||
|
<div className="h-8 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
|
||||||
|
{/* 3rd MajorNewsCard isLeft=FALSE: content LEFT, image RIGHT */}
|
||||||
|
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
|
||||||
|
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
|
||||||
|
<div className="h-8 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
|
||||||
|
{/* 3× SmallNewsCard */}
|
||||||
|
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4">
|
||||||
|
{[1, 2, 3].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
|
||||||
|
>
|
||||||
|
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="p-4">
|
||||||
|
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
|
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
|
||||||
|
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : activeTopic === 'gooseek' ? (
|
|
||||||
<div className="flex flex-col items-center justify-center min-h-[50vh] px-4" />
|
|
||||||
) : setupRequired ? (
|
) : setupRequired ? (
|
||||||
<div className="flex flex-col items-center justify-center min-h-[50vh] gap-4 px-4 text-center">
|
<div className="flex flex-col items-center justify-center min-h-[50vh] gap-4 px-4 text-center">
|
||||||
<div className="rounded-full p-4 bg-[#EA580C]/10 dark:bg-[#EA580C]/5">
|
<div className="rounded-full p-4 bg-[#EA580C]/10 dark:bg-[#EA580C]/5">
|
||||||
@@ -205,7 +274,7 @@ const Page = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : discover && discover.length > 0 ? (
|
||||||
<div className="flex flex-col gap-4 pb-28 pt-5 lg:pb-8 w-full">
|
<div className="flex flex-col gap-4 pb-28 pt-5 lg:pb-8 w-full">
|
||||||
<div className="block lg:hidden">
|
<div className="block lg:hidden">
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
@@ -342,7 +411,13 @@ const Page = () => {
|
|||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : discover && discover.length === 0 ? (
|
||||||
|
<div className="flex flex-col items-center justify-center min-h-[40vh] px-4 text-center">
|
||||||
|
<p className="text-black/60 dark:text-white/60 text-sm">
|
||||||
|
No articles found for this topic.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -80,6 +80,13 @@
|
|||||||
line-clamp: 2;
|
line-clamp: 2;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-fade {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
mask-image: linear-gradient(to right, black 75%, transparent 100%);
|
||||||
|
-webkit-mask-image: linear-gradient(to right, black 75%, transparent 100%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (-webkit-min-device-pixel-ratio: 0) {
|
@media screen and (-webkit-min-device-pixel-ratio: 0) {
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ export default function RootLayout({
|
|||||||
{setupComplete ? (
|
{setupComplete ? (
|
||||||
<ClientOnly
|
<ClientOnly
|
||||||
fallback={
|
fallback={
|
||||||
<div className="flex min-h-screen items-center justify-center bg-light-primary dark:bg-dark-primary">
|
<div className="min-h-screen bg-light-primary dark:bg-dark-primary" />
|
||||||
<div className="h-8 w-8 animate-spin rounded-full border-2 border-[#EA580C] border-t-transparent" />
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ChatProvider>
|
<ChatProvider>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: 'Library - GooSeek',
|
title: 'History - GooSeek',
|
||||||
};
|
};
|
||||||
|
|
||||||
const Layout = ({ children }: { children: React.ReactNode }) => {
|
const Layout = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
|||||||
@@ -2,9 +2,17 @@
|
|||||||
|
|
||||||
import DeleteChat from '@/components/DeleteChat';
|
import DeleteChat from '@/components/DeleteChat';
|
||||||
import { formatTimeDifference } from '@/lib/utils';
|
import { formatTimeDifference } from '@/lib/utils';
|
||||||
import { BookOpenText, ClockIcon, FileText, Globe2Icon } from 'lucide-react';
|
import {
|
||||||
|
ClockIcon,
|
||||||
|
FileText,
|
||||||
|
Globe2Icon,
|
||||||
|
MessagesSquare,
|
||||||
|
Search,
|
||||||
|
Filter,
|
||||||
|
} from 'lucide-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
import { useTranslation } from '@/lib/localization/context';
|
||||||
|
|
||||||
export interface Chat {
|
export interface Chat {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -14,9 +22,18 @@ export interface Chat {
|
|||||||
files: { fileId: string; name: string }[];
|
files: { fileId: string; name: string }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SOURCE_KEYS = ['web', 'academic', 'discussions'] as const;
|
||||||
|
type SourceKey = (typeof SOURCE_KEYS)[number];
|
||||||
|
|
||||||
|
type FilesFilter = 'all' | 'with' | 'without';
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const [chats, setChats] = useState<Chat[]>([]);
|
const [chats, setChats] = useState<Chat[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
|
const [sourceFilter, setSourceFilter] = useState<SourceKey | 'all'>('all');
|
||||||
|
const [filesFilter, setFilesFilter] = useState<FilesFilter>('all');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchChats = async () => {
|
const fetchChats = async () => {
|
||||||
@@ -30,23 +47,41 @@ const Page = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
setChats(data.chats ?? []);
|
||||||
setChats(data.chats);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchChats();
|
fetchChats();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const filteredChats = useMemo(() => {
|
||||||
|
return chats.filter((chat) => {
|
||||||
|
const matchesSearch =
|
||||||
|
!searchQuery.trim() ||
|
||||||
|
chat.title.toLowerCase().includes(searchQuery.trim().toLowerCase());
|
||||||
|
|
||||||
|
const matchesSource =
|
||||||
|
sourceFilter === 'all' ||
|
||||||
|
chat.sources.some((s) => s === sourceFilter);
|
||||||
|
|
||||||
|
const matchesFiles =
|
||||||
|
filesFilter === 'all' ||
|
||||||
|
(filesFilter === 'with' && chat.files.length > 0) ||
|
||||||
|
(filesFilter === 'without' && chat.files.length === 0);
|
||||||
|
|
||||||
|
return matchesSearch && matchesSource && matchesFiles;
|
||||||
|
});
|
||||||
|
}, [chats, searchQuery, sourceFilter, filesFilter]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex flex-col pt-10 border-b border-light-200/20 dark:border-dark-200/20 pb-6 px-2">
|
<div className="flex flex-col pt-10 border-b border-light-200/20 dark:border-dark-200/20 pb-6 px-2">
|
||||||
<div className="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-3">
|
<div className="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-3">
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<BookOpenText size={45} className="mb-2.5" />
|
<MessagesSquare size={45} className="mb-2.5" />
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<h1 className="text-5xl font-normal p-2 pb-0">
|
<h1 className="text-5xl font-normal p-2 pb-0">
|
||||||
Library
|
{t('nav.messageHistory')}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="px-2 text-sm text-black/60 dark:text-white/60 text-center lg:text-left">
|
<div className="px-2 text-sm text-black/60 dark:text-white/60 text-center lg:text-left">
|
||||||
Past chats, sources, and uploads.
|
Past chats, sources, and uploads.
|
||||||
@@ -56,38 +91,78 @@ const Page = () => {
|
|||||||
|
|
||||||
<div className="flex items-center justify-center lg:justify-end gap-2 text-xs text-black/60 dark:text-white/60">
|
<div className="flex items-center justify-center lg:justify-end gap-2 text-xs text-black/60 dark:text-white/60">
|
||||||
<span className="inline-flex items-center gap-1 rounded-full border border-black/20 dark:border-white/20 px-2 py-0.5">
|
<span className="inline-flex items-center gap-1 rounded-full border border-black/20 dark:border-white/20 px-2 py-0.5">
|
||||||
<BookOpenText size={14} />
|
<MessagesSquare size={14} />
|
||||||
{loading
|
{loading && chats.length === 0
|
||||||
? 'Loading…'
|
? '—'
|
||||||
: `${chats.length} ${chats.length === 1 ? 'chat' : 'chats'}`}
|
: `${chats.length} ${chats.length === 1 ? 'chat' : 'chats'}`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading ? (
|
{(chats.length > 0 || loading) && (
|
||||||
<div className="flex flex-row items-center justify-center min-h-[60vh]">
|
<div className="sticky top-0 z-10 flex flex-row flex-wrap items-center gap-2 pt-4 pb-2 px-2 bg-light-primary dark:bg-dark-primary border-b border-light-200/20 dark:border-dark-200/20">
|
||||||
<svg
|
<div className="relative flex-1 min-w-[140px]">
|
||||||
aria-hidden="true"
|
<Search
|
||||||
className="w-8 h-8 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]"
|
size={18}
|
||||||
viewBox="0 0 100 101"
|
className="absolute left-3 top-1/2 -translate-y-1/2 text-black/40 dark:text-white/40"
|
||||||
fill="none"
|
/>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<input
|
||||||
|
type="text"
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
placeholder={t('app.searchPlaceholder')}
|
||||||
|
className="w-full pl-10 pr-4 py-2.5 text-sm bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 rounded-xl placeholder:text-black/40 dark:placeholder:text-white/40 text-black dark:text-white focus:outline-none focus:border-light-300 dark:focus:border-dark-300 transition-colors"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap items-center gap-2 shrink-0">
|
||||||
|
<Filter size={16} className="text-black/50 dark:text-white/50" />
|
||||||
|
<select
|
||||||
|
value={sourceFilter}
|
||||||
|
onChange={(e) =>
|
||||||
|
setSourceFilter(e.target.value as SourceKey | 'all')
|
||||||
|
}
|
||||||
|
className="text-xs py-1.5 px-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-[#EA580C]/30"
|
||||||
>
|
>
|
||||||
<path
|
<option value="all">{t('library.filterSourceAll')}</option>
|
||||||
d="M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z"
|
<option value="web">{t('library.filterSourceWeb')}</option>
|
||||||
fill="currentColor"
|
<option value="academic">{t('library.filterSourceAcademic')}</option>
|
||||||
/>
|
<option value="discussions">{t('library.filterSourceSocial')}</option>
|
||||||
<path
|
</select>
|
||||||
d="M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z"
|
<select
|
||||||
fill="currentFill"
|
value={filesFilter}
|
||||||
/>
|
onChange={(e) => setFilesFilter(e.target.value as FilesFilter)}
|
||||||
</svg>
|
className="text-xs py-1.5 px-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-[#EA580C]/30"
|
||||||
|
>
|
||||||
|
<option value="all">{t('library.filterFilesAll')}</option>
|
||||||
|
<option value="with">{t('library.filterFilesWith')}</option>
|
||||||
|
<option value="without">{t('library.filterFilesWithout')}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{loading && chats.length === 0 ? (
|
||||||
|
<div className="pt-6 pb-28 px-2">
|
||||||
|
<div className="rounded-2xl border border-light-200 dark:border-dark-200 overflow-hidden bg-light-primary dark:bg-dark-primary">
|
||||||
|
{[1, 2, 3, 4].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex flex-col gap-2 p-4 border-b border-light-200 dark:border-dark-200 last:border-b-0"
|
||||||
|
>
|
||||||
|
<div className="h-5 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="flex gap-2 mt-2">
|
||||||
|
<div className="h-4 w-16 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-4 w-24 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : chats.length === 0 ? (
|
) : chats.length === 0 ? (
|
||||||
<div className="flex flex-col items-center justify-center min-h-[70vh] px-2 text-center">
|
<div className="flex flex-col items-center justify-center min-h-[70vh] px-2 text-center">
|
||||||
<div className="flex items-center justify-center w-12 h-12 rounded-2xl border border-light-200 dark:border-dark-200 bg-light-secondary dark:bg-dark-secondary">
|
<div className="flex items-center justify-center w-12 h-12 rounded-2xl border border-light-200 dark:border-dark-200 bg-light-secondary dark:bg-dark-secondary">
|
||||||
<BookOpenText className="text-black/70 dark:text-white/70" />
|
<MessagesSquare className="text-black/70 dark:text-white/70" />
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-2 text-black/70 dark:text-white/70 text-sm">
|
<p className="mt-2 text-black/70 dark:text-white/70 text-sm">
|
||||||
No chats found.
|
No chats found.
|
||||||
@@ -99,10 +174,27 @@ const Page = () => {
|
|||||||
to see it listed here.
|
to see it listed here.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
) : filteredChats.length === 0 ? (
|
||||||
|
<div className="flex flex-col items-center justify-center min-h-[50vh] px-2 text-center">
|
||||||
|
<p className="text-black/70 dark:text-white/70 text-sm">
|
||||||
|
{t('library.noResults')}
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
setSearchQuery('');
|
||||||
|
setSourceFilter('all');
|
||||||
|
setFilesFilter('all');
|
||||||
|
}}
|
||||||
|
className="mt-2 text-sm text-[#EA580C] hover:underline"
|
||||||
|
>
|
||||||
|
{t('library.clearFilters')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="pt-6 pb-28 px-2">
|
<div className="pt-6 pb-28 px-2">
|
||||||
<div className="rounded-2xl border border-light-200 dark:border-dark-200 overflow-hidden bg-light-primary dark:bg-dark-primary">
|
<div className="rounded-2xl border border-light-200 dark:border-dark-200 overflow-hidden bg-light-primary dark:bg-dark-primary">
|
||||||
{chats.map((chat, index) => {
|
{filteredChats.map((chat, index) => {
|
||||||
const sourcesLabel =
|
const sourcesLabel =
|
||||||
chat.sources.length === 0
|
chat.sources.length === 0
|
||||||
? null
|
? null
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import NextError from 'next/error';
|
|||||||
import { useChat } from '@/lib/hooks/useChat';
|
import { useChat } from '@/lib/hooks/useChat';
|
||||||
import SettingsButtonMobile from './Settings/SettingsButtonMobile';
|
import SettingsButtonMobile from './Settings/SettingsButtonMobile';
|
||||||
import { Block } from '@/lib/types';
|
import { Block } from '@/lib/types';
|
||||||
import Loader from './ui/Loader';
|
|
||||||
|
|
||||||
export interface BaseMessage {
|
export interface BaseMessage {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
@@ -69,8 +68,8 @@ const ChatWindow = () => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center justify-center min-h-screen w-full">
|
<div className="min-h-screen w-full">
|
||||||
<Loader />
|
<EmptyChat />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,11 +18,7 @@ const MajorNewsCard = ({
|
|||||||
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
|
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
|
||||||
<img
|
<img
|
||||||
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
|
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
|
||||||
src={
|
src={item.thumbnail}
|
||||||
new URL(item.thumbnail).origin +
|
|
||||||
new URL(item.thumbnail).pathname +
|
|
||||||
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
|
|
||||||
}
|
|
||||||
alt={item.title}
|
alt={item.title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,11 +48,7 @@ const MajorNewsCard = ({
|
|||||||
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
|
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
|
||||||
<img
|
<img
|
||||||
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
|
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
|
||||||
src={
|
src={item.thumbnail}
|
||||||
new URL(item.thumbnail).origin +
|
|
||||||
new URL(item.thumbnail).pathname +
|
|
||||||
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
|
|
||||||
}
|
|
||||||
alt={item.title}
|
alt={item.title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ const SmallNewsCard = ({ item }: { item: Discover }) => (
|
|||||||
<div className="relative aspect-video overflow-hidden">
|
<div className="relative aspect-video overflow-hidden">
|
||||||
<img
|
<img
|
||||||
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-300"
|
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-300"
|
||||||
src={
|
src={item.thumbnail}
|
||||||
new URL(item.thumbnail).origin +
|
|
||||||
new URL(item.thumbnail).pathname +
|
|
||||||
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
|
|
||||||
}
|
|
||||||
alt={item.title}
|
alt={item.title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const EmptyChat = () => {
|
|||||||
<SettingsButtonMobile />
|
<SettingsButtonMobile />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-center justify-center min-h-screen max-w-screen-sm mx-auto p-2 space-y-4">
|
<div className="flex flex-col items-center justify-center min-h-screen max-w-screen-sm mx-auto p-2 space-y-4">
|
||||||
<div className="flex flex-col items-center justify-center w-full space-y-8">
|
<div className="flex flex-col items-center justify-center w-full space-y-6">
|
||||||
<div className="flex flex-row items-center justify-center -mt-8 mb-2">
|
<div className="flex flex-row items-center justify-center -mt-8 mb-2">
|
||||||
<span className="text-4xl sm:text-5xl font-semibold tracking-tight select-none">
|
<span className="text-4xl sm:text-5xl font-semibold tracking-tight select-none">
|
||||||
{['G', 'o', 'o', 'S', 'e', 'e', 'k'].map((letter, i) => (
|
{['G', 'o', 'o', 'S', 'e', 'e', 'k'].map((letter, i) => (
|
||||||
@@ -54,7 +54,7 @@ const EmptyChat = () => {
|
|||||||
key={i}
|
key={i}
|
||||||
className="inline-block"
|
className="inline-block"
|
||||||
style={{
|
style={{
|
||||||
color: ['#6B7280', '#EA580C', '#9CA3AF', '#4B5563', '#EA580C', '#A8A29E', '#57534E'][i],
|
color: ['#4285F4', '#FC3F1D', '#34A853', '#FBBC05', '#FC3F1D', '#4285F4', '#34A853'][i],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{letter}
|
{letter}
|
||||||
@@ -65,22 +65,22 @@ const EmptyChat = () => {
|
|||||||
<h2 className="text-black/70 dark:text-white/70 text-3xl font-medium">
|
<h2 className="text-black/70 dark:text-white/70 text-3xl font-medium">
|
||||||
{t('empty.subtitle')}
|
{t('empty.subtitle')}
|
||||||
</h2>
|
</h2>
|
||||||
<EmptyChatMessageInput />
|
|
||||||
</div>
|
|
||||||
{(showWeather || showNews) && (
|
{(showWeather || showNews) && (
|
||||||
<div className="flex flex-col w-full gap-4 mt-2 sm:flex-row sm:justify-center">
|
<div className="flex flex-row flex-wrap w-full gap-2 sm:gap-3 justify-center items-stretch">
|
||||||
{showWeather && (
|
{showWeather && (
|
||||||
<div className="flex-1 w-full">
|
<div className="flex-1 min-w-[120px] shrink-0">
|
||||||
<WeatherWidget />
|
<WeatherWidget />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{showNews && (
|
{showNews && (
|
||||||
<div className="flex-1 w-full">
|
<div className="flex-1 min-w-[120px] shrink-0">
|
||||||
<NewsArticleWidget />
|
<NewsArticleWidget />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<EmptyChatMessageInput />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const Layout = ({ children }: { children: React.ReactNode }) => {
|
const Layout = ({ children }: { children: React.ReactNode }) => {
|
||||||
return (
|
return (
|
||||||
<main className="lg:pl-20 bg-light-primary dark:bg-dark-primary min-h-screen">
|
<main className="lg:pl-16 bg-light-primary dark:bg-dark-primary min-h-screen">
|
||||||
<div className="max-w-screen-lg lg:mx-auto mx-4">{children}</div>
|
<div className="max-w-screen-lg lg:mx-auto mx-4">{children}</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ const MessageBox = ({
|
|||||||
(b) => b.type === 'research' && b.data.subSteps.length > 0,
|
(b) => b.type === 'research' && b.data.subSteps.length > 0,
|
||||||
) && (
|
) && (
|
||||||
<div className="flex items-center gap-2 p-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200">
|
<div className="flex items-center gap-2 p-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200">
|
||||||
<Disc3 className="w-4 h-4 text-black dark:text-white animate-spin" />
|
<Disc3 className="w-4 h-4 text-black dark:text-white" />
|
||||||
<span className="text-sm text-black/70 dark:text-white/70">
|
<span className="text-sm text-black/70 dark:text-white/70">
|
||||||
{t('chat.brainstorming')}
|
{t('chat.brainstorming')}
|
||||||
</span>
|
</span>
|
||||||
@@ -191,13 +191,7 @@ const MessageBox = ({
|
|||||||
<div className="flex flex-col space-y-2">
|
<div className="flex flex-col space-y-2">
|
||||||
{sources.length > 0 && (
|
{sources.length > 0 && (
|
||||||
<div className="flex flex-row items-center space-x-2">
|
<div className="flex flex-row items-center space-x-2">
|
||||||
<Disc3
|
<Disc3 className="text-black dark:text-white" size={20} />
|
||||||
className={cn(
|
|
||||||
'text-black dark:text-white',
|
|
||||||
isLast && loading ? 'animate-spin' : 'animate-none',
|
|
||||||
)}
|
|
||||||
size={20}
|
|
||||||
/>
|
|
||||||
<h3 className="text-black dark:text-white font-medium text-xl">
|
<h3 className="text-black dark:text-white font-medium text-xl">
|
||||||
{t('chat.answer')}
|
{t('chat.answer')}
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
CopyPlus,
|
CopyPlus,
|
||||||
File,
|
File,
|
||||||
Link,
|
Link,
|
||||||
LoaderCircle,
|
|
||||||
Paperclip,
|
Paperclip,
|
||||||
Plus,
|
Plus,
|
||||||
Trash,
|
Trash,
|
||||||
@@ -56,8 +55,8 @@ const Attach = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return loading ? (
|
return loading ? (
|
||||||
<div className="active:border-none hover:bg-light-200 hover:dark:bg-dark-200 p-2 rounded-lg focus:outline-none text-black/50 dark:text-white/50 transition duration-200">
|
<div className="active:border-none p-2 rounded-lg focus:outline-none text-black/50 dark:text-white/50 transition duration-200 text-xs">
|
||||||
<LoaderCircle size={16} className="text-[#EA580C] animate-spin" />
|
<span className="text-[#EA580C]">Uploading…</span>
|
||||||
</div>
|
</div>
|
||||||
) : files.length > 0 ? (
|
) : files.length > 0 ? (
|
||||||
<Popover className="relative w-full max-w-[15rem] md:max-w-md lg:max-w-lg">
|
<Popover className="relative w-full max-w-[15rem] md:max-w-md lg:max-w-lg">
|
||||||
@@ -72,7 +71,7 @@ const Attach = () => {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{open && (
|
{open && (
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
className="absolute z-10 w-64 md:w-[350px] right-0"
|
className="absolute z-10 w-64 md:w-[350px] right-0 bottom-full mb-2"
|
||||||
static
|
static
|
||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
@@ -80,7 +79,7 @@ const Attach = () => {
|
|||||||
animate={{ opacity: 1, scale: 1 }}
|
animate={{ opacity: 1, scale: 1 }}
|
||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
transition={{ duration: 0.1, ease: 'easeOut' }}
|
transition={{ duration: 0.1, ease: 'easeOut' }}
|
||||||
className="origin-top-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
|
className="origin-bottom-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center justify-between px-3 py-2">
|
<div className="flex flex-row items-center justify-between px-3 py-2">
|
||||||
<h4 className="text-black/70 dark:text-white/70 text-sm">
|
<h4 className="text-black/70 dark:text-white/70 text-sm">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
PopoverPanel,
|
PopoverPanel,
|
||||||
Transition,
|
Transition,
|
||||||
} from '@headlessui/react';
|
} from '@headlessui/react';
|
||||||
import { File, LoaderCircle, Paperclip, Plus, Trash } from 'lucide-react';
|
import { File, Paperclip, Plus, Trash } from 'lucide-react';
|
||||||
import { Fragment, useRef, useState } from 'react';
|
import { Fragment, useRef, useState } from 'react';
|
||||||
import { useChat } from '@/lib/hooks/useChat';
|
import { useChat } from '@/lib/hooks/useChat';
|
||||||
import { AnimatePresence } from 'motion/react';
|
import { AnimatePresence } from 'motion/react';
|
||||||
@@ -47,8 +47,8 @@ const AttachSmall = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return loading ? (
|
return loading ? (
|
||||||
<div className="flex flex-row items-center justify-between space-x-1 p-1 ">
|
<div className="flex flex-row items-center justify-between space-x-1 p-1 text-xs text-[#EA580C]">
|
||||||
<LoaderCircle size={20} className="text-[#EA580C] animate-spin" />
|
Uploading…
|
||||||
</div>
|
</div>
|
||||||
) : files.length > 0 ? (
|
) : files.length > 0 ? (
|
||||||
<Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg">
|
<Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg">
|
||||||
@@ -63,7 +63,7 @@ const AttachSmall = () => {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{open && (
|
{open && (
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
className="absolute z-10 w-64 md:w-[350px] bottom-14"
|
className="absolute z-10 w-64 md:w-[350px] right-0 bottom-full mb-2"
|
||||||
static
|
static
|
||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
@@ -71,7 +71,7 @@ const AttachSmall = () => {
|
|||||||
animate={{ opacity: 1, scale: 1 }}
|
animate={{ opacity: 1, scale: 1 }}
|
||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
transition={{ duration: 0.1, ease: 'easeOut' }}
|
transition={{ duration: 0.1, ease: 'easeOut' }}
|
||||||
className="origin-bottom-left bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
|
className="origin-bottom-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center justify-between px-3 py-2">
|
<div className="flex flex-row items-center justify-between px-3 py-2">
|
||||||
<h4 className="text-black/70 dark:text-white/70 font-medium text-sm">
|
<h4 className="text-black/70 dark:text-white/70 font-medium text-sm">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Cpu, Loader2, Search } from 'lucide-react';
|
import { Cpu, Search } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react';
|
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
@@ -90,7 +90,7 @@ const ModelSelector = () => {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{open && (
|
{open && (
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
className="absolute z-10 w-[230px] sm:w-[270px] md:w-[300px] right-0"
|
className="absolute z-10 w-[230px] sm:w-[270px] md:w-[300px] right-0 bottom-full mb-2"
|
||||||
static
|
static
|
||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
@@ -98,7 +98,7 @@ const ModelSelector = () => {
|
|||||||
animate={{ opacity: 1, scale: 1 }}
|
animate={{ opacity: 1, scale: 1 }}
|
||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
transition={{ duration: 0.1, ease: 'easeOut' }}
|
transition={{ duration: 0.1, ease: 'easeOut' }}
|
||||||
className="origin-top-right bg-light-primary dark:bg-dark-primary max-h-[300px] sm:max-w-none border rounded-lg border-light-200 dark:border-dark-200 w-full flex flex-col shadow-lg overflow-hidden"
|
className="origin-bottom-right bg-light-primary dark:bg-dark-primary max-h-[300px] sm:max-w-none border rounded-lg border-light-200 dark:border-dark-200 w-full flex flex-col shadow-lg overflow-hidden"
|
||||||
>
|
>
|
||||||
<div className="p-2 border-b border-light-200 dark:border-dark-200">
|
<div className="p-2 border-b border-light-200 dark:border-dark-200">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
@@ -118,11 +118,13 @@ const ModelSelector = () => {
|
|||||||
|
|
||||||
<div className="max-h-[320px] overflow-y-auto">
|
<div className="max-h-[320px] overflow-y-auto">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex items-center justify-center py-16">
|
<div className="flex flex-col gap-2 py-16 px-4">
|
||||||
<Loader2
|
{[1, 2, 3, 4].map((i) => (
|
||||||
className="animate-spin text-black/40 dark:text-white/40"
|
<div
|
||||||
size={24}
|
key={i}
|
||||||
|
className="h-10 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse"
|
||||||
/>
|
/>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : filteredProviders.length === 0 ? (
|
) : filteredProviders.length === 0 ? (
|
||||||
<div className="text-center py-16 px-4 text-black/60 dark:text-white/60 text-sm">
|
<div className="text-center py-16 px-4 text-black/60 dark:text-white/60 text-sm">
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ const Optimization = () => {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{open && (
|
{open && (
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
className="absolute z-10 w-64 md:w-[250px] left-0"
|
className="absolute z-10 w-64 md:w-[250px] left-0 bottom-full mb-2"
|
||||||
static
|
static
|
||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
@@ -72,7 +72,7 @@ const Optimization = () => {
|
|||||||
animate={{ opacity: 1, scale: 1 }}
|
animate={{ opacity: 1, scale: 1 }}
|
||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
transition={{ duration: 0.1, ease: 'easeOut' }}
|
transition={{ duration: 0.1, ease: 'easeOut' }}
|
||||||
className="origin-top-left flex flex-col space-y-2 bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-2 max-h-[200px] md:max-h-none overflow-y-auto"
|
className="origin-bottom-left flex flex-col space-y-2 bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-2 max-h-[200px] md:max-h-none overflow-y-auto"
|
||||||
>
|
>
|
||||||
{OptimizationModes.map((mode, i) => (
|
{OptimizationModes.map((mode, i) => (
|
||||||
<PopoverButton
|
<PopoverButton
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ const Sources = () => {
|
|||||||
{open && (
|
{open && (
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
static
|
static
|
||||||
className="absolute z-10 w-64 md:w-[225px] right-0"
|
className="absolute z-10 w-64 md:w-[225px] right-0 bottom-full mb-2"
|
||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, scale: 0.9 }}
|
initial={{ opacity: 0, scale: 0.9 }}
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
animate={{ opacity: 1, scale: 1 }}
|
||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
transition={{ duration: 0.1, ease: 'easeOut' }}
|
transition={{ duration: 0.1, ease: 'easeOut' }}
|
||||||
className="origin-top-right flex flex-col bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-1 max-h-[200px] md:max-h-none overflow-y-auto shadow-lg"
|
className="origin-bottom-right flex flex-col bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-1 max-h-[200px] md:max-h-none overflow-y-auto shadow-lg"
|
||||||
>
|
>
|
||||||
{sourcesList.map((source, i) => (
|
{sourcesList.map((source, i) => (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ const NewsArticleWidget = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-stretch w-full h-24 min-h-[96px] max-h-[96px] p-0 overflow-hidden">
|
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-stretch w-full h-20 min-h-[80px] max-h-[80px] p-0 overflow-hidden">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="animate-pulse flex flex-row items-stretch w-full h-full">
|
<div className="animate-pulse flex flex-row items-stretch w-full h-full">
|
||||||
<div className="w-24 min-w-24 max-w-24 h-full bg-light-200 dark:bg-dark-200" />
|
<div className="w-20 min-w-20 max-w-20 h-full bg-light-200 dark:bg-dark-200" />
|
||||||
<div className="flex flex-col justify-center flex-1 px-3 py-2 gap-2">
|
<div className="flex flex-col justify-center flex-1 px-2.5 py-1.5 gap-1">
|
||||||
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200" />
|
<div className="h-3 w-full max-w-[80%] rounded bg-light-200 dark:bg-dark-200" />
|
||||||
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200" />
|
<div className="h-3 w-16 rounded bg-light-200 dark:bg-dark-200" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : error ? (
|
) : error ? (
|
||||||
@@ -43,7 +43,7 @@ const NewsArticleWidget = () => {
|
|||||||
href={`/?q=${encodeURIComponent(`Summary: ${article.url}`)}&title=${encodeURIComponent(article.title)}`}
|
href={`/?q=${encodeURIComponent(`Summary: ${article.url}`)}&title=${encodeURIComponent(article.title)}`}
|
||||||
className="flex flex-row items-stretch w-full h-full relative overflow-hidden group"
|
className="flex flex-row items-stretch w-full h-full relative overflow-hidden group"
|
||||||
>
|
>
|
||||||
<div className="relative w-24 min-w-24 max-w-24 h-full overflow-hidden">
|
<div className="relative w-20 min-w-20 max-w-20 h-full overflow-hidden">
|
||||||
<img
|
<img
|
||||||
className="object-cover w-full h-full bg-light-200 dark:bg-dark-200 group-hover:scale-110 transition-transform duration-300"
|
className="object-cover w-full h-full bg-light-200 dark:bg-dark-200 group-hover:scale-110 transition-transform duration-300"
|
||||||
src={
|
src={
|
||||||
@@ -54,11 +54,11 @@ const NewsArticleWidget = () => {
|
|||||||
alt={article.title}
|
alt={article.title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col justify-center flex-1 px-3 py-2">
|
<div className="flex flex-col justify-center flex-1 px-2.5 py-1.5 min-w-0">
|
||||||
<div className="font-semibold text-xs text-black dark:text-white leading-tight line-clamp-2 mb-1">
|
<div className="font-semibold text-[11px] text-black dark:text-white leading-tight line-clamp-2 mb-0.5">
|
||||||
{article.title}
|
{article.title}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-black/60 dark:text-white/60 text-[10px] leading-relaxed line-clamp-2">
|
<p className="text-black/60 dark:text-white/60 text-[9px] leading-relaxed line-clamp-2">
|
||||||
{article.content}
|
{article.content}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Dialog, DialogPanel } from '@headlessui/react';
|
import { Dialog, DialogPanel } from '@headlessui/react';
|
||||||
import { Loader2, Plus } from 'lucide-react';
|
import { Plus } from 'lucide-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { ConfigModelProvider } from '@/lib/config/types';
|
import { ConfigModelProvider } from '@/lib/config/types';
|
||||||
@@ -142,11 +142,7 @@ const AddModel = ({
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? 'Adding…' : 'Add Model'}
|
||||||
<Loader2 className="animate-spin" size={16} />
|
|
||||||
) : (
|
|
||||||
'Add Model'
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
DialogPanel,
|
DialogPanel,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@headlessui/react';
|
} from '@headlessui/react';
|
||||||
import { Loader2, Plus } from 'lucide-react';
|
import { Plus } from 'lucide-react';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import {
|
import {
|
||||||
@@ -196,11 +196,7 @@ const AddProvider = ({
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? 'Adding…' : 'Add Connection'}
|
||||||
<Loader2 className="animate-spin" size={16} />
|
|
||||||
) : (
|
|
||||||
'Add Connection'
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Dialog, DialogPanel } from '@headlessui/react';
|
import { Dialog, DialogPanel } from '@headlessui/react';
|
||||||
import { Loader2, Trash2 } from 'lucide-react';
|
import { Trash2 } from 'lucide-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { ConfigModelProvider } from '@/lib/config/types';
|
import { ConfigModelProvider } from '@/lib/config/types';
|
||||||
@@ -100,11 +100,7 @@ const DeleteProvider = ({
|
|||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="px-4 py-2 rounded-lg text-sm bg-red-500 text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
className="px-4 py-2 rounded-lg text-sm bg-red-500 text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? 'Deleting…' : 'Delete'}
|
||||||
<Loader2 className="animate-spin" size={16} />
|
|
||||||
) : (
|
|
||||||
'Delete'
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</DialogPanel>
|
</DialogPanel>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Dialog, DialogPanel } from '@headlessui/react';
|
import { Dialog, DialogPanel } from '@headlessui/react';
|
||||||
import { Loader2, Pencil } from 'lucide-react';
|
import { Pencil } from 'lucide-react';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import {
|
import {
|
||||||
@@ -168,11 +168,7 @@ const UpdateProvider = ({
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? 'Updating…' : 'Update Connection'}
|
||||||
<Loader2 className="animate-spin" size={16} />
|
|
||||||
) : (
|
|
||||||
'Update Connection'
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import Preferences from './Sections/Preferences';
|
|||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import Loader from '../ui/Loader';
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import Models from './Sections/Models/Section';
|
import Models from './Sections/Models/Section';
|
||||||
import SearchSection from './Sections/Search';
|
import SearchSection from './Sections/Search';
|
||||||
@@ -121,8 +120,22 @@ const SettingsDialogue = ({
|
|||||||
>
|
>
|
||||||
<DialogPanel className="space-y-4 border border-light-200 dark:border-dark-200 bg-light-primary dark:bg-dark-primary backdrop-blur-lg rounded-xl h-[calc(100vh-2%)] w-[calc(100vw-2%)] md:h-[calc(100vh-7%)] md:w-[calc(100vw-7%)] lg:h-[calc(100vh-20%)] lg:w-[calc(100vw-30%)] overflow-hidden flex flex-col">
|
<DialogPanel className="space-y-4 border border-light-200 dark:border-dark-200 bg-light-primary dark:bg-dark-primary backdrop-blur-lg rounded-xl h-[calc(100vh-2%)] w-[calc(100vw-2%)] md:h-[calc(100vh-7%)] md:w-[calc(100vw-7%)] lg:h-[calc(100vh-20%)] lg:w-[calc(100vw-30%)] overflow-hidden flex flex-col">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex items-center justify-center h-full w-full">
|
<div className="flex flex-col gap-3 p-6 h-full w-full overflow-y-auto">
|
||||||
<Loader />
|
<div className="h-8 w-48 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="flex gap-4 mt-4">
|
||||||
|
<div className="w-48 space-y-2">
|
||||||
|
{[1, 2, 3, 4].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="h-10 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex-1 space-y-4">
|
||||||
|
<div className="h-24 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
<div className="h-32 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-1 inset-0 h-full overflow-hidden">
|
<div className="flex flex-1 inset-0 h-full overflow-hidden">
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { useState } from 'react';
|
|||||||
import Select from '../ui/Select';
|
import Select from '../ui/Select';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { Loader2 } from 'lucide-react';
|
|
||||||
import { Switch } from '@headlessui/react';
|
import { Switch } from '@headlessui/react';
|
||||||
|
|
||||||
const emitClientConfigChanged = () => {
|
const emitClientConfigChanged = () => {
|
||||||
@@ -160,11 +159,6 @@ const SettingsInput = ({
|
|||||||
type="text"
|
type="text"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
{loading && (
|
|
||||||
<span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-black/40 dark:text-white/40">
|
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -237,11 +231,6 @@ const SettingsTextarea = ({
|
|||||||
rows={4}
|
rows={4}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
{loading && (
|
|
||||||
<span className="pointer-events-none absolute right-3 translate-y-3 text-black/40 dark:text-white/40">
|
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -2,110 +2,246 @@
|
|||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import {
|
import {
|
||||||
BookOpenText,
|
MessagesSquare,
|
||||||
Home,
|
|
||||||
Search,
|
|
||||||
SquarePen,
|
|
||||||
Settings,
|
|
||||||
Plus,
|
Plus,
|
||||||
ArrowLeft,
|
Search,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useSelectedLayoutSegments } from 'next/navigation';
|
import { useSelectedLayoutSegments } from 'next/navigation';
|
||||||
import React, { useState, type ReactNode } from 'react';
|
import React, { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
import { useTranslation } from '@/lib/localization/context';
|
import { useTranslation } from '@/lib/localization/context';
|
||||||
import Layout from './Layout';
|
import Layout from './Layout';
|
||||||
import {
|
|
||||||
Description,
|
|
||||||
Dialog,
|
|
||||||
DialogPanel,
|
|
||||||
DialogTitle,
|
|
||||||
} from '@headlessui/react';
|
|
||||||
import SettingsButton from './Settings/SettingsButton';
|
import SettingsButton from './Settings/SettingsButton';
|
||||||
|
|
||||||
|
interface ChatItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
const VerticalIconContainer = ({ children }: { children: ReactNode }) => {
|
const VerticalIconContainer = ({ children }: { children: ReactNode }) => {
|
||||||
return <div className="flex flex-col items-center w-full">{children}</div>;
|
return <div className="flex flex-col items-center w-full">{children}</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface HistorySubmenuProps {
|
||||||
|
onMouseEnter: () => void;
|
||||||
|
onMouseLeave: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HistorySubmenu = ({ onMouseEnter, onMouseLeave }: HistorySubmenuProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [chats, setChats] = useState<ChatItem[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchChats = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/chats');
|
||||||
|
const data = await res.json();
|
||||||
|
setChats((data.chats ?? []).reverse());
|
||||||
|
} catch {
|
||||||
|
setChats([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchChats();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="min-w-[180px] w-56 h-screen overflow-y-auto bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 shadow-xl py-2 z-[9999]"
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<div className="px-4 py-3 text-sm text-black/60 dark:text-white/60">
|
||||||
|
{t('common.loading')}
|
||||||
|
</div>
|
||||||
|
) : chats.length === 0 ? (
|
||||||
|
<div className="px-4 py-3 text-sm text-black/60 dark:text-white/60">
|
||||||
|
—
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<nav className="flex flex-col">
|
||||||
|
{chats.map((chat) => (
|
||||||
|
<Link
|
||||||
|
key={chat.id}
|
||||||
|
href={`/c/${chat.id}`}
|
||||||
|
className="px-4 py-2.5 text-sm text-black dark:text-white hover:bg-light-200 dark:hover:bg-dark-200 text-fade block transition-colors"
|
||||||
|
title={chat.title}
|
||||||
|
>
|
||||||
|
{chat.title}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
||||||
const segments = useSelectedLayoutSegments();
|
const segments = useSelectedLayoutSegments();
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(true);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [historyOpen, setHistoryOpen] = useState(false);
|
||||||
|
const historyRef = useRef<HTMLDivElement>(null);
|
||||||
|
const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
const [submenuStyle, setSubmenuStyle] = useState({ top: 0, left: 0 });
|
||||||
|
|
||||||
const navLinks = [
|
const discoverLink = {
|
||||||
{
|
|
||||||
icon: Home,
|
|
||||||
href: '/',
|
|
||||||
active: segments.length === 0 || segments.includes('c'),
|
|
||||||
label: t('nav.home'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Search,
|
icon: Search,
|
||||||
href: '/discover',
|
href: '/discover',
|
||||||
active: segments.includes('discover'),
|
active: segments.includes('discover'),
|
||||||
label: t('nav.discover'),
|
label: t('nav.discover'),
|
||||||
},
|
};
|
||||||
{
|
|
||||||
icon: BookOpenText,
|
const libraryLink = {
|
||||||
|
icon: MessagesSquare,
|
||||||
href: '/library',
|
href: '/library',
|
||||||
active: segments.includes('library'),
|
active: segments.includes('library'),
|
||||||
label: t('nav.library'),
|
label: t('nav.messageHistory'),
|
||||||
},
|
};
|
||||||
];
|
|
||||||
|
const navLinks = [discoverLink, libraryLink];
|
||||||
|
|
||||||
|
const handleHistoryMouseEnter = () => {
|
||||||
|
if (hideTimeoutRef.current) {
|
||||||
|
clearTimeout(hideTimeoutRef.current);
|
||||||
|
hideTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
if (historyRef.current) {
|
||||||
|
const rect = historyRef.current.getBoundingClientRect();
|
||||||
|
setSubmenuStyle({ top: 0, left: rect.right + 4 });
|
||||||
|
}
|
||||||
|
setHistoryOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleHistoryMouseLeave = () => {
|
||||||
|
hideTimeoutRef.current = setTimeout(() => setHistoryOpen(false), 150);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelHide = () => {
|
||||||
|
if (hideTimeoutRef.current) {
|
||||||
|
clearTimeout(hideTimeoutRef.current);
|
||||||
|
hideTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-[72px] lg:flex-col border-r border-light-200 dark:border-dark-200">
|
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-[56px] lg:flex-col border-r border-light-200 dark:border-dark-200">
|
||||||
<div className="flex grow flex-col items-center justify-between gap-y-5 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-8 shadow-sm shadow-light-200/10 dark:shadow-black/25">
|
<div className="flex grow flex-col items-center justify-start gap-y-1 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-6 shadow-sm shadow-light-200/10 dark:shadow-black/25">
|
||||||
<a
|
<a
|
||||||
className="p-2.5 rounded-full bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70 hover:opacity-70 hover:scale-105 tansition duration-200"
|
className="p-2.5 rounded-full bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70 hover:opacity-70 hover:scale-105 transition duration-200 cursor-pointer"
|
||||||
href="/"
|
href="/"
|
||||||
>
|
>
|
||||||
<Plus size={19} className="cursor-pointer" />
|
<Plus size={19} className="cursor-pointer" />
|
||||||
</a>
|
</a>
|
||||||
<VerticalIconContainer>
|
<VerticalIconContainer>
|
||||||
{navLinks.map((link, i) => (
|
|
||||||
<Link
|
<Link
|
||||||
key={i}
|
href={discoverLink.href}
|
||||||
href={link.href}
|
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
|
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
|
||||||
link.active
|
discoverLink.active
|
||||||
? 'text-black/70 dark:text-white/70'
|
? 'text-black/70 dark:text-white/70'
|
||||||
: 'text-black/60 dark:text-white/60',
|
: 'text-black/60 dark:text-white/60',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
link.active && 'bg-light-200 dark:bg-dark-200',
|
discoverLink.active && 'bg-light-200 dark:bg-dark-200',
|
||||||
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
|
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<link.icon
|
<discoverLink.icon
|
||||||
size={25}
|
size={25}
|
||||||
className={cn(
|
className={cn(
|
||||||
!link.active && 'group-hover:scale-105',
|
!discoverLink.active && 'group-hover:scale-105',
|
||||||
'transition duration:200 m-1.5',
|
'transition duration:200 m-1.5',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
link.active
|
discoverLink.active
|
||||||
? 'text-black/80 dark:text-white/80'
|
? 'text-black/80 dark:text-white/80'
|
||||||
: 'text-black/60 dark:text-white/60',
|
: 'text-black/60 dark:text-white/60',
|
||||||
'text-[10px]',
|
'text-[10px] text-fade',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{link.label}
|
{discoverLink.label}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
|
||||||
|
<div
|
||||||
|
ref={historyRef}
|
||||||
|
className="relative w-full"
|
||||||
|
onMouseEnter={handleHistoryMouseEnter}
|
||||||
|
onMouseLeave={handleHistoryMouseLeave}
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href={libraryLink.href}
|
||||||
|
className={cn(
|
||||||
|
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
|
||||||
|
libraryLink.active
|
||||||
|
? 'text-black/70 dark:text-white/70'
|
||||||
|
: 'text-black/60 dark:text-white/60',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
libraryLink.active && 'bg-light-200 dark:bg-dark-200',
|
||||||
|
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<libraryLink.icon
|
||||||
|
size={25}
|
||||||
|
className={cn(
|
||||||
|
!libraryLink.active && 'group-hover:scale-105',
|
||||||
|
'transition duration:200 m-1.5',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
className={cn(
|
||||||
|
libraryLink.active
|
||||||
|
? 'text-black/80 dark:text-white/80'
|
||||||
|
: 'text-black/60 dark:text-white/60',
|
||||||
|
'text-[10px] text-fade',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{libraryLink.label}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
{historyOpen &&
|
||||||
|
typeof document !== 'undefined' &&
|
||||||
|
createPortal(
|
||||||
|
<div
|
||||||
|
style={{ top: submenuStyle.top, left: submenuStyle.left }}
|
||||||
|
className="fixed z-[9999]"
|
||||||
|
>
|
||||||
|
<HistorySubmenu
|
||||||
|
onMouseEnter={cancelHide}
|
||||||
|
onMouseLeave={handleHistoryMouseLeave}
|
||||||
|
/>
|
||||||
|
</div>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</VerticalIconContainer>
|
</VerticalIconContainer>
|
||||||
|
|
||||||
|
<div className="mt-auto pt-4">
|
||||||
<SettingsButton />
|
<SettingsButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="fixed bottom-0 w-full z-50 flex flex-row items-center gap-x-6 bg-light-secondary dark:bg-dark-secondary px-4 py-4 shadow-sm lg:hidden">
|
<div className="fixed bottom-0 w-full z-50 flex flex-row items-center gap-x-6 bg-light-secondary dark:bg-dark-secondary px-4 py-4 shadow-sm lg:hidden">
|
||||||
{navLinks.map((link, i) => (
|
{navLinks.map((link, i) => (
|
||||||
@@ -123,7 +259,7 @@ const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
|||||||
<div className="absolute top-0 -mt-4 h-1 w-full rounded-b-lg bg-black dark:bg-white" />
|
<div className="absolute top-0 -mt-4 h-1 w-full rounded-b-lg bg-black dark:bg-white" />
|
||||||
)}
|
)}
|
||||||
<link.icon />
|
<link.icon />
|
||||||
<p className="text-xs">{link.label}</p>
|
<p className="text-xs text-fade min-w-0">{link.label}</p>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -158,16 +158,16 @@ const WeatherWidget = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-center w-full h-24 min-h-[96px] max-h-[96px] px-3 py-2 gap-3">
|
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-center w-full h-20 min-h-[80px] max-h-[80px] px-2.5 py-1.5 gap-2">
|
||||||
{error ? (
|
{error ? (
|
||||||
<div className="flex items-center justify-center w-full h-full text-xs text-black/50 dark:text-white/50">
|
<div className="flex items-center justify-center w-full h-full text-xs text-black/50 dark:text-white/50">
|
||||||
Weather unavailable
|
Weather unavailable
|
||||||
</div>
|
</div>
|
||||||
) : loading ? (
|
) : loading ? (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col items-center justify-center w-16 min-w-16 max-w-16 h-full animate-pulse">
|
<div className="flex flex-col items-center justify-center w-12 min-w-12 max-w-12 h-full animate-pulse">
|
||||||
<div className="h-10 w-10 rounded-full bg-light-200 dark:bg-dark-200 mb-2" />
|
<div className="h-8 w-8 rounded-full bg-light-200 dark:bg-dark-200 mb-1" />
|
||||||
<div className="h-4 w-10 rounded bg-light-200 dark:bg-dark-200" />
|
<div className="h-3 w-8 rounded bg-light-200 dark:bg-dark-200" />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col justify-between flex-1 h-full py-1 animate-pulse">
|
<div className="flex flex-col justify-between flex-1 h-full py-1 animate-pulse">
|
||||||
<div className="flex flex-row items-center justify-between">
|
<div className="flex flex-row items-center justify-between">
|
||||||
@@ -183,30 +183,30 @@ const WeatherWidget = () => {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col items-center justify-center w-16 min-w-16 max-w-16 h-full">
|
<div className="flex flex-col items-center justify-center w-12 min-w-12 max-w-12 h-full">
|
||||||
<img
|
<img
|
||||||
src={`/weather-ico/${data.icon}.svg`}
|
src={`/weather-ico/${data.icon}.svg`}
|
||||||
alt={data.condition}
|
alt={data.condition}
|
||||||
className="h-10 w-auto"
|
className="h-8 w-auto"
|
||||||
/>
|
/>
|
||||||
<span className="text-base font-semibold text-black dark:text-white">
|
<span className="text-sm font-semibold text-black dark:text-white">
|
||||||
{data.temperature}°{data.temperatureUnit}
|
{data.temperature}°{data.temperatureUnit}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col justify-between flex-1 h-full py-2">
|
<div className="flex flex-col justify-between flex-1 h-full py-1">
|
||||||
<div className="flex flex-row items-center justify-between">
|
<div className="flex flex-row items-center justify-between">
|
||||||
<span className="text-sm font-semibold text-black dark:text-white">
|
<span className="text-xs font-semibold text-black dark:text-white truncate">
|
||||||
{data.location}
|
{data.location}
|
||||||
</span>
|
</span>
|
||||||
<span className="flex items-center text-xs text-black/60 dark:text-white/60 font-medium">
|
<span className="flex items-center text-[10px] text-black/60 dark:text-white/60 font-medium shrink-0">
|
||||||
<Wind className="w-3 h-3 mr-1" />
|
<Wind className="w-2.5 h-2.5 mr-0.5" />
|
||||||
{data.windSpeed} {data.windSpeedUnit}
|
{data.windSpeed} {data.windSpeedUnit}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs text-black/50 dark:text-white/50 italic">
|
<span className="text-[10px] text-black/50 dark:text-white/50 italic truncate">
|
||||||
{data.condition}
|
{data.condition}
|
||||||
</span>
|
</span>
|
||||||
<div className="flex flex-row justify-between w-full mt-auto pt-2 border-t border-light-200/50 dark:border-dark-200/50 text-xs text-black/50 dark:text-white/50 font-medium">
|
<div className="flex flex-row justify-between w-full mt-auto pt-1 border-t border-light-200/50 dark:border-dark-200/50 text-[10px] text-black/50 dark:text-white/50 font-medium">
|
||||||
<span>Humidity {data.humidity}%</span>
|
<span>Humidity {data.humidity}%</span>
|
||||||
<span className="font-semibold text-black/70 dark:text-white/70">
|
<span className="font-semibold text-black/70 dark:text-white/70">
|
||||||
Now
|
Now
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { Loader2, ChevronDown } from 'lucide-react';
|
import { ChevronDown } from 'lucide-react';
|
||||||
import { SelectHTMLAttributes, forwardRef } from 'react';
|
import { SelectHTMLAttributes, forwardRef } from 'react';
|
||||||
|
|
||||||
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
|
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
|
||||||
@@ -34,11 +34,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
|
|||||||
})}
|
})}
|
||||||
</select>
|
</select>
|
||||||
<span className="pointer-events-none absolute right-3 flex h-4 w-4 items-center justify-center text-black/50 dark:text-white/60">
|
<span className="pointer-events-none absolute right-3 flex h-4 w-4 items-center justify-center text-black/50 dark:text-white/60">
|
||||||
{loading ? (
|
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<ChevronDown className="h-4 w-4" />
|
<ChevronDown className="h-4 w-4" />
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const defaultTranslations: Translations = {
|
|||||||
'nav.home': 'Home',
|
'nav.home': 'Home',
|
||||||
'nav.discover': 'Discover',
|
'nav.discover': 'Discover',
|
||||||
'nav.library': 'Library',
|
'nav.library': 'Library',
|
||||||
|
'nav.messageHistory': 'History',
|
||||||
'chat.related': 'Follow-up questions',
|
'chat.related': 'Follow-up questions',
|
||||||
'chat.searchImages': 'Search images',
|
'chat.searchImages': 'Search images',
|
||||||
'chat.searchVideos': 'Search videos',
|
'chat.searchVideos': 'Search videos',
|
||||||
@@ -75,6 +76,15 @@ const defaultTranslations: Translations = {
|
|||||||
'chat.source': 'source',
|
'chat.source': 'source',
|
||||||
'chat.document': 'document',
|
'chat.document': 'document',
|
||||||
'chat.documents': 'documents',
|
'chat.documents': 'documents',
|
||||||
|
'library.filterSourceAll': 'All sources',
|
||||||
|
'library.filterSourceWeb': 'Web',
|
||||||
|
'library.filterSourceAcademic': 'Academic',
|
||||||
|
'library.filterSourceSocial': 'Social',
|
||||||
|
'library.filterFilesAll': 'All',
|
||||||
|
'library.filterFilesWith': 'With files',
|
||||||
|
'library.filterFilesWithout': 'No files',
|
||||||
|
'library.noResults': 'No chats match your filters.',
|
||||||
|
'library.clearFilters': 'Clear filters',
|
||||||
};
|
};
|
||||||
|
|
||||||
const LocalizationContext = createContext<LocalizationContextValue | null>(null);
|
const LocalizationContext = createContext<LocalizationContextValue | null>(null);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Home',
|
'nav.home': 'Home',
|
||||||
'nav.discover': 'Discover',
|
'nav.discover': 'Discover',
|
||||||
'nav.library': 'Library',
|
'nav.library': 'Library',
|
||||||
|
'nav.messageHistory': 'History',
|
||||||
'chat.related': 'Follow-up questions',
|
'chat.related': 'Follow-up questions',
|
||||||
'chat.searchImages': 'Search images',
|
'chat.searchImages': 'Search images',
|
||||||
'chat.searchVideos': 'Search videos',
|
'chat.searchVideos': 'Search videos',
|
||||||
@@ -54,6 +55,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'source',
|
'chat.source': 'source',
|
||||||
'chat.document': 'document',
|
'chat.document': 'document',
|
||||||
'chat.documents': 'documents',
|
'chat.documents': 'documents',
|
||||||
|
'library.filterSourceAll': 'All sources',
|
||||||
|
'library.filterSourceWeb': 'Web',
|
||||||
|
'library.filterSourceAcademic': 'Academic',
|
||||||
|
'library.filterSourceSocial': 'Social',
|
||||||
|
'library.filterFilesAll': 'All',
|
||||||
|
'library.filterFilesWith': 'With files',
|
||||||
|
'library.filterFilesWithout': 'No files',
|
||||||
|
'library.noResults': 'No chats match your filters.',
|
||||||
|
'library.clearFilters': 'Clear filters',
|
||||||
},
|
},
|
||||||
ru: {
|
ru: {
|
||||||
'app.title': 'GooSeek',
|
'app.title': 'GooSeek',
|
||||||
@@ -74,6 +84,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Главная',
|
'nav.home': 'Главная',
|
||||||
'nav.discover': 'Обзор',
|
'nav.discover': 'Обзор',
|
||||||
'nav.library': 'Библиотека',
|
'nav.library': 'Библиотека',
|
||||||
|
'nav.messageHistory': 'История',
|
||||||
'chat.related': 'Что ещё спросить',
|
'chat.related': 'Что ещё спросить',
|
||||||
'chat.searchImages': 'Поиск изображений',
|
'chat.searchImages': 'Поиск изображений',
|
||||||
'chat.searchVideos': 'Поиск видео',
|
'chat.searchVideos': 'Поиск видео',
|
||||||
@@ -102,6 +113,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'источнику',
|
'chat.source': 'источнику',
|
||||||
'chat.documents': 'документов',
|
'chat.documents': 'документов',
|
||||||
'chat.document': 'документу',
|
'chat.document': 'документу',
|
||||||
|
'library.filterSourceAll': 'Все источники',
|
||||||
|
'library.filterSourceWeb': 'Веб',
|
||||||
|
'library.filterSourceAcademic': 'Академия',
|
||||||
|
'library.filterSourceSocial': 'Соцсети',
|
||||||
|
'library.filterFilesAll': 'Все',
|
||||||
|
'library.filterFilesWith': 'С файлами',
|
||||||
|
'library.filterFilesWithout': 'Без файлов',
|
||||||
|
'library.noResults': 'Нет чатов по вашим фильтрам.',
|
||||||
|
'library.clearFilters': 'Сбросить фильтры',
|
||||||
},
|
},
|
||||||
de: {
|
de: {
|
||||||
'app.title': 'GooSeek',
|
'app.title': 'GooSeek',
|
||||||
@@ -122,6 +142,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Start',
|
'nav.home': 'Start',
|
||||||
'nav.discover': 'Entdecken',
|
'nav.discover': 'Entdecken',
|
||||||
'nav.library': 'Bibliothek',
|
'nav.library': 'Bibliothek',
|
||||||
|
'nav.messageHistory': 'Verlauf',
|
||||||
'chat.related': 'Weitere Fragen',
|
'chat.related': 'Weitere Fragen',
|
||||||
'chat.searchImages': 'Bilder suchen',
|
'chat.searchImages': 'Bilder suchen',
|
||||||
'chat.searchVideos': 'Videos suchen',
|
'chat.searchVideos': 'Videos suchen',
|
||||||
@@ -150,6 +171,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'Quelle',
|
'chat.source': 'Quelle',
|
||||||
'chat.document': 'Dokument',
|
'chat.document': 'Dokument',
|
||||||
'chat.documents': 'Dokumente',
|
'chat.documents': 'Dokumente',
|
||||||
|
'library.filterSourceAll': 'Alle Quellen',
|
||||||
|
'library.filterSourceWeb': 'Web',
|
||||||
|
'library.filterSourceAcademic': 'Akademisch',
|
||||||
|
'library.filterSourceSocial': 'Sozial',
|
||||||
|
'library.filterFilesAll': 'Alle',
|
||||||
|
'library.filterFilesWith': 'Mit Dateien',
|
||||||
|
'library.filterFilesWithout': 'Ohne Dateien',
|
||||||
|
'library.noResults': 'Keine Chats entsprechen Ihren Filtern.',
|
||||||
|
'library.clearFilters': 'Filter zurücksetzen',
|
||||||
},
|
},
|
||||||
fr: {
|
fr: {
|
||||||
'app.title': 'GooSeek',
|
'app.title': 'GooSeek',
|
||||||
@@ -170,6 +200,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Accueil',
|
'nav.home': 'Accueil',
|
||||||
'nav.discover': 'Découvrir',
|
'nav.discover': 'Découvrir',
|
||||||
'nav.library': 'Bibliothèque',
|
'nav.library': 'Bibliothèque',
|
||||||
|
'nav.messageHistory': 'Historique',
|
||||||
'chat.related': 'Questions de suivi',
|
'chat.related': 'Questions de suivi',
|
||||||
'chat.searchImages': 'Rechercher des images',
|
'chat.searchImages': 'Rechercher des images',
|
||||||
'chat.searchVideos': 'Rechercher des vidéos',
|
'chat.searchVideos': 'Rechercher des vidéos',
|
||||||
@@ -198,6 +229,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'source',
|
'chat.source': 'source',
|
||||||
'chat.document': 'document',
|
'chat.document': 'document',
|
||||||
'chat.documents': 'documents',
|
'chat.documents': 'documents',
|
||||||
|
'library.filterSourceAll': 'Toutes les sources',
|
||||||
|
'library.filterSourceWeb': 'Web',
|
||||||
|
'library.filterSourceAcademic': 'Académique',
|
||||||
|
'library.filterSourceSocial': 'Réseaux',
|
||||||
|
'library.filterFilesAll': 'Tous',
|
||||||
|
'library.filterFilesWith': 'Avec fichiers',
|
||||||
|
'library.filterFilesWithout': 'Sans fichiers',
|
||||||
|
'library.noResults': 'Aucun chat ne correspond à vos filtres.',
|
||||||
|
'library.clearFilters': 'Effacer les filtres',
|
||||||
},
|
},
|
||||||
es: {
|
es: {
|
||||||
'app.title': 'GooSeek',
|
'app.title': 'GooSeek',
|
||||||
@@ -218,6 +258,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Inicio',
|
'nav.home': 'Inicio',
|
||||||
'nav.discover': 'Descubrir',
|
'nav.discover': 'Descubrir',
|
||||||
'nav.library': 'Biblioteca',
|
'nav.library': 'Biblioteca',
|
||||||
|
'nav.messageHistory': 'Historial',
|
||||||
'chat.related': 'Preguntas de seguimiento',
|
'chat.related': 'Preguntas de seguimiento',
|
||||||
'chat.searchImages': 'Buscar imágenes',
|
'chat.searchImages': 'Buscar imágenes',
|
||||||
'chat.searchVideos': 'Buscar videos',
|
'chat.searchVideos': 'Buscar videos',
|
||||||
@@ -246,6 +287,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'fuente',
|
'chat.source': 'fuente',
|
||||||
'chat.document': 'documento',
|
'chat.document': 'documento',
|
||||||
'chat.documents': 'documentos',
|
'chat.documents': 'documentos',
|
||||||
|
'library.filterSourceAll': 'Todas las fuentes',
|
||||||
|
'library.filterSourceWeb': 'Web',
|
||||||
|
'library.filterSourceAcademic': 'Académico',
|
||||||
|
'library.filterSourceSocial': 'Social',
|
||||||
|
'library.filterFilesAll': 'Todos',
|
||||||
|
'library.filterFilesWith': 'Con archivos',
|
||||||
|
'library.filterFilesWithout': 'Sin archivos',
|
||||||
|
'library.noResults': 'Ningún chat coincide con sus filtros.',
|
||||||
|
'library.clearFilters': 'Borrar filtros',
|
||||||
},
|
},
|
||||||
uk: {
|
uk: {
|
||||||
'app.title': 'GooSeek',
|
'app.title': 'GooSeek',
|
||||||
@@ -266,6 +316,7 @@ export const embeddedTranslations: Record<
|
|||||||
'nav.home': 'Головна',
|
'nav.home': 'Головна',
|
||||||
'nav.discover': 'Огляд',
|
'nav.discover': 'Огляд',
|
||||||
'nav.library': 'Бібліотека',
|
'nav.library': 'Бібліотека',
|
||||||
|
'nav.messageHistory': 'Історія',
|
||||||
'chat.related': 'Що ще запитати',
|
'chat.related': 'Що ще запитати',
|
||||||
'chat.searchImages': 'Пошук зображень',
|
'chat.searchImages': 'Пошук зображень',
|
||||||
'chat.searchVideos': 'Пошук відео',
|
'chat.searchVideos': 'Пошук відео',
|
||||||
@@ -294,6 +345,15 @@ export const embeddedTranslations: Record<
|
|||||||
'chat.source': 'джерелу',
|
'chat.source': 'джерелу',
|
||||||
'chat.document': 'документу',
|
'chat.document': 'документу',
|
||||||
'chat.documents': 'документів',
|
'chat.documents': 'документів',
|
||||||
|
'library.filterSourceAll': 'Усі джерела',
|
||||||
|
'library.filterSourceWeb': 'Веб',
|
||||||
|
'library.filterSourceAcademic': 'Академія',
|
||||||
|
'library.filterSourceSocial': 'Соцмережі',
|
||||||
|
'library.filterFilesAll': 'Усі',
|
||||||
|
'library.filterFilesWith': 'З файлами',
|
||||||
|
'library.filterFilesWithout': 'Без файлів',
|
||||||
|
'library.noResults': 'Немає чатів за вашими фільтрами.',
|
||||||
|
'library.clearFilters': 'Скинути фільтри',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
node_modules
|
|
||||||
data
|
|
||||||
.env
|
|
||||||
*.db
|
|
||||||
.git
|
|
||||||
5
apps/posts-mcs/.gitignore
vendored
5
apps/posts-mcs/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
data/
|
|
||||||
dist/
|
|
||||||
.env
|
|
||||||
*.db
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
FROM node:22-alpine
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN mkdir -p data && chmod +x entrypoint.sh
|
|
||||||
|
|
||||||
EXPOSE 4001
|
|
||||||
ENV PORT=4001
|
|
||||||
|
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# Publications Service — всё для публикаций
|
|
||||||
|
|
||||||
Сервис публикаций в папке `posts-microservice`: CRUD, планирование, rich-контент (изображения, видео, аудио, таблицы и т.д.), календарь выпусков и API для SearXNG.
|
|
||||||
|
|
||||||
## Запуск
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd posts-microservice
|
|
||||||
npm install
|
|
||||||
npm run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Сервис: `http://localhost:4001`
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### Публикации
|
|
||||||
|
|
||||||
| Метод | URL | Описание |
|
|
||||||
|-------|-----|----------|
|
|
||||||
| POST | `/api/publications` | Создать |
|
|
||||||
| GET | `/api/publications` | Список (`?status=`, `?q=`, `?limit=`, `?offset=`) |
|
|
||||||
| GET | `/api/publications/calendar` | Календарь (`?year=`, `?month=`) |
|
|
||||||
| GET | `/api/publications/:id` | По ID |
|
|
||||||
| GET | `/api/publications/slug/:slug` | По slug |
|
|
||||||
| PATCH | `/api/publications/:id` | Обновить |
|
|
||||||
| DELETE | `/api/publications/:id` | Удалить |
|
|
||||||
|
|
||||||
### Поля публикации
|
|
||||||
|
|
||||||
- `title` — заголовок
|
|
||||||
- `slug` — URL-slug (генерируется из title)
|
|
||||||
- `excerpt` — краткое описание
|
|
||||||
- `contentBlocks` — массив блоков (текст, изображения, видео, аудио, таблицы, embed)
|
|
||||||
- `previewImage` — URL превью
|
|
||||||
- `url` — ссылка на страницу
|
|
||||||
- `author` — автор
|
|
||||||
- `status` — `draft` | `scheduled` | `published`
|
|
||||||
- `scheduledAt` — время публикации (ISO)
|
|
||||||
- `publishedAt` — время фактической публикации
|
|
||||||
|
|
||||||
### Блоки контента (`contentBlocks`)
|
|
||||||
|
|
||||||
```json
|
|
||||||
[
|
|
||||||
{ "type": "text", "data": { "html": "<p>Текст</p>" } },
|
|
||||||
{ "type": "image", "data": { "src": "https://...", "alt": "...", "caption": "..." } },
|
|
||||||
{ "type": "video", "data": { "src": "https://...", "poster": "...", "caption": "..." } },
|
|
||||||
{ "type": "audio", "data": { "src": "https://...", "caption": "..." } },
|
|
||||||
{ "type": "table", "data": { "html": "<table>...</table>", "caption": "..." } },
|
|
||||||
{ "type": "embed", "data": { "url": "https://...", "caption": "..." } },
|
|
||||||
{ "type": "heading", "data": { "level": 1, "text": "Заголовок" } },
|
|
||||||
{ "type": "divider" }
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Планирование
|
|
||||||
|
|
||||||
- Публикация со `status: "scheduled"` и `scheduledAt` автоматически переходит в `published` при наступлении времени.
|
|
||||||
- Планировщик запускается каждую минуту.
|
|
||||||
|
|
||||||
### SearXNG
|
|
||||||
|
|
||||||
Эндпоинт `/search?q={query}&page={pageno}` отдаёт только опубликованные публикации в формате JSON engine SearXNG.
|
|
||||||
|
|
||||||
Конфиг в `searxng-engine-example.yml`.
|
|
||||||
|
|
||||||
## Алиасы
|
|
||||||
|
|
||||||
- `/api/posts` → тот же API (для обратной совместимости)
|
|
||||||
42
apps/posts-mcs/docker-compose.yaml
Normal file
42
apps/posts-mcs/docker-compose.yaml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Ghost + MySQL
|
||||||
|
# Требует: порт 2369, MySQL 8
|
||||||
|
|
||||||
|
services:
|
||||||
|
ghost:
|
||||||
|
image: ghost:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
ports:
|
||||||
|
- "2369:2368"
|
||||||
|
environment:
|
||||||
|
database__client: mysql2
|
||||||
|
database__connection__host: mysql
|
||||||
|
database__connection__user: ghost
|
||||||
|
database__connection__password: ghost
|
||||||
|
database__connection__database: ghost
|
||||||
|
url: http://localhost:2369
|
||||||
|
volumes:
|
||||||
|
- ghost_content:/var/lib/ghost/content
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: ghost
|
||||||
|
MYSQL_USER: ghost
|
||||||
|
MYSQL_PASSWORD: ghost
|
||||||
|
volumes:
|
||||||
|
- ghost_mysql:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 15
|
||||||
|
start_period: 30s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
ghost_content:
|
||||||
|
ghost_mysql:
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { defineConfig } from 'drizzle-kit';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
dialect: 'sqlite',
|
|
||||||
schema: './src/db/schema.ts',
|
|
||||||
out: './drizzle',
|
|
||||||
dbCredentials: {
|
|
||||||
url: path.join(process.cwd(), 'data', 'posts.db'),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
mkdir -p /app/data
|
|
||||||
npx tsx src/init-db.ts 2>/dev/null || true
|
|
||||||
exec npx tsx src/index.ts
|
|
||||||
3145
apps/posts-mcs/package-lock.json
generated
3145
apps/posts-mcs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "posts-microservice",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"type": "module",
|
|
||||||
"description": "Сервис постинга для SearXNG - API для отображения своих постов вместо Bing",
|
|
||||||
"main": "src/index.ts",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "npx tsx watch src/index.ts",
|
|
||||||
"start": "npx tsx src/index.ts",
|
|
||||||
"db:generate": "drizzle-kit generate",
|
|
||||||
"db:migrate": "drizzle-kit migrate",
|
|
||||||
"db:push": "drizzle-kit push"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"better-sqlite3": "^11.9.1",
|
|
||||||
"drizzle-orm": "^0.40.1",
|
|
||||||
"express": "^4.21.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/better-sqlite3": "^7.6.12",
|
|
||||||
"@types/express": "^4.17.21",
|
|
||||||
"drizzle-kit": "^0.30.5",
|
|
||||||
"tsx": "^4.19.0",
|
|
||||||
"typescript": "^5.9.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Добавьте этот engine в /etc/searxng/settings.yml в секцию engines:
|
|
||||||
#
|
|
||||||
# Ваши публикации будут отображаться в результатах поиска Perplexica
|
|
||||||
# Замените http://localhost:4001 на ваш URL (например http://posts:4001 в Docker)
|
|
||||||
|
|
||||||
- name: my_publications
|
|
||||||
engine: json_engine
|
|
||||||
paging: true
|
|
||||||
search_url: http://localhost:4001/search?q={query}&page={pageno}
|
|
||||||
results_query: results
|
|
||||||
url_query: url
|
|
||||||
title_query: title
|
|
||||||
content_query: content
|
|
||||||
disabled: false
|
|
||||||
|
|
||||||
# Чтобы отключить Bing и использовать только свои посты:
|
|
||||||
# - name: bing
|
|
||||||
# disabled: true
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import Database from 'better-sqlite3';
|
|
||||||
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
|
||||||
import * as schema from './schema';
|
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const dataDir = path.join(process.cwd(), 'data');
|
|
||||||
if (!fs.existsSync(dataDir)) {
|
|
||||||
fs.mkdirSync(dataDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
const sqlite = new Database(path.join(dataDir, 'posts.db'));
|
|
||||||
export const db = drizzle(sqlite, { schema });
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import { sql } from 'drizzle-orm';
|
|
||||||
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
||||||
|
|
||||||
// Типы блоков контента (изображения, видео, аудио, таблицы и т.д.)
|
|
||||||
export type ContentBlock =
|
|
||||||
| { type: 'text'; data: { html: string } }
|
|
||||||
| { type: 'image'; data: { src: string; alt?: string; caption?: string } }
|
|
||||||
| { type: 'video'; data: { src: string; poster?: string; caption?: string } }
|
|
||||||
| { type: 'audio'; data: { src: string; caption?: string } }
|
|
||||||
| { type: 'table'; data: { html: string; caption?: string } }
|
|
||||||
| { type: 'embed'; data: { url: string; caption?: string } }
|
|
||||||
| { type: 'divider' }
|
|
||||||
| { type: 'heading'; data: { level: 1 | 2 | 3; text: string } };
|
|
||||||
|
|
||||||
export const publications = sqliteTable('publications', {
|
|
||||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
||||||
title: text('title').notNull(),
|
|
||||||
slug: text('slug').notNull().unique(),
|
|
||||||
// Простой текст для поиска; полный контент в contentBlocks
|
|
||||||
excerpt: text('excerpt'),
|
|
||||||
// JSON массив ContentBlock[]
|
|
||||||
contentBlocks: text('contentBlocks', { mode: 'json' })
|
|
||||||
.$type<ContentBlock[]>()
|
|
||||||
.default(sql`'[]'`),
|
|
||||||
// Превью изображение
|
|
||||||
previewImage: text('previewImage'),
|
|
||||||
url: text('url').notNull(),
|
|
||||||
author: text('author'),
|
|
||||||
status: text({ enum: ['draft', 'scheduled', 'published'] }).notNull().default('draft'),
|
|
||||||
publishedAt: text('publishedAt'),
|
|
||||||
scheduledAt: text('scheduledAt'),
|
|
||||||
createdAt: text('createdAt')
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
|
||||||
updatedAt: text('updatedAt')
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type Publication = typeof publications.$inferSelect;
|
|
||||||
export type NewPublication = typeof publications.$inferInsert;
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import express from 'express';
|
|
||||||
import publicationsRouter from './routes/publications.js';
|
|
||||||
import searchRouter from './routes/search.js';
|
|
||||||
import { runScheduledPublish } from './lib/scheduler.js';
|
|
||||||
|
|
||||||
const app = express();
|
|
||||||
const PORT = process.env.PORT || 4001;
|
|
||||||
|
|
||||||
app.use(express.json({ limit: '10mb' }));
|
|
||||||
|
|
||||||
// API публикаций
|
|
||||||
app.use('/api/publications', publicationsRouter);
|
|
||||||
|
|
||||||
// Алиас /api/posts -> publications (обратная совместимость)
|
|
||||||
app.use('/api/posts', (req, res, next) => {
|
|
||||||
const origJson = res.json.bind(res);
|
|
||||||
res.json = (body: unknown) => {
|
|
||||||
if (body && typeof body === 'object' && 'publications' in body) {
|
|
||||||
return origJson({ ...body, posts: (body as any).publications });
|
|
||||||
}
|
|
||||||
return origJson(body);
|
|
||||||
};
|
|
||||||
next();
|
|
||||||
}, publicationsRouter);
|
|
||||||
|
|
||||||
// SearXNG JSON Engine — поиск по опубликованным
|
|
||||||
app.use('/search', searchRouter);
|
|
||||||
|
|
||||||
// Health
|
|
||||||
app.get('/health', (_, res) => res.json({ status: 'ok' }));
|
|
||||||
|
|
||||||
// Планировщик: каждую минуту проверяет и публикует запланированные
|
|
||||||
setInterval(runScheduledPublish, 60_000);
|
|
||||||
runScheduledPublish();
|
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
|
||||||
console.log(`Publications Service: http://localhost:${PORT}`);
|
|
||||||
console.log(` API: /api/publications`);
|
|
||||||
console.log(` Calendar: /api/publications/calendar`);
|
|
||||||
console.log(` SearXNG: /search?q=...`);
|
|
||||||
});
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import Database from 'better-sqlite3';
|
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const dataDir = path.join(process.cwd(), 'data');
|
|
||||||
if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true });
|
|
||||||
const dbPath = path.join(dataDir, 'posts.db');
|
|
||||||
const db = new Database(dbPath);
|
|
||||||
db.exec(`
|
|
||||||
CREATE TABLE IF NOT EXISTS publications (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
title TEXT NOT NULL,
|
|
||||||
slug TEXT NOT NULL UNIQUE,
|
|
||||||
excerpt TEXT,
|
|
||||||
contentBlocks TEXT DEFAULT '[]',
|
|
||||||
previewImage TEXT,
|
|
||||||
url TEXT NOT NULL,
|
|
||||||
author TEXT,
|
|
||||||
status TEXT NOT NULL DEFAULT 'draft',
|
|
||||||
publishedAt TEXT,
|
|
||||||
scheduledAt TEXT,
|
|
||||||
createdAt TEXT NOT NULL DEFAULT (datetime('now')),
|
|
||||||
updatedAt TEXT NOT NULL DEFAULT (datetime('now'))
|
|
||||||
);
|
|
||||||
`);
|
|
||||||
db.close();
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import type { ContentBlock } from '../db/schema.js';
|
|
||||||
|
|
||||||
/** Извлекает поисковый текст из блоков контента */
|
|
||||||
export function blocksToSearchText(blocks: ContentBlock[] | null): string {
|
|
||||||
if (!blocks || !Array.isArray(blocks)) return '';
|
|
||||||
return blocks
|
|
||||||
.map((b) => {
|
|
||||||
if (b.type === 'text' && b.data?.html) return stripHtml(String(b.data.html));
|
|
||||||
if (b.type === 'heading' && b.data?.text) return b.data.text;
|
|
||||||
if (b.type === 'image' && b.data?.caption) return b.data.caption;
|
|
||||||
if (b.type === 'video' && b.data?.caption) return b.data.caption;
|
|
||||||
if (b.type === 'audio' && b.data?.caption) return b.data.caption;
|
|
||||||
if (b.type === 'table' && b.data?.html) return stripHtml(String(b.data.html));
|
|
||||||
return '';
|
|
||||||
})
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function stripHtml(html: string): string {
|
|
||||||
return html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { db } from '../db/index.js';
|
|
||||||
import { publications } from '../db/schema.js';
|
|
||||||
import { eq, sql } from 'drizzle-orm';
|
|
||||||
|
|
||||||
/** Переводит запланированные публикации в published, когда наступило время */
|
|
||||||
export function runScheduledPublish() {
|
|
||||||
const now = new Date().toISOString();
|
|
||||||
const rows = db
|
|
||||||
.select({ id: publications.id })
|
|
||||||
.from(publications)
|
|
||||||
.where(
|
|
||||||
sql`${publications.status} = 'scheduled' AND ${publications.scheduledAt} IS NOT NULL AND ${publications.scheduledAt} <= ${now}`,
|
|
||||||
)
|
|
||||||
.all();
|
|
||||||
|
|
||||||
for (const row of rows) {
|
|
||||||
db.update(publications)
|
|
||||||
.set({ status: 'published', publishedAt: now, updatedAt: now })
|
|
||||||
.where(eq(publications.id, row.id))
|
|
||||||
.run();
|
|
||||||
}
|
|
||||||
if (rows.length > 0) {
|
|
||||||
console.log(`[scheduler] Опубликовано: ${rows.length}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
import { Router } from 'express';
|
|
||||||
import { db } from '../db/index.js';
|
|
||||||
import { publications } from '../db/schema.js';
|
|
||||||
import { desc, eq, and } from 'drizzle-orm';
|
|
||||||
import { blocksToSearchText } from '../lib/content.js';
|
|
||||||
import type { ContentBlock } from '../db/schema.js';
|
|
||||||
|
|
||||||
const router = Router();
|
|
||||||
|
|
||||||
function slugify(s: string): string {
|
|
||||||
const slug = s
|
|
||||||
.toLowerCase()
|
|
||||||
.replace(/[^\p{L}\p{N}\s-]/gu, '')
|
|
||||||
.replace(/\s+/g, '-')
|
|
||||||
.replace(/-+/g, '-')
|
|
||||||
.trim();
|
|
||||||
return slug || `post-${Date.now()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Создать публикацию
|
|
||||||
router.post('/', (req, res) => {
|
|
||||||
try {
|
|
||||||
const {
|
|
||||||
title,
|
|
||||||
slug,
|
|
||||||
excerpt,
|
|
||||||
content,
|
|
||||||
contentBlocks,
|
|
||||||
previewImage,
|
|
||||||
url,
|
|
||||||
author,
|
|
||||||
status,
|
|
||||||
scheduledAt,
|
|
||||||
} = req.body;
|
|
||||||
|
|
||||||
if (!title || !url) {
|
|
||||||
return res.status(400).json({ error: 'Необходимы поля: title, url' });
|
|
||||||
}
|
|
||||||
|
|
||||||
const finalSlug = slug || slugify(title);
|
|
||||||
const pubStatus = status || 'draft';
|
|
||||||
const now = new Date().toISOString();
|
|
||||||
const blocks: ContentBlock[] =
|
|
||||||
contentBlocks && Array.isArray(contentBlocks)
|
|
||||||
? contentBlocks
|
|
||||||
: content
|
|
||||||
? [{ type: 'text', data: { html: content } }]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
let publishedAt: string | null = null;
|
|
||||||
if (pubStatus === 'published') publishedAt = now;
|
|
||||||
if (pubStatus === 'scheduled' && scheduledAt) publishedAt = null;
|
|
||||||
|
|
||||||
const result = db
|
|
||||||
.insert(publications)
|
|
||||||
.values({
|
|
||||||
title,
|
|
||||||
slug: finalSlug,
|
|
||||||
excerpt: excerpt || (typeof content === 'string' ? content.slice(0, 300) : null),
|
|
||||||
contentBlocks: blocks,
|
|
||||||
previewImage: previewImage || null,
|
|
||||||
url,
|
|
||||||
author: author || null,
|
|
||||||
status: pubStatus,
|
|
||||||
publishedAt,
|
|
||||||
scheduledAt: scheduledAt || null,
|
|
||||||
})
|
|
||||||
.run();
|
|
||||||
|
|
||||||
res.status(201).json({ id: result.lastInsertRowid, message: 'Публикация создана' });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
res.status(500).json({ error: 'Ошибка создания публикации' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Список публикаций (с фильтрами)
|
|
||||||
router.get('/', (req, res) => {
|
|
||||||
try {
|
|
||||||
const q = req.query.q as string | undefined;
|
|
||||||
const status = req.query.status as string | undefined;
|
|
||||||
const limit = Math.min(parseInt(req.query.limit as string) || 50, 100);
|
|
||||||
const offset = parseInt(req.query.offset as string) || 0;
|
|
||||||
|
|
||||||
let baseQuery = db.select().from(publications).orderBy(desc(publications.createdAt));
|
|
||||||
|
|
||||||
const conditions = [];
|
|
||||||
if (status) {
|
|
||||||
conditions.push(eq(publications.status, status as 'draft' | 'scheduled' | 'published'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const whereClause = conditions.length ? and(...conditions) : undefined;
|
|
||||||
const items = (whereClause
|
|
||||||
? baseQuery.where(whereClause)
|
|
||||||
: baseQuery
|
|
||||||
)
|
|
||||||
.limit(limit)
|
|
||||||
.offset(offset)
|
|
||||||
.all();
|
|
||||||
|
|
||||||
let result = items;
|
|
||||||
if (q) {
|
|
||||||
const qLower = q.toLowerCase();
|
|
||||||
result = items.filter(
|
|
||||||
(p) =>
|
|
||||||
p.title?.toLowerCase().includes(qLower) ||
|
|
||||||
(p.excerpt && p.excerpt.toLowerCase().includes(qLower)) ||
|
|
||||||
p.url?.toLowerCase().includes(qLower) ||
|
|
||||||
blocksToSearchText(p.contentBlocks).toLowerCase().includes(qLower),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json({ publications: result });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
res.status(500).json({ error: 'Ошибка получения публикаций' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Календарь: публикации по датам (для редакторского календаря)
|
|
||||||
router.get('/calendar', (req, res) => {
|
|
||||||
try {
|
|
||||||
const year = parseInt(req.query.year as string) || new Date().getFullYear();
|
|
||||||
const month = parseInt(req.query.month as string);
|
|
||||||
|
|
||||||
const items = db
|
|
||||||
.select({
|
|
||||||
id: publications.id,
|
|
||||||
title: publications.title,
|
|
||||||
status: publications.status,
|
|
||||||
scheduledAt: publications.scheduledAt,
|
|
||||||
publishedAt: publications.publishedAt,
|
|
||||||
createdAt: publications.createdAt,
|
|
||||||
})
|
|
||||||
.from(publications)
|
|
||||||
.all();
|
|
||||||
|
|
||||||
const byDate: Record<string, typeof items> = {};
|
|
||||||
for (const p of items) {
|
|
||||||
const dateStr =
|
|
||||||
p.scheduledAt?.slice(0, 10) || p.publishedAt?.slice(0, 10) || p.createdAt?.slice(0, 10);
|
|
||||||
if (!dateStr) continue;
|
|
||||||
if (month !== undefined) {
|
|
||||||
const [, m] = dateStr.split('-').map(Number);
|
|
||||||
if (m !== month) continue;
|
|
||||||
}
|
|
||||||
const [y] = dateStr.split('-').map(Number);
|
|
||||||
if (y !== year) continue;
|
|
||||||
if (!byDate[dateStr]) byDate[dateStr] = [];
|
|
||||||
byDate[dateStr].push(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json({ calendar: byDate });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
res.status(500).json({ error: 'Ошибка календаря' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Одна публикация по ID
|
|
||||||
router.get('/:id', (req, res) => {
|
|
||||||
const id = parseInt(req.params.id);
|
|
||||||
if (isNaN(id)) return res.status(400).json({ error: 'Неверный ID' });
|
|
||||||
const row = db.select().from(publications).where(eq(publications.id, id)).get();
|
|
||||||
if (!row) return res.status(404).json({ error: 'Публикация не найдена' });
|
|
||||||
res.json(row);
|
|
||||||
});
|
|
||||||
|
|
||||||
// По slug
|
|
||||||
router.get('/slug/:slug', (req, res) => {
|
|
||||||
const row = db
|
|
||||||
.select()
|
|
||||||
.from(publications)
|
|
||||||
.where(eq(publications.slug, req.params.slug))
|
|
||||||
.get();
|
|
||||||
if (!row) return res.status(404).json({ error: 'Публикация не найдена' });
|
|
||||||
res.json(row);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Обновить
|
|
||||||
router.patch('/:id', (req, res) => {
|
|
||||||
const id = parseInt(req.params.id);
|
|
||||||
if (isNaN(id)) return res.status(400).json({ error: 'Неверный ID' });
|
|
||||||
|
|
||||||
const {
|
|
||||||
title,
|
|
||||||
slug,
|
|
||||||
excerpt,
|
|
||||||
contentBlocks,
|
|
||||||
previewImage,
|
|
||||||
url,
|
|
||||||
author,
|
|
||||||
status,
|
|
||||||
scheduledAt,
|
|
||||||
publishedAt,
|
|
||||||
} = req.body;
|
|
||||||
|
|
||||||
const updates: Record<string, unknown> = {
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
if (title !== undefined) updates.title = title;
|
|
||||||
if (slug !== undefined) updates.slug = slug;
|
|
||||||
if (excerpt !== undefined) updates.excerpt = excerpt;
|
|
||||||
if (contentBlocks !== undefined) updates.contentBlocks = contentBlocks;
|
|
||||||
if (previewImage !== undefined) updates.previewImage = previewImage;
|
|
||||||
if (url !== undefined) updates.url = url;
|
|
||||||
if (author !== undefined) updates.author = author;
|
|
||||||
if (status !== undefined) updates.status = status;
|
|
||||||
if (scheduledAt !== undefined) updates.scheduledAt = scheduledAt;
|
|
||||||
if (publishedAt !== undefined) updates.publishedAt = publishedAt;
|
|
||||||
|
|
||||||
const result = db.update(publications).set(updates as any).where(eq(publications.id, id)).run();
|
|
||||||
if (result.changes === 0) return res.status(404).json({ error: 'Публикация не найдена' });
|
|
||||||
res.json({ message: 'Публикация обновлена' });
|
|
||||||
});
|
|
||||||
|
|
||||||
// Удалить
|
|
||||||
router.delete('/:id', (req, res) => {
|
|
||||||
const id = parseInt(req.params.id);
|
|
||||||
if (isNaN(id)) return res.status(400).json({ error: 'Неверный ID' });
|
|
||||||
const result = db.delete(publications).where(eq(publications.id, id)).run();
|
|
||||||
if (result.changes === 0) return res.status(404).json({ error: 'Публикация не найдена' });
|
|
||||||
res.json({ message: 'Публикация удалена' });
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
import { Router } from 'express';
|
|
||||||
import { db } from '../db/index.js';
|
|
||||||
import { publications } from '../db/schema.js';
|
|
||||||
import { sql } from 'drizzle-orm';
|
|
||||||
import { blocksToSearchText } from '../lib/content.js';
|
|
||||||
|
|
||||||
const router = Router();
|
|
||||||
|
|
||||||
/** Только опубликованные или запланированные (когда время наступило) */
|
|
||||||
function getPublishedItems() {
|
|
||||||
const now = new Date().toISOString();
|
|
||||||
const items = db
|
|
||||||
.select()
|
|
||||||
.from(publications)
|
|
||||||
.where(
|
|
||||||
sql`(${publications.status} = 'published' OR (${publications.status} = 'scheduled' AND ${publications.scheduledAt} <= ${now}))`,
|
|
||||||
)
|
|
||||||
.all();
|
|
||||||
return items.sort((a, b) => {
|
|
||||||
const da = a.publishedAt || a.scheduledAt || a.createdAt || '';
|
|
||||||
const dbVal = b.publishedAt || b.scheduledAt || b.createdAt || '';
|
|
||||||
return dbVal.localeCompare(da);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// SearXNG JSON Engine API
|
|
||||||
router.get('/', (req, res) => {
|
|
||||||
try {
|
|
||||||
const query = (req.query.q as string)?.trim() || '';
|
|
||||||
const pageno = Math.max(1, parseInt((req.query.page || req.query.pageno) as string) || 1);
|
|
||||||
const pageSize = 10;
|
|
||||||
const offset = (pageno - 1) * pageSize;
|
|
||||||
|
|
||||||
const allItems = getPublishedItems();
|
|
||||||
let filtered = allItems;
|
|
||||||
if (query) {
|
|
||||||
const q = query.toLowerCase();
|
|
||||||
filtered = allItems.filter(
|
|
||||||
(p) =>
|
|
||||||
p.title?.toLowerCase().includes(q) ||
|
|
||||||
(p.excerpt && p.excerpt.toLowerCase().includes(q)) ||
|
|
||||||
p.url?.toLowerCase().includes(q) ||
|
|
||||||
blocksToSearchText(p.contentBlocks).toLowerCase().includes(q),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const items = filtered.slice(offset, offset + pageSize);
|
|
||||||
|
|
||||||
const results = filtered.map((p) => ({
|
|
||||||
url: p.url,
|
|
||||||
title: p.title,
|
|
||||||
content: (p.excerpt || blocksToSearchText(p.contentBlocks) || '').slice(0, 500),
|
|
||||||
...(p.author && { author: p.author }),
|
|
||||||
...(p.previewImage && { thumbnail: p.previewImage }),
|
|
||||||
}));
|
|
||||||
|
|
||||||
res.json({ results });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
res.status(500).json({ results: [] });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2022",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"outDir": "dist",
|
|
||||||
"rootDir": "src"
|
|
||||||
},
|
|
||||||
"include": ["src/**/*"]
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
"docker:build": "docker build -f docker/Dockerfile -t gooseek:latest .",
|
"docker:build": "docker build -f docker/Dockerfile -t gooseek:latest .",
|
||||||
"docker:up": "docker compose -f docker/docker-compose.yaml up -d",
|
"docker:up": "docker compose -f docker/docker-compose.yaml up -d",
|
||||||
"docker:down": "docker compose -f docker/docker-compose.yaml down",
|
"docker:down": "docker compose -f docker/docker-compose.yaml down",
|
||||||
|
"chatwoot:up": "docker compose -f chatwoot/docker-compose.yaml up -d",
|
||||||
|
"chatwoot:down": "docker compose -f chatwoot/docker-compose.yaml down",
|
||||||
"dev:geo": "npm run dev -w geo-device-service",
|
"dev:geo": "npm run dev -w geo-device-service",
|
||||||
"dev:locale": "npm run dev -w localization-service"
|
"dev:locale": "npm run dev -w localization-service"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user