added homepage

This commit is contained in:
specCon18 2024-02-14 14:32:54 -05:00
commit 1936d7cab9
13 changed files with 1262 additions and 0 deletions

1
.direnv/flake-profile Symbolic link
View file

@ -0,0 +1 @@
flake-profile-2-link

View file

@ -0,0 +1 @@
/nix/store/8q0la01v17vcszprb68c867dll45qklc-nix-shell-env

View file

@ -0,0 +1 @@
/nix/store/xp5h122fsq5nih25lp5di2l1y7hz0aj6-nix-shell-env

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1080
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

16
Cargo.toml Normal file
View file

@ -0,0 +1,16 @@
[package]
name = "portfolio"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.79"
askama = "0.12.1"
axum = "0.7.4"
tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] }
tower = "0.4.13"
tower-http = { version = "0.5.1", features = ["fs"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

26
flake.lock generated Normal file
View file

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1707743206,
"narHash": "sha256-AehgH64b28yKobC/DAWYZWkJBxL/vP83vkY+ag2Hhy4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2d627a2a704708673e56346fcb13d25344b8eaf3",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

24
flake.nix Normal file
View file

@ -0,0 +1,24 @@
{
description = "SunServer";
inputs={
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }@inputs:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system:
import nixpkgs {
inherit system;
}
);
in {
packages = forAllSystems (system: {
default = pkgs.${system}.callPackage ./nix/default.nix { };
});
devShells = forAllSystems (system: {
default = pkgs.${system}.callPackage ./nix/devshell.nix { };
});
};
}

10
nix/default.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs ? import <nixpkgs> { }, lib }:
pkgs.rustPlatform.buildRustPackage rec {
pname = "sun_server";
version = "1.0.0";
cargoLock.lockFile = ../Cargo.lock;
src = pkgs.lib.cleanSource ../.;
buildInputs = [ ];
# doCheck = false;
}

16
nix/devshell.nix Normal file
View file

@ -0,0 +1,16 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
# Get dependencies from the main package
inputsFrom = [ (pkgs.callPackage ./default.nix { }) ];
# Additional tooling
buildInputs = with pkgs; [
cargo
cargo-watch
rustc
rustup
clippy
rust-analyzer
pkg-config
bacon
];
}

59
src/main.rs Normal file
View file

@ -0,0 +1,59 @@
use askama::Template;
use axum::{
http::StatusCode,
response::{Html, IntoResponse, Response},
routing::get,
Router,
};
use tracing::info;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
#[tokio::main]
async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "portfolio=info".into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
info!("hello, web server!");
// build our application with a single route
let app = Router::new().route("/", get(root));
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
async fn root() -> impl IntoResponse {
let template = HelloTemplate {};
HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "index.html")]
struct HelloTemplate;
/// A wrapper type that we'll use to encapsulate HTML parsed by askama into valid HTML for axum to serve.
struct HtmlTemplate<T>(T);
/// Allows us to convert Askama HTML templates into valid HTML for axum to serve in the response.
impl<T> IntoResponse for HtmlTemplate<T>
where
T: Template,
{
fn into_response(self) -> Response {
// Attempt to render the template with askama
match self.0.render() {
// If we're able to successfully parse and aggregate the template, serve it
Ok(html) => Html(html).into_response(),
// If we're not, return an error or some bit of fallback HTML
Err(err) => (
StatusCode::INTERNAL_SERVER_ERROR,
format!("Failed to render template. Error: {}", err),
)
.into_response(),
}
}
}

26
templates/index.html Normal file
View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<head>
<title>Steven Carpenters Portfolio</title>
</head>
<body>
<nav>
<ul>
<li>Home</li>
<li>Blog</li>
<li>Projects</li>
<li>Resume</li>
</ul>
</nav>
<p>Hello! My name is Steven Carpenter, and I am 25 years old. Since 2011, I have been immersed in the world of coding,
driven by a passion to enhance the ease and security of our daily computer use for everyone. My primary programming
language is Rust, but I also have experience in seven other languages, including Go and JavaScript.</p>
<p>I aim to update my blog at least twice a week, typically on Tuesdays and Thursdays. Additionally, you might see
extra posts coinciding with major updates to my projects or significant news in the tech industry. If you wish to
get in touch, please email me at steven.carpenter@skdevstudios.com, using 'Portfolio Contact' as the subject.</p>
<p>I've chosen to create my own website for this venture instead of relying on traditional blogging platforms or
social media because I view those as channels primarily for discoverability. In contrast, this website represents my
own space on the web—a space I own, moderate, and host. This independence ensures that my content remains unaffected
by the profit-driven algorithms of other platforms.</p>
</body>