WIP frontend isn't completely broken now

Still more work left with integrating apalis and need to fully update
it.

These changes are mostly for fixing the frontend I broke by eagerly
updating everything.
This commit is contained in:
2025-02-10 00:51:04 -05:00
parent 7a8f7dc415
commit 98c06cbe91
10 changed files with 1053 additions and 611 deletions

1565
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -16,21 +16,21 @@ ammonia = "4"
ansi-to-html = "0.2" ansi-to-html = "0.2"
anyhow = "1" anyhow = "1"
# apalis v0.6 fixes this issue: https://github.com/geofmureithi/apalis/issues/351 # apalis v0.6 fixes this issue: https://github.com/geofmureithi/apalis/issues/351
apalis = { version = "0.6.0-rc.7", features = ["retry"] } apalis = { version = "0.6.0-rc.8", features = ["retry"] }
apalis-cron = "0.6.0-rc.7" apalis-cron = "0.6.0-rc.8"
apalis-redis = "0.6.0-rc.7" apalis-redis = "0.6.0-rc.8"
async-trait = "0.1" async-trait = "0.1"
axum = { version = "0.7", features = ["form", "multipart", "query"] } axum = { version = "0.7", features = ["form", "multipart", "query"] }
axum-client-ip = "0.6" axum-client-ip = "0.6"
axum-extra = { version = "0.9", features = ["typed-header"] } axum-extra = { version = "0.9", features = ["typed-header"] }
axum-login = "0.15" axum-login = "0.16"
base64 = "0.22" base64 = "0.22"
bytes = "1.4" bytes = "1.4"
# TODO: replace chrono with time # TODO: replace chrono with time
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.4", features = ["derive", "env"] } clap = { version = "4.4", features = ["derive", "env"] }
dotenvy = "0.15" dotenvy = "0.15"
feed-rs = "1.3" feed-rs = "2.1"
fred = "9" fred = "9"
futures = "0.3" futures = "0.3"
headers = "0.4" headers = "0.4"
@@ -41,6 +41,7 @@ lettre = { version = "0.11", features = ["builder"] }
maud = { git = "https://github.com/vidhanio/maud", branch = "patch-1", features = [ maud = { git = "https://github.com/vidhanio/maud", branch = "patch-1", features = [
"axum", "axum",
] } ] }
# upgrading this to > 6 causes infinite reloads with tower-livereload
notify = "6" notify = "6"
once_cell = "1.18" once_cell = "1.18"
opml = "1.1" opml = "1.1"
@@ -59,21 +60,21 @@ sqlx = { version = "0.7", features = [
"uuid", "uuid",
"ipnetwork", "ipnetwork",
] } ] }
thiserror = "1" thiserror = "2"
time = "0.3" time = "0.3"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["sync"] } tokio-stream = { version = "0.1", features = ["sync"] }
tower = "0.4" tower = { version = "0.5", features = ["retry"] }
tower-livereload = "0.9" tower-livereload = "0.9"
tower-http = { version = "0.5", features = ["trace", "fs"] } tower-http = { version = "0.6", features = ["trace", "fs"] }
tower-sessions = { version = "0.12", features = ["signed"] } tower-sessions = { version = "0.13", features = ["signed"] }
tower-sessions-redis-store = "0.12" tower-sessions-redis-store = "0.14"
tracing = { version = "0.1", features = ["valuable", "attributes"] } tracing = { version = "0.1", features = ["valuable", "attributes"] }
tracing-appender = "0.2" tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
uuid = { version = "1.4", features = ["serde"] } uuid = { version = "1.4", features = ["serde"] }
url = "2.4" url = "2.4"
validator = { version = "0.18", features = ["derive"] } validator = { version = "0.19", features = ["derive"] }
[profile.dev.package.sqlx-macros] [profile.dev.package.sqlx-macros]
opt-level = 3 opt-level = 3

Binary file not shown.

View File

@@ -1,10 +1,5 @@
import htmx from 'htmx.org'; import htmx from 'htmx.org';
// import assets so they get named with a content hash that busts caches
// import '../css/styles.css';
import './localTimeController';
declare global { declare global {
interface Window { interface Window {
htmx: typeof htmx; htmx: typeof htmx;
@@ -13,5 +8,16 @@ declare global {
window.htmx = htmx; window.htmx = htmx;
// eslint-disable-next-line import/first // Wait for htmx to be fully initialized before loading extensions
import 'htmx.org/dist/ext/sse'; document.addEventListener(
'htmx:load',
() => {
import('htmx.org/dist/ext/sse');
},
{ once: true }
);
// import assets so they get named with a content hash that busts caches
// import '../css/styles.css';
import './localTimeController';

View File

@@ -2,21 +2,21 @@
"name": "crawlnicle-frontend", "name": "crawlnicle-frontend",
"module": "js/index.ts", "module": "js/index.ts",
"devDependencies": { "devDependencies": {
"@tailwindcss/forms": "^0.5.7", "@tailwindcss/forms": "^0.5.10",
"@tailwindcss/typography": "^0.5.13", "@tailwindcss/typography": "^0.5.16",
"@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.8.0", "@typescript-eslint/parser": "^7.18.0",
"bun-types": "^1.1.8", "bun-types": "^1.2.2",
"eslint": "^9.2.0", "eslint": "^9.20.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "latest", "eslint-config-standard-with-typescript": "latest",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.6.0", "eslint-plugin-n": "^17.15.1",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^6.6.0",
"prettier": "^3.2.5", "prettier": "^3.4.2",
"tailwindcss": "^3.4.3", "tailwindcss": "^3.4.17",
"typescript": "^5.4.5" "typescript": "^5.7.3"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.0.0" "typescript": "^5.0.0"

View File

@@ -1,8 +1,8 @@
const plugin = require('tailwindcss/plugin'); import plugin from 'tailwindcss/plugin';
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { export default {
content: ['./src/**/*.rs'], content: ['../src/**/*.rs'],
theme: { theme: {
extend: {}, extend: {},
}, },

View File

@@ -7,14 +7,22 @@ install-frontend:
clean-frontend: clean-frontend:
rm -rf ./static/js/* ./static/css/* ./static/img/* rm -rf ./static/js/* ./static/css/* ./static/img/*
build-frontend: clean-frontend [working-directory: 'frontend']
bunx tailwindcss -i frontend/css/styles.css -o static/css/styles.css --minify build-css:
bunx tailwindcss -i css/styles.css -o ../static/css/styles.css --minify
[working-directory: 'frontend']
build-dev-css:
bunx tailwindcss -i css/styles.css -o ../static/css/styles.css
build-frontend: clean-frontend build-css
bun build frontend/js/index.ts \ bun build frontend/js/index.ts \
--outdir ./static \ --outdir ./static \
--root ./frontend \ --root ./frontend \
--entry-naming [dir]/[name]-[hash].[ext] \ --entry-naming [dir]/[name]-[hash].[ext] \
--chunk-naming [dir]/[name]-[hash].[ext] \ --chunk-naming [dir]/[name]-[hash].[ext] \
--asset-naming [dir]/[name]-[hash].[ext] \ --asset-naming [dir]/[name]-[hash].[ext] \
--sourcemap=linked \
--minify --minify
mkdir -p static/img mkdir -p static/img
cp frontend/img/* static/img/ cp frontend/img/* static/img/
@@ -22,14 +30,14 @@ build-frontend: clean-frontend
touch ./static/css/manifest.txt # create empty manifest to be overwritten by build.rs touch ./static/css/manifest.txt # create empty manifest to be overwritten by build.rs
touch .frontend-built # trigger build.rs to run touch .frontend-built # trigger build.rs to run
build-dev-frontend: clean-frontend build-dev-frontend: clean-frontend build-dev-css
bunx tailwindcss -i frontend/css/styles.css -o static/css/styles.css
bun build frontend/js/index.ts \ bun build frontend/js/index.ts \
--outdir ./static \ --outdir ./static \
--root ./frontend \ --root ./frontend \
--entry-naming [dir]/[name]-[hash].[ext] \ --entry-naming [dir]/[name]-[hash].[ext] \
--chunk-naming [dir]/[name]-[hash].[ext] \ --chunk-naming [dir]/[name]-[hash].[ext] \
--asset-naming [dir]/[name]-[hash].[ext] --asset-naming [dir]/[name]-[hash].[ext] \
--sourcemap=linked
mkdir -p static/img mkdir -p static/img
cp frontend/img/* static/img/ cp frontend/img/* static/img/
touch ./static/js/manifest.txt # create empty manifest needed so binary compiles touch ./static/js/manifest.txt # create empty manifest needed so binary compiles

View File

@@ -11,7 +11,7 @@ use uuid::Uuid;
use crate::actors::crawl_scheduler::{CrawlSchedulerHandle, CrawlSchedulerHandleMessage}; use crate::actors::crawl_scheduler::{CrawlSchedulerHandle, CrawlSchedulerHandleMessage};
use crate::error::Error; use crate::error::Error;
use crate::models::feed::{Feed, CreateFeed}; use crate::models::feed::{CreateFeed, Feed};
use crate::state::Imports; use crate::state::Imports;
use crate::uuid::Base62Uuid; use crate::uuid::Base62Uuid;

View File

@@ -19,7 +19,6 @@ use dotenvy::dotenv;
use fred::prelude::*; use fred::prelude::*;
use lettre::transport::smtp::authentication::Credentials; use lettre::transport::smtp::authentication::Credentials;
use lettre::SmtpTransport; use lettre::SmtpTransport;
use notify::Watcher;
use reqwest::Client; use reqwest::Client;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use time::Duration; use time::Duration;
@@ -27,7 +26,6 @@ use tokio::sync::watch::channel;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tower::ServiceBuilder; use tower::ServiceBuilder;
use tower_http::{services::ServeDir, trace::TraceLayer}; use tower_http::{services::ServeDir, trace::TraceLayer};
use tower_livereload::LiveReloadLayer;
use tower_sessions::cookie::Key; use tower_sessions::cookie::Key;
use tower_sessions_redis_store::{ use tower_sessions_redis_store::{
fred::{ fred::{
@@ -193,6 +191,8 @@ async fn main() -> Result<()> {
.layer(ip_source_extension); .layer(ip_source_extension);
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
use notify::Watcher;
use tower_livereload::LiveReloadLayer;
debug!("starting livereload"); debug!("starting livereload");
let livereload = LiveReloadLayer::new().request_predicate(not_htmx_predicate); let livereload = LiveReloadLayer::new().request_predicate(not_htmx_predicate);
let reloader = livereload.reloader(); let reloader = livereload.reloader();

View File

@@ -1,2 +0,0 @@
const config = require('./frontend/tailwind.config.js');
export default config;