crablog/README.md

66 lines
2.1 KiB
Markdown
Raw Normal View History

# Crablog
Pure rust. Built with actix, diesel, tera, serde and sqlite3.
## Run instructions using docker
2024-08-10 09:08:43 +02:00
**TODO REWRITE, OUTDATED**
1. Clone the repository
```bash
2021-04-03 23:41:04 +02:00
git clone https://github.com/mtrx1337/crablog
2020-11-22 00:54:24 +01:00
cd crablog/site
```
2020-11-22 00:54:24 +01:00
2. Install diesel and create a database
```bash
2021-04-02 23:16:07 +02:00
cargo install diesel_cli --no-default-features --features "sqlite"
2020-11-22 00:54:24 +01:00
diesel setup --database-url ../content/db.sqlite3
diesel migration run --database-url ../content/db.sqlite3
```
3. Set up your configuration file (see below)
4. Pull the image (or build from source) and run the docker container
```bash
2020-11-17 18:12:26 +01:00
docker-compose up -d
```
## Configuration environment file
2024-08-10 09:08:43 +02:00
All configuration options are defined in .env which should be placed in the path where crablog is run. An example configuration is provided:
2024-08-10 09:08:43 +02:00
`.env`
2021-04-03 23:42:21 +02:00
```
USERNAME=yourusername
2024-08-10 09:08:43 +02:00
EMAIL=me@mydomain.tld # optional
BIND_PORT=8000 # optional
SUBMIT_TOKEN=Submit!123 # required, token needed for submitting
GITHUB_ACCOUNT=yourusername # optional
TWITTER_ACCOUNT=yourusername # optional
MASTODON_ACCOUNT=yourusername@mastodon.social # optional
REDDIT_ACCOUNT=yourusername # optional
DISCORD_ACCOUNT=yourusername # optional
2020-11-21 22:49:12 +01:00
# only needed when not using a docker container
ROOT_PATH=/path/to/template/directory/and/sqliteDB
```
2020-11-21 21:33:05 +01:00
## Routes
| Route | Description |
| ------------ | -------------------------------------------------- |
| `/` | shows the last 5 posts |
| `/id/<id>` | shows a single post by id |
| `/all` | shows all posts |
| `/submit` | set your submit token and create posts |
| `/edit/<id>` | edit, delete or hide posts |
| `/about` | information about this blog, social media accounts |
2020-11-21 21:33:05 +01:00
**API Routes**
2021-04-03 23:42:21 +02:00
| Route | Description |
| ---------------- | ------------------------- |
| `api/blog/posts` | returns all posts as json |
2024-08-10 09:08:43 +02:00
## Regenerate Migrations from Schema:
`diesel migration generate --diff-schema=./src/db/schema.rs create_posts`