Anshul Prasad commited on
Commit ·
6f90cba
1
Parent(s): 2f8e4be
remove google loging support for now.
Browse files- Dockerfile +1 -12
- app/guru_app/{static/guru/index.html → index.html} +0 -0
- app/guru_app/static/guru/images/image1.webp +0 -3
- app/guru_app/templates/account/login.html +0 -201
- app/guru_app/templates/guru/index.html +0 -519
- app/guru_app/templates/guru/login.html +0 -1
- app/guru_app/views.py +16 -39
- app/guru_project/settings.py +10 -51
- manage.py +0 -6
Dockerfile
CHANGED
|
@@ -31,15 +31,4 @@ WORKDIR /app
|
|
| 31 |
# HF Spaces requires port 7860
|
| 32 |
EXPOSE 7860
|
| 33 |
|
| 34 |
-
CMD ["
|
| 35 |
-
PYTHONPATH=/app/app python manage.py migrate --run-syncdb && \
|
| 36 |
-
PYTHONPATH=/app/app python manage.py shell -c \"\
|
| 37 |
-
import os; \
|
| 38 |
-
from django.contrib.auth import get_user_model; \
|
| 39 |
-
User = get_user_model(); \
|
| 40 |
-
email = os.environ.get('ADMIN_EMAIL','admin@example.com'); \
|
| 41 |
-
password = os.environ.get('ADMIN_PASSWORD','changeme123'); \
|
| 42 |
-
User.objects.filter(username='admin').exists() or User.objects.create_superuser('admin', email, password); \
|
| 43 |
-
\" && \
|
| 44 |
-
PYTHONPATH=/app/app gunicorn guru_project.wsgi:application --bind 0.0.0.0:7860 --workers 2 --timeout 120 \
|
| 45 |
-
"]
|
|
|
|
| 31 |
# HF Spaces requires port 7860
|
| 32 |
EXPOSE 7860
|
| 33 |
|
| 34 |
+
CMD ["gunicorn", "guru_project.wsgi:application", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/guru_app/{static/guru/index.html → index.html}
RENAMED
|
File without changes
|
app/guru_app/static/guru/images/image1.webp
DELETED
Git LFS Details
|
app/guru_app/templates/account/login.html
DELETED
|
@@ -1,201 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8"/>
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
-
<title>Sign In — Ask the Guru</title>
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300&family=Jost:wght@300;400;500&display=swap" rel="stylesheet"/>
|
| 8 |
-
<style>
|
| 9 |
-
:root {
|
| 10 |
-
--bg: #faf7f2;
|
| 11 |
-
--surface: #ffffff;
|
| 12 |
-
--border: #e8e0d4;
|
| 13 |
-
--text: #2c2416;
|
| 14 |
-
--muted: #8c7b6b;
|
| 15 |
-
--accent: #b5732a;
|
| 16 |
-
--gold: #c9a84c;
|
| 17 |
-
--radius: 16px;
|
| 18 |
-
--shadow: 0 8px 40px rgba(44,36,22,0.10);
|
| 19 |
-
}
|
| 20 |
-
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
| 21 |
-
|
| 22 |
-
body {
|
| 23 |
-
background: var(--bg);
|
| 24 |
-
color: var(--text);
|
| 25 |
-
font-family: 'Jost', sans-serif;
|
| 26 |
-
min-height: 100vh;
|
| 27 |
-
display: flex;
|
| 28 |
-
align-items: center;
|
| 29 |
-
justify-content: center;
|
| 30 |
-
padding: 1rem;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
body::before {
|
| 34 |
-
content: '';
|
| 35 |
-
position: fixed;
|
| 36 |
-
top: -150px; right: -150px;
|
| 37 |
-
width: 500px; height: 500px;
|
| 38 |
-
background: radial-gradient(circle, rgba(201,168,76,0.1) 0%, transparent 70%);
|
| 39 |
-
border-radius: 50%;
|
| 40 |
-
pointer-events: none;
|
| 41 |
-
}
|
| 42 |
-
body::after {
|
| 43 |
-
content: '';
|
| 44 |
-
position: fixed;
|
| 45 |
-
bottom: -150px; left: -150px;
|
| 46 |
-
width: 400px; height: 400px;
|
| 47 |
-
background: radial-gradient(circle, rgba(181,115,42,0.07) 0%, transparent 70%);
|
| 48 |
-
border-radius: 50%;
|
| 49 |
-
pointer-events: none;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
.card {
|
| 53 |
-
background: var(--surface);
|
| 54 |
-
border: 1px solid var(--border);
|
| 55 |
-
border-radius: var(--radius);
|
| 56 |
-
box-shadow: var(--shadow);
|
| 57 |
-
padding: 3rem 2.5rem;
|
| 58 |
-
max-width: 420px;
|
| 59 |
-
width: 100%;
|
| 60 |
-
text-align: center;
|
| 61 |
-
position: relative;
|
| 62 |
-
z-index: 1;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
.guru-image-wrap {
|
| 66 |
-
position: relative;
|
| 67 |
-
display: inline-block;
|
| 68 |
-
margin-bottom: 1.5rem;
|
| 69 |
-
}
|
| 70 |
-
.guru-image-wrap::before {
|
| 71 |
-
content: '';
|
| 72 |
-
position: absolute;
|
| 73 |
-
inset: -6px;
|
| 74 |
-
border-radius: 50%;
|
| 75 |
-
background: conic-gradient(from 0deg, var(--gold), var(--accent), var(--gold), #7a4f2d, var(--gold));
|
| 76 |
-
animation: spin 12s linear infinite;
|
| 77 |
-
opacity: 0.45;
|
| 78 |
-
}
|
| 79 |
-
@keyframes spin { to { transform: rotate(360deg); } }
|
| 80 |
-
|
| 81 |
-
.guru-img {
|
| 82 |
-
position: relative;
|
| 83 |
-
width: 90px; height: 90px;
|
| 84 |
-
border-radius: 50%;
|
| 85 |
-
object-fit: cover;
|
| 86 |
-
border: 3px solid var(--bg);
|
| 87 |
-
display: block;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
h1 {
|
| 91 |
-
font-family: 'Cormorant Garamond', serif;
|
| 92 |
-
font-size: 2.2rem;
|
| 93 |
-
font-weight: 300;
|
| 94 |
-
color: var(--text);
|
| 95 |
-
margin-bottom: 0.4rem;
|
| 96 |
-
}
|
| 97 |
-
.tagline {
|
| 98 |
-
font-size: 0.8rem;
|
| 99 |
-
color: var(--muted);
|
| 100 |
-
letter-spacing: 0.1em;
|
| 101 |
-
text-transform: uppercase;
|
| 102 |
-
margin-bottom: 2.5rem;
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
.divider {
|
| 106 |
-
display: flex;
|
| 107 |
-
align-items: center;
|
| 108 |
-
gap: 0.75rem;
|
| 109 |
-
margin-bottom: 2rem;
|
| 110 |
-
}
|
| 111 |
-
.divider::before, .divider::after {
|
| 112 |
-
content: '';
|
| 113 |
-
flex: 1;
|
| 114 |
-
height: 1px;
|
| 115 |
-
background: linear-gradient(to right, transparent, var(--gold), transparent);
|
| 116 |
-
}
|
| 117 |
-
.divider span { color: var(--gold); font-size: 1rem; }
|
| 118 |
-
|
| 119 |
-
.signin-text {
|
| 120 |
-
font-size: 0.85rem;
|
| 121 |
-
color: var(--muted);
|
| 122 |
-
margin-bottom: 1.25rem;
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
/* Google button */
|
| 126 |
-
.btn-google {
|
| 127 |
-
display: flex;
|
| 128 |
-
align-items: center;
|
| 129 |
-
justify-content: center;
|
| 130 |
-
gap: 0.75rem;
|
| 131 |
-
width: 100%;
|
| 132 |
-
padding: 0.9rem 1.5rem;
|
| 133 |
-
background: var(--surface);
|
| 134 |
-
border: 1.5px solid var(--border);
|
| 135 |
-
border-radius: 10px;
|
| 136 |
-
font-family: 'Jost', sans-serif;
|
| 137 |
-
font-size: 0.95rem;
|
| 138 |
-
font-weight: 500;
|
| 139 |
-
color: var(--text);
|
| 140 |
-
cursor: pointer;
|
| 141 |
-
text-decoration: none;
|
| 142 |
-
transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
|
| 143 |
-
}
|
| 144 |
-
.btn-google:hover {
|
| 145 |
-
border-color: var(--gold);
|
| 146 |
-
box-shadow: 0 4px 16px rgba(201,168,76,0.15);
|
| 147 |
-
transform: translateY(-1px);
|
| 148 |
-
}
|
| 149 |
-
.btn-google svg { width: 20px; height: 20px; flex-shrink: 0; }
|
| 150 |
-
|
| 151 |
-
.footer-note {
|
| 152 |
-
margin-top: 2rem;
|
| 153 |
-
font-size: 0.72rem;
|
| 154 |
-
color: var(--muted);
|
| 155 |
-
line-height: 1.6;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
.om {
|
| 159 |
-
font-size: 1.5rem;
|
| 160 |
-
color: var(--gold);
|
| 161 |
-
margin-top: 1.5rem;
|
| 162 |
-
display: block;
|
| 163 |
-
}
|
| 164 |
-
</style>
|
| 165 |
-
</head>
|
| 166 |
-
<body>
|
| 167 |
-
<div class="card">
|
| 168 |
-
{% load static %}
|
| 169 |
-
<div class="guru-image-wrap">
|
| 170 |
-
<img class="guru-img" src="{% static 'guru/images/image1.webp' %}" alt="Guru"
|
| 171 |
-
onerror="this.style.display='none'"/>
|
| 172 |
-
</div>
|
| 173 |
-
|
| 174 |
-
<h1>Ask the Guru</h1>
|
| 175 |
-
<p class="tagline">Advaita Vedanta · Self-Knowledge</p>
|
| 176 |
-
|
| 177 |
-
<div class="divider"><span>✦</span></div>
|
| 178 |
-
|
| 179 |
-
<p class="signin-text">Sign in to begin your inquiry</p>
|
| 180 |
-
|
| 181 |
-
{% load socialaccount %}
|
| 182 |
-
<a class="btn-google" href="{% provider_login_url 'google' %}">
|
| 183 |
-
<!-- Google G logo SVG -->
|
| 184 |
-
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
| 185 |
-
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
|
| 186 |
-
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
|
| 187 |
-
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/>
|
| 188 |
-
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
|
| 189 |
-
</svg>
|
| 190 |
-
Continue with Google
|
| 191 |
-
</a>
|
| 192 |
-
|
| 193 |
-
<p class="footer-note">
|
| 194 |
-
Your questions and answers are private to your session.<br/>
|
| 195 |
-
We do not store your conversations permanently.
|
| 196 |
-
</p>
|
| 197 |
-
|
| 198 |
-
<span class="om">ॐ</span>
|
| 199 |
-
</div>
|
| 200 |
-
</body>
|
| 201 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/guru_app/templates/guru/index.html
DELETED
|
@@ -1,519 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8"/>
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
-
<title>Ask the Guru</title>
|
| 7 |
-
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Jost:wght@300;400;500&display=swap" rel="stylesheet"/>
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--bg: #faf7f2;
|
| 12 |
-
--surface: #ffffff;
|
| 13 |
-
--border: #e8e0d4;
|
| 14 |
-
--text: #2c2416;
|
| 15 |
-
--muted: #8c7b6b;
|
| 16 |
-
--accent: #b5732a;
|
| 17 |
-
--accent2: #7a4f2d;
|
| 18 |
-
--gold: #c9a84c;
|
| 19 |
-
--answer-bg: #f5f0e8;
|
| 20 |
-
--radius: 16px;
|
| 21 |
-
--shadow: 0 4px 32px rgba(44,36,22,0.08);
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
| 25 |
-
|
| 26 |
-
body {
|
| 27 |
-
background: var(--bg);
|
| 28 |
-
color: var(--text);
|
| 29 |
-
font-family: 'Jost', sans-serif;
|
| 30 |
-
min-height: 100vh;
|
| 31 |
-
display: flex;
|
| 32 |
-
flex-direction: column;
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
/* ── Mandala Background ── */
|
| 36 |
-
body::before {
|
| 37 |
-
content: '';
|
| 38 |
-
position: fixed;
|
| 39 |
-
top: -200px; right: -200px;
|
| 40 |
-
width: 600px; height: 600px;
|
| 41 |
-
background: radial-gradient(circle, rgba(201,168,76,0.08) 0%, transparent 70%);
|
| 42 |
-
border-radius: 50%;
|
| 43 |
-
pointer-events: none;
|
| 44 |
-
z-index: 0;
|
| 45 |
-
}
|
| 46 |
-
body::after {
|
| 47 |
-
content: '';
|
| 48 |
-
position: fixed;
|
| 49 |
-
bottom: -200px; left: -200px;
|
| 50 |
-
width: 500px; height: 500px;
|
| 51 |
-
background: radial-gradient(circle, rgba(181,115,42,0.06) 0%, transparent 70%);
|
| 52 |
-
border-radius: 50%;
|
| 53 |
-
pointer-events: none;
|
| 54 |
-
z-index: 0;
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
/* ── User Bar ── */
|
| 58 |
-
.user-bar {
|
| 59 |
-
display: flex;
|
| 60 |
-
align-items: center;
|
| 61 |
-
justify-content: space-between;
|
| 62 |
-
padding: 0.6rem 1.5rem;
|
| 63 |
-
background: var(--surface);
|
| 64 |
-
border-bottom: 1px solid var(--border);
|
| 65 |
-
position: absolute;
|
| 66 |
-
top: 0; left: 0; right: 0;
|
| 67 |
-
}
|
| 68 |
-
.user-info {
|
| 69 |
-
display: flex;
|
| 70 |
-
align-items: center;
|
| 71 |
-
gap: 0.6rem;
|
| 72 |
-
}
|
| 73 |
-
.user-avatar {
|
| 74 |
-
width: 30px; height: 30px;
|
| 75 |
-
border-radius: 50%;
|
| 76 |
-
object-fit: cover;
|
| 77 |
-
border: 1.5px solid var(--gold);
|
| 78 |
-
}
|
| 79 |
-
.user-avatar-placeholder {
|
| 80 |
-
width: 30px; height: 30px;
|
| 81 |
-
border-radius: 50%;
|
| 82 |
-
background: linear-gradient(135deg, var(--accent), var(--gold));
|
| 83 |
-
color: #fff;
|
| 84 |
-
font-size: 0.8rem;
|
| 85 |
-
font-weight: 600;
|
| 86 |
-
display: flex;
|
| 87 |
-
align-items: center;
|
| 88 |
-
justify-content: center;
|
| 89 |
-
}
|
| 90 |
-
.user-name {
|
| 91 |
-
font-size: 0.82rem;
|
| 92 |
-
color: var(--muted);
|
| 93 |
-
}
|
| 94 |
-
.btn-logout {
|
| 95 |
-
font-size: 0.72rem;
|
| 96 |
-
letter-spacing: 0.08em;
|
| 97 |
-
text-transform: uppercase;
|
| 98 |
-
color: var(--muted);
|
| 99 |
-
text-decoration: none;
|
| 100 |
-
border: 1px solid var(--border);
|
| 101 |
-
border-radius: 6px;
|
| 102 |
-
padding: 0.3rem 0.7rem;
|
| 103 |
-
transition: border-color 0.2s, color 0.2s;
|
| 104 |
-
}
|
| 105 |
-
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }
|
| 106 |
-
|
| 107 |
-
/* ── Header ── */
|
| 108 |
-
header {
|
| 109 |
-
position: relative;
|
| 110 |
-
z-index: 1;
|
| 111 |
-
text-align: center;
|
| 112 |
-
padding: 5rem 1rem 2rem;
|
| 113 |
-
border-bottom: 1px solid var(--border);
|
| 114 |
-
background: linear-gradient(180deg, #fff8ee 0%, var(--bg) 100%);
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
.guru-image-wrap {
|
| 118 |
-
position: relative;
|
| 119 |
-
display: inline-block;
|
| 120 |
-
margin-bottom: 1.25rem;
|
| 121 |
-
}
|
| 122 |
-
.guru-image-wrap::before {
|
| 123 |
-
content: '';
|
| 124 |
-
position: absolute;
|
| 125 |
-
inset: -8px;
|
| 126 |
-
border-radius: 50%;
|
| 127 |
-
background: conic-gradient(from 0deg, var(--gold), var(--accent), var(--gold), var(--accent2), var(--gold));
|
| 128 |
-
animation: halo-spin 12s linear infinite;
|
| 129 |
-
opacity: 0.5;
|
| 130 |
-
}
|
| 131 |
-
@keyframes halo-spin { to { transform: rotate(360deg); } }
|
| 132 |
-
|
| 133 |
-
.guru-image {
|
| 134 |
-
position: relative;
|
| 135 |
-
width: 110px; height: 110px;
|
| 136 |
-
border-radius: 50%;
|
| 137 |
-
object-fit: cover;
|
| 138 |
-
border: 3px solid var(--bg);
|
| 139 |
-
display: block;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
header h1 {
|
| 143 |
-
font-family: 'Cormorant Garamond', serif;
|
| 144 |
-
font-size: clamp(2rem, 5vw, 3rem);
|
| 145 |
-
font-weight: 300;
|
| 146 |
-
letter-spacing: 0.04em;
|
| 147 |
-
color: var(--text);
|
| 148 |
-
}
|
| 149 |
-
header p {
|
| 150 |
-
font-size: 0.9rem;
|
| 151 |
-
color: var(--muted);
|
| 152 |
-
margin-top: 0.4rem;
|
| 153 |
-
letter-spacing: 0.08em;
|
| 154 |
-
text-transform: uppercase;
|
| 155 |
-
font-weight: 300;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
/* ── Divider ── */
|
| 159 |
-
.divider {
|
| 160 |
-
display: flex;
|
| 161 |
-
align-items: center;
|
| 162 |
-
gap: 1rem;
|
| 163 |
-
padding: 0 2rem;
|
| 164 |
-
margin: 1.5rem 0;
|
| 165 |
-
}
|
| 166 |
-
.divider::before, .divider::after {
|
| 167 |
-
content: '';
|
| 168 |
-
flex: 1;
|
| 169 |
-
height: 1px;
|
| 170 |
-
background: linear-gradient(to right, transparent, var(--gold), transparent);
|
| 171 |
-
}
|
| 172 |
-
.divider span {
|
| 173 |
-
font-size: 1.2rem;
|
| 174 |
-
color: var(--gold);
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
/* ── Main Layout ── */
|
| 178 |
-
main {
|
| 179 |
-
position: relative;
|
| 180 |
-
z-index: 1;
|
| 181 |
-
max-width: 800px;
|
| 182 |
-
width: 100%;
|
| 183 |
-
margin: 0 auto;
|
| 184 |
-
padding: 2rem 1rem 4rem;
|
| 185 |
-
flex: 1;
|
| 186 |
-
display: flex;
|
| 187 |
-
flex-direction: column;
|
| 188 |
-
gap: 1.5rem;
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
/* ── Input Card ── */
|
| 192 |
-
.input-card {
|
| 193 |
-
background: var(--surface);
|
| 194 |
-
border: 1px solid var(--border);
|
| 195 |
-
border-radius: var(--radius);
|
| 196 |
-
box-shadow: var(--shadow);
|
| 197 |
-
padding: 1.5rem;
|
| 198 |
-
}
|
| 199 |
-
.input-card label {
|
| 200 |
-
display: block;
|
| 201 |
-
font-size: 0.75rem;
|
| 202 |
-
letter-spacing: 0.12em;
|
| 203 |
-
text-transform: uppercase;
|
| 204 |
-
color: var(--muted);
|
| 205 |
-
margin-bottom: 0.75rem;
|
| 206 |
-
}
|
| 207 |
-
.input-row {
|
| 208 |
-
display: flex;
|
| 209 |
-
gap: 0.75rem;
|
| 210 |
-
}
|
| 211 |
-
.input-row input {
|
| 212 |
-
flex: 1;
|
| 213 |
-
padding: 0.85rem 1.1rem;
|
| 214 |
-
font-family: 'Jost', sans-serif;
|
| 215 |
-
font-size: 1rem;
|
| 216 |
-
background: var(--bg);
|
| 217 |
-
border: 1px solid var(--border);
|
| 218 |
-
border-radius: 10px;
|
| 219 |
-
color: var(--text);
|
| 220 |
-
transition: border-color 0.2s, box-shadow 0.2s;
|
| 221 |
-
}
|
| 222 |
-
.input-row input::placeholder { color: var(--muted); }
|
| 223 |
-
.input-row input:focus {
|
| 224 |
-
outline: none;
|
| 225 |
-
border-color: var(--gold);
|
| 226 |
-
box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
|
| 227 |
-
}
|
| 228 |
-
.btn-ask {
|
| 229 |
-
padding: 0.85rem 1.5rem;
|
| 230 |
-
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
| 231 |
-
color: #fff;
|
| 232 |
-
border: none;
|
| 233 |
-
border-radius: 10px;
|
| 234 |
-
font-family: 'Jost', sans-serif;
|
| 235 |
-
font-size: 0.9rem;
|
| 236 |
-
font-weight: 500;
|
| 237 |
-
letter-spacing: 0.05em;
|
| 238 |
-
cursor: pointer;
|
| 239 |
-
transition: opacity 0.2s, transform 0.1s;
|
| 240 |
-
white-space: nowrap;
|
| 241 |
-
}
|
| 242 |
-
.btn-ask:hover { opacity: 0.88; transform: translateY(-1px); }
|
| 243 |
-
.btn-ask:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
| 244 |
-
|
| 245 |
-
/* ── Answer Box ── */
|
| 246 |
-
.answer-card {
|
| 247 |
-
background: var(--answer-bg);
|
| 248 |
-
border: 1px solid var(--border);
|
| 249 |
-
border-left: 3px solid var(--gold);
|
| 250 |
-
border-radius: var(--radius);
|
| 251 |
-
padding: 1.5rem;
|
| 252 |
-
display: none;
|
| 253 |
-
animation: fade-in 0.4s ease;
|
| 254 |
-
}
|
| 255 |
-
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
| 256 |
-
|
| 257 |
-
.answer-card.visible { display: block; }
|
| 258 |
-
.answer-label {
|
| 259 |
-
font-size: 0.7rem;
|
| 260 |
-
letter-spacing: 0.14em;
|
| 261 |
-
text-transform: uppercase;
|
| 262 |
-
color: var(--gold);
|
| 263 |
-
margin-bottom: 0.75rem;
|
| 264 |
-
font-weight: 500;
|
| 265 |
-
}
|
| 266 |
-
.answer-text {
|
| 267 |
-
font-family: 'Cormorant Garamond', serif;
|
| 268 |
-
font-size: 1.2rem;
|
| 269 |
-
line-height: 1.85;
|
| 270 |
-
color: var(--text);
|
| 271 |
-
}
|
| 272 |
-
.answer-text p { margin-bottom: 0.75rem; }
|
| 273 |
-
.answer-text p:last-child { margin-bottom: 0; }
|
| 274 |
-
|
| 275 |
-
/* Loading dots */
|
| 276 |
-
.dots span {
|
| 277 |
-
display: inline-block;
|
| 278 |
-
width: 6px; height: 6px;
|
| 279 |
-
border-radius: 50%;
|
| 280 |
-
background: var(--gold);
|
| 281 |
-
margin: 0 2px;
|
| 282 |
-
animation: dot-bounce 1.2s infinite ease-in-out;
|
| 283 |
-
}
|
| 284 |
-
.dots span:nth-child(2) { animation-delay: 0.2s; }
|
| 285 |
-
.dots span:nth-child(3) { animation-delay: 0.4s; }
|
| 286 |
-
@keyframes dot-bounce {
|
| 287 |
-
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
| 288 |
-
40% { transform: scale(1); opacity: 1; }
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
/* ── History Section ── */
|
| 292 |
-
.history-header {
|
| 293 |
-
display: flex;
|
| 294 |
-
align-items: center;
|
| 295 |
-
justify-content: space-between;
|
| 296 |
-
margin-top: 1rem;
|
| 297 |
-
}
|
| 298 |
-
.history-header h2 {
|
| 299 |
-
font-family: 'Cormorant Garamond', serif;
|
| 300 |
-
font-size: 1.3rem;
|
| 301 |
-
font-weight: 400;
|
| 302 |
-
color: var(--muted);
|
| 303 |
-
}
|
| 304 |
-
.btn-clear {
|
| 305 |
-
font-size: 0.75rem;
|
| 306 |
-
letter-spacing: 0.08em;
|
| 307 |
-
text-transform: uppercase;
|
| 308 |
-
background: none;
|
| 309 |
-
border: 1px solid var(--border);
|
| 310 |
-
border-radius: 6px;
|
| 311 |
-
padding: 0.35rem 0.8rem;
|
| 312 |
-
color: var(--muted);
|
| 313 |
-
cursor: pointer;
|
| 314 |
-
font-family: 'Jost', sans-serif;
|
| 315 |
-
transition: border-color 0.2s, color 0.2s;
|
| 316 |
-
}
|
| 317 |
-
.btn-clear:hover { border-color: var(--accent); color: var(--accent); }
|
| 318 |
-
|
| 319 |
-
.history-list {
|
| 320 |
-
display: flex;
|
| 321 |
-
flex-direction: column;
|
| 322 |
-
gap: 1rem;
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
.history-item {
|
| 326 |
-
background: var(--surface);
|
| 327 |
-
border: 1px solid var(--border);
|
| 328 |
-
border-radius: var(--radius);
|
| 329 |
-
padding: 1.25rem 1.5rem;
|
| 330 |
-
animation: fade-in 0.3s ease;
|
| 331 |
-
}
|
| 332 |
-
.history-item .q {
|
| 333 |
-
font-size: 0.82rem;
|
| 334 |
-
font-weight: 500;
|
| 335 |
-
letter-spacing: 0.04em;
|
| 336 |
-
color: var(--accent);
|
| 337 |
-
margin-bottom: 0.5rem;
|
| 338 |
-
}
|
| 339 |
-
.history-item .q span {
|
| 340 |
-
color: var(--muted);
|
| 341 |
-
font-weight: 300;
|
| 342 |
-
margin-left: 0.5rem;
|
| 343 |
-
}
|
| 344 |
-
.history-item .a {
|
| 345 |
-
font-family: 'Cormorant Garamond', serif;
|
| 346 |
-
font-size: 1.1rem;
|
| 347 |
-
line-height: 1.75;
|
| 348 |
-
color: var(--text);
|
| 349 |
-
}
|
| 350 |
-
.history-item .a p { margin-bottom: 0.4rem; }
|
| 351 |
-
.history-item .a p:last-child { margin-bottom: 0; }
|
| 352 |
-
|
| 353 |
-
.no-history {
|
| 354 |
-
text-align: center;
|
| 355 |
-
color: var(--muted);
|
| 356 |
-
font-size: 0.9rem;
|
| 357 |
-
padding: 2rem;
|
| 358 |
-
font-style: italic;
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
/* ── Footer ── */
|
| 362 |
-
footer {
|
| 363 |
-
position: relative;
|
| 364 |
-
z-index: 1;
|
| 365 |
-
text-align: center;
|
| 366 |
-
padding: 1.5rem;
|
| 367 |
-
border-top: 1px solid var(--border);
|
| 368 |
-
font-size: 0.78rem;
|
| 369 |
-
color: var(--muted);
|
| 370 |
-
letter-spacing: 0.05em;
|
| 371 |
-
}
|
| 372 |
-
|
| 373 |
-
@media (max-width: 480px) {
|
| 374 |
-
.input-row { flex-direction: column; }
|
| 375 |
-
.btn-ask { width: 100%; }
|
| 376 |
-
header { padding: 2rem 1rem 1.5rem; }
|
| 377 |
-
}
|
| 378 |
-
</style>
|
| 379 |
-
</head>
|
| 380 |
-
<body>
|
| 381 |
-
|
| 382 |
-
<header>
|
| 383 |
-
{% load static %}
|
| 384 |
-
<!-- User bar -->
|
| 385 |
-
<div class="user-bar">
|
| 386 |
-
<div class="user-info">
|
| 387 |
-
{% if avatar_url %}
|
| 388 |
-
<img class="user-avatar" src="{{ avatar_url }}" alt="{{ user.first_name }}"/>
|
| 389 |
-
{% else %}
|
| 390 |
-
<div class="user-avatar-placeholder">{{ user.first_name|first|upper }}</div>
|
| 391 |
-
{% endif %}
|
| 392 |
-
<span class="user-name">{{ user.first_name }} {{ user.last_name }}</span>
|
| 393 |
-
</div>
|
| 394 |
-
<a class="btn-logout" href="/accounts/logout/">Sign Out</a>
|
| 395 |
-
</div>
|
| 396 |
-
|
| 397 |
-
<div class="guru-image-wrap">
|
| 398 |
-
<img class="guru-image" src="{% static 'guru/images/image1.webp' %}" alt="Spiritual Guru" onerror="this.style.display='none'"/>
|
| 399 |
-
</div>
|
| 400 |
-
<h1>Ask the Guru</h1>
|
| 401 |
-
<p>Advaita Vedanta · Inner Inquiry · Self-Knowledge</p>
|
| 402 |
-
</header>
|
| 403 |
-
|
| 404 |
-
<main>
|
| 405 |
-
<div class="divider"><span>✦</span></div>
|
| 406 |
-
|
| 407 |
-
<!-- Input -->
|
| 408 |
-
<div class="input-card">
|
| 409 |
-
<label>Your Question</label>
|
| 410 |
-
<div class="input-row">
|
| 411 |
-
<input type="text" id="question" placeholder="What is the nature of the self?" autocomplete="off"
|
| 412 |
-
onkeydown="if(event.key==='Enter') ask()"/>
|
| 413 |
-
<button class="btn-ask" id="ask-btn" onclick="ask()">Ask</button>
|
| 414 |
-
</div>
|
| 415 |
-
</div>
|
| 416 |
-
|
| 417 |
-
<!-- Live Answer -->
|
| 418 |
-
<div class="answer-card" id="answer-card">
|
| 419 |
-
<div class="answer-label">✦ The Guru Speaks</div>
|
| 420 |
-
<div class="answer-text" id="answer-text"></div>
|
| 421 |
-
</div>
|
| 422 |
-
|
| 423 |
-
<!-- History -->
|
| 424 |
-
<div class="history-header">
|
| 425 |
-
<h2>Previous Inquiries</h2>
|
| 426 |
-
<button class="btn-clear" onclick="clearHistory()">Clear All</button>
|
| 427 |
-
</div>
|
| 428 |
-
|
| 429 |
-
<div class="history-list" id="history-list">
|
| 430 |
-
{% if history %}
|
| 431 |
-
{% for item in history reversed %}
|
| 432 |
-
<div class="history-item">
|
| 433 |
-
<div class="q">{{ item.query }}<span>{{ item.timestamp }}</span></div>
|
| 434 |
-
<div class="a" data-answer="{{ item.answer|escapejs }}"></div>
|
| 435 |
-
</div>
|
| 436 |
-
{% endfor %}
|
| 437 |
-
{% else %}
|
| 438 |
-
<div class="no-history" id="no-history">Your inquiries will appear here.</div>
|
| 439 |
-
{% endif %}
|
| 440 |
-
</div>
|
| 441 |
-
</main>
|
| 442 |
-
|
| 443 |
-
<footer>
|
| 444 |
-
॥ सत्यमेव जयते ॥ · Truth alone prevails
|
| 445 |
-
</footer>
|
| 446 |
-
|
| 447 |
-
<script>
|
| 448 |
-
// Render markdown in history items on load
|
| 449 |
-
document.querySelectorAll('.history-item .a[data-answer]').forEach(el => {
|
| 450 |
-
el.innerHTML = marked.parse(el.dataset.answer);
|
| 451 |
-
});
|
| 452 |
-
|
| 453 |
-
async function ask() {
|
| 454 |
-
const input = document.getElementById('question');
|
| 455 |
-
const btn = document.getElementById('ask-btn');
|
| 456 |
-
const card = document.getElementById('answer-card');
|
| 457 |
-
const box = document.getElementById('answer-text');
|
| 458 |
-
const q = input.value.trim();
|
| 459 |
-
|
| 460 |
-
if (!q) {
|
| 461 |
-
box.innerHTML = '<span style="color:#c0392b">Please enter a question.</span>';
|
| 462 |
-
card.classList.add('visible');
|
| 463 |
-
return;
|
| 464 |
-
}
|
| 465 |
-
|
| 466 |
-
btn.disabled = true;
|
| 467 |
-
card.classList.add('visible');
|
| 468 |
-
box.innerHTML = '<div class="dots"><span></span><span></span><span></span></div>';
|
| 469 |
-
|
| 470 |
-
try {
|
| 471 |
-
const res = await fetch('/ask/', {
|
| 472 |
-
method: 'POST',
|
| 473 |
-
headers: { 'Content-Type': 'application/json' },
|
| 474 |
-
body: JSON.stringify({ query: q })
|
| 475 |
-
});
|
| 476 |
-
const data = await res.json();
|
| 477 |
-
|
| 478 |
-
if (data.answer) {
|
| 479 |
-
box.innerHTML = marked.parse(data.answer);
|
| 480 |
-
// Prepend to history
|
| 481 |
-
addToHistory(data.query, data.answer, data.timestamp);
|
| 482 |
-
input.value = '';
|
| 483 |
-
} else {
|
| 484 |
-
box.innerHTML = `<span style="color:#c0392b">${data.error || 'No answer returned.'}</span>`;
|
| 485 |
-
}
|
| 486 |
-
} catch {
|
| 487 |
-
box.innerHTML = '<span style="color:#c0392b">Error contacting server. Please try again.</span>';
|
| 488 |
-
} finally {
|
| 489 |
-
btn.disabled = false;
|
| 490 |
-
}
|
| 491 |
-
}
|
| 492 |
-
|
| 493 |
-
function addToHistory(query, answer, timestamp) {
|
| 494 |
-
const list = document.getElementById('history-list');
|
| 495 |
-
const noHistory = document.getElementById('no-history');
|
| 496 |
-
if (noHistory) noHistory.remove();
|
| 497 |
-
|
| 498 |
-
const item = document.createElement('div');
|
| 499 |
-
item.className = 'history-item';
|
| 500 |
-
item.innerHTML = `
|
| 501 |
-
<div class="q">${escapeHtml(query)}<span>${timestamp}</span></div>
|
| 502 |
-
<div class="a">${marked.parse(answer)}</div>
|
| 503 |
-
`;
|
| 504 |
-
list.insertBefore(item, list.firstChild);
|
| 505 |
-
}
|
| 506 |
-
|
| 507 |
-
function escapeHtml(str) {
|
| 508 |
-
return str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
| 509 |
-
}
|
| 510 |
-
|
| 511 |
-
async function clearHistory() {
|
| 512 |
-
await fetch('/clear-history/', { method: 'POST' });
|
| 513 |
-
const list = document.getElementById('history-list');
|
| 514 |
-
list.innerHTML = '<div class="no-history" id="no-history">Your inquiries will appear here.</div>';
|
| 515 |
-
document.getElementById('answer-card').classList.remove('visible');
|
| 516 |
-
}
|
| 517 |
-
</script>
|
| 518 |
-
</body>
|
| 519 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/guru_app/templates/guru/login.html
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{% include "guru/login.html" %}
|
|
|
|
|
|
app/guru_app/views.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import sys
|
| 2 |
import json
|
| 3 |
import pickle
|
|
@@ -9,7 +10,6 @@ from django.shortcuts import render
|
|
| 9 |
from django.http import JsonResponse
|
| 10 |
from django.views.decorators.csrf import csrf_exempt
|
| 11 |
from django.views.decorators.http import require_http_methods
|
| 12 |
-
from django.contrib.auth.decorators import login_required
|
| 13 |
|
| 14 |
# Make sure project root is on path so config, api, utils are importable
|
| 15 |
BASE = Path(__file__).resolve().parent.parent
|
|
@@ -23,7 +23,7 @@ from utils.token import count_tokens, trim_to_token_limit
|
|
| 23 |
|
| 24 |
logger = logging.getLogger(__name__)
|
| 25 |
|
| 26 |
-
# ── Data loaded once at module import ──────────
|
| 27 |
_file_paths: list = []
|
| 28 |
_transcripts: list = []
|
| 29 |
_data_loaded = False
|
|
@@ -49,32 +49,20 @@ _load_data()
|
|
| 49 |
|
| 50 |
# ── Views ──────────────────────────────────────────────────────────────────────
|
| 51 |
|
| 52 |
-
@login_required
|
| 53 |
def index(request):
|
| 54 |
-
"""Render the main chat page
|
| 55 |
history = request.session.get('chat_history', [])
|
| 56 |
-
|
| 57 |
-
# Get Google profile picture if available
|
| 58 |
-
avatar_url = None
|
| 59 |
-
try:
|
| 60 |
-
social = user.socialaccount_set.filter(provider='google').first()
|
| 61 |
-
if social:
|
| 62 |
-
avatar_url = social.extra_data.get('picture')
|
| 63 |
-
except Exception:
|
| 64 |
-
pass
|
| 65 |
-
|
| 66 |
-
return render(request, 'guru/index.html', {
|
| 67 |
-
'history': history,
|
| 68 |
-
'user': user,
|
| 69 |
-
'avatar_url': avatar_url,
|
| 70 |
-
})
|
| 71 |
|
| 72 |
|
| 73 |
@csrf_exempt
|
| 74 |
-
@login_required
|
| 75 |
@require_http_methods(['POST'])
|
| 76 |
def ask(request):
|
| 77 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
try:
|
| 79 |
data = json.loads(request.body)
|
| 80 |
except json.JSONDecodeError:
|
|
@@ -85,7 +73,7 @@ def ask(request):
|
|
| 85 |
return JsonResponse({'error': 'Query cannot be empty'}, status=400)
|
| 86 |
|
| 87 |
if not _data_loaded:
|
| 88 |
-
return JsonResponse({'error': 'Transcript data not loaded.'}, status=503)
|
| 89 |
|
| 90 |
try:
|
| 91 |
retrieved = retrieve_transcripts(query, _file_paths, _transcripts, top_k=15)
|
|
@@ -96,27 +84,16 @@ def ask(request):
|
|
| 96 |
limited_context = trim_to_token_limit(full_context, MAX_CONTEXT_TOKENS)
|
| 97 |
answer = generate_response(query, limited_context)
|
| 98 |
|
| 99 |
-
logger.info('
|
| 100 |
-
request.user.email, query, count_tokens(limited_context))
|
| 101 |
-
|
| 102 |
-
# ── Save to database log ───────────────────────────────────────────────
|
| 103 |
-
try:
|
| 104 |
-
from app.guru_app.models import QueryLog
|
| 105 |
-
QueryLog.objects.create(
|
| 106 |
-
user=request.user,
|
| 107 |
-
query=query,
|
| 108 |
-
answer=answer,
|
| 109 |
-
tokens_used=count_tokens(limited_context),
|
| 110 |
-
)
|
| 111 |
-
except Exception as log_exc:
|
| 112 |
-
logger.warning('Failed to save query log: %s', log_exc)
|
| 113 |
|
|
|
|
| 114 |
history = request.session.get('chat_history', [])
|
| 115 |
history.append({
|
| 116 |
'query': query,
|
| 117 |
'answer': answer,
|
| 118 |
'timestamp': datetime.now().strftime('%d %b %Y, %H:%M'),
|
| 119 |
})
|
|
|
|
| 120 |
request.session['chat_history'] = history[-50:]
|
| 121 |
request.session.modified = True
|
| 122 |
|
|
@@ -128,19 +105,19 @@ def ask(request):
|
|
| 128 |
|
| 129 |
except Exception as exc:
|
| 130 |
logger.exception('Error processing query: %s', exc)
|
| 131 |
-
return JsonResponse({'error': 'Internal server error.'}, status=500)
|
| 132 |
|
| 133 |
|
| 134 |
-
@login_required
|
| 135 |
@require_http_methods(['GET'])
|
| 136 |
def history(request):
|
|
|
|
| 137 |
return JsonResponse({'history': request.session.get('chat_history', [])})
|
| 138 |
|
| 139 |
|
| 140 |
@csrf_exempt
|
| 141 |
-
@login_required
|
| 142 |
@require_http_methods(['POST'])
|
| 143 |
def clear_history(request):
|
|
|
|
| 144 |
request.session['chat_history'] = []
|
| 145 |
request.session.modified = True
|
| 146 |
return JsonResponse({'status': 'cleared'})
|
|
|
|
| 1 |
+
import os
|
| 2 |
import sys
|
| 3 |
import json
|
| 4 |
import pickle
|
|
|
|
| 10 |
from django.http import JsonResponse
|
| 11 |
from django.views.decorators.csrf import csrf_exempt
|
| 12 |
from django.views.decorators.http import require_http_methods
|
|
|
|
| 13 |
|
| 14 |
# Make sure project root is on path so config, api, utils are importable
|
| 15 |
BASE = Path(__file__).resolve().parent.parent
|
|
|
|
| 23 |
|
| 24 |
logger = logging.getLogger(__name__)
|
| 25 |
|
| 26 |
+
# ── Data loaded once at module import (same as FastAPI startup event) ──────────
|
| 27 |
_file_paths: list = []
|
| 28 |
_transcripts: list = []
|
| 29 |
_data_loaded = False
|
|
|
|
| 49 |
|
| 50 |
# ── Views ──────────────────────────────────────────────────────────────────────
|
| 51 |
|
|
|
|
| 52 |
def index(request):
|
| 53 |
+
"""Render the main chat page."""
|
| 54 |
history = request.session.get('chat_history', [])
|
| 55 |
+
return render(request, 'guru/index.html', {'history': history})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
@csrf_exempt
|
|
|
|
| 59 |
@require_http_methods(['POST'])
|
| 60 |
def ask(request):
|
| 61 |
+
"""
|
| 62 |
+
POST /ask/
|
| 63 |
+
Body: {"query": "..."}
|
| 64 |
+
Returns: {"answer": "...", "query": "...", "timestamp": "..."}
|
| 65 |
+
"""
|
| 66 |
try:
|
| 67 |
data = json.loads(request.body)
|
| 68 |
except json.JSONDecodeError:
|
|
|
|
| 73 |
return JsonResponse({'error': 'Query cannot be empty'}, status=400)
|
| 74 |
|
| 75 |
if not _data_loaded:
|
| 76 |
+
return JsonResponse({'error': 'Transcript data not loaded. Please check server logs.'}, status=503)
|
| 77 |
|
| 78 |
try:
|
| 79 |
retrieved = retrieve_transcripts(query, _file_paths, _transcripts, top_k=15)
|
|
|
|
| 84 |
limited_context = trim_to_token_limit(full_context, MAX_CONTEXT_TOKENS)
|
| 85 |
answer = generate_response(query, limited_context)
|
| 86 |
|
| 87 |
+
logger.info('Query: %s | Tokens: %d', query, count_tokens(limited_context))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
+
# ── Save to session chat history ───────────────────────────────────────
|
| 90 |
history = request.session.get('chat_history', [])
|
| 91 |
history.append({
|
| 92 |
'query': query,
|
| 93 |
'answer': answer,
|
| 94 |
'timestamp': datetime.now().strftime('%d %b %Y, %H:%M'),
|
| 95 |
})
|
| 96 |
+
# Keep last 50 exchanges
|
| 97 |
request.session['chat_history'] = history[-50:]
|
| 98 |
request.session.modified = True
|
| 99 |
|
|
|
|
| 105 |
|
| 106 |
except Exception as exc:
|
| 107 |
logger.exception('Error processing query: %s', exc)
|
| 108 |
+
return JsonResponse({'error': 'Internal server error. Please try again.'}, status=500)
|
| 109 |
|
| 110 |
|
|
|
|
| 111 |
@require_http_methods(['GET'])
|
| 112 |
def history(request):
|
| 113 |
+
"""GET /history/ — return full chat history as JSON."""
|
| 114 |
return JsonResponse({'history': request.session.get('chat_history', [])})
|
| 115 |
|
| 116 |
|
| 117 |
@csrf_exempt
|
|
|
|
| 118 |
@require_http_methods(['POST'])
|
| 119 |
def clear_history(request):
|
| 120 |
+
"""POST /clear-history/ — wipe session chat history."""
|
| 121 |
request.session['chat_history'] = []
|
| 122 |
request.session.modified = True
|
| 123 |
return JsonResponse({'status': 'cleared'})
|
app/guru_project/settings.py
CHANGED
|
@@ -8,20 +8,11 @@ DEBUG = True
|
|
| 8 |
ALLOWED_HOSTS = ['*']
|
| 9 |
|
| 10 |
INSTALLED_APPS = [
|
| 11 |
-
# Django core
|
| 12 |
-
'django.contrib.admin',
|
| 13 |
-
'django.contrib.staticfiles',
|
| 14 |
'django.contrib.contenttypes',
|
| 15 |
'django.contrib.auth',
|
| 16 |
'django.contrib.sessions',
|
| 17 |
'django.contrib.messages',
|
| 18 |
-
'django.contrib.
|
| 19 |
-
# allauth
|
| 20 |
-
'allauth',
|
| 21 |
-
'allauth.account',
|
| 22 |
-
'allauth.socialaccount',
|
| 23 |
-
'allauth.socialaccount.providers.google',
|
| 24 |
-
# our app
|
| 25 |
'guru_app',
|
| 26 |
]
|
| 27 |
|
|
@@ -29,10 +20,6 @@ MIDDLEWARE = [
|
|
| 29 |
'django.middleware.security.SecurityMiddleware',
|
| 30 |
'django.contrib.sessions.middleware.SessionMiddleware',
|
| 31 |
'django.middleware.common.CommonMiddleware',
|
| 32 |
-
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
| 33 |
-
'django.contrib.messages.middleware.MessageMiddleware',
|
| 34 |
-
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
| 35 |
-
'allauth.account.middleware.AccountMiddleware',
|
| 36 |
]
|
| 37 |
|
| 38 |
ROOT_URLCONF = 'guru_project.urls'
|
|
@@ -40,13 +27,13 @@ ROOT_URLCONF = 'guru_project.urls'
|
|
| 40 |
TEMPLATES = [
|
| 41 |
{
|
| 42 |
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
'APP_DIRS': True,
|
| 45 |
'OPTIONS': {
|
| 46 |
'context_processors': [
|
| 47 |
'django.template.context_processors.request',
|
| 48 |
-
'django.contrib.auth.context_processors.auth',
|
| 49 |
-
'django.contrib.messages.context_processors.messages',
|
| 50 |
],
|
| 51 |
},
|
| 52 |
},
|
|
@@ -54,7 +41,10 @@ TEMPLATES = [
|
|
| 54 |
|
| 55 |
WSGI_APPLICATION = 'guru_project.wsgi.application'
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
DATABASES = {
|
| 59 |
'default': {
|
| 60 |
'ENGINE': 'django.db.backends.sqlite3',
|
|
@@ -62,42 +52,11 @@ DATABASES = {
|
|
| 62 |
}
|
| 63 |
}
|
| 64 |
|
| 65 |
-
STATIC_URL = '/static/'
|
| 66 |
-
STATICFILES_DIRS = [BASE_DIR / 'guru_app' / 'static']
|
| 67 |
-
|
| 68 |
MEDIA_URL = '/media/'
|
| 69 |
MEDIA_ROOT = BASE_DIR / 'media'
|
| 70 |
|
| 71 |
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
| 72 |
|
| 73 |
-
#
|
| 74 |
-
SESSION_ENGINE = 'django.contrib.sessions.backends.
|
| 75 |
SESSION_COOKIE_AGE = 86400 # 1 day
|
| 76 |
-
|
| 77 |
-
# ── Authentication ────────────────────────────────────────────────────────────
|
| 78 |
-
AUTHENTICATION_BACKENDS = [
|
| 79 |
-
'django.contrib.auth.backends.ModelBackend',
|
| 80 |
-
'allauth.account.auth_backends.AuthenticationBackend',
|
| 81 |
-
]
|
| 82 |
-
|
| 83 |
-
SITE_ID = 1
|
| 84 |
-
|
| 85 |
-
# allauth config
|
| 86 |
-
ACCOUNT_EMAIL_VERIFICATION = 'none'
|
| 87 |
-
ACCOUNT_LOGIN_ON_GET = True
|
| 88 |
-
LOGIN_REDIRECT_URL = '/'
|
| 89 |
-
LOGOUT_REDIRECT_URL = '/accounts/login/'
|
| 90 |
-
LOGIN_URL = '/accounts/login/'
|
| 91 |
-
|
| 92 |
-
# ── Google OAuth credentials (set via environment variables) ──────────────────
|
| 93 |
-
SOCIALACCOUNT_PROVIDERS = {
|
| 94 |
-
'google': {
|
| 95 |
-
'APP': {
|
| 96 |
-
'client_id': os.environ.get('GOOGLE_CLIENT_ID', ''),
|
| 97 |
-
'secret': os.environ.get('GOOGLE_CLIENT_SECRET', ''),
|
| 98 |
-
'key': '',
|
| 99 |
-
},
|
| 100 |
-
'SCOPE': ['profile', 'email'],
|
| 101 |
-
'AUTH_PARAMS': {'access_type': 'online'},
|
| 102 |
-
}
|
| 103 |
-
}
|
|
|
|
| 8 |
ALLOWED_HOSTS = ['*']
|
| 9 |
|
| 10 |
INSTALLED_APPS = [
|
|
|
|
|
|
|
|
|
|
| 11 |
'django.contrib.contenttypes',
|
| 12 |
'django.contrib.auth',
|
| 13 |
'django.contrib.sessions',
|
| 14 |
'django.contrib.messages',
|
| 15 |
+
'django.contrib.staticfiles',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
'guru_app',
|
| 17 |
]
|
| 18 |
|
|
|
|
| 20 |
'django.middleware.security.SecurityMiddleware',
|
| 21 |
'django.contrib.sessions.middleware.SessionMiddleware',
|
| 22 |
'django.middleware.common.CommonMiddleware',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
]
|
| 24 |
|
| 25 |
ROOT_URLCONF = 'guru_project.urls'
|
|
|
|
| 27 |
TEMPLATES = [
|
| 28 |
{
|
| 29 |
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
| 30 |
+
# Supports the current single-file template layout (app/guru_app/index.html)
|
| 31 |
+
# and a conventional templates directory when present.
|
| 32 |
+
'DIRS': [BASE_DIR / 'guru_app', BASE_DIR / 'guru_app' / 'templates'],
|
| 33 |
'APP_DIRS': True,
|
| 34 |
'OPTIONS': {
|
| 35 |
'context_processors': [
|
| 36 |
'django.template.context_processors.request',
|
|
|
|
|
|
|
| 37 |
],
|
| 38 |
},
|
| 39 |
},
|
|
|
|
| 41 |
|
| 42 |
WSGI_APPLICATION = 'guru_project.wsgi.application'
|
| 43 |
|
| 44 |
+
STATIC_URL = '/static/'
|
| 45 |
+
_static_dir = BASE_DIR / 'guru_app' / 'static'
|
| 46 |
+
STATICFILES_DIRS = [_static_dir] if _static_dir.exists() else []
|
| 47 |
+
|
| 48 |
DATABASES = {
|
| 49 |
'default': {
|
| 50 |
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
| 55 |
MEDIA_URL = '/media/'
|
| 56 |
MEDIA_ROOT = BASE_DIR / 'media'
|
| 57 |
|
| 58 |
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
| 59 |
|
| 60 |
+
# Session settings for chat history
|
| 61 |
+
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
|
| 62 |
SESSION_COOKIE_AGE = 86400 # 1 day
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
manage.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
import os
|
| 3 |
import sys
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
|
| 6 |
|
| 7 |
def main():
|
| 8 |
-
# Add django/ folder to path so guru_project is findable
|
| 9 |
-
sys.path.insert(0, str(Path(__file__).resolve().parent / 'app'))
|
| 10 |
-
|
| 11 |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guru_project.settings')
|
| 12 |
try:
|
| 13 |
from django.core.management import execute_from_command_line
|
|
@@ -15,6 +10,5 @@ def main():
|
|
| 15 |
raise ImportError("Couldn't import Django.") from exc
|
| 16 |
execute_from_command_line(sys.argv)
|
| 17 |
|
| 18 |
-
|
| 19 |
if __name__ == '__main__':
|
| 20 |
main()
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
import os
|
| 3 |
import sys
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def main():
|
|
|
|
|
|
|
|
|
|
| 6 |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guru_project.settings')
|
| 7 |
try:
|
| 8 |
from django.core.management import execute_from_command_line
|
|
|
|
| 10 |
raise ImportError("Couldn't import Django.") from exc
|
| 11 |
execute_from_command_line(sys.argv)
|
| 12 |
|
|
|
|
| 13 |
if __name__ == '__main__':
|
| 14 |
main()
|