checkpoint

This commit is contained in:
2025-03-27 00:54:58 -06:00
parent 3e7509a9c7
commit e64aee2b31
2 changed files with 114 additions and 53 deletions

View File

@@ -12,12 +12,12 @@ pub const BOOKS_IN_ORDER: [&str; 66] = [
"Joshua",
"Judges",
"Ruth",
"1 Samuel",
"2 Samuel",
"1 Kings",
"2 Kings",
"1 Chronicles",
"2 Chronicles",
"1-Samuel",
"2-Samuel",
"1-Kings",
"2-Kings",
"1-Chronicles",
"2-Chronicles",
"Ezra",
"Nehemiah",
"Esther",
@@ -25,7 +25,7 @@ pub const BOOKS_IN_ORDER: [&str; 66] = [
"Psalms",
"Proverbs",
"Ecclesiastes",
"Song of Solomon",
"Song-of-Solomon",
"Isaiah",
"Jeremiah",
"Lamentations",
@@ -49,31 +49,43 @@ pub const BOOKS_IN_ORDER: [&str; 66] = [
"John",
"Acts",
"Romans",
"1 Corinthians",
"2 Corinthians",
"1-Corinthians",
"2-Corinthians",
"Galations",
"Ephesians",
"Philippians",
"Colossians",
"1 Thessalonians",
"2 Thessalonians",
"1 Timothy",
"2 Timothy",
"1-Thessalonians",
"2-Thessalonians",
"1-Timothy",
"2-Timothy",
"Titus",
"Philemon",
"Hebrews",
"James",
"1 Peter",
"2 Peter",
"1 John",
"2 John",
"3 John",
"1-Peter",
"2-Peter",
"1-John",
"2-John",
"3-John",
"Jude",
"Revelation",
];
pub fn search_for_word(word: &str, from_files: &Bible) -> Vec<String> {
todo!()
let mut found = Vec::new();
for test in &from_files.testaments {
for book in &test.books {
for chapter in &book.chapters {
for verse in &chapter.verses {
if verse.text.contains(word) {
found.push(format!("{} {}:{}", BOOKS_IN_ORDER[book.number-1], chapter.number, verse.number));
}
}
}
}
}
found
}
pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String> {
@@ -92,7 +104,14 @@ pub fn get(book: &str, chap_and_ver: &str, bibles: Vec<&Bible>) -> Option<String
let res = BOOKS_IN_ORDER
.iter()
.enumerate()
.filter(|(_, lbook)| lbook.replace(" ", "").to_lowercase().starts_with(&book.trim().to_lowercase()))
.filter(|(_, lbook)| lbook
.to_lowercase()
.starts_with(&book
.trim()
.replace(" ", "-")
.to_lowercase()
)
)
.collect::<Vec<(usize, &&str)>>();
let (book_idx, book_name) = match res.len() {