Getting tool to work on Linux

This commit is contained in:
Henry Whitney 2019-05-07 17:00:02 -04:00
parent 101ebd647a
commit 15a655e785
5 changed files with 3601 additions and 0 deletions

View File

@ -0,0 +1,418 @@
# Routine to take missing.log entries and link to UGNT and ULB.KJV.Strongs
# Same as version 2 but in Linux outputs all html files to temp dir and then opens
use 5.12.0;
use File::Slurp;
$| = "\n";
use utf8;
#use open IN => ":utf8", OUT => ":utf8";
use open IO => ":utf8";
binmode(STDOUT, ":utf8");
use File::Find ;
use FindBin '$Bin';
use Cwd ;
my ($d) = ("\\");
my ($workDir, $textEditor, $repoPath, $browser, $blbRef, $tN_page) = ($Bin, "\\");
my %abbr;
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
open LOG, ">:utf8", "$Bin${d}Logs${d}mine_log.log" or die ("$!:\n$Bin$[d}Logs${d}mine_log.log");
while (<DATA>) {
chomp;
if (/^([^\t]*)\t([^\t]*)\t([^\t]*)$/) {
$abbr{$3} = $2;
}
}
my ($udf) = "User_defaults.windows.txt";
if ($^O eq "linux") {$udf = "User_defaults.linux.txt"}
elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
chdir $Bin;
if ($^O eq "MSWin32" || $^O eq "MSWin64") {$workDir =~ s/\//\\/g}
open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!";
GetUserDefaults();
my ($exceptions_file, $topDir, $txtFile, $dataFile, $displayFile, $filePattern, $sn, $xfAbr, $thisULB) = (
"$Bin${d}Exceptions${d}Exceptions_tWs_from_OSHB.txt",
"$repoPath${d}en_tw/bible",
"$Bin${d}Temp${d}ULB_NASB_Strongs.txt",
"$Bin${d}User${d}tW_work_OT.txt",
"$Bin${d}Temp${d}mine_results.html",
"*\.md"
);
my ($missingLine, $bk, $ch, $vs, $ref, $strong, $word, $flag, $tNid, $abbr, $doFlag, $xmlFile, $lbsBk);
my (%bkAbr, %wa, %tW_file);
my @tWfiles;
find( sub { push @tWfiles, $File::Find::name if ( m/^(.*)$filePattern$/ ) }, $topDir) ;
open OUT, ">:utf8", "$displayFile" or die;
say OUT "<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\"/>
</head>
<body>
";
ParseLine();
FindVerse($ref);
ChecktWPages($word);
Finish();
say OUT "
</body>
</html>";
close OUT;
close LOG;
print "\n\tDone.\n\n";
sub GetUserDefaults {
open (my $defaults, "<:utf8", "$Bin${d}User${d}$udf") or die "$Bin${d}User${d}$udf:\n$!";
while (my $thisLine = <$defaults>) {
chomp $thisLine;
if ($thisLine =~ /^Text editor: (.*)$/) {
$textEditor = $1;
if ($^O eq "MSWin32" || $^O eq "MSWin64") {$textEditor =~ s/^(.*)$/"$1"/g;}
} elsif ($thisLine =~ /^Repository directory: (.*)$/) {
$repoPath = $1
} elsif ($thisLine =~ /^HTML browser: (.*)$/) {
$browser = $1;
if ($^O eq "MSWin32" || $^O eq "MSWin64") {$textEditor =~ s/^(.*)$/"$1"/g;}
}
}
say LOG "\$textEditor: $textEditor\n\$repoPath: $repoPath\n\$browser: $browser";
die "No text editor found" if $textEditor eq "";
die "No path to repo found" if $repoPath eq "";
if ($^O eq "darwin") {$textEditor = "open -a $textEditor"; $browser = "open -a $browser"}
close $defaults;
}
sub ParseLine {
my ($sch, $svs);
if ($^O eq "linux" || $^O eq "darwin") {
say "\nEnter line from Entries_not_handled.txt:\n";
$missingLine = <STDIN>; # I moved chomp to a new line to make it more readable
chomp $missingLine; # Get rid of newline character at the end
exit 0 if ($missingLine eq ""); # If empty string, exit.
#$missingLine = "Zephaniah 1:2 5486";
} else {
$missingLine = read_file ("Temp${d}temp.tmp");
}
if ($missingLine =~ /^(([^:]*) (\d+):(\d+))\t(\d+)/) {
($ref, $bk, $ch, $vs, $sn, $xfAbr) = ($1, $2, $3, $4, $5, $bkAbr{$1});
($sch, $svs) = ($ch, $vs);
if ($^O eq "MSWin32" || $^O eq "linux") {
my $bbkk = $bk;
$bbkk =~ s/ /_/g;
$bbkk = lc $bbkk;
$blbRef = "https://www.biblehub.com/$bbkk/$ch-$vs.htm"
}
else {$blbRef = "https://www.blueletterbible.org/net/$abbr{$bk}/$ch/$vs";}
say LOG "\$blbRef: $blbRef";
$strong = "H$sn";
say LOG "\$missingLine: $missingLine, \$ref: $ref, \$bk: $bk, \$ch: $ch, \$vs: $vs\n\n";
say LOG "\$bk: $bk";
open (my $file, "<:utf8", "$dataFile") or die "$dataFile:\n$!";
while (my $line = <$file>) {
chomp $line;
say LOG "\$line: $line";
if ($line =~ /^(# )?([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)$/) {
my ($fullBk, $wabbr, $numBk, $abr, $lbsBk) = ($2, $3, $4, $5, $5);
if ($fullBk eq $bk) {
say LOG "\$fullBk: |$fullBk|, \$wa{$fullBk}: |$wa{$fullBk}|, \$numBk: $numBk, \$abr: $abr, \$bk: |$bk|, \$lbsBk: $lbsBk";
($wa{$fullBk}) = ($wabbr);
$abbr = lc $numBk;
say LOG "\$abbr: $abbr";
my $mxl = 2;
if ($bk eq "Psalms?") {$mxl = 3}
while (length $ch < $mxl) {$ch =~ s/^/0/}
while (length $vs < $mxl) {$vs =~ s/^/0/}
$xmlFile = "$repoPath/OSHB/${numBk}.xml";
$tN_page = "$repoPath/en_tn/$wa{$fullBk}/$ch/${vs}.md";
say LOG "\n\$wa{$fullBk}/\$ch/\$vs: $wa{$fullBk}/$ch/$vs\nTo system:\n$textEditor $tN_page\n";
if ($^O eq "darwin") {system "$textEditor $tN_page"}
elsif ($^O eq "linux") {system "xdg-open $tN_page &"}
elsif ($^O eq "MSWin32" || $^O eq "MSWin64") {system "START \"\" $tN_page"}
#say "open -a /Applications/Logos.app \"logos4:TextComparison;ref=BibleBHS.$lbsBk${sch}.$svs;res=esv,niv2011,niv,nasb95,nrsv,gs-netbible,nlt,leb,kjv1900\"";
if ($^O eq "darwin") {system `open -a /Applications/Logos.app "logos4:TextComparison;ref=BibleNIV.$lbsBk${sch}.$svs;res=esv,niv2011,niv,nasb95,nrsv,gs-netbible,nlt,leb,kjv1900"`}
}
}
}
close $file;
} else {
die "\n\tInput unreadable.\n"
}
#system `open -a /Applications/Logos.app "logosres:esv;ref=BibleESV.$lbsBk${ch}.$vs"`;
}
sub FindVerse {
my $fileText = read_file("$txtFile", binmode => 'utf8');
if ($fileText =~ /$ref([^\n]*\n)/) {
$thisULB = $1;
}
say LOG "FindVerse |$strong|.";
if ($flag && $fileText =~ /($ref\t[^\n]*\n)[^\n]*\n/) {
say LOG "($ref\t[^\n]*\n)[^\n]*\n";
exit 0;
} else {
if ($fileText =~ /$ref([^\n]*\n )(([^\n]*<)$strong(.?>[^\n]*))/) {
my ($fore, $allNasb, $precon, $aft) = ($1, $2, $3, $4);
say LOG "\$ref: $ref\n\$fore: $fore\n$allNasb\n\$precon:\n$precon\n\$aft: $aft\n\$thisULB: $thisULB";
my $preprecon;
if ($precon =~ /^(.*([,>\w\'\"\- —;] |[";\.\?\!]))([\w\'\-]+) (<[^<>]*> ){0,}<$/) {
($preprecon, $word) = ($1, $3);
say LOG "\$&: $&\n\$preprecon: $preprecon\n\$word: $word";
} elsif ($precon =~ /^(\w+) <$/) {
($preprecon, $word) = ("", $1);
} elsif ($precon =~ /^(.*)\b(\w+)\b <$/) {
($preprecon, $word) = ($1, $2);
}
$preprecon =~ s/</&lt;/g;
$preprecon =~ s/>/&gt;/g;
$aft =~ s/</&lt;/g;
$aft =~ s/>/&gt;/g;
say OUT "<p>$ref$fore</p>\n<p>$preprecon<span style=\"color:red\">$word</span> <<span style=\"color:red\">$strong</span>$aft</p>\n";
} else {
say OUT "<p>The Strong's code <<<span style=\"color:red\">$strong</span>>> is not found in $ref.</p>";
#system ("bbfind -g \"${ref}\\t[^\\n]*\\n[^\\n]*\" 'data${d}ULB_NASB_Strongs.txt'") or die "$!";
my $dump;
$dump = "<p></p><p>";
foreach my $file ( @tWfiles ) {
my $fileText = read_file("$file", binmode => 'utf8');
# While finds entries and Strong's numbers
while ($fileText =~ /($strong)[^\d]/g) {
my $found = $1;
#system `clear`;
my $abb = $file;
$abb =~ s/.md$//;
$dump .= "$abb: <span style=color:red>$found</span><br />\n";
}
}
say $strong;
if ($^O eq "darwin") {system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`}
$strong =~ s/^[HG]//;
say OUT "$dump</p><p>$strong</p>";
#system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;");
#system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\$\" {} \\;");
}
}
if ($word eq "") {
say "There is no \$word in $ref\n$thisULB";
if ($^O eq "darwin") {
system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=H$strong`;
}
if ($^O eq "linux") {
#system "chromium https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=H$strong &";
system "xdg-open https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=H$strong &";
}
if ($^O eq "MSWin32" || $^O eq "MSWin64" ) {
system "START \"\" https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=H$strong";
}
die
}
return $word;
}
sub ChecktWPages{
say LOG "<<$word>>";
if ($word eq "") {
say "\nThere is no \$word for \$strong = $strong in $ref\n$thisULB\n";
die
}
my $topDir = "$repoPath${d}en_tw${d}bible";
say OUT "<p>";
foreach my $file ( @tWfiles ) {
my $fileText = read_file("$file", binmode => 'utf8');
my $foundHere;
# While finds entries and Strong's numbers
while ($fileText =~ /($strong)[^\d]|^(# [^\n]*\b$word\b)/g) {
$foundHere = 1;
#system `clear`;
my $abb = $file;
$abb =~ s/.md$//;
say OUT "$abb<br />\n";
}
if ($foundHere == 1) {unless (exists $tW_file{$file}) {$tW_file{$file} = $file}}
}
say OUT "</p>";
}
sub Finish {
say "\nLooking for $strong.";
# find $topDir -name "*.md" -exec grep -H '($strong[^\d]|$strong$)' {} +
#system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;");
say OUT "<p>";
foreach my $file ( @tWfiles ) {
if ($^O eq "MSWin32" || $^O eq "MSWin64") {$file =~ s/\//\\/g}
my $fileText = read_file("$file", binmode => 'utf8') or die "$!";
# While finds entries and Strong's numbers
if ($fileText =~ /([^\n]*)($strong\b)([^\n]*)/g) {
my ($pre, $found, $post) = ($1, $2, $3);
my $abb = $file;
$abb =~ s/.md$//;
say OUT "$abb: $pre<span style=\"color:red\">$found</span>$post<br />\n";
unless (exists $tW_file{$file}) {$tW_file{$file} = $file}
}
}
say OUT "</p>";
say "\nLooking for $word.";
say OUT "<p>";
foreach my $file ( @tWfiles ) {
my $fileText = read_file("$file", binmode => 'utf8');
# While finds entries and Strong's numbers
if ($fileText =~ /#{1,1} ([^\n]*)(\b$word\b)([^\n]*)/g) {
my ($pre, $found, $post) = ($1, $2, $3);
my $abb = $file;
$abb =~ s/.md$//;
say OUT "$abb: $pre<span style=\"color:red\">$found</span>$post<br />\n";
unless (exists $tW_file{$file}) {$tW_file{$file} = $file}
}
}
say OUT "</p>";
my $tW_files;
foreach my $key (sort keys %tW_file) {
$tW_files .= "$key ";
}
say "\nOpening .md files.";
if ($^O eq "darwin") {
system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`;
system `$textEditor $tW_files`;
system `$textEditor $exceptions_file`;}
if ($^O eq "linux") {
say "curl https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong > $Bin/Temp/Strongs.html";
#system "xdg-open https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong &";
system "curl https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong > $Bin/Temp/Strongs.html";
system "sleep 1s";
say "curl $blbRef > $Bin/Temp/This_verse.html";
system "curl $blbRef > $Bin/Temp/This_verse.html";
#system "xdg-open $blbRef &";
my @tWs = split / /,$tW_files;
foreach (@tWs) {
say "Opening $_";
system "xdg-open $_ &"
}
#say "Opening $exceptions_file";
#system "xdg-open $exceptions_file &";
#system "sleep 1s";
say "Opening $displayFile";
system "xdg-open $displayFile &";
system "sleep 1s";
say "Opening $Bin/Temp/This_verse.html";
system "xdg-open $Bin/Temp/This_verse.html &";
system "sleep 1s";
say "Opening $Bin/Temp/Strongs.html";
system "xdg-open $Bin/Temp/Strongs.html &";
}
if ($^O eq "MSWin32" || $^O eq "MSWin64" ) {
say "Opening $blbRef";
system "START \"\" $blbRef";
say "Opening https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong";
system "START \"\" https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong";
my @tWs = split / /,$tW_files;
foreach (@tWs) {
say "Opening $_";
system "START \"\" $_"
}
#say "Opening $displayFile";
#system "START \"\" $displayFile";
}
}
__DATA__
01 gen Genesis
02 exo Exodus
03 lev Leviticus
04 num Numbers
05 deu Deuteronomy
06 jos Joshua
07 jdg Judges
08 rut Ruth
09 1sa 1 Samuel
10 2sa 2 Samuel
11 1ki 1 Kings
12 2ki 2 Kings
13 1ch 1 Chronicles
14 2ch 2 Chronicles
15 ezr Ezra
16 neh Nehemiah
17 est Esther
18 job Job
19 psa Psalms
20 pro Proverbs
21 ecc Ecclesiastes
22 sng Song of Solomon
23 isa Isaiah
24 jer Jeremiah
25 lam Lamentations
26 ezk Ezekiel
27 dan Daniel
28 hos Hosea
29 jol Joel
30 amo Amos
31 oba Obadiah
32 jon Jonah
33 mic Micah
34 nam Nahum
35 hab Habakkuk
36 zep Zephaniah
37 hag Haggai
38 zec Zechariah
39 mal Malachi
41 mat Matthew
42 mrk Mark
43 luk Luke
44 jhn John
45 act Acts
46 rom Romans
47 1co 1 Corinthians
48 2co 2 Corinthians
49 gal Galatians
50 eph Ephesians
51 php Philippians
52 col Colossians
53 1th 1 Thessalonians
54 2th 2 Thessalonians
55 1ti 1 Timothy
56 2ti 2 Timothy
57 tit Titus
58 phm Philemon
59 heb Hebrews
60 jas James
61 1pe 1 Peter
62 2pe 2 Peter
63 1jn 1 John
64 2jn 2 John
65 3jn 3 John
66 jud Jude
67 rev Revelation

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
echo "pushing ULB"
(cd "/home/henry/Documents/WA_Repo/en_ulb";
git pull
git commit -a -m "$1"
git push) || { echo 'Could not commit!' >&2; exit 1; }
echo "pushing UDB"
(cd "/home/henry/Documents/WA_Repo/en_udb";
git pull
git commit -a -m "$1"
git push) || { echo 'Could not commit!' >&2; exit 1; }
echo "pushing tW"
(cd "/home/henry/Documents/WA_Repo/en_tw";
git pull
git commit -a -m "$1"
git push) || { echo 'Could not commit!' >&2; exit 1; }
echo "pushing tN"
(cd "/home/henry/Documents/WA_Repo/en_tn";
git pull
git commit -a -m "$1"
git push) || { echo 'Could not commit!' >&2; exit 1; }
echo "pushing Files for Update"
(cd "/home/henry/Documents/WA_Repo/Tips_and_Hacks/MAST_tW_PDF_Updater/FilesForUpdates";
git pull
git commit -a -m "$1"
git push) || { echo 'Could not commit!' >&2; exit 1; }

View File

@ -0,0 +1,24 @@
echo "ULB"
(cd "/home/henry/Documents/WA_Repo/en_ulb"; git pull)
echo "UDB"
(cd "/home/henry/Documents/WA_Repo/en_udb"; git pull)
echo "tW"
(cd "/home/henry/Documents/WA_Repo/en_tw"; git pull)
echo "tN"
(cd "/home/henry/Documents/WA_Repo/en_tn"; git pull)
echo "MakeULB.4.pl"
perl "MakeULB.4.pl"
echo "FindMismatchedULBSnippets.3.noChunks.pl"
perl "FindMismatchedULBSnippets.3.noChunks.pl"
echo "CombineULBandNASBwithCodes.pl"
perl "CombineULBandNASBwithCodes.pl"
xdg-open "Temp/mismatched_snippets.html" &
echo "OpenMismatchedFiles.pl"
perl "OpenMismatchedFiles.pl"
echo "Opening Temp/ULB_text.txt"
xdg-open "Temp/ULB_text.txt"
# echo "ExtractLinksFromScratchPad.pl"
# perl "ExtractLinksFromScratchPad.pl"
echo ExtractLinksFromMismatchedSnippets.pl
perl ExtractLinksFromMismatchedSnippets.pl
xdg-open "Temp/ULB_NASB_Strongs.txt"