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)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Path to the [aquatic-crawler](https://github.com/yggverse/aquatic-crawler) file storage
|
/// Path to the [aquatic-crawler](https://github.com/yggverse/aquatic-crawler) preload files
|
||||||
#[arg(long, short)]
|
#[arg(long)]
|
||||||
pub storage: PathBuf,
|
pub preload: 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,
|
|
||||||
|
|
||||||
/// Server name
|
/// Server name
|
||||||
#[arg(long, default_value_t = String::from("βtracker"))]
|
#[arg(long, default_value_t = String::from("βtracker"))]
|
||||||
|
|
@ -30,7 +22,7 @@ pub struct Config {
|
||||||
|
|
||||||
/// Canonical URL
|
/// Canonical URL
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub link: Option<Url>,
|
pub canonical_url: Option<Url>,
|
||||||
|
|
||||||
/// Display following tracker(s) in the header, append also to the magnet links
|
/// Display following tracker(s) in the header, append also to the magnet links
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
|
@ -39,12 +31,24 @@ pub struct Config {
|
||||||
/// Format timestamps (on the web view)
|
/// Format timestamps (on the web view)
|
||||||
///
|
///
|
||||||
/// * tip: escape with `%%d/%%m/%%Y %%H:%%M` in the CLI/bash argument
|
/// * 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,
|
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
|
/// Bind server on given host
|
||||||
#[arg(long, short, default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
|
#[arg(long, default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
|
||||||
pub address: IpAddr,
|
pub host: IpAddr,
|
||||||
|
|
||||||
/// Bind server on given port
|
/// Bind server on given port
|
||||||
#[arg(long, short, default_value_t = 8000)]
|
#[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]
|
#[launch]
|
||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use rocket::fs::FileServer;
|
||||||
let config = Config::parse();
|
let config = Config::parse();
|
||||||
let feed = Feed::init(
|
let feed = Feed::init(
|
||||||
config.title.clone(),
|
config.title.clone(),
|
||||||
config.description.clone(),
|
config.description.clone(),
|
||||||
config.link.clone(),
|
config.canonical_url.clone(),
|
||||||
config.tracker.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()
|
rocket::build()
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.configure(rocket::Config {
|
.configure(rocket::Config {
|
||||||
port: config.port,
|
port: config.port,
|
||||||
address: config.address,
|
address: config.host,
|
||||||
..rocket::Config::debug_default()
|
..rocket::Config::debug_default()
|
||||||
})
|
})
|
||||||
.manage(feed)
|
.manage(feed)
|
||||||
.manage(storage)
|
.manage(storage)
|
||||||
.manage(Meta {
|
.manage(Meta {
|
||||||
canonical: config.link,
|
canonical: config.canonical_url,
|
||||||
description: config.description,
|
description: config.description,
|
||||||
format_time: config.format_time,
|
format_time: config.format_time,
|
||||||
title: config.title,
|
title: config.title,
|
||||||
trackers: config.tracker,
|
trackers: config.tracker,
|
||||||
})
|
})
|
||||||
|
.mount("/", FileServer::from(config.statics))
|
||||||
.mount("/", routes![index, rss])
|
.mount("/", routes![index, rss])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
147
static/theme/default.css
Normal file
147
static/theme/default.css
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
* {
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
:focus,
|
||||||
|
:focus-within,
|
||||||
|
:focus-visible,
|
||||||
|
:active,
|
||||||
|
:target,
|
||||||
|
:hover {
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity .2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #282b3c;
|
||||||
|
color: #ccc;
|
||||||
|
font-family: Sans-serif;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:visited,
|
||||||
|
a:active {
|
||||||
|
color: #96d9a1;
|
||||||
|
text-decoration: none;
|
||||||
|
opacity: .9;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5 {
|
||||||
|
display: inline-block;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
color: #ccc;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > * {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 748px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header, footer {
|
||||||
|
text-align: center;
|
||||||
|
margin: 16px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
header > a,
|
||||||
|
header > a:active,
|
||||||
|
header > a:hover,
|
||||||
|
header > a:visited {
|
||||||
|
color: #ccc;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header::first-letter {
|
||||||
|
color: #96d9a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
header > div {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header > div > code:not(:last-child)::after {
|
||||||
|
content: "|";
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pagination */
|
||||||
|
main > a {
|
||||||
|
background: #34384f;
|
||||||
|
border-radius: 3px;
|
||||||
|
float: right;
|
||||||
|
margin-left: 8px;
|
||||||
|
opacity: .96;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* item row */
|
||||||
|
main > div {
|
||||||
|
background-color: #34384f;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin: 8px 0;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* item row description */
|
||||||
|
main > div > p {
|
||||||
|
margin: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* item row meta, controls */
|
||||||
|
main > div > div {
|
||||||
|
border-top: 1px #4f536a solid;
|
||||||
|
margin-top: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > ul > li {
|
||||||
|
cursor: default;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > ul > li > span {
|
||||||
|
color: white;
|
||||||
|
font-size: smaller;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > ul > li > span:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > ul > li:not(:last-child)::after {
|
||||||
|
content: "•";
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main > div > div > a > svg {
|
||||||
|
float: right;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pagination info */
|
||||||
|
main > span {
|
||||||
|
float: right;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
@ -6,156 +6,7 @@
|
||||||
{% if meta.description %}
|
{% if meta.description %}
|
||||||
<meta name="description" content="{{ meta.description }}" />
|
<meta name="description" content="{{ meta.description }}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<style>
|
<link rel="stylesheet" type="text/css" href="/theme/default.css?v=1" />
|
||||||
* {
|
|
||||||
border: 0;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
:focus,
|
|
||||||
:focus-within,
|
|
||||||
:focus-visible,
|
|
||||||
:active,
|
|
||||||
:target,
|
|
||||||
:hover {
|
|
||||||
opacity: 1;
|
|
||||||
transition: opacity .2s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background: #282b3c;
|
|
||||||
color: #ccc;
|
|
||||||
font-family: Sans-serif;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a,
|
|
||||||
a:visited,
|
|
||||||
a:active {
|
|
||||||
color: #96d9a1;
|
|
||||||
text-decoration: none;
|
|
||||||
opacity: .9;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5 {
|
|
||||||
display: inline-block;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
color: #ccc;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body > * {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 748px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header, footer {
|
|
||||||
text-align: center;
|
|
||||||
margin: 16px auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
header > a,
|
|
||||||
header > a:active,
|
|
||||||
header > a:hover,
|
|
||||||
header > a:visited {
|
|
||||||
color: #ccc;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header::first-letter {
|
|
||||||
color: #96d9a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
header > div {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header > div > code:not(:last-child)::after {
|
|
||||||
content: "|";
|
|
||||||
margin: 0 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pagination */
|
|
||||||
main > a {
|
|
||||||
background: #34384f;
|
|
||||||
border-radius: 3px;
|
|
||||||
float: right;
|
|
||||||
margin-left: 8px;
|
|
||||||
opacity: .96;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* item row */
|
|
||||||
main > div {
|
|
||||||
background-color: #34384f;
|
|
||||||
border-radius: 3px;
|
|
||||||
margin: 8px 0;
|
|
||||||
padding: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* item row description */
|
|
||||||
main > div > p {
|
|
||||||
margin: 8px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* item row meta, controls */
|
|
||||||
main > div > div {
|
|
||||||
border-top: 1px #4f536a solid;
|
|
||||||
margin-top: 16px;
|
|
||||||
overflow: hidden;
|
|
||||||
padding-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > ul {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > ul > li {
|
|
||||||
cursor: default;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > ul > li > span {
|
|
||||||
color: white;
|
|
||||||
font-size: smaller;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > ul > li > span:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > ul > li:not(:last-child)::after {
|
|
||||||
content: "•";
|
|
||||||
margin: 0 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
main > div > div > a > svg {
|
|
||||||
float: right;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pagination info */
|
|
||||||
main > span {
|
|
||||||
display: inline-block;
|
|
||||||
float: right;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue