diff --git a/input b/cooking.txt similarity index 100% rename from input rename to cooking.txt diff --git a/frakes.txt b/frakes.txt new file mode 100644 index 0000000..0b2cfc3 --- /dev/null +++ b/frakes.txt @@ -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? diff --git a/src/main.rs b/src/main.rs index 9ea570d..0c624b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,15 +12,24 @@ use std::{ }; lazy_static! { - static ref CHAIN: Chain = build_chain(); + static ref FOOD_CHAIN: Chain = build_chain("cooking.txt"); + static ref FRAKES_CHAIN: Chain = 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 { - 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 { + 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 { #[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, diff --git a/style.css b/style.css new file mode 100644 index 0000000..8abec64 --- /dev/null +++ b/style.css @@ -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; +} diff --git a/templates/index.html b/templates/index.html index 0b02ba0..76bdc8a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,40 +7,13 @@ charset="utf-8" name="viewport" /> - diff --git a/templates/style.css b/templates/style.css new file mode 100644 index 0000000..8abec64 --- /dev/null +++ b/templates/style.css @@ -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; +} diff --git a/templates/wisdom.html b/templates/wisdom.html new file mode 100644 index 0000000..9820300 --- /dev/null +++ b/templates/wisdom.html @@ -0,0 +1,17 @@ + + + + + + Wisdom + + + +
+ + {{ wisdom }} + home +
+
+ + diff --git a/templates/wisdom.html.tera b/templates/wisdom.html.tera new file mode 100644 index 0000000..9820300 --- /dev/null +++ b/templates/wisdom.html.tera @@ -0,0 +1,17 @@ + + + + + + Wisdom + + + +
+ + {{ wisdom }} + home +
+
+ +