cleanup
This commit is contained in:
parent
e93f394263
commit
c4c52f6064
@ -1,4 +1,4 @@
|
|||||||
// src/config/prompts.ts - Enhanced with phase completion reasoning
|
// src/config/prompts.ts
|
||||||
|
|
||||||
export const AI_PROMPTS = {
|
export const AI_PROMPTS = {
|
||||||
|
|
||||||
|
@ -180,7 +180,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
return apiSpecial.invalidJSON();
|
return apiSpecial.invalidJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preprocess form data to handle autocomplete inputs
|
|
||||||
body = preprocessFormData(body);
|
body = preprocessFormData(body);
|
||||||
|
|
||||||
const sanitizedBody = sanitizeInput(body);
|
const sanitizedBody = sanitizeInput(body);
|
||||||
|
@ -588,10 +588,8 @@ const currentUrl = Astro.url.href;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make generateTOCContent available globally for the auth check script
|
|
||||||
window.generateTOCContent = generateTOCContent;
|
window.generateTOCContent = generateTOCContent;
|
||||||
|
|
||||||
// Initialize everything on page load
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
calculateReadingTime();
|
calculateReadingTime();
|
||||||
generateSidebarTOC();
|
generateSidebarTOC();
|
||||||
|
@ -1887,7 +1887,6 @@ input[type="checkbox"] {
|
|||||||
box-shadow: 0 2px 4px 0 rgb(255 255 255 / 10%);
|
box-shadow: 0 2px 4px 0 rgb(255 255 255 / 10%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enhanced contextual analysis cards */
|
|
||||||
.contextual-analysis-card {
|
.contextual-analysis-card {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
border-left: 4px solid;
|
border-left: 4px solid;
|
||||||
@ -1984,7 +1983,6 @@ input[type="checkbox"] {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enhanced queue status for micro-tasks */
|
|
||||||
.queue-status-card.micro-task-mode {
|
.queue-status-card.micro-task-mode {
|
||||||
border-left: 4px solid var(--color-primary);
|
border-left: 4px solid var(--color-primary);
|
||||||
}
|
}
|
||||||
@ -1997,7 +1995,6 @@ input[type="checkbox"] {
|
|||||||
border-radius: 0.5rem 0.5rem 0 0;
|
border-radius: 0.5rem 0.5rem 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile responsive adjustments */
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.micro-task-steps {
|
.micro-task-steps {
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
--color-warning: #d97706;
|
--color-warning: #d97706;
|
||||||
--color-error: #dc2626;
|
--color-error: #dc2626;
|
||||||
|
|
||||||
/* Enhanced card type colors */
|
|
||||||
--color-hosted: #7c3aed;
|
--color-hosted: #7c3aed;
|
||||||
--color-hosted-bg: #f3f0ff;
|
--color-hosted-bg: #f3f0ff;
|
||||||
--color-oss: #059669;
|
--color-oss: #059669;
|
||||||
|
@ -52,22 +52,17 @@ function getEnv(key: string): string {
|
|||||||
|
|
||||||
export function getSessionFromRequest(request: Request): string | null {
|
export function getSessionFromRequest(request: Request): string | null {
|
||||||
const cookieHeader = request.headers.get('cookie');
|
const cookieHeader = request.headers.get('cookie');
|
||||||
console.log('[DEBUG] Cookie header:', cookieHeader ? 'present' : 'missing');
|
|
||||||
|
|
||||||
if (!cookieHeader) return null;
|
if (!cookieHeader) return null;
|
||||||
|
|
||||||
const cookies = parseCookie(cookieHeader);
|
const cookies = parseCookie(cookieHeader);
|
||||||
console.log('[DEBUG] Parsed cookies:', Object.keys(cookies));
|
|
||||||
console.log('[DEBUG] Session cookie found:', !!cookies.session);
|
|
||||||
|
|
||||||
return cookies.session || null;
|
return cookies.session || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function verifySession(sessionToken: string): Promise<SessionData | null> {
|
export async function verifySession(sessionToken: string): Promise<SessionData | null> {
|
||||||
try {
|
try {
|
||||||
console.log('[DEBUG] Verifying session token, length:', sessionToken.length);
|
|
||||||
const { payload } = await jwtVerify(sessionToken, SECRET_KEY);
|
const { payload } = await jwtVerify(sessionToken, SECRET_KEY);
|
||||||
console.log('[DEBUG] JWT verification successful, payload keys:', Object.keys(payload));
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof payload.userId === 'string' &&
|
typeof payload.userId === 'string' &&
|
||||||
@ -75,7 +70,6 @@ export async function verifySession(sessionToken: string): Promise<SessionData |
|
|||||||
typeof payload.authenticated === 'boolean' &&
|
typeof payload.authenticated === 'boolean' &&
|
||||||
typeof payload.exp === 'number'
|
typeof payload.exp === 'number'
|
||||||
) {
|
) {
|
||||||
console.log('[DEBUG] Session validation successful for user:', payload.userId);
|
|
||||||
return {
|
return {
|
||||||
userId: payload.userId,
|
userId: payload.userId,
|
||||||
email: payload.email,
|
email: payload.email,
|
||||||
@ -84,17 +78,14 @@ export async function verifySession(sessionToken: string): Promise<SessionData |
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[DEBUG] Session payload validation failed, payload:', payload);
|
|
||||||
return null;
|
return null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('[DEBUG] Session verification failed:', error.message);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createSession(userId: string, email: string): Promise<string> {
|
export async function createSession(userId: string, email: string): Promise<string> {
|
||||||
const exp = Math.floor(Date.now() / 1000) + SESSION_DURATION;
|
const exp = Math.floor(Date.now() / 1000) + SESSION_DURATION;
|
||||||
console.log('[DEBUG] Creating session for user:', userId, 'exp:', exp);
|
|
||||||
|
|
||||||
const token = await new SignJWT({
|
const token = await new SignJWT({
|
||||||
userId,
|
userId,
|
||||||
@ -106,7 +97,6 @@ export async function createSession(userId: string, email: string): Promise<stri
|
|||||||
.setExpirationTime(exp)
|
.setExpirationTime(exp)
|
||||||
.sign(SECRET_KEY);
|
.sign(SECRET_KEY);
|
||||||
|
|
||||||
console.log('[DEBUG] Session token created, length:', token.length);
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +113,6 @@ export function createSessionCookie(sessionToken: string): string {
|
|||||||
path: '/'
|
path: '/'
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[DEBUG] Created session cookie:', cookie.substring(0, 100) + '...');
|
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +281,6 @@ export async function createSessionWithCookie(userInfo: UserInfo): Promise<{
|
|||||||
|
|
||||||
export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'general'): Promise<AuthContext | Response> {
|
export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'general'): Promise<AuthContext | Response> {
|
||||||
const authRequired = getAuthRequirement(context);
|
const authRequired = getAuthRequirement(context);
|
||||||
console.log(`[DEBUG PAGE] Auth required for ${context}:`, authRequired);
|
|
||||||
console.log('[DEBUG PAGE] Request URL:', Astro.url.toString());
|
|
||||||
|
|
||||||
if (!authRequired) {
|
if (!authRequired) {
|
||||||
return {
|
return {
|
||||||
@ -305,10 +292,8 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sessionToken = getSessionFromRequest(Astro.request);
|
const sessionToken = getSessionFromRequest(Astro.request);
|
||||||
console.log('[DEBUG PAGE] Session token found:', !!sessionToken);
|
|
||||||
|
|
||||||
if (!sessionToken) {
|
if (!sessionToken) {
|
||||||
console.log('[DEBUG PAGE] No session token, redirecting to login');
|
|
||||||
const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
|
const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 302,
|
status: 302,
|
||||||
@ -317,10 +302,8 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
|
|||||||
}
|
}
|
||||||
|
|
||||||
const session = await verifySession(sessionToken);
|
const session = await verifySession(sessionToken);
|
||||||
console.log('[DEBUG PAGE] Session verification result:', !!session);
|
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
console.log('[DEBUG PAGE] Session verification failed, redirecting to login');
|
|
||||||
const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
|
const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 302,
|
status: 302,
|
||||||
@ -328,7 +311,6 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[DEBUG PAGE] Page authentication successful for ${context}:`, session.userId);
|
|
||||||
return {
|
return {
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
session,
|
session,
|
||||||
@ -354,10 +336,8 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sessionToken = getSessionFromRequest(request);
|
const sessionToken = getSessionFromRequest(request);
|
||||||
console.log(`[DEBUG API] Session token found for ${context}:`, !!sessionToken);
|
|
||||||
|
|
||||||
if (!sessionToken) {
|
if (!sessionToken) {
|
||||||
console.log(`[DEBUG API] No session token found for ${context}`);
|
|
||||||
return {
|
return {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
userId: '',
|
userId: '',
|
||||||
@ -366,10 +346,8 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
|
|||||||
}
|
}
|
||||||
|
|
||||||
const session = await verifySession(sessionToken);
|
const session = await verifySession(sessionToken);
|
||||||
console.log(`[DEBUG API] Session verification result for ${context}:`, !!session);
|
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
console.log(`[DEBUG API] Session verification failed for ${context}`);
|
|
||||||
return {
|
return {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
userId: '',
|
userId: '',
|
||||||
@ -377,7 +355,6 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[DEBUG API] Authentication successful for ${context}:`, session.userId);
|
|
||||||
return {
|
return {
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
userId: session.userId,
|
userId: session.userId,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// src/utils/dataService.ts - Enhanced for micro-task AI pipeline
|
// src/utils/dataService.ts
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { load } from 'js-yaml';
|
import { load } from 'js-yaml';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// src/utils/remarkVideoPlugin.ts - SIMPLIFIED: Basic video and iframe enhancement only
|
// src/utils/remarkVideoPlugin.ts
|
||||||
import { visit } from 'unist-util-visit';
|
import { visit } from 'unist-util-visit';
|
||||||
import type { Plugin } from 'unified';
|
import type { Plugin } from 'unified';
|
||||||
import type { Root } from 'hast';
|
import type { Root } from 'hast';
|
||||||
@ -16,7 +16,6 @@ function escapeHtml(unsafe: string): string {
|
|||||||
|
|
||||||
export const remarkVideoPlugin: Plugin<[], Root> = () => {
|
export const remarkVideoPlugin: Plugin<[], Root> = () => {
|
||||||
return (tree: Root) => {
|
return (tree: Root) => {
|
||||||
// Process video tags
|
|
||||||
visit(tree, 'html', (node: any, index: number | undefined, parent: any) => {
|
visit(tree, 'html', (node: any, index: number | undefined, parent: any) => {
|
||||||
if (node.value && node.value.includes('<video') && typeof index === 'number') {
|
if (node.value && node.value.includes('<video') && typeof index === 'number') {
|
||||||
const srcMatch = node.value.match(/src=["']([^"']+)["']/);
|
const srcMatch = node.value.match(/src=["']([^"']+)["']/);
|
||||||
@ -26,14 +25,12 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
|
|||||||
const originalSrc = srcMatch[1];
|
const originalSrc = srcMatch[1];
|
||||||
const title = titleMatch?.[1] || 'Video';
|
const title = titleMatch?.[1] || 'Video';
|
||||||
|
|
||||||
// Extract existing attributes
|
|
||||||
const hasControls = node.value.includes('controls');
|
const hasControls = node.value.includes('controls');
|
||||||
const hasAutoplay = node.value.includes('autoplay');
|
const hasAutoplay = node.value.includes('autoplay');
|
||||||
const hasMuted = node.value.includes('muted');
|
const hasMuted = node.value.includes('muted');
|
||||||
const hasLoop = node.value.includes('loop');
|
const hasLoop = node.value.includes('loop');
|
||||||
const preloadMatch = node.value.match(/preload=["']([^"']+)["']/);
|
const preloadMatch = node.value.match(/preload=["']([^"']+)["']/);
|
||||||
|
|
||||||
// Create enhanced video with responsive wrapper
|
|
||||||
const enhancedHTML = `
|
const enhancedHTML = `
|
||||||
<div class="video-container">
|
<div class="video-container">
|
||||||
<video
|
<video
|
||||||
@ -60,10 +57,8 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process all iframes with consistent styling
|
|
||||||
if (node.value && node.value.includes('<iframe') && typeof index === 'number' && parent) {
|
if (node.value && node.value.includes('<iframe') && typeof index === 'number' && parent) {
|
||||||
|
|
||||||
// Skip if already wrapped in video-container to prevent double-wrapping
|
|
||||||
if (node.value.includes('video-container')) {
|
if (node.value.includes('video-container')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -71,7 +66,6 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
|
|||||||
const titleMatch = node.value.match(/title=["']([^"']+)["']/);
|
const titleMatch = node.value.match(/title=["']([^"']+)["']/);
|
||||||
const title = titleMatch?.[1] || 'Embedded Video';
|
const title = titleMatch?.[1] || 'Embedded Video';
|
||||||
|
|
||||||
// Wrap iframe in simple responsive container
|
|
||||||
const enhancedHTML = `
|
const enhancedHTML = `
|
||||||
<div class="video-container">
|
<div class="video-container">
|
||||||
${node.value}
|
${node.value}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user