Compare commits

...

3 commits

Author SHA1 Message Date
Imbus
a0b1b20c26 Theme change 2023-11-06 00:24:33 +01:00
Imbus
37ff3da023 Css experimentation 2023-11-06 00:24:27 +01:00
Imbus
757e670dbb Require DATABASE_URL to be set 2023-11-06 00:23:44 +01:00
7 changed files with 27 additions and 20 deletions

View file

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" data-theme="dracula">
<html lang="en">
<head>
<meta charset="UTF-8" />

View file

@ -4,8 +4,8 @@ import { LoginContext, ModalContext } from "./Root";
export function LoginForm() {
const modal_ctx = useContext(ModalContext);
const login_ctx = useContext(LoginContext);
const [username, setUsername] = createSignal("");
const [password, setPassword] = createSignal("");
const [username, setUsername] = createSignal<string>("");
const [password, setPassword] = createSignal<string>("");
const [waiting, setWaiting] = createSignal(false);
const [error, setError] = createSignal(false);

View file

@ -7,7 +7,7 @@ import { LoginForm } from "./Login";
function Menu() {
let login_ctx = useContext(LoginContext);
return (
<ul class="menu menu-horizontal bg-base-200 rounded-box space-x-2">
<ul class="menu menu-horizontal bg-base-100 rounded-box space-x-2">
<li>
<A href="/" end>
Home
@ -31,21 +31,20 @@ export function Navbar() {
let login_ctx = useContext(LoginContext);
return (
<div class="navbar bg-base-100 max-w-3xl max-w flex">
<div class="navbar text-neutral-content max-w-3xl max-w">
<div class="flex-1">
<A href={"/"} class="btn btn-ghost normal-case text-xl">
FrostByte
</A>
</div>
<div class="">
<div class="hidden md:flex">
<Menu />
</div>
<div class="flex-1 justify-end">
<div class="flex-1 justify-end hidden md:flex">
<A
href="#"
class="btn btn-ghost normal-case text-sm"
onClick={(b) => {
b.preventDefault();
onClick={() => {
if (login_ctx?.token() != "") {
localStorage.setItem("token", "");
localStorage.setItem("username", "");

View file

@ -8,15 +8,15 @@ export default {
themes: [
{
mytheme: {
"primary": "#86e8d9",
"secondary": "#b5385d",
"accent": "#88ed5a",
"neutral": "#14171f",
"base-100": "#343154",
"info": "#9bc3e9",
"success": "#1f9363",
"warning": "#f2ce4a",
"error": "#e77d6a",
"primary": "#64279e",
"secondary": "#9454af",
"accent": "#6ff7c5",
"neutral": "#1f2329",
"base-100": "#2a3a47",
"info": "#8b9be5",
"success": "#79e2b4",
"warning": "#efb261",
"error": "#e1604c",
},
},
],

View file

@ -28,6 +28,8 @@ RUN addgroup -S user && adduser -S user -G user
WORKDIR /runner
# Copy the server binary and the public directory, note the debug binary
COPY --from=builder /build/target/x86_64-unknown-linux-musl/debug/server /runner/server
RUN mkdir /runner/public
RUN echo "Debug build!" > /runner/public/index.html
# Make sure the user can access the files
RUN chown -R user:user /runner

View file

@ -22,7 +22,7 @@ build-container-server-debug:
# Builds a debug container and runs it
[private]
start-debug: build-container-server-debug remove-podman-containers
{{runtime}} run -d -p 8080:8080 --name frostbyte-debug fb-server-debug
{{runtime}} run -d -e DATABASE_URL=sqlite:debug.db -p 8080:8080 --name frostbyte-debug fb-server-debug
@echo "Debug server started."
# Builds a release container
@ -32,6 +32,7 @@ build-container-release:
# Builds a release container and runs it
start-release: build-container-release remove-podman-containers
{{runtime}} network create fb_network --ignore
{{runtime}} run -d --network fb_network -e DATABASE_URL=sqlite:release.db -p 8080:8080 --name frostbyte fb-server
init-sqlx:
@ -43,6 +44,7 @@ init-sqlx:
# Removes and stops any containers related to the project
[private]
remove-podman-containers:
{{runtime}} network rm -f fb_network
{{runtime}} container rm -f frostbyte
{{runtime}} container rm -f frostbyte-debug

View file

@ -31,7 +31,11 @@ impl ServerState {
pub async fn new() -> Self {
// This is almost certainly bad practice for more reasons than I can count
dotenvy::dotenv().ok();
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
let db_url = dotenvy::var("DATABASE_URL").unwrap_or_else(|_| {
error!("DATABASE_URL not set in environment!");
std::process::exit(1);
});
info!("Using db_url: {}", &db_url);
if !sqlx::Sqlite::database_exists(&db_url).await.unwrap() {