first brush at the homepage

This commit is contained in:
Nickiel12 2024-07-07 01:20:21 +00:00
parent 0d48150dc7
commit c6cde944f9
14 changed files with 2678 additions and 11 deletions

1
.envrc
View file

@ -1 +1,2 @@
use flake
PATH_add scripts

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/target
.direnv
result
*/static/*/*.css

View file

@ -1,5 +0,0 @@
{
"rust-analyzer.linkedProjects": [
"./helloworld/Cargo.toml",
]
}

2512
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,3 @@
[workspace]
members = ["helloworld"]
members = ["artist-alerts"]
resolver = "2"

View file

@ -1,8 +1,19 @@
[package]
name = "helloworld"
name = "artist-alerts"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
askama = "0.12.1"
askama_axum = "0.4.0"
axum = { version = "0.7.5", features = ["macros"] }
console-subscriber = "0.3.0"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
sqlx = { version = "0.7.4", features = ["postgres", "runtime-tokio"] }
tokio = { version = "1.38.0", features = ["full"] }
tower-http = { version = "0.5.2", features = ["fs", "trace"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

View file

@ -1,3 +1,70 @@
fn main() {
println!("Hello, world!");
use std::path::PathBuf;
use askama::Template;
use axum::{
routing::{get, post},
http::StatusCode,
Json, Router,
};
use serde::{Deserialize, Serialize};
use tower_http::{services::ServeDir, trace::TraceLayer};
#[derive(Template)]
#[template(path = "index.html")]
struct HelloTemplate {
name: String
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let assets_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("static");
let static_files_service = ServeDir::new(assets_dir).append_index_html_on_directories(true);
let app = Router::new()
.route("/", get(index))
.route("/users", post(create_user))
.nest_service("/static", static_files_service)
.layer(TraceLayer::new_for_http())
.with_state("Nick".to_string())
;
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
#[axum::debug_handler]
async fn index (axum::extract::State(name): axum::extract::State<String>) -> Result<HelloTemplate, (axum::http::StatusCode, String)> {
Ok(HelloTemplate { name })
}
async fn create_user(
// this argument tells axum to parse the request body␍
// as JSON into a `CreateUser` type␍
Json(payload): Json<CreateUser>,
) -> (StatusCode, Json<User>) {
// insert your application logic here␍
let user = User {
id: 1337,
username: payload.username,
};
// this will be converted into a JSON response␍
// with a status code of `201 Created`␍
(StatusCode::CREATED, Json(user))
}
// the input to our `create_user` handler␍
#[derive(Deserialize)]
struct CreateUser {
username: String,
}
// the output to our `create_user` handler␍
#[derive(Serialize)]
struct User {
id: u64,
username: String,
}

1
artist-alerts/static/htmx@2.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
console.log("Hello World");

View file

@ -0,0 +1,13 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./templates/**/*.html"],
theme: {
extend: {
aspectRatio: {
albumCarousel: "1/1.25",
},
},
},
plugins: [],
}

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href="/static/css/main.css" rel="stylesheet"/>
<script src="/static/htmx@2.0.min.js"></script>
<script src="/static/index.js"></script>
</head>
<body>
<nav class="bg-emerald-800">
<div class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8">
<div class="relative flex h-16 items-center justify-between">
<div class="flex flex-1 items-center justify-center sm:items-stretch sm:justify-start">
<div class="flex flex-shrink-0 items-center">
<img class="h-8 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=500" alt="Your Company">
</div>
<div class="hidden sm:ml-6 sm:block">
<div class="flex space-x-4">
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
<a href="#" class="rounded-md bg-slate-800 px-3 py-2 text-sm font-medium text-white" aria-current="page">Dashboard</a>
<a href="#" class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-emerald-700 hover:text-white">Team</a>
<a href="#" class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-emerald-700 hover:text-white">Projects</a>
<a href="#" class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-emerald-700 hover:text-white">Calendar</a>
</div>
</div>
<div class="me-0 ms-auto justify-center text-white">
Hello {{ name }}!
</div>
</div>
</div>
</div>
</nav>
<div class="flex items-center justify-center h-full bg-gray-900 bg-opacity-50 p-6 pb-12">
<div class="max-w-2xl text-center text-white">
<h1 class="text-5xl md:text-7xl font-extrabold mb-6">Artist Alerts</h1>
<p class="text-xl md:text-3xl mb-10">Want to be notified when your favorite music artists release new music?</p>
<a href="#services" class="bg-green-500 hover:bg-green-700 text-white font-semibold py-3 px-6 rounded-lg">Start now!</a>
</div>
</div>
<div class="max-w-7xl pt-6 mx-auto">
<div class="w-100 h-64 flex overflow-x-auto rounded-lg bg-slate-200">
<div class="mx-5 my-auto rounded-md overflow-hidden aspect-albumCarousel h-56 bg-emerald-500">
<div class="aspect-square bg-slate-800">
</div>
<div class="text-white flex justify-center">
<p>
Album Name
</p>
</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View file

@ -35,7 +35,7 @@ Some utility commands:
rustSettings = with pkgs; {
src = ./.;
#nativeBuildInputs = [ pkg-config ];
#buildInputs = [ openssl ];
buildInputs = [ tailwindcss ];
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
@ -50,6 +50,7 @@ Some utility commands:
(pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
})
cargo-watch
cargo-edit
bacon
];

3
scripts/run-dev-server Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
tailwindcss -i ./templates/input.css -o ./static/css/main.css
cargo watch -x run -w templates -w src