buckn 2 years ago
commit 4e67a31cdc

4
.gitignore vendored

@ -0,0 +1,4 @@
debug/
target/
Cargo.lock
**/*.rs.bk

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "resume"]
path = resume
url = http://208.167.242.150:3000/buckn/resume

@ -0,0 +1,11 @@
[package]
name = "buckn_dev"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-files = "0.6.2"
actix-web = "4.3.0"
structopt = "0.3.26"

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
<title>Nathan Buck's Site</title>
</head>
<body>
<div class="columns is-centered">
<div class="column is-12">
<div class="columns is-centered">
<div class="column is-3">
<br><br>
<section class="hero is-info p-4" style="border-radius: 1rem; text-align: center;">
<p class="title">Contact Info:</p>
</section>
</div>
</div>
<br><br>
<div class="columns is-centered">
<div class="column is-6">
<div class="content is-large p-6" style="text-align: center;">
<p>Email: public@buckn.dev</p>
</div>
</div>
</div>
</div>
<br>
</div>
</body>
</html>

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
<title>Nathan Buck's Site</title>
</head>
<body>
<div class="columns is-centered">
<div class="column is-12">
<div class="columns is-centered">
<div class="column is-3">
<br><br>
<section class="hero is-info p-4" style="border-radius: 1rem; text-align: center;">
<p class="title">Hi, I'm Nathan</p>
</section>
</div>
</div>
<br><br>
<div class="columns is-centered">
<div class="column is-6">
<div class="content is-large p-6" style="text-align: center;">
<p>This is my personal site</p>
<p>Here you can find my git, resume, and contact info</p>
<p>I'll be adding more to this site as I work on music, programming projects and more!</p>
</div>
</div>
</div>
</div>
<br>
</div>
</body>
</html>

@ -0,0 +1,27 @@
let url;
if (window.location.hostname.substring(0, 3) == "www") {
url = window.location.hostname.substring(4, window.location.hostname.length);
} else {
url = window.location.hostname;
}
let navbar = `
<nav class="navbar is-info has-shadow" role="navigation" aria-label="main navigation">
<div class="navbar-brand" style="padding: 1rem;">
<a class="navbar-item is-size-1" href="www.${url}">
NJB
</a>
</div>
<div id="navbar-menu" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="https://git.buckn.dev">Git</a>
<a class="navbar-item" href="/resume">Resume</a>
<a class="navbar-item" href="/contact">Contact</a>
</div>
</div>
</nav>
`;
document.querySelector("body").insertAdjacentHTML("afterbegin", navbar)

@ -0,0 +1 @@
Subproject commit 039b4356d057994938e3a24e8ad86f9611fe9d36

@ -0,0 +1,81 @@
use std::path::PathBuf;
use std::fs::*;
use std::io::prelude::*;
use structopt::StructOpt;
use actix_web::{get, web, App, HttpServer, HttpResponse, Responder, Result, HttpRequest};
use actix_files;
use actix_files::*;
#[derive(StructOpt, Debug)]
#[structopt(name = "personal site server")]
struct Opt {
#[structopt(short, long)]
address: String,
#[structopt(short, long)]
port: u16,
}
fn inject_js(html: &mut String) {
let body_location;
match html.find("</body>") {
Some(val) => body_location = val,
None => { eprintln!("this html string failed to inject the js string: {:?}", html); return; },
}
html.insert_str(body_location - 1 as usize, r#"<script type="text/javascript" src="main.js"></script>"#);
}
#[get("/")]
async fn index() -> impl Responder {
let mut file = File::open("index/index.html").unwrap();
let mut html = String::new();
file.read_to_string(&mut html).unwrap();
inject_js(&mut html);
HttpResponse::Ok().body(html)
}
#[get("/resume")]
async fn resume() -> impl Responder {
let mut file = File::open("resume/index.html").unwrap();
let mut html = String::new();
file.read_to_string(&mut html).unwrap();
inject_js(&mut html);
HttpResponse::Ok().body(html)
}
#[get("/contact")]
async fn contact() -> impl Responder {
let mut file = File::open("contact/index.html").unwrap();
let mut html = String::new();
file.read_to_string(&mut html).unwrap();
inject_js(&mut html);
HttpResponse::Ok().body(html)
}
#[get("/main.js")]
async fn js() -> impl Responder {
let mut file = File::open("index/main.js").unwrap();
let mut js = String::new();
file.read_to_string(&mut js).unwrap();
HttpResponse::Ok().body(js)
}
#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
use actix_web::{web, App, HttpServer};
let opt = Opt::from_args();
HttpServer::new(|| {
App::new()
.service(index)
.service(js)
.service(resume)
.service(contact)
})
.bind((opt.address, opt.port))?
.run()
.await
}
Loading…
Cancel
Save