Adding current working progress to hashmap for dynamic routes. #3
@ -2,14 +2,31 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Not Found</title>
|
||||
<style>
|
||||
body {
|
||||
background: orange;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/assets/style.css" />
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
<script src="/assets/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page cannot be found</h1>
|
||||
<h3>Sorry, this page cannot be found.</h3>
|
||||
<header id="site-header">
|
||||
<div id="site-name">
|
||||
<a href="/">BatFlip</a>
|
||||
</div>
|
||||
<div id="site-menu">
|
||||
<ul>
|
||||
<li><a href="/scorecards">Past Scorecards</a></li>
|
||||
<li><a href="/add-scorecard">Add New</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
<div id="main-content">
|
||||
<h1>Sorry, this page cannot be found.</h1>
|
||||
<h2>Sorry, this page cannot be found.</h2>
|
||||
<h3>Sorry, this page cannot be found.</h3>
|
||||
<h4>Sorry, this page cannot be found.</h4>
|
||||
<h5>Sorry, this page cannot be found.</h5>
|
||||
<h6>Sorry, this page cannot be found.</h6>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,2 +1 @@
|
||||
alert("time to rock");
|
||||
console.log("hello");
|
||||
console.log("main.js loaded");
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css2?family=Anton&family=Bebas+Neue&display=swap");
|
||||
:root {
|
||||
--blue: #002D62;
|
||||
--red: #C8102E;
|
||||
--green: #4CAF50;
|
||||
--background: #F5F5F5;
|
||||
--primary-text: #1A1A1A;
|
||||
--secondary-text: #555555;
|
||||
--success: #2E8B57;
|
||||
--warning: #FFA500;
|
||||
--error: #D72638;
|
||||
--primary-font: "Bebas Neue", sans-serif;
|
||||
--secondary-font: "Anton", sans-serif;
|
||||
}
|
||||
|
||||
/* 1. Use a more-intuitive box-sizing model */
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
@ -53,8 +69,58 @@ h1, h2, h3, h4, h5, h6 {
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
header {
|
||||
background: var(--blue);
|
||||
padding: 20px;
|
||||
}
|
||||
header #site-name {
|
||||
font-family: var(--secondary-font);
|
||||
font-size: 2rem;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
header a {
|
||||
color: var(--background);
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: var(--primary-font);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
body {
|
||||
background: orange;
|
||||
background: var(--background);
|
||||
color: var(--primary-text);
|
||||
padding: 20px;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
img {
|
||||
|
||||
@ -1 +1 @@
|
||||
{"version":3,"sourceRoot":"","sources":["../../theme/reset.scss","../../theme/styles.scss"],"names":[],"mappings":"AAAA;AACA;EACE;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;IACE;;;AAIJ;AACE;EACA;AACA;EACA;;;AAGF;AACA;EACE;EACA;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;;;AAEF;EACE;;;AAGF;AAAA;AAAA;AAGA;EACE;;;AClDF;EACE;;;AAGF;EACE;EACA","file":"style.css"}
|
||||
{"version":3,"sourceRoot":"","sources":["../../theme/styles.scss","../../theme/variables.scss","../../theme/reset.scss","../../theme/header.scss","../../theme/headings.scss"],"names":[],"mappings":"AAAQ;AACA;ACAR;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;ACZF;AACA;EACE;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;IACE;;;AAIJ;AACE;EACA;AACA;EACA;;;AAGF;AACA;EACE;EACA;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;;;AAEF;EACE;;;AAGF;AAAA;AAAA;AAGA;EACE;;;ACpDF;EACE;EACA;;AAEA;EACE;EACA;EACA;;AAGF;EACE;;;ACXJ;EACE;;;AAGF;EACE;EACA;;;AAIF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAIF;EACE;EACA;;;AAIF;EACE;EACA;;;AJ3BF;EACE;EACA;EACA;EACA;;;AAKF;EACE;EACA","file":"style.css"}
|
||||
BIN
public/images/fenway.jpg
Normal file
BIN
public/images/fenway.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 594 KiB |
@ -1,12 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Toolshed</title>
|
||||
<title>BatFlip Scoring App</title>
|
||||
<link rel="stylesheet" href="/assets/style.css" />
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
<script src="/assets/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>This is my toolshed. This web server is built using Rust :)</h1>
|
||||
<img src="/images/6.jpg" alt="some image" />
|
||||
<header id="site-header">
|
||||
<div id="site-name">
|
||||
<a href="/">BatFlip</a>
|
||||
</div>
|
||||
<div id="site-menu">
|
||||
<ul>
|
||||
<li><a href="/scorecards">Past Scorecards</a></li>
|
||||
<li><a href="/add-scorecard">Add New</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
<div id="main-content">
|
||||
<h1>Live Baseball Scoring App, written in Rust</h1>
|
||||
<img src="/images/fenway.jpg" alt="some image" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -51,26 +51,12 @@ pub fn handle_connection(mut stream: TcpStream) {
|
||||
);
|
||||
stream.write(response.as_bytes()).unwrap();
|
||||
stream.write(&image_data).unwrap();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
response = return_response(&inc_request.path);
|
||||
stream.write(response.as_bytes()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn get_header(headers: Vec<String>, needle: &str) -> String {
|
||||
let mut value = String::new();
|
||||
for header in headers {
|
||||
let split_header: Vec<&str> = header.split(":").collect();
|
||||
let header_key: String = split_header.first().expect("Nothing here").to_string();
|
||||
if header_key == needle {
|
||||
value = split_header[1].to_string();
|
||||
}
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
fn return_response(path_or_code: &str) -> String {
|
||||
let status_line: String;
|
||||
let contents: String;
|
||||
@ -99,3 +85,16 @@ fn return_response(path_or_code: &str) -> String {
|
||||
pub fn path_exists(path: &str) -> bool {
|
||||
fs::metadata(path).is_ok()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn get_header(headers: Vec<String>, needle: &str) -> String {
|
||||
let mut value = String::new();
|
||||
for header in headers {
|
||||
let split_header: Vec<&str> = header.split(":").collect();
|
||||
let header_key: String = split_header.first().expect("Nothing here").to_string();
|
||||
if header_key == needle {
|
||||
value = split_header[1].to_string();
|
||||
}
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
@ -1,8 +1,28 @@
|
||||
use std::fs;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub fn get_route_data(route: &str) -> String {
|
||||
match route {
|
||||
// @required - set valid routes here.
|
||||
let route_map = HashMap::from([
|
||||
("/", "./public/index.html"),
|
||||
]);
|
||||
|
||||
dbg!(route_map.get(route));
|
||||
|
||||
// match route_map.get(route) {
|
||||
// None => ,
|
||||
// Some(page) => Some(page),
|
||||
// };
|
||||
// Some("test".to_string())
|
||||
//
|
||||
//
|
||||
// High leve list of thigns to do
|
||||
// 1. get the correct file to retrieve
|
||||
// 2. parse the file and swap out any dynamic sections
|
||||
// 3. return the string based response.
|
||||
let route_file: String = match route {
|
||||
"/" => {
|
||||
"
|
||||
return fs::read_to_string("./public/index.html").unwrap();
|
||||
},
|
||||
"/about" => {
|
||||
@ -17,6 +37,8 @@ pub fn get_route_data(route: &str) -> String {
|
||||
return fs::read_to_string("./public/404.html").unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// fs::read_to_string(route_file).unwrap();
|
||||
}
|
||||
|
||||
// pub fn path_exists(path: &str) -> bool {
|
||||
|
||||
14
theme/header.scss
Normal file
14
theme/header.scss
Normal file
@ -0,0 +1,14 @@
|
||||
header {
|
||||
background: var(--blue);
|
||||
padding: 20px;
|
||||
|
||||
#site-name {
|
||||
font-family: var(--secondary-font);
|
||||
font-size: 2rem;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--background);
|
||||
}
|
||||
}
|
||||
36
theme/headings.scss
Normal file
36
theme/headings.scss
Normal file
@ -0,0 +1,36 @@
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: var(--primary-font);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 500;
|
||||
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 500;
|
||||
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
@ -1,9 +1,19 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Anton&family=Bebas+Neue&display=swap');
|
||||
@import "variables";
|
||||
@import "reset";
|
||||
@import "header";
|
||||
@import "headings";
|
||||
|
||||
body {
|
||||
background: orange;
|
||||
background: var(--background);
|
||||
color: var(--primary-text);
|
||||
padding: 20px;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
|
||||
14
theme/variables.scss
Normal file
14
theme/variables.scss
Normal file
@ -0,0 +1,14 @@
|
||||
// Color Scheme
|
||||
:root {
|
||||
--blue: #002D62;
|
||||
--red: #C8102E;
|
||||
--green: #4CAF50;
|
||||
--background: #F5F5F5;
|
||||
--primary-text: #1A1A1A;
|
||||
--secondary-text: #555555;
|
||||
--success: #2E8B57;
|
||||
--warning: #FFA500;
|
||||
--error: #D72638;
|
||||
--primary-font: "Bebas Neue", sans-serif;
|
||||
--secondary-font: "Anton", sans-serif;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user