mirror of
https://github.com/YGGverse/btracker-gemini.git
synced 2026-03-31 09:05:30 +00:00
use long var name
This commit is contained in:
parent
277667cdca
commit
fdd6e10e3a
1 changed files with 12 additions and 6 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -156,13 +156,14 @@ fn response(
|
|||
stream: &mut TlsStream<TcpStream>,
|
||||
) {
|
||||
debug!("Incoming request from `{peer}` to `{}`", request.url.path());
|
||||
let p = request.url.path().trim_matches('/');
|
||||
let path = request.url.path().trim_matches('/');
|
||||
// try index page
|
||||
if p.is_empty() {
|
||||
if path.is_empty() {
|
||||
send(
|
||||
&match index(
|
||||
config,
|
||||
public,
|
||||
request.url.query(),
|
||||
request.url.query_pairs().find_map(|a| {
|
||||
if a.0 == "page" {
|
||||
a.1.parse::<usize>().ok()
|
||||
|
|
@ -195,7 +196,7 @@ fn response(
|
|||
)
|
||||
}
|
||||
// try search
|
||||
else if p == "search" {
|
||||
else if path == "search" {
|
||||
send(
|
||||
&response::Input::Default(response::input::Default {
|
||||
message: Some("Keyword, file, hash...".into()),
|
||||
|
|
@ -213,7 +214,7 @@ fn response(
|
|||
)
|
||||
}
|
||||
// try info page
|
||||
else if let Ok(id) = Id20::from_str(p)
|
||||
else if let Ok(id) = Id20::from_str(path)
|
||||
&& let Some(torrent) = public.torrent(id)
|
||||
{
|
||||
send(
|
||||
|
|
@ -282,11 +283,16 @@ fn send(data: &[u8], stream: &mut TlsStream<TcpStream>, callback: impl FnOnce(Re
|
|||
|
||||
// rotes
|
||||
|
||||
fn index(config: &Config, public: &Public, page: Option<usize>) -> Result<String> {
|
||||
fn index(
|
||||
config: &Config,
|
||||
public: &Public,
|
||||
keyword: Option<&str>,
|
||||
page: Option<usize>,
|
||||
) -> Result<String> {
|
||||
use plurify::Plurify;
|
||||
|
||||
let (total, torrents) = public.torrents(
|
||||
None, // @TODO
|
||||
keyword,
|
||||
Some((Sort::Modified, Order::Desc)),
|
||||
page.map(|p| if p > 0 { p - 1 } else { p } * public.default_limit),
|
||||
Some(public.default_limit),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue