Module comments, update example config
This commit is contained in:
parent
5bcc40d573
commit
d97184cd51
9 changed files with 52 additions and 6 deletions
11
README.md
11
README.md
|
|
@ -27,8 +27,19 @@ Early development: not usable yet.
|
|||
* [ ] Error pages
|
||||
* [ ] Webdesign
|
||||
* [ ] Compatibility with other forges
|
||||
* [ ] Serve at a subdirectory
|
||||
* [ ] Better logo (contribution welcome)
|
||||
|
||||
## Install
|
||||
|
||||
Use `example_config.toml`. The settings that are important to look at are `listen_host`, `listen_port`, `data_dir`, `api_client_user_agent` and `origin`.
|
||||
|
||||
The executable is self-contained. Serve it behind any reverse proxy. The process must have read/write access to `data_dir`, where the repositories will be stored.
|
||||
|
||||
```bash
|
||||
blindforge config.toml
|
||||
```
|
||||
|
||||
## Design choices
|
||||
|
||||
**Language**: It would have been simpler to use good old PHP and SQL. But I have more fun with Rust.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
data_dir = "/dev/shm/blindforge"
|
||||
|
||||
# Client will connect to the Git forge API using this User-Agent.
|
||||
#api_client_user_agent = "Blindforge"
|
||||
# Please edit this with your instance's public address.
|
||||
#api_client_user_agent = "Blindforge (https://git.zoai.re/tuxmain/blindforge)"
|
||||
|
||||
# Client will download at most this number of pages.
|
||||
#api_client_max_page = 32
|
||||
|
|
@ -30,4 +31,25 @@ data_dir = "/dev/shm/blindforge"
|
|||
# Maximum length of an URL for the client. (characters)
|
||||
#api_client_max_url_len = 256
|
||||
|
||||
#origin = "https://blindforge.zoai.re"
|
||||
# Files that are served when showing a directory (separated by colon `:`, in order of decreasing priority)
|
||||
#default_files = "README.md:README.MD:readme.md:README.txt:README.TXT:readme.txt:README:readme"
|
||||
|
||||
# Maximum number of rendered webpages to keep in cache
|
||||
#page_cache_size = 200
|
||||
|
||||
# Maximum number of repository trees to keep in cache
|
||||
#repo_cache_size = 20
|
||||
|
||||
# File extensions that will be served as images (and associated MIME type)
|
||||
#image_extensions = {ani="image/x-icon", apng="image/apng", bmp="image/bmp", cur="image/x-icon", gif="image/gif", ico="image/x-icon", jpeg="image/jpeg", jpg="image/jpeg", jxl="image/jxl", png="image/png", qoi="image/qoi", tif="image/tiff", tiff="image/tiff", webp="image/webp"}
|
||||
|
||||
# File extensions that will be served as videos (and associated MIME type)
|
||||
#video_extensions = {3gp="video/3gp", avi="video/x-msvideo", mkv="application/x-matroska", mp4="video/mp4", mpeg="video/mpeg", ogv="video/ogg", webm="video/webm"}
|
||||
|
||||
# File extensions that will be served as audio (and associated MIME type)
|
||||
#audio_extensions = {aac="audio/aac", flac="audio/flac", m4a="audio/mp4", m4b="audio/mp4", m4p="audio/mp4", m4r="audio/mp4", m4v="audio/mp4", mp3="audio/mp3", oga="audio/ogg", ogg="audio/ogg", opus="audio/opus", spx="audio/x-speex", wav="audio/x-wav", wave="audio/x-wav", wma="audio/x-ms-wma"}
|
||||
|
||||
# Authorized origin for serving inline files (CORS)
|
||||
# You should set your instance's address (e.g. "https://domain.tld")
|
||||
# to prevent people using your server as a CDN.
|
||||
#origin = "*"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Client for downloading repositories from a forge's API.
|
||||
|
||||
use std::{collections::HashSet, io::Write, path::PathBuf};
|
||||
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Generic caching in-memory map.
|
||||
|
||||
use dashmap::DashMap;
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Server configuration structure, reading and default.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct Config {
|
||||
|
|
@ -41,7 +43,9 @@ impl Default for Config {
|
|||
listen_host: String::from("127.0.0.1"),
|
||||
listen_port: 44617,
|
||||
data_dir: String::from("/var/lib/blindforge"),
|
||||
api_client_user_agent: String::from("Blindforge"),
|
||||
api_client_user_agent: String::from(
|
||||
"Blindforge (https://git.zoai.re/tuxmain/blindforge)",
|
||||
),
|
||||
api_client_max_page: 32,
|
||||
max_entries: 1024,
|
||||
max_file_size: 8 * 1024 * 1024,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! File rendering: code highlighting and markdown.
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
use linemd::Parser;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Repository data structures and storage logic.
|
||||
|
||||
use crate::api_client::{MAX_PATH_SIZE, MAX_URL_SIZE};
|
||||
|
||||
use std::{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Where routes are defined and handled.
|
||||
|
||||
use crate::{cache, config::Config, render, repo, templates};
|
||||
|
||||
use askama::Template;
|
||||
|
|
@ -315,9 +317,6 @@ pub fn make_router(config: &'static Config) -> impl Handler {
|
|||
.ok(file_content)
|
||||
}
|
||||
}
|
||||
})
|
||||
.get("/e/:secret", |conn: Conn| async move {
|
||||
conn.ok(crate::templates::Home {}.render().unwrap())
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! Templates for storing data to be rendered as HTML.
|
||||
|
||||
use std::{collections::BTreeMap, iter::Peekable};
|
||||
|
||||
use log::warn;
|
||||
|
|
|
|||
Loading…
Reference in a new issue