LucidMinds3ye commited on
Commit
c4900cf
·
verified ·
1 Parent(s): b911810

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +281 -30
app.py CHANGED
@@ -1,3 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Custom CSS for styling
2
  st.markdown("""
3
  <style>
@@ -76,40 +145,47 @@ st.markdown("""
76
  border-radius: 8px;
77
  padding: 12px;
78
  }
79
-
80
- /* DROPDOWN FIXES - SIMPLIFIED APPROACH */
81
-
82
- /* Select box labels */
83
  .stSelectbox label {
84
  color: #2c3e50 !important;
85
  font-size: 1.1rem;
86
  font-weight: 500;
87
  }
88
-
89
- /* Dropdown input text - make it black */
90
- .stSelectbox div[data-baseweb="select"] div {
91
- color: #000000 !important;
 
 
 
92
  }
93
-
94
- /* Dropdown options panel */
95
- section[data-baseweb="popover"] div {
96
- background-color: white !important;
97
  color: #000000 !important;
 
98
  }
99
-
100
- /* Individual dropdown options */
101
- section[data-baseweb="popover"] li {
102
- background-color: white !important;
 
 
 
 
 
103
  color: #000000 !important;
104
  padding: 10px 15px !important;
 
105
  }
106
-
107
- /* Dropdown options on hover */
108
- section[data-baseweb="popover"] li:hover {
109
  background-color: #f0f7f0 !important;
110
  color: #000000 !important;
111
  }
112
-
 
 
 
113
  /* Number input styling */
114
  .stNumberInput input {
115
  color: #000000 !important;
@@ -119,24 +195,20 @@ st.markdown("""
119
  border-radius: 8px !important;
120
  padding: 8px 12px !important;
121
  }
122
-
123
- /* Number input labels */
124
  .stNumberInput label {
125
  color: #2c3e50 !important;
126
  font-size: 1.1rem !important;
127
  font-weight: 500 !important;
128
  }
129
-
130
- /* Make all regular text consistent */
131
  body, p, div, span, h1, h2, h3, h4, h5, h6 {
132
  color: #2c3e50 !important;
133
  }
134
-
135
  /* Tab styling */
136
  .stTabs [data-baseweb="tab-list"] {
137
  gap: 8px;
138
  }
139
-
140
  .stTabs [data-baseweb="tab"] {
141
  height: 50px;
142
  white-space: pre-wrap;
@@ -146,12 +218,10 @@ st.markdown("""
146
  padding: 12px 24px;
147
  font-weight: bold;
148
  }
149
-
150
  .stTabs [aria-selected="true"] {
151
  background-color: #4a7c59;
152
  color: white !important;
153
  }
154
-
155
  /* Expander styling */
156
  .streamlit-expanderHeader {
157
  font-size: 1.2rem;
@@ -162,7 +232,6 @@ st.markdown("""
162
  border-radius: 8px;
163
  margin: 8px 0;
164
  }
165
-
166
  /* Metric cards styling */
167
  [data-testid="metric-container"] {
168
  background-color: #f0f7f0;
@@ -171,7 +240,6 @@ st.markdown("""
171
  padding: 15px;
172
  text-align: center;
173
  }
174
-
175
  /* Footer styling */
176
  .footer {
177
  text-align: center;
@@ -181,4 +249,187 @@ st.markdown("""
181
  font-style: italic;
182
  }
183
  </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  """, unsafe_allow_html=True)
 
1
+ import streamlit as st
2
+ import sqlite3
3
+ from datetime import datetime
4
+
5
+ # Set up the page
6
+ st.set_page_config(
7
+ page_title="Scripture Decipher",
8
+ page_icon="📖",
9
+ layout="wide"
10
+ )
11
+
12
+ # Initialize database
13
+ def init_db():
14
+ conn = sqlite3.connect('scripture_decipher.db')
15
+ c = conn.cursor()
16
+ c.execute('''CREATE TABLE IF NOT EXISTS simplified_verses
17
+ (id INTEGER PRIMARY KEY AUTOINCREMENT,
18
+ book TEXT NOT NULL,
19
+ chapter INTEGER NOT NULL,
20
+ verse INTEGER NOT NULL,
21
+ original_text TEXT NOT NULL,
22
+ simplified_text TEXT NOT NULL,
23
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
24
+ conn.commit()
25
+ conn.close()
26
+
27
+ # Add a new simplified verse to the database
28
+ def add_simplified_verse(book, chapter, verse, original_text, simplified_text):
29
+ conn = sqlite3.connect('scripture_decipher.db')
30
+ c = conn.cursor()
31
+ c.execute("INSERT INTO simplified_verses (book, chapter, verse, original_text, simplified_text) VALUES (?, ?, ?, ?, ?)",
32
+ (book, chapter, verse, original_text, simplified_text))
33
+ conn.commit()
34
+ conn.close()
35
+
36
+ # Get all simplified verses from the database
37
+ def get_all_simplified_verses():
38
+ conn = sqlite3.connect('scripture_decipher.db')
39
+ c = conn.cursor()
40
+ c.execute("SELECT * FROM simplified_verses ORDER BY created_at DESC")
41
+ verses = c.fetchall()
42
+ conn.close()
43
+ return verses
44
+
45
+ # Sample Bible verses data
46
+ SAMPLE_VERSES = {
47
+ "John": {
48
+ 3: {
49
+ 16: "For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life."
50
+ }
51
+ },
52
+ "Matthew": {
53
+ 5: {
54
+ 3: "Blessed are the poor in spirit, for theirs is the kingdom of heaven.",
55
+ 4: "Blessed are those who mourn, for they shall be comforted.",
56
+ 5: "Blessed are the meek, for they shall inherit the earth."
57
+ }
58
+ },
59
+ "Psalm": {
60
+ 23: {
61
+ 1: "The Lord is my shepherd; I shall not want.",
62
+ 4: "Even though I walk through the valley of the shadow of death, I will fear no evil, for you are with me; your rod and your staff, they comfort me."
63
+ }
64
+ }
65
+ }
66
+
67
+ # Initialize database
68
+ init_db()
69
+
70
  # Custom CSS for styling
71
  st.markdown("""
72
  <style>
 
145
  border-radius: 8px;
146
  padding: 12px;
147
  }
148
+ /* Select box label styling */
 
 
 
149
  .stSelectbox label {
150
  color: #2c3e50 !important;
151
  font-size: 1.1rem;
152
  font-weight: 500;
153
  }
154
+ /* DROPDOWN INPUT BOX - FIXED */
155
+ div[data-baseweb="select"] > div {
156
+ background-color: #f8f9fa !important;
157
+ border: 2px solid #4a7c59 !important;
158
+ border-radius: 8px !important;
159
+ padding: 8px 12px !important;
160
+ font-size: 1.1rem !important;
161
  }
162
+ /* TARGET THE TEXT INSIDE THE CLOSED BOX - CRITICAL FIX */
163
+ div[data-baseweb="select"] div[style] {
 
 
164
  color: #000000 !important;
165
+ font-weight: 500 !important;
166
  }
167
+ /* DROPDOWN OPTIONS PANEL - FIXED */
168
+ div[data-baseweb="popover"] {
169
+ background-color: #ffffff !important;
170
+ border: 2px solid #4a7c59 !important;
171
+ border-radius: 8px !important;
172
+ }
173
+ /* DROPDOWN OPTIONS - FIXED */
174
+ div[data-baseweb="popover"] li {
175
+ background-color: #ffffff !important;
176
  color: #000000 !important;
177
  padding: 10px 15px !important;
178
+ font-size: 1.1rem !important;
179
  }
180
+ /* DROPDOWN OPTIONS HOVER - FIXED */
181
+ div[data-baseweb="popover"] li:hover {
 
182
  background-color: #f0f7f0 !important;
183
  color: #000000 !important;
184
  }
185
+ /* Placeholder text for dropdown */
186
+ div[data-baseweb="select"] input::placeholder {
187
+ color: #6c757d !important;
188
+ }
189
  /* Number input styling */
190
  .stNumberInput input {
191
  color: #000000 !important;
 
195
  border-radius: 8px !important;
196
  padding: 8px 12px !important;
197
  }
198
+ /* Number input label */
 
199
  .stNumberInput label {
200
  color: #2c3e50 !important;
201
  font-size: 1.1rem !important;
202
  font-weight: 500 !important;
203
  }
204
+ /* Make all text consistent */
 
205
  body, p, div, span, h1, h2, h3, h4, h5, h6 {
206
  color: #2c3e50 !important;
207
  }
 
208
  /* Tab styling */
209
  .stTabs [data-baseweb="tab-list"] {
210
  gap: 8px;
211
  }
 
212
  .stTabs [data-baseweb="tab"] {
213
  height: 50px;
214
  white-space: pre-wrap;
 
218
  padding: 12px 24px;
219
  font-weight: bold;
220
  }
 
221
  .stTabs [aria-selected="true"] {
222
  background-color: #4a7c59;
223
  color: white !important;
224
  }
 
225
  /* Expander styling */
226
  .streamlit-expanderHeader {
227
  font-size: 1.2rem;
 
232
  border-radius: 8px;
233
  margin: 8px 0;
234
  }
 
235
  /* Metric cards styling */
236
  [data-testid="metric-container"] {
237
  background-color: #f0f7f0;
 
240
  padding: 15px;
241
  text-align: center;
242
  }
 
243
  /* Footer styling */
244
  .footer {
245
  text-align: center;
 
249
  font-style: italic;
250
  }
251
  </style>
252
+ """, unsafe_allow_html=True)
253
+
254
+ # App title and description
255
+ st.markdown('<h1 class="main-header">📖 Scripture Decipher</h1>', unsafe_allow_html=True)
256
+ st.markdown("""
257
+ <div style="text-align: center; margin-bottom: 2rem;">
258
+ <p style="font-size: 1.2rem;">Making Bible scriptures easier to understand for everyone</p>
259
+ </div>
260
+ """, unsafe_allow_html=True)
261
+
262
+ # Create tabs for different functionalities
263
+ tab1, tab2, tab3 = st.tabs(["Simplify Scripture", "View Saved Verses", "About"])
264
+
265
+ with tab1:
266
+ st.markdown('<h2 class="sub-header">Simplify a Bible Verse</h2>', unsafe_allow_html=True)
267
+
268
+ col1, col2 = st.columns([1, 2])
269
+
270
+ with col1:
271
+ # Book selection
272
+ books = list(SAMPLE_VERSES.keys())
273
+ selected_book = st.selectbox("Select Book", books)
274
+
275
+ # Chapter selection based on book
276
+ if selected_book:
277
+ chapters = list(SAMPLE_VERSES[selected_book].keys())
278
+ selected_chapter = st.selectbox("Select Chapter", chapters)
279
+
280
+ # Verse selection based on chapter
281
+ if selected_chapter:
282
+ verses = list(SAMPLE_VERSES[selected_book][selected_chapter].keys())
283
+ selected_verse = st.selectbox("Select Verse", verses)
284
+
285
+ with col2:
286
+ # Display original verse
287
+ if selected_book and selected_chapter and selected_verse:
288
+ original_text = SAMPLE_VERSES[selected_book][selected_chapter][selected_verse]
289
+ st.markdown("### Original Scripture")
290
+ st.markdown(f'<div class="scripture-box">{selected_book} {selected_chapter}:{selected_verse} - "{original_text}"</div>', unsafe_allow_html=True)
291
+
292
+ # Input for simplified version
293
+ simplified_text = st.text_area(
294
+ "Simplified Version",
295
+ placeholder="Enter your simplified version of this verse here...",
296
+ height=150
297
+ )
298
+
299
+ # Sample simplified versions for demonstration
300
+ sample_simplifications = {
301
+ "John 3:16": "God loved people so much that He sent His only Son Jesus. Anyone who believes in Him will live forever with God instead of dying separated from Him.",
302
+ "Matthew 5:3": "Happy are those who realize they need God's help, because Heaven belongs to them.",
303
+ "Psalm 23:1": "The Lord takes care of all my needs, just like a shepherd cares for his sheep."
304
+ }
305
+
306
+ current_ref = f"{selected_book} {selected_chapter}:{selected_verse}"
307
+ if current_ref in sample_simplifications:
308
+ with st.expander("See example simplification"):
309
+ st.info(sample_simplifications[current_ref])
310
+
311
+ # Save button
312
+ if st.button("Save Simplified Verse") and simplified_text:
313
+ add_simplified_verse(
314
+ selected_book, selected_chapter, selected_verse,
315
+ original_text, simplified_text
316
+ )
317
+ st.markdown('<div class="success-box">Simplified verse saved successfully!</div>', unsafe_allow_html=True)
318
+
319
+ with tab2:
320
+ st.markdown('<h2 class="sub-header">Saved Simplified Verses</h2>', unsafe_allow_html=True)
321
+
322
+ # Get all saved verses from database
323
+ saved_verses = get_all_simplified_verses()
324
+
325
+ if not saved_verses:
326
+ st.info("No simplified verses saved yet. Use the 'Simplify Scripture' tab to get started.")
327
+ else:
328
+ # Filter options
329
+ col1, col2, col3 = st.columns(3)
330
+ with col1:
331
+ filter_book = st.selectbox("Filter by Book", ["All"] + books, key="filter_book")
332
+ with col2:
333
+ sort_order = st.selectbox("Sort Order", ["Newest First", "Oldest First"])
334
+ with col3:
335
+ items_per_page = st.selectbox("Items per page", [5, 10, 20], index=0)
336
+
337
+ # Filter and sort verses
338
+ filtered_verses = saved_verses
339
+ if filter_book != "All":
340
+ filtered_verses = [v for v in saved_verses if v[1] == filter_book]
341
+
342
+ if sort_order == "Oldest First":
343
+ filtered_verses = sorted(filtered_verses, key=lambda x: x[6])
344
+ else:
345
+ filtered_verses = sorted(filtered_verses, key=lambda x: x[6], reverse=True)
346
+
347
+ # Pagination
348
+ total_verses = len(filtered_verses)
349
+ if total_verses > 0:
350
+ total_pages = (total_verses - 1) // items_per_page + 1
351
+ page = st.number_input("Page", min_value=1, max_value=total_pages, value=1)
352
+ start_idx = (page - 1) * items_per_page
353
+ end_idx = min(start_idx + items_per_page, total_verses)
354
+
355
+ st.write(f"Showing {start_idx + 1}-{end_idx} of {total_verses} verses")
356
+
357
+ # Display verses for current page
358
+ for verse in filtered_verses[start_idx:end_idx]:
359
+ with st.expander(f"{verse[1]} {verse[2]}:{verse[3]} - {verse[6].split()[0]}"):
360
+ col1, col2 = st.columns(2)
361
+ with col1:
362
+ st.write("**Original:**")
363
+ st.markdown(f'<div class="scripture-box">{verse[4]}</div>', unsafe_allow_html=True)
364
+ with col2:
365
+ st.write("**Simplified:**")
366
+ st.markdown(f'<div style="background-color: #e8f4f8; border-radius: 10px; padding: 20px; margin: 15px 0; border-left: 5px solid #5c8da5;">{verse[5]}</div>', unsafe_allow_html=True)
367
+
368
+ # Statistics
369
+ st.markdown("---")
370
+ st.subheader("Statistics")
371
+ col1, col2, col3 = st.columns(3)
372
+
373
+ with col1:
374
+ st.metric("Total Verses Simplified", total_verses)
375
+
376
+ with col2:
377
+ if total_verses > 0:
378
+ books_count = {}
379
+ for verse in saved_verses:
380
+ book = verse[1]
381
+ books_count[book] = books_count.get(book, 0) + 1
382
+ most_common_book = max(books_count, key=books_count.get)
383
+ st.metric("Most Common Book", most_common_book)
384
+
385
+ with col3:
386
+ if total_verses > 0:
387
+ earliest = min([verse[6] for verse in saved_verses])
388
+ st.metric("First Simplification", earliest.split()[0])
389
+
390
+ with tab3:
391
+ st.markdown('<h2 class="sub-header">About Scripture Decipher</h2>', unsafe_allow_html=True)
392
+
393
+ st.markdown("""
394
+ <div class="scripture-box">
395
+ <h3>Our Mission</h3>
396
+ <p>Scripture Decipher is designed to make the Bible more accessible and understandable to people of all backgrounds.
397
+ We believe that everyone should be able to engage with scripture in a way that resonates with them.</p>
398
+ </div>
399
+ """, unsafe_allow_html=True)
400
+
401
+ col1, col2 = st.columns(2)
402
+
403
+ with col1:
404
+ st.markdown("""
405
+ ### How It Works
406
+ 1. Select a book, chapter, and verse from the Bible
407
+ 2. Read the original text
408
+ 3. Create your simplified version that's easier to understand
409
+ 4. Save it to your personal database
410
+ 5. Review all your simplified verses anytime
411
+ """)
412
+
413
+ with col2:
414
+ st.markdown("""
415
+ ### Benefits
416
+ - Helps with personal Bible study
417
+ - Useful for teaching and sermons
418
+ - Creates a personal repository of understood scriptures
419
+ - Great for new believers or those new to the Bible
420
+ """)
421
+
422
+ st.markdown("---")
423
+ st.markdown("""
424
+ <div style="text-align: center;">
425
+ <p>Created with ❤️ for the Hugging Face community</p>
426
+ </div>
427
+ """, unsafe_allow_html=True)
428
+
429
+ # Add footer
430
+ st.markdown("---")
431
+ st.markdown("""
432
+ <div style="text-align: center; color: #6c757d; padding: 20px;">
433
+ <p>Scripture Decipher • Making the Bible accessible to all</p>
434
+ </div>
435
  """, unsafe_allow_html=True)