mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
move css to separated cachable file, update config api
This commit is contained in:
parent
1d64acef2c
commit
054968ca5d
4 changed files with 173 additions and 169 deletions
|
|
@ -8,17 +8,9 @@ use url::Url;
|
|||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Config {
|
||||
/// Path to the [aquatic-crawler](https://github.com/yggverse/aquatic-crawler) file storage
|
||||
#[arg(long, short)]
|
||||
pub storage: PathBuf,
|
||||
|
||||
/// Default listing limit
|
||||
#[arg(long, default_value_t = 50)]
|
||||
pub list_limit: usize,
|
||||
|
||||
/// Default capacity (estimated torrents in `storage`)
|
||||
#[arg(long, default_value_t = 1000)]
|
||||
pub capacity: usize,
|
||||
/// Path to the [aquatic-crawler](https://github.com/yggverse/aquatic-crawler) preload files
|
||||
#[arg(long)]
|
||||
pub preload: PathBuf,
|
||||
|
||||
/// Server name
|
||||
#[arg(long, default_value_t = String::from("βtracker"))]
|
||||
|
|
@ -30,7 +22,7 @@ pub struct Config {
|
|||
|
||||
/// Canonical URL
|
||||
#[arg(long)]
|
||||
pub link: Option<Url>,
|
||||
pub canonical_url: Option<Url>,
|
||||
|
||||
/// Display following tracker(s) in the header, append also to the magnet links
|
||||
#[arg(long)]
|
||||
|
|
@ -39,12 +31,24 @@ pub struct Config {
|
|||
/// Format timestamps (on the web view)
|
||||
///
|
||||
/// * tip: escape with `%%d/%%m/%%Y %%H:%%M` in the CLI/bash argument
|
||||
#[arg(long, short, default_value_t = String::from("%d/%m/%Y %H:%M"))]
|
||||
#[arg(long, default_value_t = String::from("%d/%m/%Y %H:%M"))]
|
||||
pub format_time: String,
|
||||
|
||||
/// Path to the framework assets
|
||||
#[arg(long, default_value_t = String::from("./static"))]
|
||||
pub statics: String,
|
||||
|
||||
/// Default listing limit
|
||||
#[arg(long, default_value_t = 20)]
|
||||
pub list_limit: usize,
|
||||
|
||||
/// Default capacity (estimated torrents in `storage`)
|
||||
#[arg(long, default_value_t = 1000)]
|
||||
pub capacity: usize,
|
||||
|
||||
/// Bind server on given host
|
||||
#[arg(long, short, default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
|
||||
pub address: IpAddr,
|
||||
#[arg(long, default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
|
||||
pub host: IpAddr,
|
||||
|
||||
/// Bind server on given port
|
||||
#[arg(long, short, default_value_t = 8000)]
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -106,29 +106,31 @@ fn rss(feed: &State<Feed>, storage: &State<Storage>) -> Result<RawXml<String>, C
|
|||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
use clap::Parser;
|
||||
use rocket::fs::FileServer;
|
||||
let config = Config::parse();
|
||||
let feed = Feed::init(
|
||||
config.title.clone(),
|
||||
config.description.clone(),
|
||||
config.link.clone(),
|
||||
config.canonical_url.clone(),
|
||||
config.tracker.clone(),
|
||||
);
|
||||
let storage = Storage::init(config.storage, config.list_limit, config.capacity).unwrap(); // @TODO handle
|
||||
let storage = Storage::init(config.preload, config.list_limit, config.capacity).unwrap(); // @TODO handle
|
||||
rocket::build()
|
||||
.attach(Template::fairing())
|
||||
.configure(rocket::Config {
|
||||
port: config.port,
|
||||
address: config.address,
|
||||
address: config.host,
|
||||
..rocket::Config::debug_default()
|
||||
})
|
||||
.manage(feed)
|
||||
.manage(storage)
|
||||
.manage(Meta {
|
||||
canonical: config.link,
|
||||
canonical: config.canonical_url,
|
||||
description: config.description,
|
||||
format_time: config.format_time,
|
||||
title: config.title,
|
||||
trackers: config.tracker,
|
||||
})
|
||||
.mount("/", FileServer::from(config.statics))
|
||||
.mount("/", routes![index, rss])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue