Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import sqlite3
|
| 3 |
-
from
|
| 4 |
|
| 5 |
# Set up the page
|
| 6 |
st.set_page_config(
|
|
@@ -50,28 +50,6 @@ def delete_simplified_verse(verse_id):
|
|
| 50 |
conn.commit()
|
| 51 |
conn.close()
|
| 52 |
|
| 53 |
-
# Sample Bible verses data
|
| 54 |
-
SAMPLE_VERSES = {
|
| 55 |
-
"John": {
|
| 56 |
-
3: {
|
| 57 |
-
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."
|
| 58 |
-
}
|
| 59 |
-
},
|
| 60 |
-
"Matthew": {
|
| 61 |
-
5: {
|
| 62 |
-
3: "Blessed are the poor in spirit, for theirs is the kingdom of heaven.",
|
| 63 |
-
4: "Blessed are those who mourn, for they shall be comforted.",
|
| 64 |
-
5: "Blessed are the meek, for they shall inherit the earth."
|
| 65 |
-
}
|
| 66 |
-
},
|
| 67 |
-
"Psalm": {
|
| 68 |
-
23: {
|
| 69 |
-
1: "The Lord is my shepherd; I shall not want.",
|
| 70 |
-
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."
|
| 71 |
-
}
|
| 72 |
-
}
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
# Initialize database
|
| 76 |
init_db()
|
| 77 |
|
|
@@ -172,54 +150,49 @@ with tab1:
|
|
| 172 |
col1, col2 = st.columns([1, 2])
|
| 173 |
|
| 174 |
with col1:
|
| 175 |
-
# Book selection
|
| 176 |
-
books =
|
| 177 |
selected_book = st.selectbox("Select Book", books)
|
| 178 |
|
| 179 |
# Chapter selection based on book
|
| 180 |
if selected_book:
|
| 181 |
-
chapters =
|
| 182 |
selected_chapter = st.selectbox("Select Chapter", chapters)
|
| 183 |
|
| 184 |
# Verse selection based on chapter
|
| 185 |
if selected_chapter:
|
| 186 |
-
verses =
|
| 187 |
selected_verse = st.selectbox("Select Verse", verses)
|
| 188 |
|
| 189 |
with col2:
|
| 190 |
-
# Display original verse
|
| 191 |
if selected_book and selected_chapter and selected_verse:
|
| 192 |
-
original_text =
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
# Sample simplified versions for demonstration
|
| 204 |
-
sample_simplifications = {
|
| 205 |
-
"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.",
|
| 206 |
-
"Matthew 5:3": "Happy are those who realize they need God's help, because Heaven belongs to them.",
|
| 207 |
-
"Psalm 23:1": "The Lord takes care of all my needs, just like a shepherd cares for his sheep."
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
current_ref = f"{selected_book} {selected_chapter}:{selected_verse}"
|
| 211 |
-
if current_ref in sample_simplifications:
|
| 212 |
-
with st.expander("See example simplification"):
|
| 213 |
-
st.info(sample_simplifications[current_ref])
|
| 214 |
-
|
| 215 |
-
# Save button
|
| 216 |
-
if st.button("Save Simplified Verse") and simplified_text:
|
| 217 |
-
add_simplified_verse(
|
| 218 |
-
selected_book, selected_chapter, selected_verse,
|
| 219 |
-
original_text, simplified_text
|
| 220 |
)
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
with tab2:
|
| 225 |
st.markdown('<h2 class="sub-header">Saved Simplified Verses</h2>', unsafe_allow_html=True)
|
|
@@ -230,10 +203,13 @@ with tab2:
|
|
| 230 |
if not saved_verses:
|
| 231 |
st.info("No simplified verses saved yet. Use the 'Simplify Scripture' tab to get started.")
|
| 232 |
else:
|
|
|
|
|
|
|
|
|
|
| 233 |
# Filter options
|
| 234 |
col1, col2, col3 = st.columns(3)
|
| 235 |
with col1:
|
| 236 |
-
filter_book = st.selectbox("Filter by Book", ["All"] +
|
| 237 |
with col2:
|
| 238 |
sort_order = st.selectbox("Sort Order", ["Newest First", "Oldest First"])
|
| 239 |
with col3:
|
|
@@ -257,7 +233,6 @@ with tab2:
|
|
| 257 |
start_idx = (page - 1) * items_per_page
|
| 258 |
end_idx = min(start_idx + items_per_page, total_verses)
|
| 259 |
|
| 260 |
-
# Fixed the formatting issue here
|
| 261 |
st.write(f"Showing {start_idx + 1}-{end_idx} of {total_verses} verse{'s' if total_verses != 1 else ''}")
|
| 262 |
|
| 263 |
# Display verses for current page
|
|
@@ -321,8 +296,14 @@ with tab3:
|
|
| 321 |
st.markdown("""
|
| 322 |
<div class="scripture-box">
|
| 323 |
<h3>Our Mission</h3>
|
| 324 |
-
<p>Scripture Decipher is designed to make the Bible more accessible and understandable
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
</div>
|
| 327 |
""", unsafe_allow_html=True)
|
| 328 |
|
|
@@ -331,7 +312,7 @@ with tab3:
|
|
| 331 |
with col1:
|
| 332 |
st.markdown("""
|
| 333 |
### How It Works
|
| 334 |
-
1. Select a book, chapter, and verse from
|
| 335 |
2. Read the original text
|
| 336 |
3. Create your simplified version that's easier to understand
|
| 337 |
4. Save it to your personal database
|
|
@@ -341,16 +322,18 @@ with tab3:
|
|
| 341 |
with col2:
|
| 342 |
st.markdown("""
|
| 343 |
### Benefits
|
| 344 |
-
- Helps with personal Bible study
|
| 345 |
-
- Useful for teaching and
|
| 346 |
- Creates a personal repository of understood scriptures
|
| 347 |
-
- Great for new believers or those new to the Bible
|
|
|
|
| 348 |
""")
|
| 349 |
|
| 350 |
st.markdown("---")
|
| 351 |
st.markdown("""
|
| 352 |
<div style="text-align: center;">
|
| 353 |
<p>Created with ❤️ for the Hugging Face community</p>
|
|
|
|
| 354 |
</div>
|
| 355 |
""", unsafe_allow_html=True)
|
| 356 |
|
|
@@ -359,5 +342,6 @@ st.markdown("---")
|
|
| 359 |
st.markdown("""
|
| 360 |
<div class="footer">
|
| 361 |
<p>Scripture Decipher • Making the Bible accessible to all</p>
|
|
|
|
| 362 |
</div>
|
| 363 |
""", unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import sqlite3
|
| 3 |
+
from scripture_data import get_books, get_chapters, get_verses, get_verse_text, get_simplified_example
|
| 4 |
|
| 5 |
# Set up the page
|
| 6 |
st.set_page_config(
|
|
|
|
| 50 |
conn.commit()
|
| 51 |
conn.close()
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# Initialize database
|
| 54 |
init_db()
|
| 55 |
|
|
|
|
| 150 |
col1, col2 = st.columns([1, 2])
|
| 151 |
|
| 152 |
with col1:
|
| 153 |
+
# Book selection using the module
|
| 154 |
+
books = get_books()
|
| 155 |
selected_book = st.selectbox("Select Book", books)
|
| 156 |
|
| 157 |
# Chapter selection based on book
|
| 158 |
if selected_book:
|
| 159 |
+
chapters = get_chapters(selected_book)
|
| 160 |
selected_chapter = st.selectbox("Select Chapter", chapters)
|
| 161 |
|
| 162 |
# Verse selection based on chapter
|
| 163 |
if selected_chapter:
|
| 164 |
+
verses = get_verses(selected_book, selected_chapter)
|
| 165 |
selected_verse = st.selectbox("Select Verse", verses)
|
| 166 |
|
| 167 |
with col2:
|
| 168 |
+
# Display original verse using the module
|
| 169 |
if selected_book and selected_chapter and selected_verse:
|
| 170 |
+
original_text = get_verse_text(selected_book, selected_chapter, selected_verse)
|
| 171 |
+
if original_text:
|
| 172 |
+
st.markdown("### Original Scripture")
|
| 173 |
+
st.markdown(f'<div class="scripture-box">{selected_book} {selected_chapter}:{selected_verse} - "{original_text}"</div>', unsafe_allow_html=True)
|
| 174 |
+
|
| 175 |
+
# Input for simplified version
|
| 176 |
+
simplified_text = st.text_area(
|
| 177 |
+
"Simplified Version",
|
| 178 |
+
placeholder="Enter your simplified version of this verse here...",
|
| 179 |
+
height=150
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
)
|
| 181 |
+
|
| 182 |
+
# Get sample simplification using the module
|
| 183 |
+
sample_simplification = get_simplified_example(selected_book, selected_chapter, selected_verse)
|
| 184 |
+
if sample_simplification:
|
| 185 |
+
with st.expander("See example simplification"):
|
| 186 |
+
st.info(sample_simplification)
|
| 187 |
+
|
| 188 |
+
# Save button
|
| 189 |
+
if st.button("Save Simplified Verse") and simplified_text:
|
| 190 |
+
add_simplified_verse(
|
| 191 |
+
selected_book, selected_chapter, selected_verse,
|
| 192 |
+
original_text, simplified_text
|
| 193 |
+
)
|
| 194 |
+
st.markdown('<div class="success-box">Simplified verse saved successfully!</div>', unsafe_allow_html=True)
|
| 195 |
+
st.rerun()
|
| 196 |
|
| 197 |
with tab2:
|
| 198 |
st.markdown('<h2 class="sub-header">Saved Simplified Verses</h2>', unsafe_allow_html=True)
|
|
|
|
| 203 |
if not saved_verses:
|
| 204 |
st.info("No simplified verses saved yet. Use the 'Simplify Scripture' tab to get started.")
|
| 205 |
else:
|
| 206 |
+
# Get unique books for filtering
|
| 207 |
+
unique_books = sorted(list(set(verse[1] for verse in saved_verses)))
|
| 208 |
+
|
| 209 |
# Filter options
|
| 210 |
col1, col2, col3 = st.columns(3)
|
| 211 |
with col1:
|
| 212 |
+
filter_book = st.selectbox("Filter by Book", ["All"] + unique_books, key="filter_book")
|
| 213 |
with col2:
|
| 214 |
sort_order = st.selectbox("Sort Order", ["Newest First", "Oldest First"])
|
| 215 |
with col3:
|
|
|
|
| 233 |
start_idx = (page - 1) * items_per_page
|
| 234 |
end_idx = min(start_idx + items_per_page, total_verses)
|
| 235 |
|
|
|
|
| 236 |
st.write(f"Showing {start_idx + 1}-{end_idx} of {total_verses} verse{'s' if total_verses != 1 else ''}")
|
| 237 |
|
| 238 |
# Display verses for current page
|
|
|
|
| 296 |
st.markdown("""
|
| 297 |
<div class="scripture-box">
|
| 298 |
<h3>Our Mission</h3>
|
| 299 |
+
<p>Scripture Decipher is designed to make the Bible more accessible and understandable for people of all backgrounds and reading levels. We believe that everyone should be able to engage with God's Word in a way that resonates with them.</p>
|
| 300 |
+
|
| 301 |
+
<h3>Now with Expanded Scriptures!</h3>
|
| 302 |
+
<p>We've expanded our library to include verses from across the entire Bible. You can now find and simplify passages from:</p>
|
| 303 |
+
<ul>
|
| 304 |
+
<li>Old Testament: Genesis, Exodus, Psalms, Proverbs, Isaiah</li>
|
| 305 |
+
<li>New Testament: Matthew, John, Romans, Philippians, Hebrews, James, 1 John</li>
|
| 306 |
+
</ul>
|
| 307 |
</div>
|
| 308 |
""", unsafe_allow_html=True)
|
| 309 |
|
|
|
|
| 312 |
with col1:
|
| 313 |
st.markdown("""
|
| 314 |
### How It Works
|
| 315 |
+
1. Select a book, chapter, and verse from our expanded library
|
| 316 |
2. Read the original text
|
| 317 |
3. Create your simplified version that's easier to understand
|
| 318 |
4. Save it to your personal database
|
|
|
|
| 322 |
with col2:
|
| 323 |
st.markdown("""
|
| 324 |
### Benefits
|
| 325 |
+
- Helps with personal Bible study and devotionals
|
| 326 |
+
- Useful for teaching, sermons, and small groups
|
| 327 |
- Creates a personal repository of understood scriptures
|
| 328 |
+
- Great for new believers, children, or those new to the Bible
|
| 329 |
+
- Perfect for ESL readers or those with reading difficulties
|
| 330 |
""")
|
| 331 |
|
| 332 |
st.markdown("---")
|
| 333 |
st.markdown("""
|
| 334 |
<div style="text-align: center;">
|
| 335 |
<p>Created with ❤️ for the Hugging Face community</p>
|
| 336 |
+
<p><small>Now featuring an expanded scripture library with easy-to-manage data modules</small></p>
|
| 337 |
</div>
|
| 338 |
""", unsafe_allow_html=True)
|
| 339 |
|
|
|
|
| 342 |
st.markdown("""
|
| 343 |
<div class="footer">
|
| 344 |
<p>Scripture Decipher • Making the Bible accessible to all</p>
|
| 345 |
+
<p><small>Expanded scripture library now available</small></p>
|
| 346 |
</div>
|
| 347 |
""", unsafe_allow_html=True)
|