diff --git a/books.pl b/books.pl
index f10c7c7..401525c 100755
--- a/books.pl
+++ b/books.pl
@@ -5,8 +5,8 @@ use 5.010;
use strict;
use warnings;
use File::Slurp; # https://metacpan.org/pod/File::Slurp
-use JSON;
-use Time::Piece;
+use JSON; # https://metacpan.org/pod/JSON
+use Time::Piece; # https://perldoc.perl.org/Time::Piece
use DateTime;
@@ -19,15 +19,24 @@ use DateTime;
# splitting them up into "pages" for easier display
#
# license GPLv3.0 https://www.gnu.org/licenses/gpl-3.0.en.html
-# Code repository:
-#
+# Code repository: https://code.jacobhaddon.com/jake/dbpc
# Written by Jacob Haddon https://jacobhaddon.com
#
-# This uses File::Slurp - https://metacpan.org/pod/File::Slurp
+# This uses
+# * File::Slurp - https://metacpan.org/pod/File::Slurp
+# * JSON - https://metacpan.org/pod/JSON
+#
# Texts are from Project Gutenburg - https://www.gutenberg.org/
#
###################################
+# While these have json formatting, they are JS files
+my $complete_books_js = "complete_books.js";
+my $book_pages_js = "book_pages2.js";
+
+# number of lines in a page
+my $number_of_lines = 31;
+
my $json = new JSON;
# my $date = localtime->strftime('%Y-%m-%d');
@@ -38,19 +47,22 @@ my @books = (
title => "Wuthering Heights",
author => "Emily Bronte",
url => "https://www.gutenberg.org/ebooks/768",
- file => "books/wutheringheights.txt"
+ file => "books/wutheringheights.txt",
+ chapter_marker => "CHAPTER"
},
{
title => "Jane Eyre",
author => "Charlotte Bronte",
url => "https://www.gutenberg.org/ebooks/1260",
- file => "books/janeeyre.txt"
+ file => "books/janeeyre.txt",
+ chapter_marker => "CHAPTER"
},
{
title => "Agnes Grey",
author => "Anne Bronte",
url => "https://www.gutenberg.org/ebooks/767",
- file => "books/agnesgrey.txt"
+ file => "books/agnesgrey.txt",
+ chapter_marker => "CHAPTER"
}
); # books hash
@@ -69,12 +81,11 @@ foreach (@books) {
# read in a whole file into a scalar
my $book = read_file($books[$k]{'file'});
-my @chapters = split('\nCHAPTER', $book);
+my @chapters = split('\n' . $books[$k]{'chapter_marker'}, $book);
my $test = @chapters;
# print($test);
-# number of lines in a page
-my $number_of_lines = 31;
+
my $j = 0;
my @page_text;
@@ -141,10 +152,10 @@ $books[$k]{'pages'} = \@page_text;
# my $json_text = encode_json(\%books);
my $json_text = $json->pretty->encode( \@books );
-my $js_text = "let book = " . $json_text;
+my $js_text = "let books = " . $json_text;
# write the file
-open(FH, '>', "test4.js") or die $!;
+open(FH, '>', $complete_books_js) or die $!;
print FH $js_text;
close(FH);
@@ -182,12 +193,18 @@ for ( my $l; $l < 365; $l++){
# my $new_test = $dt->add(days => 1)->ymd;
# print $new_test . "\n";
- $page_list2{$dt->add(days => 1)->ymd} = {
+# $page_list2{$dt->add(days => 1)->ymd} = {
+# title => $books[$book_list]{'title'},
+# author => $books[$book_list]{'author'},
+# page => $page_rand
+# };
+
+ $page_list2{$dt->ymd} = {
title => $books[$book_list]{'title'},
author => $books[$book_list]{'author'},
page => $page_rand
};
-
+ $dt->add(days => 1);
# print $dt->add(days => 1)->ymd;
# my $new_date = $dt->add(days => $l);
@@ -207,10 +224,10 @@ for ( my $l; $l < 365; $l++){
# my $json_text = encode_json(\%books);
my $json_text2 = $json->pretty->encode( \%page_list2 );
-my $js_text2 = "let book = " . $json_text2;
+my $js_text2 = "let book_pages = " . $json_text2;
# write the file
-open(FH, '>', "test5.js") or die $!;
+open(FH, '>', $book_pages_js) or die $!;
print FH $js_text2;
close(FH);
diff --git a/index.html b/index.html
index 5480a45..49b7924 100644
--- a/index.html
+++ b/index.html
@@ -36,7 +36,7 @@ this file uses:
-
+