Compare commits

..

5 Commits

4 changed files with 68 additions and 21 deletions

View File

@ -25,14 +25,14 @@ use DateTime;
# This uses # This uses
# * File::Slurp - https://metacpan.org/pod/File::Slurp # * File::Slurp - https://metacpan.org/pod/File::Slurp
# * JSON - https://metacpan.org/pod/JSON # * JSON - https://metacpan.org/pod/JSON
# #
# Texts are from Project Gutenburg - https://www.gutenberg.org/ # Texts are from Project Gutenburg - https://www.gutenberg.org/
# #
################################### ###################################
# While these have json formatting, they are JS files # While these have json formatting, they are JS files
my $complete_books_js = "complete_books.js"; my $complete_books_js = "complete_books.js";
my $book_pages_js = "book_pages2.js"; my $book_pages_js = "book_pages.js";
# number of lines in a page # number of lines in a page
my $number_of_lines = 31; my $number_of_lines = 31;
@ -54,13 +54,48 @@ my @books = (
url => "https://www.gutenberg.org/ebooks/1260", url => "https://www.gutenberg.org/ebooks/1260",
file => "books/janeeyre.txt", file => "books/janeeyre.txt",
chapter_marker => "CHAPTER" chapter_marker => "CHAPTER"
}, },
{ {
title => "Agnes Grey", title => "Agnes Grey",
author => "Anne Bronte", author => "Anne Bronte",
url => "https://www.gutenberg.org/ebooks/767", url => "https://www.gutenberg.org/ebooks/767",
file => "books/agnesgrey.txt", file => "books/agnesgrey.txt",
chapter_marker => "CHAPTER" chapter_marker => "CHAPTER"
},
{
title => "Northanger Abbey",
author => "Jane Austen",
url => "https://www.gutenberg.org/ebooks/121",
file => "books/northangerabbey.txt",
chapter_marker => "CHAPTER"
},
{
title => "The Picture of Dorian Gray",
author => "Oscar Wilde",
url => "https://www.gutenberg.org/ebooks/174",
file => "books/doriangray.txt",
chapter_marker => "CHAPTER"
},
{
title => "The Mysteries of Udolpho",
author => "Ann Ward Radcliffe",
url => "https://www.gutenberg.org/ebooks/3268",
file => "books/udolpho.txt",
chapter_marker => "CHAPTER"
},
{
title => "The Enchanted Castle",
author => "E. Nesbit",
url => "https://www.gutenberg.org/ebooks/34219",
file => "books/enchantedcastle.txt",
chapter_marker => "CHAPTER"
},
{
title => "Frankenstein",
author => "Mary Wollstonecraft Shelley",
url => "https://www.gutenberg.org/ebooks/84",
file => "books/frankenstein.txt",
chapter_marker => "Chapter"
} }
); # books hash ); # books hash
@ -70,6 +105,7 @@ my $json = new JSON;
# Make the books into pages # Make the books into pages
################################### ###################################
# iterate over books
my $k = 0; my $k = 0;
foreach (@books) { foreach (@books) {
@ -81,9 +117,11 @@ foreach (@books) {
my @chapters = split('\n' . $books[$k]{'chapter_marker'}, $book); my @chapters = split('\n' . $books[$k]{'chapter_marker'}, $book);
# go through each chapter and make pages based on number of desired lines # go through each chapter and make pages based on number of desired lines
#iterate over chapters
my $j = 0; my $j = 0;
my @page_text; my @page_text;
foreach (@chapters) { foreach (@chapters) {
my @chapter_lines = split(/\r\n/, $chapters[$j]); my @chapter_lines = split(/\r\n/, $chapters[$j]);
@ -168,6 +206,9 @@ for ( my $l; $l < $number_of_pages; $l++){
# pull out a random chapter from that book # pull out a random chapter from that book
my $chapter_select = int(rand($chapter_list)); my $chapter_select = int(rand($chapter_list));
# pop off the last page, as it may be blank, or short
pop @{$books[$book_list]{'pages'}[$chapter_select]};
# get the number of pages in the chapter # get the number of pages in the chapter
my $page_list = @{$books[$book_list]{'pages'}[$chapter_select]}; my $page_list = @{$books[$book_list]{'pages'}[$chapter_select]};
# pull out a random page from the chapter # pull out a random page from the chapter

View File

@ -19,8 +19,9 @@ you can copy the words below
texts are public domain from Project Gutenberg - https://www.gutenberg.org/ texts are public domain from Project Gutenberg - https://www.gutenberg.org/
content licensed CC-BY-SA https://creativecommons.org/licenses/by-sa/4.0/ content licensed CC-BY-SA https://creativecommons.org/licenses/by-sa/4.0/
code license GPLv3.0 https://www.gnu.org/licenses/gpl-3.0.en.html code 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 Written by Jacob Haddon https://jacobhaddon.com
this file uses: this file uses:
@ -187,7 +188,7 @@ $(document).ready(function(){
<header> <header>
<h1>Daily <span class="purple">Blackout</span> Poetry Challenge</h1> <h1>Daily <span class="purple">Blackout</span> Poetry Challenge</h1>
<p>Your daily blackout poetry challenge! Make a poem, save the poem, share the poem!</p> <p>Your daily blackout poetry challenge! Make a poem, save the poem, share the poem! There is a new page each day!</p>
<p>Tag the poem: #dailyBlackoutPoetryChallenge</p> <p>Tag the poem: #dailyBlackoutPoetryChallenge</p>
@ -216,9 +217,16 @@ $(document).ready(function(){
<div id="poem_list"></div> <div id="poem_list"></div>
</section> </section>
<section>
<h2>More Blackout Poetry Awaits!</h2>
<p>Check out our site for more blackout poetry, including HIDE AND SEEK a Blackout Poetry workbook by Bram Stoker nominated poet Jessica McHugh!</p>
<p><a href="http://apokrupha.com/blackout">apokrupha.com/blackout</a></p>
</section>
<footer> <footer>
<h2>About</h2>
<p>This site made with <a href="https://jquery.com/">jQuery</a>, PHP and <a href="https://www.barebones.com/products/bbedit/">BBEdit</a> with help from <a href="https://espressoapp.com/">Espresso</a>.</p> <p>This site made with <a href="https://jquery.com/">jQuery</a>, PHP and <a href="https://www.barebones.com/products/bbedit/">BBEdit</a> with help from <a href="https://espressoapp.com/">Espresso</a>.</p>
<p><a href="https://code.jacobhaddon.com/jake/smhn">Code</a> by Jacob Haddon - license <a href="https://www.gnu.org/licenses/gpl-3.0.en.html">GPLv3.0</a> - <a href="https://Apokrupha.com/BlackOut">Apokrupha.com/Blackout</a></p> <p><a href="https://code.jacobhaddon.com/jake/dbpc">Code</a> by Jacob Haddon - license <a href="https://www.gnu.org/licenses/gpl-3.0.en.html">GPLv3.0</a> - <a href="https://Apokrupha.com/BlackOut">Apokrupha.com/Blackout</a></p>
</footer> </footer>
<!--Help Section--> <!--Help Section-->
@ -273,7 +281,7 @@ $(document).ready(function(){
<h1>Contact</h1> <h1>Contact</h1>
<p>webmaster@ </p> <p>webmaster@dailyblackoutpoetrychallenge.com</p>
<p>We are intolerant of intolerance. If you see something hateful, transphobic, homophobic, racist, or the like, let us know.</p> <p>We are intolerant of intolerance. If you see something hateful, transphobic, homophobic, racist, or the like, let us know.</p>

View File

@ -5,27 +5,25 @@ Daily Blackout Poetry Challenge
style.css style.css
license GPLv3.0 https://www.gnu.org/licenses/gpl-3.0.en.html 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 Written by Jacob Haddon https://jacobhaddon.com
*/ */
@font-face { @font-face {
font-family: "lora"; font-family: "lora";
src: local("Lora"), src: url("fonts/Lora/webfonts/Lora-Regular.woff2") format('woff2'),
url("fonts/Lora/webfonts/Lora-Regular.woff2") format('woff2'), url("fonts/Lora/variable/Lora-VariableFont_wght.ttf") format('truetype');
url("fonts/Lora/variable/Lora-VariableFont_wght.ttf") format('truetype'); font-style: normal;
font-style: normal; font-weight: normal;
font-weight: normal;
} }
@font-face { @font-face {
font-family: "lora"; font-family: "lora";
src: local("Lora"), src: url("fonts/Lora/webfonts/Lora-Italic.woff2") format('woff2'),
url("fonts/Lora/webfonts/Lora-Italic.woff2") format('woff2'), url("fonts/Lora/variable/Lora-Italic-VariableFont_wght.ttf")format('truetype');
url("fonts/Lora/variable/Lora-Italic-VariableFont_wght.ttf")format('truetype'); font-style: italic;
font-weight: normal; font-weight: normal;
font-style: italic;
} }
body { body {