broadfield-dev commited on
Commit
5be321a
·
verified ·
1 Parent(s): 2e63d3b

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +23 -110
templates/index.html CHANGED
@@ -1,125 +1,38 @@
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>Bible Search App</title>
6
  <style>
7
  body { font-family: sans-serif; margin: 2em; background-color: #f4f4f9; color: #333; }
8
  .container { max-width: 800px; margin: auto; background: #fff; padding: 2em; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
9
- .admin-section { background-color: #f8f9fa; padding: 1.5em; border-radius: 5px; border: 1px solid #e1e1e8; }
10
- #build-status { margin-top: 1em; padding: 1em; border-radius: 4px; display: none; }
11
- #build-status.info { background-color: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
12
- #build-status.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
13
- #build-status.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
14
- /* Other styles remain the same */
15
- h1, h2, h3 { color: #4a4a4a; }
16
- input[type="text"] { width: 70%; padding: 0.8em; border: 1px solid #ccc; border-radius: 4px; }
17
- input[type="submit"] { padding: 0.8em 1.5em; border: none; background-color: #5c67f2; color: white; border-radius: 4px; cursor: pointer; }
18
- input[type="submit"]:hover { background-color: #4a54e1; }
19
- .result { border: 1px solid #e1e1e8; padding: 1em; margin-bottom: 1em; border-radius: 5px; background: #fdfdff; }
20
- .reference { font-weight: bold; color: #5c67f2; }
21
- hr { border: none; border-top: 1px solid #e1e1e8; margin: 2em 0; }
22
  </style>
23
  </head>
24
  <body>
25
  <div class="container">
26
- <h1>Bible Search</h1>
27
- <form action="/search" method="post">
28
- <input type="text" name="query" size="50" value="{{ query or '' }}" placeholder="e.g., love is patient, love is kind">
29
- <input type="submit" value="Search">
30
- </form>
31
- <hr>
32
- <div class="admin-section">
33
- <h3>Admin Panel</h3>
34
- <form id="build-form">
35
- <p>Build the vector database from the JSON files and upload it for persistence. <strong>Requires a write-permission HF_TOKEN secret.</strong></p>
36
- <input type="submit" id="build-button" value="Build and Push Database to Hub">
37
- </form>
38
- <div id="build-status"></div>
39
  </div>
40
-
41
- {% if query %}
42
- <h2>Results for: "{{ query }}"</h2>
43
- {% endif %}
44
-
45
- {% if results %}
46
- {% for result in results %}
47
- <div class="result">
48
- <p class="reference">{{ result.reference }} ({{result.version}})</p>
49
- <p>{{ result.text }}</p>
50
- <small>Score (Distance): {{ "%.4f"|format(result.score) }}</small>
51
- </div>
52
- {% endfor %}
53
- {% endif %}
54
  </div>
55
-
56
- <script>
57
- const buildForm = document.getElementById('build-form');
58
- const buildButton = document.getElementById('build-button');
59
- const statusDiv = document.getElementById('build-status');
60
- let statusInterval;
61
-
62
- function updateStatusDisplay(status, message) {
63
- statusDiv.style.display = 'block';
64
- statusDiv.textContent = message;
65
- statusDiv.className = ''; // Reset classes
66
-
67
- if (status.startsWith('IN_PROGRESS')) {
68
- statusDiv.classList.add('info');
69
- buildButton.disabled = true;
70
- buildButton.value = 'Building...';
71
- } else if (status === 'SUCCESS') {
72
- statusDiv.classList.add('success');
73
- buildButton.disabled = false;
74
- buildButton.value = 'Build and Push Database to Hub';
75
- clearInterval(statusInterval);
76
- // Prompt user to refresh to load the new data
77
- if(confirm("Build successful! Refresh the page to start searching?")) {
78
- window.location.reload();
79
- }
80
- } else if (status === 'FAILED') {
81
- statusDiv.classList.add('error');
82
- buildButton.disabled = false;
83
- buildButton.value = 'Try Build Again';
84
- clearInterval(statusInterval);
85
- } else { // NOT_STARTED
86
- statusDiv.style.display = 'none';
87
- buildButton.disabled = false;
88
- }
89
- }
90
-
91
- async function checkStatus() {
92
- try {
93
- const response = await fetch('/status');
94
- const data = await response.json();
95
- updateStatusDisplay(data.status, data.message);
96
- } catch (error) {
97
- console.error('Error fetching status:', error);
98
- updateStatusDisplay('FAILED', 'Could not connect to server to get status.');
99
- }
100
- }
101
-
102
- buildForm.addEventListener('submit', async function(event) {
103
- event.preventDefault();
104
-
105
- if (!confirm('This will start the build process. It can take a long time. Are you sure?')) {
106
- return;
107
- }
108
-
109
- buildButton.disabled = true;
110
- updateStatusDisplay('IN_PROGRESS', 'Initiating build process...');
111
-
112
- try {
113
- await fetch('/build-rag', { method: 'POST' });
114
- // Start polling for status updates every 5 seconds
115
- statusInterval = setInterval(checkStatus, 5000);
116
- } catch (error) {
117
- updateStatusDisplay('FAILED', 'Failed to send build request to the server.');
118
- }
119
- });
120
-
121
- // Check status on page load
122
- document.addEventListener('DOMContentLoaded', checkStatus);
123
- </script>
124
  </body>
125
  </html>
 
1
+ <!-- templates/book.html -->
2
  <!DOCTYPE html>
3
  <html lang="en">
4
  <head>
5
  <meta charset="UTF-8">
6
+ <title>The Book of {{ book_name }} - Bible App</title>
7
  <style>
8
  body { font-family: sans-serif; margin: 2em; background-color: #f4f4f9; color: #333; }
9
  .container { max-width: 800px; margin: auto; background: #fff; padding: 2em; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
10
+ h1, h2 { color: #4a4a4a; }
11
+ p { line-height: 1.6; }
12
+ .verse-num { font-weight: bold; color: #5c67f2; vertical-align: super; font-size: 0.8em; margin-left: 4px; }
13
+ .nav-links { margin-bottom: 2em; font-size: 1.1em; }
14
+ a { color: #5c67f2; text-decoration: none; }
15
+ a:hover { text-decoration: underline; }
16
+ .chapter-heading { margin-top: 2em; border-bottom: 1px solid #e1e1e8; padding-bottom: 0.5em;}
 
 
 
 
 
 
17
  </style>
18
  </head>
19
  <body>
20
  <div class="container">
21
+ <div class="nav-links">
22
+ <a href="/">← Back to Search</a>
 
 
 
 
 
 
 
 
 
 
 
23
  </div>
24
+
25
+ <h1>The Book of {{ book_name }}</h1>
26
+ <hr>
27
+
28
+ {% for chapter_num in chapters.keys()|sort %}
29
+ <h2 class="chapter-heading">Chapter {{ chapter_num }}</h2>
30
+ <p>
31
+ {% for verse in chapters[chapter_num] %}
32
+ <span class="verse-num">{{ verse.verse }}</span> {{ verse.text }}
33
+ {% endfor %}
34
+ </p>
35
+ {% endfor %}
 
 
36
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  </body>
38
  </html>