From 549928a460696b2fc994daf7d1a375d0280b87a8 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 6 Nov 2024 17:43:08 -0500 Subject: Increase horizontal padding on the /me link so it looks a little less cramped --- ui/routes/+layout.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/routes/+layout.svelte') diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index ef3e823..0aeb144 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -33,7 +33,7 @@ understory {#if $currentUser} -
+ {/if} -- cgit v1.2.3 From 7a26a75506de82ba1e2e0567f8f96fc2784874e9 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 8 Nov 2024 17:28:48 -0500 Subject: Rename the project to `pilcrow`. --- .envrc | 2 +- .gitignore | 3 ++ Cargo.lock | 70 +++++++++++++++++++++--------------------- Cargo.toml | 11 +++---- Dockerfile.builder | 4 +-- debian/default | 4 +-- debian/hi.service | 6 ++-- debian/postinst | 4 +-- docs/api/book.toml | 2 +- docs/design.md | 4 +-- docs/internal-server-errors.md | 2 +- docs/ops.md | 8 ++--- git-hooks/pre-commit | 4 +-- package-lock.json | 4 +-- package.json | 2 +- src/cli.rs | 33 ++++++++++---------- src/error.rs | 2 +- src/lib.rs | 2 +- src/main.rs | 2 +- tools/build-builder | 4 +-- tools/build-debian | 2 +- tools/run | 3 +- tools/version | 2 +- ui/routes/(app)/+layout.svelte | 2 +- ui/routes/+layout.svelte | 2 +- 25 files changed, 93 insertions(+), 91 deletions(-) (limited to 'ui/routes/+layout.svelte') diff --git a/.envrc b/.envrc index 0423909..56295f5 100644 --- a/.envrc +++ b/.envrc @@ -1,6 +1,6 @@ PATH_add tools PATH_add target/debug -export DATABASE_URL="${DATABASE_URL:-sqlite://.hi?mode=rwc}" +export DATABASE_URL="${DATABASE_URL:-sqlite://pilcrow.db?mode=rwc}" source_env_if_exists .envrc.local diff --git a/.gitignore b/.gitignore index 7977b18..11b7d6f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ /.hi /.hi.pre-commit /.hi.backup +/pilcrow.db +/pilcrow.db.backup +/pilcrow.db.pre-commit /vite.config.js.*.mjs diff --git a/Cargo.lock b/Cargo.lock index d98f51f..0e4c143 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -798,41 +798,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" -[[package]] -name = "hi" -version = "0.1.0" -dependencies = [ - "argon2", - "async-trait", - "axum", - "axum-extra", - "chrono", - "clap", - "faker_rand", - "futures", - "headers", - "hex-literal", - "itertools", - "mime", - "password-hash", - "pin-project", - "rand", - "rand_core", - "rusqlite", - "rust-embed", - "serde", - "serde_json", - "sqlx", - "thiserror", - "tokio", - "tokio-stream", - "unicode-casefold", - "unicode-normalization", - "unicode-segmentation", - "unix_path", - "uuid", -] - [[package]] name = "hkdf" version = "0.12.4" @@ -1262,6 +1227,41 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pilcrow" +version = "0.1.0" +dependencies = [ + "argon2", + "async-trait", + "axum", + "axum-extra", + "chrono", + "clap", + "faker_rand", + "futures", + "headers", + "hex-literal", + "itertools", + "mime", + "password-hash", + "pin-project", + "rand", + "rand_core", + "rusqlite", + "rust-embed", + "serde", + "serde_json", + "sqlx", + "thiserror", + "tokio", + "tokio-stream", + "unicode-casefold", + "unicode-normalization", + "unicode-segmentation", + "unix_path", + "uuid", +] + [[package]] name = "pin-project" version = "1.1.7" diff --git a/Cargo.toml b/Cargo.toml index 868308f..371ade5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,23 +1,22 @@ [package] -name = "hi" +name = "pilcrow" version = "0.1.0" edition = "2021" rust-version = "1.82" -default-run = "hi" authors = [ - "Owen Jacobson ", + "Owen Jacobson ", "Kit La Touche ", ] [package.metadata.deb] -maintainer = "Owen Jacobson " +maintainer = "Owen Jacobson " maintainer-scripts = "debian" assets = [ # Binaries - ["target/release/hi", "/usr/bin/hi", "755"], + ["target/release/pilcrow", "/usr/bin/pilcrow", "755"], # Configuration - ["debian/default", "/etc/default/hi", "644"], + ["debian/default", "/etc/default/pilcrow", "644"], ] [package.metadata.deb.systemd-units] diff --git a/Dockerfile.builder b/Dockerfile.builder index da80c69..720b95a 100644 --- a/Dockerfile.builder +++ b/Dockerfile.builder @@ -1,7 +1,7 @@ FROM rust:1-slim-bookworm -COPY builder /opt/hi-builder -RUN /opt/hi-builder/image-setup +COPY builder /opt/pilcrow-builder +RUN /opt/pilcrow-builder/image-setup RUN mkdir /app WORKDIR /app diff --git a/debian/default b/debian/default index 3076699..3cabe21 100644 --- a/debian/default +++ b/debian/default @@ -1,2 +1,2 @@ -DATABASE_URL=sqlite:///var/lib/hi/hi.db -BACKUP_DATABASE_URL=sqlite:///var/lib/hi/backup.db +DATABASE_URL=sqlite:///var/lib/pilcrow/pilcrow.db +BACKUP_DATABASE_URL=sqlite:///var/lib/pilcrow/backup.db diff --git a/debian/hi.service b/debian/hi.service index cc4a951..e4c3589 100644 --- a/debian/hi.service +++ b/debian/hi.service @@ -1,10 +1,10 @@ [Unit] -Description=Hi chat service +Description=Pilcrow chat service After=network-online.target [Service] -EnvironmentFile=/etc/default/hi -ExecStart=/usr/bin/hi +EnvironmentFile=/etc/default/pilcrow +ExecStart=/usr/bin/pilcrow Restart=on-failure [Install] diff --git a/debian/postinst b/debian/postinst index d88a7ad..a3f58a0 100755 --- a/debian/postinst +++ b/debian/postinst @@ -4,7 +4,7 @@ set -e adduser \ --system \ --group \ - --home /var/lib/hi \ - hi + --home /var/lib/pilcrow \ + pilcrow #DEBHELPER# diff --git a/docs/api/book.toml b/docs/api/book.toml index 476872c..493939b 100644 --- a/docs/api/book.toml +++ b/docs/api/book.toml @@ -1,5 +1,5 @@ [book] -title = "The hi API" +title = "The Pilcrow API" authors = ["Owen Jacobson"] language = "en" multilingual = false diff --git a/docs/design.md b/docs/design.md index 1180b83..6cd0075 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,6 +1,6 @@ # Internal design -`hi`'s design is discovered and not planned. Do not take this as doctrine; continue to experiment on the structure as you find new needs. +`pilcrow`'s design is discovered and not planned. Do not take this as doctrine; continue to experiment on the structure as you find new needs. As of this writing, the basic flow of most requests hits several subsystems: @@ -15,7 +15,7 @@ This approach helps enable testing (see [testing.md] and the implementation of m Handling time in a service is always tricky. -`hi` takes the approach that a request is considered to be serviced at one time, and that that time is determined when the request is received. The internals of `hi` - the "app" and data access types described below, as well as most other supporting tools - are written with an eye towards accepting the "current time" as an argument, rather than calling out to a clock for themselves. +`pilcrow` takes the approach that a request is considered to be serviced at one time, and that that time is determined when the request is received. The internals of `pilcrow` - the "app" and data access types described below, as well as most other supporting tools - are written with an eye towards accepting the "current time" as an argument, rather than calling out to a clock for themselves. The "current time" for a request is determined in `src/clock.rs`, which runs on every request, and is available to the handler via the `RequestedAt` extractor defined in that module. diff --git a/docs/internal-server-errors.md b/docs/internal-server-errors.md index 16d61a2..7532e10 100644 --- a/docs/internal-server-errors.md +++ b/docs/internal-server-errors.md @@ -1,6 +1,6 @@ # Internal Server Errors -When `hi` encounters a problem that prevents a request from completing, it may report a `500 Internal Server Error` to clients, along with an error code. The actual error will be printed to standard error, with the error code. The following sections describe errors we've encountered, the likely operational consequences, and recommend approaches for addressing them. +When the `pilcrow` server encounters a problem that prevents a request from completing, it may report a `500 Internal Server Error` to clients, along with an error code. The actual error will be printed to standard error, with the error code. The following sections describe errors we've encountered, the likely operational consequences, and recommend approaches for addressing them. ## database is locked diff --git a/docs/ops.md b/docs/ops.md index 02644c2..4274e22 100644 --- a/docs/ops.md +++ b/docs/ops.md @@ -1,11 +1,11 @@ -# Operating `hi` +# Operating pilcrow ## Upgrades -`hi` will automatically upgrade its database on startup. Before doing so, it will create a backup of your database (at `.hi.backup`, or controlled by `--backup-database-url`). If the migration process succeeds, this backup will be deleted automatically. If the migration process _fails_, however, `hi` will attempt to restore your existing database from the backup before exiting. If the restore process also fails, then both the backup database and the suspected-broken database will be left in place. +The `pilcrow` server will automatically upgrade its database on startup. Before doing so, it will create a backup of your database (at `pilcrow.db.backup`, or controlled by `--backup-database-url`). If the migration process succeeds, this backup will be deleted automatically. If the migration process _fails_, however, `pilcrow` will attempt to restore your existing database from the backup before exiting. If the restore process also fails, then both the backup database and the suspected-broken database will be left in place. -To avoid destroying backups that may still be needed, `hi` will not start if the backup database already exists. **There is no catch-all advice on how to proceed**, but you can try the following: +To avoid destroying backups that may still be needed, `pilcrow` will not start if the backup database already exists. **There is no catch-all advice on how to proceed**, but you can try the following: * Start the server with **a copy** of the backup database, and determine if any data has been lost. If not, shut it down, replace your main database by copying the backup, and carry on. -The `hi` database is an ordinary file. While the server is not running, it can be freely copied or renamed without invalidating the data in it. +The `pilcrow` database is an ordinary file. While the server is not running, it can be freely copied or renamed without invalidating the data in it. diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index 6715430..587e349 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -13,7 +13,7 @@ npm run lint cargo check # Make sure the prepared statement data in .sqlx is up to date. Requires # `cargo-sqlx` (`cargo install cargo-sqlx`). -export DATABASE_URL=sqlite://.hi.pre-commit?mode=rwc -rm -f .hi.pre-commit +export DATABASE_URL=sqlite://pilcrow.db.pre-commit?mode=rwc +rm -f pilcrow.db.pre-commit cargo sqlx migrate run cargo sqlx prepare --check diff --git a/package-lock.json b/package-lock.json index 2f85351..01b0cce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "hi", + "name": "pilcrow", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "hi", + "name": "pilcrow", "version": "0.0.1", "dependencies": { "axios": "^1.7.7", diff --git a/package.json b/package.json index cb57efe..c51974c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "hi", + "name": "pilcrow", "version": "0.0.1", "private": true, "engines": { diff --git a/src/cli.rs b/src/cli.rs index 308294d..0d448d2 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,6 @@ -//! The `hi` command-line interface. +//! The `pilcrow` command-line interface. //! -//! This module supports running `hi` as a freestanding program, via the +//! This module supports running `pilcrow` as a freestanding program, via the //! [`Args`] struct. use std::{future, io}; @@ -22,18 +22,18 @@ use crate::{ ui, }; -/// Command-line entry point for running the `hi` server. +/// Command-line entry point for running the `pilcrow` server. /// /// This is intended to be used as a Clap [Parser], to capture command-line -/// arguments for the `hi` server: +/// arguments for the `pilcrow` server: /// /// ```no_run -/// # use hi::cli::Error; +/// # use pilcrow::cli::Error; /// # /// # #[tokio::main] /// # async fn main() -> Result<(), Error> { /// use clap::Parser; -/// use hi::cli::Args; +/// use pilcrow::cli::Args; /// /// let args = Args::parse(); /// args.run().await?; @@ -43,35 +43,36 @@ use crate::{ #[derive(Parser)] #[command( version, - about = "Run the `hi` server.", - long_about = r#"Run the `hi` server. + about = "Run the `pilcrow` server.", + long_about = r#"Run the `pilcrow` server. The database at `--database-url` will be created, or upgraded, automatically."# )] pub struct Args { - /// The network address `hi` should listen on + /// The network address `pilcrow` should listen on #[arg(short, long, env, default_value = "localhost")] address: String, - /// The network port `hi` should listen on + /// The network port `pilcrow` should listen on #[arg(short, long, env, default_value_t = 64209)] port: u16, - /// Sqlite URL or path for the `hi` database - #[arg(short, long, env, default_value = "sqlite://.hi")] + /// Sqlite URL or path for the `pilcrow` database + #[arg(short, long, env, default_value = "sqlite://pilcrow.db")] database_url: String, - /// Sqlite URL or path for a backup of the `hi` database during upgrades - #[arg(short = 'D', long, env, default_value = "sqlite://.hi.backup")] + /// Sqlite URL or path for a backup of the `pilcrow` database during + /// upgrades + #[arg(short = 'D', long, env, default_value = "sqlite://pilcrow.db.backup")] backup_database_url: String, } impl Args { - /// Runs the `hi` server, using the parsed configuation in `self`. + /// Runs the `pilcrow` server, using the parsed configuation in `self`. /// /// This will perform the following tasks: /// - /// * Migrate the `hi` database (at `--database-url`). + /// * Migrate the `pilcrow` database (at `--database-url`). /// * Start an HTTP server (on the interface and port controlled by /// `--address` and `--port`). /// * Print a status message. diff --git a/src/error.rs b/src/error.rs index f3399c6..7483f00 100644 --- a/src/error.rs +++ b/src/error.rs @@ -40,7 +40,7 @@ impl fmt::Display for Internal { impl IntoResponse for Internal { fn into_response(self) -> Response { let Self(id, error) = &self; - eprintln!("hi: [{id}] {error}"); + eprintln!("pilcrow: [{id}] {error}"); (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()).into_response() } } diff --git a/src/lib.rs b/src/lib.rs index 84b8dfc..765e625 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -//! `hi` - a web-based, self-hosted chat system. +//! Pilcrow - a web-based, self-hosted chat system. #![warn(clippy::all)] #![warn(clippy::pedantic)] diff --git a/src/main.rs b/src/main.rs index d0830ff..427294e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use clap::Parser; -use hi::cli; +use pilcrow::cli; #[tokio::main] async fn main() -> Result<(), cli::Error> { diff --git a/tools/build-builder b/tools/build-builder index fcb1e84..8174b4e 100755 --- a/tools/build-builder +++ b/tools/build-builder @@ -8,7 +8,7 @@ cd "$(dirname "$0")/.." docker build \ --platform "linux/arm64,linux/amd64" \ - --tag "hi-debian-builder:$(tools/version)" \ - --tag "hi-debian-builder:latest" \ + --tag "pilcrow-debian-builder:$(tools/version)" \ + --tag "pilcrow-debian-builder:latest" \ --file Dockerfile.builder \ . diff --git a/tools/build-debian b/tools/build-debian index c64fc78..0e496a8 100755 --- a/tools/build-debian +++ b/tools/build-debian @@ -15,6 +15,6 @@ for platform in linux/arm64 linux/amd64; do --interactive \ --tty \ --volume "$PWD:/app" \ - "hi-debian-builder:$(tools/version)" \ + "pilcrow-debian-builder:$(tools/version)" \ cargo deb done diff --git a/tools/run b/tools/run index 562a94d..bbe0dbd 100755 --- a/tools/run +++ b/tools/run @@ -2,8 +2,7 @@ ## tools/run [ARGS...] -if [ -z ${HI_DEV+x} ]; then - tools/build-ui +if [ -z ${PILCROW_DEV+x} ]; then cargo run -- "$@" else npm run dev & PIDS[0]=$! diff --git a/tools/version b/tools/version index 8e47a7c..f11c0e8 100755 --- a/tools/version +++ b/tools/version @@ -8,4 +8,4 @@ cd "$(dirname "$0")/.." cargo metadata \ --format-version 1 | -jq -r '.packages[] | select(.name == "hi") | .version' +jq -r '.packages[] | select(.name == "pilcrow") | .version' diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index db400c4..86bc330 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -56,7 +56,7 @@ - understory + pilcrow {#if loading} diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index 0aeb144..8940659 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -30,7 +30,7 @@ logo - understory + pilcrow {#if $currentUser}
-- cgit v1.2.3