From 2c1cc78cb3a71e80f193726dce979c92f415bb25 Mon Sep 17 00:00:00 2001 From: Overlord Date: Wed, 26 Nov 2025 11:00:11 +0100 Subject: [PATCH] qol --- .gitignore | 1 + app/src/assets/style/style.css.zst | Bin 2106 -> 0 bytes app/src/database/db.v | 22 ++++++++++++++++++ app/src/main.v | 4 ++-- .../style => template/assets}/error.css | 0 .../style => template/assets}/style.css | 5 +++- app/src/template/dashboard.html | 1 + app/src/util/structs.v | 20 +++++++++------- 8 files changed, 41 insertions(+), 12 deletions(-) delete mode 100644 app/src/assets/style/style.css.zst rename app/src/{assets/style => template/assets}/error.css (100%) rename app/src/{assets/style => template/assets}/style.css (99%) diff --git a/.gitignore b/.gitignore index eadfb2d..26d2be1 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ main *.out *.zst *.gzip +*.env bin/ diff --git a/app/src/assets/style/style.css.zst b/app/src/assets/style/style.css.zst deleted file mode 100644 index 3fe1c4e0e3f5319667d53c453e7e0ec461edf88a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2106 zcmV-A2*vj(wJ-f-z93~m0JcB4B>;2uY-Z%v9t2 zq5psD4=b_&s{p0|5r!f~w|Ims&;vnG^jMzD^E}aY*pAT!@$#X=c7v0AN=d>v#X0w= zRO{%eI2XY0sYBQvFVP?d@UwMR7%!Czv_Qx~{XFJhkswKO`PM&@E>b1Z3jHET0sJ!C zm9$oyqSiJ5CP0E$PJQd|sPVPh7bzg%iO=jUINGieb-RJx_LSmPCxe7N)(L)Uk`hc% z5Q&6D5U?6G>(SQeL*9nfXreO4wh$aYDks|&Gjjxl2?DX5qSZAkgl=VQJ|%uxPwUD^ zc{oR9RsU*6z%1vWhadG(W*TOl%6?j*)A()YOK}`OTII`2+rGtl_&L>_$~lqP_K5VV zcIto~N$a;=+LxO--S*RF;O2UIMHt*rpE8VsoBB1X72FI&V6fN8Ee5!GS{*E4PjpZ@ z7r3eXZ+4qc%j(82o3d)DJ*`p}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QcMM~mEuhe+27!s6MCyeQ(Hj7qJYIDb zCpaO!H|KaFxCNw{aj3p6u1;Dz2B#V*fGecsEtV-qWx&P;)$U!NBpcaZTRd{kNQ!1z zv_5|71U08gjFzD?;iS+p^O{Va?ic*GtfNwR-fdB`OgFNQbfHCHqvG;WWwbsJgxr3e zz}4n#LR%88+c7mfL7c#e)5lcrkZ`yM2iN?fF2(R@jF4t@0Lk@GVw_fvE~EvD+-b`G z_(;VR=-x2Z+b(h#Ux(45Mk2r>9k97TLdsodN$-TaJRSGAR(LSQ6U znMauLK{hWKl0FD4z3#a;mj#BF$9=Yv!rH|Xls+#hN^xACS8eBT5*qxMu;l3N5&V>4 zz?Hao@pCzgpP)~yqxy-_EU~!rjKF##)slcI6<3V4t1_UvFfXg@s4&aLXT}XJFd1ab k{8IY$C#xuenRefAfd~s7Jp>47O=ldRBQj9X0$Zim!(96IlmGw# diff --git a/app/src/database/db.v b/app/src/database/db.v index f4740a0..5fa8c2e 100644 --- a/app/src/database/db.v +++ b/app/src/database/db.v @@ -14,3 +14,25 @@ pub fn Crypto.hash_password(password string) !string { pub fn Crypto.hash_verify(password string, hash string) !bool { return argon2.verify(hash, password.bytes()) or { return error('argon2 verify failed: ${err}') } } + +// db structure +// +// users +// CREATE TABLE users ( +// id SERIAL PRIMARY KEY, +// name TEXT UNIQUE NOT NULL, +// password_hash TEXT NOT NULL +// ); +// +// logins +// CREATE TABLE login_attempts ( +// id SERIAL PRIMARY KEY, +// username TEXT NOT NULL, +// ip TEXT NOT NULL, +// success BOOLEAN NOT NULL, +// attempt_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +// ); +// +// files +// +// diff --git a/app/src/main.v b/app/src/main.v index 88b57b7..d2bde07 100644 --- a/app/src/main.v +++ b/app/src/main.v @@ -127,8 +127,8 @@ fn populate() (&util.Config, &util.Embedded) { } } }, &util.Embedded{ - style_css: $embed_file('assets/style/style.css', .zlib).to_string() - error_css: $embed_file('assets/style/error.css', .zlib).to_string() + style_css: $embed_file('template/assets/style.css', .zlib).to_string() + error_css: $embed_file('template/assets/error.css', .zlib).to_string() } } diff --git a/app/src/assets/style/error.css b/app/src/template/assets/error.css similarity index 100% rename from app/src/assets/style/error.css rename to app/src/template/assets/error.css diff --git a/app/src/assets/style/style.css b/app/src/template/assets/style.css similarity index 99% rename from app/src/assets/style/style.css rename to app/src/template/assets/style.css index 68ecb4f..9d618d0 100644 --- a/app/src/assets/style/style.css +++ b/app/src/template/assets/style.css @@ -170,7 +170,6 @@ body { border-bottom: 1px solid var(--border-color); background-color: var(--bg-secondary); transition: background-color 0.3s ease, border-color 0.3s ease; - overflow: scroll; height: 100%; } @@ -244,6 +243,10 @@ body { -webkit-tap-highlight-color: transparent; } +.icon svg { + fill: var(--text-secondary); +} + .file-list { display: flex; flex-direction: column; diff --git a/app/src/template/dashboard.html b/app/src/template/dashboard.html index f4e8859..60a783f 100644 --- a/app/src/template/dashboard.html +++ b/app/src/template/dashboard.html @@ -12,6 +12,7 @@
+
Folder Path
@{directory} diff --git a/app/src/util/structs.v b/app/src/util/structs.v index 521c50f..d01437c 100644 --- a/app/src/util/structs.v +++ b/app/src/util/structs.v @@ -6,15 +6,16 @@ import time pub struct Database { pub: + host string + port int username string password string } pub struct Config { -pub mut: - root string - port int pub: + root string + port int database Database } @@ -53,6 +54,8 @@ pub fn Utility.get_icon(ext string, is_dir bool) string { 'zip': '' 'rar': '' '7z': '' + 'zst': '' + 'gzip': '' 'mp3': '' 'mp4': '' 'avi': '' @@ -116,7 +119,7 @@ pub fn Utility.list_files(dir_path string, relative string) ![]FileEntry { entries << FileEntry{ name: if is_dir { '${file}/' } else { file } abs_path: Utility.normalize_path(full_path) - path: Utility.normalize_path(full_path).split(relative)[1] // if relative != "" { Utility.normalize_path(full_path.split(relative)[1]) } else { Utility.normalize_path(full_path) } + path: Utility.normalize_path(full_path).split(relative)[1] or { 'err' } is_dir: is_dir size: if !is_dir { file_info.size } else { 0 } modified: file_info.mtime @@ -191,18 +194,17 @@ pub fn HtmlBuilder.generate_file_list(entries []FileEntry, current_path string) for entry in entries { if entry.is_dir { dir_count++ - file_class := 'directory' - html += '
' - html += '
${entry.icon}
' + html += '
' + html += '
${entry.icon}
' html += '' - html += '
-
' + html += '
${Utility.format_size(entry.size)}
' html += '
${Utility.format_date(entry.modified)}
' html += '
' } else { file_count++ total_size += entry.size html += '
' - html += '
${entry.icon}
' + html += '
${entry.icon}
' html += '' html += '
${Utility.format_size(entry.size)}
' html += '
${Utility.format_date(entry.modified)}
'