#!/usr/bin/perl # HTML Generator for Bible texts ######################################################################### # Bible Lookup Program (Generator Program) v 1.0 # by Chris Priebe, Authentic Walk Ministries, 2000 # http://www.authenticwalk.com # # This program is dedicated to God and His servants # Please feel free to copy and modify this program # for any task that would honor our King # # Please ensure that you have permission to copy all texts # and are not enfringing on copyright laws ########################################################################## # This program takes a file written in standard Bible Markup Tags # and converts it into html files based on book names and chapter # Where each book has it's own directory and each chapter has it's # own html file. # This corresponds to the format acceptable by the Bible Lookup Program # # You may also modify it to work with other tags # You may run this program off your harddrive if you install the perl # program (which can be douwnloaded free from www.perl.com # Please set the following information ####################################################### print "Content-type: text/html\n\n"; # Name and Location of text file to be worked on $filename = 'web.gbf'; $template = "template.htm"; # This is the filename of the template for the chapters $template2 = "template2.htm"; # This is the filename of the template for the books $directory = "c:/Projects/freescripts"; # This is the server address of where the files are going, no / on the end # The following can be altered to try to use other text variations $Book_name_start = "" , "

", # Title "" , "

", "" , "

", # Subheading "" , "

", "" , "

", # Subheading "" , "

", "" , "", # Subheading "" , "", "" , "", # Subheading "" , "", "" , "

", # New paragraph "" , "", # Psalm book title "" , ""); # The following is the names of the books of the Bible which will form the directories %BooksOfBible = ( "Genesis" , "ge", "Exodus" , "ex", "Leviticus" , "le", "Numbers" , "nu", "Deuteronomy" , "de", "Joshua" , " jos", "Judges" , " jud", "Ruth" , "ru", "1Samuel" , "1sa", "2Samuel" , "2sa", "1Kings" , "1ki", "2Kings" , "2ki", "1Chronicles" , "1ch", "2Chronicles" , "2ch", "Ezra" , "ezr", "Nehemiah" , "ne", "Esther" , "es", "Job" , "job", "Psalms" , "ps", "Proverbs" , "pr", "Ecclesiastes" , "ec", "Songofsongs" , "so", "Isaiah" , "isa", "Jeremiah" , "jer", "Lamentations" , "la", "Ezekiel" , "eze", "Daniel" , "da", "Hosea" , "ho", "Joel" , "joe", "Amos" , "am", "Obadiah" , "ob", "Jonah" , "jon", "Micah" , "mic", "Nahum" , "na", "Habakkuk" , "hab", "Zephaniah" , "zep", "Haggai" , "hag", "Zechariah" , "zec", "Malachi" , "mal", "Matthew" , "mt", "Mark" , "mr", "Luke" , "lu", "John" , "joh", "Acts" , "ac", "Romans" , "ro", "1Corinthians" , "1co", "2Corinthians" , "2co", "Galatians" , "ga", "Ephesians" , "eph", "Philippians" , "php", "Colossians" , "col", "1Thessalonians" , "1th", "2Thessalonians" , "2th", "1Timothy" , "1ti", "2Timothy" , "2ti", "Titus" , "tit", "Philemon" , "phm", "Hebrews" , "heb", "James" , "jas", "1Peter" , "1pe", "2Peter" , "2pe", "1John" , "1jo", "2John" , "2jo", "3John" , "3jo", "Jude" , "jude", "Revelation" , "re" ); ########################################################## ## Main Code begins here #### open(TEXT,"$filename") or &dienice("Could not open file: $filename.\n"); while () {$line = $_; ## What to do when encounter a new book name ## if ($line =~ /$Book_name_start(.*?)$Book_name_end/) {$newbook = $1; # Save the new name, the old name is stored in $book after the first time through $output = "$output $`"; #Save the data before it as part of the last chapter $line = $'; #Now the line is set to all the data after the new book if ($book eq "") {&TranslatorsNotes;} #It is the first time through so no text yet, just translation information else { $old_chapter = $chapter; &SaveChapter; # Since the last chapter has not been written, write it now $chapter = ""; #Set it to nothing so it skips it till next chapter &SaveBook;} $book = $newbook; $chapters = ""; } # End of get ready for a new book if ($line =~ /$Chapter_name_start(.*?)$Chapter_name_end/) {$old_chapter = $chapter; # Before saving the new chapter, remember the one to save $chapter = $1; # New chapter number $output="$output$`"; # Remember the data before the new chapter aswell $line = $'; # Remember the data after for next chapter unless ($old_chapter eq "") {&SaveChapter;} ## Finished all the save old chapter, now set the information for the new chapter if ($chapter eq "1") {$book = $newbook;} $verses = ""; # The code for the verses in the header $chapters = "$chapters $chapter"; $output = ""; } # End of get ready for a new Chapter $output = "$output $line"; # Add this line (or what remains of it) to the output to save later } # End of read file ######## Make one last file since at end of file $old_chapter = $chapter; &SaveChapter; # Since the last chapter has not been written, write it now &SaveBook; close(TEXT); ########################################################## sub show_all_symbols { open(TEXT,"$filename") or &dienice("Could not open file: $filename because of $!.\n"); while () {$line = $_; while ($line =~ /<(.*?)>/) {$symbol{$1} = $1; $line =~ s/<$1>//;} } # End of read line from file close(TEXT); foreach $key (sort (keys(%symbol))) { print "$symbol{$key}\n";}; } ########################################################## sub SaveChapter { open(TEM, "$template") or &dienice("Could not open file: $template because of $!.\n"); @tmp1 = ; close(TEM); $tmp2 = join ("",@tmp1); ##### Get the right format for the book name since different text files vary ######## @array = split(//, $book); if (@array[1] eq " ") {@array[1]=""; } $book = join ("", @array); @ref = split (" ", $book); foreach $key (keys(%BooksOfBible)) {$test = "\U@ref[0]\E"; if (("\U$key\E" =~ /^\b$test.*$/i) || ("\U$BooksOfBible{$key}\E" eq $test)) {$book = $key;$abv_book = $BooksOfBible{$key};} } ###### Change the formatting ####### while ($output =~ /$Verse_name_start(.*?)$Verse_name_end/) {$output =~ s/$Verse_name_start(.*?)$Verse_name_end/\1 <\/a><\/small><\/small><\/font>/; $verses = "$verses $1 "; } $notenum = 1; $notes = ""; while ($output =~ /$Footnote_start/) {$this_note = $'; $output = $`; $this_note =~ /$Footnote_end/; $notes = "$notes $notenum $`
"; $output = "$output*$notenum <\/a><\/small><\/small>$'"; $notenum += 1; } ## Format the text based on the parameters set near the top ## foreach $key (sort (keys(%FormattingTags))) { $output =~ s/$key/$FormattingTags{$key}/g;} $tmp2 =~ s/~\{book name\}~/$book/g; $tmp2 =~ s/~\{book abv\}~/$abv_book/g; $tmp2 =~ s/~\{chapter\}~/$old_chapter/g; $tmp2 =~ s/~\{body\}~/$output/g; $tmp2 =~ s/~\{verses\}~/$verses/g; $tmp2 =~ s/~\{notes\}~/$notes/g; $tmp2 =~ s/~\{version\}~/$version/g; $tmp2 =~ s/~\{abb_ver\}~/$abb_ver/g; $tmp2 =~ s/~\{Copyright_short\}~/$Copyright_short/g; $tmp2 =~ s/~\{Copyright_long\}~/$Copyright_long/g; unless (-e "$directory/$book/") {mkdir ("$directory/$book", 0755) or &dienice("Could not create the directory: $directory/$book/ because of $!.\n");} open(FILE, ">$directory/$book/$old_chapter.html") or &dienice("Could not open file: $directory/$book/$old_chapter.html because of $!.\n"); print FILE "$tmp2"; close(FILE); print "I just made chapter $old_chapter of $book as $directory/$book/chapter$old_chapter.htm\n
"; } ########################################################## sub TranslatorsNotes {$output =~ /

(.*?)(.*?)(.*?)(.*?)$template2 because of $!.\n"); @tmp1 = ; close(TEM); $tmp2 = join ("",@tmp1); # Make the template one variable to edit easier ##### Get the right format for the book name since different text files vary ######## @array = split(//, $book); if (@array[1] eq " ") {@array[1]=""; } $book = join ("", @array); @ref = split (" ", $book); foreach $key (keys(%BooksOfBible)) {$test = "\U@ref[0]\E"; if (("\U$key\E" =~ /^\b$test.*$/i) || ("\U$BooksOfBible{$key}\E" eq $test)) {$book = $key;} } ###### Change the formatting ####### $tmp2 =~ s/~\{book name\}~/$book/g; $tmp2 =~ s/~\{body\}~/$output/g; $tmp2 =~ s/~\{chapters\}~/$chapters/g; $tmp2 =~ s/~\{version\}~/$version/g; $tmp2 =~ s/~\{abb_ver\}~/$abb_ver/g; $tmp2 =~ s/~\{Copyright_short\}~/$Copyright_short/g; $tmp2 =~ s/~\{Copyright_long\}~/$Copyright_long/g; open(FILE, ">$directory/$book/index.html") or &dienice("Could not create file: $directory/$book/index.html because of $!.\n"); print FILE "$tmp2"; close(FILE); print "\nNEW BOOK CREATED CALLED $directory/$book/index.html\n
"; ### In order to add chapter links, I'm going to edit all the files in the directory since I know how many chapters there are now opendir (DIR, "$directory/$book") or die "Can't open $directory/$book directory"; @these_files = readdir(DIR); closedir (DIR); foreach $this_one (@these_files) {if ($this_one =~ ".*html") {open(TEM, "$directory/$book/$this_one") or &dienice("Could not open file: $this_one because of $!.\n"); @contents = ; close(TEM); $temp = join ("",@contents); $temp =~ s/~\{chapters\}~/$chapters/g; open(TEM2, ">$directory/$book/$this_one") or &dienice("Could not open file:$this_one because of $!.\n"); print TEM2 "$temp"; close(TEM2);}} } ################################################## sub dienice { print "Content-type: text/html\n\nError $_[0]\n"; }