mirror of
https://github.com/YGGverse/btracker-gemini.git
synced 2026-03-31 17:15:30 +00:00
add date format option, update headers
This commit is contained in:
parent
b2f3809656
commit
90d8e48b55
2 changed files with 12 additions and 10 deletions
|
|
@ -12,6 +12,10 @@ pub struct Config {
|
||||||
#[arg(short, long, default_value_t = String::from("βtracker"))]
|
#[arg(short, long, default_value_t = String::from("βtracker"))]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
||||||
|
/// Date format
|
||||||
|
#[arg(short, long, default_value_t = String::from("%Y/%m/%d"))]
|
||||||
|
pub date: String,
|
||||||
|
|
||||||
/// Tracker(s) to join / scrape requests
|
/// Tracker(s) to join / scrape requests
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub tracker: Option<Vec<Url>>,
|
pub tracker: Option<Vec<Url>>,
|
||||||
|
|
|
||||||
18
src/main.rs
18
src/main.rs
|
|
@ -36,7 +36,6 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = Arc::new(Config::parse());
|
let config = Arc::new(Config::parse());
|
||||||
|
|
||||||
let public = Arc::new(Public::init(&config.storage, config.limit, config.capacity).unwrap());
|
let public = Arc::new(Public::init(&config.storage, config.limit, config.capacity).unwrap());
|
||||||
|
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#the-use-of-tls
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#the-use-of-tls
|
||||||
|
|
@ -236,7 +235,8 @@ fn index(config: &Config, public: &Public, page: Option<usize>) -> Result<String
|
||||||
for torrent in torrents {
|
for torrent in torrents {
|
||||||
let i: TorrentMetaV1Owned = torrent_from_bytes(&torrent.bytes)?;
|
let i: TorrentMetaV1Owned = torrent_from_bytes(&torrent.bytes)?;
|
||||||
b.push(format!(
|
b.push(format!(
|
||||||
"### {}",
|
"=> /{} {}",
|
||||||
|
i.info_hash.as_string(),
|
||||||
i.info
|
i.info
|
||||||
.name
|
.name
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -244,23 +244,21 @@ fn index(config: &Config, public: &Public, page: Option<usize>) -> Result<String
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
));
|
));
|
||||||
b.push(format!(
|
b.push(format!(
|
||||||
"=> {} {} • {} • {}",
|
"{} • {} • {}\n",
|
||||||
i.info_hash.as_string(),
|
torrent.time.format(&config.date),
|
||||||
torrent.time.format("%Y/%m/%d"), // @TODO optional
|
|
||||||
size(&i),
|
size(&i),
|
||||||
files(&i),
|
files(&i),
|
||||||
));
|
))
|
||||||
|
/*b.push(format!(
|
||||||
b.push(format!(
|
|
||||||
"=> {} Magnet\n",
|
"=> {} Magnet\n",
|
||||||
magnet(&i, config.tracker.as_ref())
|
magnet(&i, config.tracker.as_ref())
|
||||||
))
|
))*/
|
||||||
}
|
}
|
||||||
|
|
||||||
b.push("## Navigation\n".into());
|
b.push("## Navigation\n".into());
|
||||||
|
|
||||||
b.push(format!(
|
b.push(format!(
|
||||||
"Page {} / {} ({total} {} total)",
|
"Page {} / {} ({total} {} total)\n",
|
||||||
page.unwrap_or(1),
|
page.unwrap_or(1),
|
||||||
(total as f64 / public.default_limit as f64).ceil(),
|
(total as f64 / public.default_limit as f64).ceil(),
|
||||||
total.plurify(&["torrent", "torrents", "torrents"])
|
total.plurify(&["torrent", "torrents", "torrents"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue