This commit is contained in:
zoe 2022-01-20 13:18:23 +01:00
parent 295411d8fa
commit 32e72eb2e2
8 changed files with 178 additions and 44 deletions

View File

61
frakes.txt Normal file
View File

@ -0,0 +1,61 @@
Have you ever walked out of a mall into a huge parking area and realized you'd forgotten where you parked your car?
Have you ever gone mountain biking?
What do you wanna be when you grow up?
What's the right tip?
You call a plumber to your home lately?
How superstitious are you?
How much money would it take to make you spend a night in a cemetary?
Would you display this as a trophy?
Do you have a pet?
Do you have a sweet tooth?
Do you believe in the power of a curse?
Have you had your hearing tested lately?
Are you planning a trip soon?
Can you remember the tallest man you've ever seen?
Do you love to go a-wandering beneath the clear blue sky?
Have you noticed what big stars real estate agents have become?
Are you careful with your personal records?
Does your computer ever seem to have a mind of it's own?
Have you ever visited a chinatown section at a major city?
Have you ever visited a flea market?
Have you ever visited a truck stop?
Did you ever have a job as a waiter?
Have you ever noticed how many successful restaurants are theme based these days?
Have you ever had the desire to write your initials in wet cement?
We have all heard the expression clothes make the man. But is it really true?
Did you have a favorite book as a child?
Do you have a favorite method of falling asleep?
Is there anything more precious than the gift of sight?
Who can explain the mystery of music?
Do we make our own luck.
Can a home ever be truly safe?
Have you checked the back sections of newspapers and magazines lately?
What is the secret of the green thumb?
What mysteries lie within the frame of a portrait?
How many dramas have taken place within these tight little boxes?
How do you describe terror.
Have you ever noticed the curious things one sees discarded by the roadside?
Who knows why certain people say certain things?
Have you ever experienced a sleepwalking episode?
Is there a more important job than that of a teacher?
Is there a more annoying sound than the screech of chalk against chalkboard?
What really happened here?
Who is the cowboy that confronted Johnny and Larry that night?
Was the old woman in on it too?
What about the mysterious behavior of the bbq lid?
Could Danny have been hallucinating?
But if Dan was hallucinating who ate Hal's food?
Does this story seem possible?
Was it really the nanny?
Does this story seem possible?
Was the morgue attendant in on the deception too?
Where there gasses trapped within the milk bucket that caused the activity?
How was the doctor able to send an email without a computer?
Was a sewing machine taken over by the spirit of Byron's grandmother?
Could a plant really identify a murderer?
Is it possible that a parrot could give a young girl the will to live?
Was the sisters husband really the victim of amnesia?
But then how do you explain the bullet hole in his phone?
Is this story true?
Can a fertilized octopus egg ingested into the human system actually grow inside the body?
[bass note] Do you belive this story?

View File

@ -12,15 +12,24 @@ use std::{
};
lazy_static! {
static ref CHAIN: Chain<String> = build_chain();
static ref FOOD_CHAIN: Chain<String> = build_chain("cooking.txt");
static ref FRAKES_CHAIN: Chain<String> = build_chain("frakes.txt");
static ref ARGS: Args = Args::parse();
}
#[get("/")]
fn index() -> Template {
let context: HashMap<&str, String> =
[("wisdom", CHAIN.generate_str())].iter().cloned().collect();
Template::render("index", context)
fn index() -> String {
"Hello".to_string()
}
#[get("/cooking")]
fn cooking() -> Template {
get_wisdom_template_from(FOOD_CHAIN.generate_str())
}
#[get("/frakes")]
fn frakes() -> Template {
get_wisdom_template_from(FRAKES_CHAIN.generate_str())
}
#[launch]
@ -29,14 +38,19 @@ fn rocket() -> _ {
config.port = ARGS.port;
rocket::custom(config)
.attach(Template::fairing())
.mount("/", routes![index])
.mount("/", routes![index, cooking, frakes])
}
fn build_chain() -> Chain<String> {
println!("Building Chain from \"{}\"...", ARGS.input);
fn get_wisdom_template_from(string: String) -> Template {
let context: HashMap<&str, String> = [("wisdom", string)].iter().cloned().collect();
Template::render("wisdom", context)
}
fn build_chain(input: &str) -> Chain<String> {
println!("Building Chain from \"{}\"...", input);
let mut new_chain = Chain::new();
// get input from input file
let file = File::open(&ARGS.input).expect("No input file!");
let file = File::open(input).expect("No input file!");
let reader = BufReader::new(file);
for line in reader.lines() {
new_chain.feed_str(&line.unwrap());
@ -47,10 +61,6 @@ fn build_chain() -> Chain<String> {
#[derive(Parser, Debug)]
#[clap(about, version, author)]
struct Args {
// Input file to make markov chain from
#[clap(short, long)]
input: String,
// Port number for server
#[clap(short, long, default_value_t = 8000)]
port: u16,

28
style.css Normal file
View File

@ -0,0 +1,28 @@
@import url("https://fonts.googleapis.com/css2?family=Prata&display=swap");
body {
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
margin-left: 24%;
margin-right: 24%;
}
a {
color: floralwhite;
font-size: 400%;
text-align: center;
font-family: "Prata", serif;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
body {
background-color: #080808;
}

View File

@ -7,40 +7,13 @@
charset="utf-8"
name="viewport"
/>
<style>
@import url('https://fonts.googleapis.com/css2?family=Prata&display=swap');
body {
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
margin-left: 24%;
margin-right: 24%;
}
a {
color: floralwhite;
font-size: 40pt;
text-align: center;
font-family: 'Prata', serif;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
body {
background-color: #080808;
}
</style>
</head>
<body id="body">
<div class="main">
<a href=".">{{wisdom}}</a>
<br>
<a href="./frakes">Wisdom website asks you things</a>
<a href="./cooking">Cooking wisdom</a>
<br>
</div>
</body>
</html>

28
templates/style.css Normal file
View File

@ -0,0 +1,28 @@
@import url("https://fonts.googleapis.com/css2?family=Prata&display=swap");
body {
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
margin-left: 24%;
margin-right: 24%;
}
a {
color: floralwhite;
font-size: 400%;
text-align: center;
font-family: "Prata", serif;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
body {
background-color: #080808;
}

17
templates/wisdom.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html5>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>
<title>Wisdom</title>
<meta charset="utf-8" name="viewport" />
</head>
<body id="body">
<div class="main">
</head />
<a href="">{{ wisdom }}</a>
<a id="home_link" href=".">home</a>
<br />
</div>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html5>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>
<title>Wisdom</title>
<meta charset="utf-8" name="viewport" />
</head>
<body id="body">
<div class="main">
</head />
<a href="">{{ wisdom }}</a>
<a id="home_link" href=".">home</a>
<br />
</div>
</body>
</html>