Fix post ID parsing
This commit is contained in:
parent
e731cfbac4
commit
6feb347c27
16
src/main.rs
16
src/main.rs
@ -1,7 +1,6 @@
|
|||||||
// Import Crates
|
// Import Crates
|
||||||
// use askama::filters::format;
|
// use askama::filters::format;
|
||||||
use surf::utils::async_trait;
|
use tide::{Middleware, Next, Request, Response, utils::{After, async_trait}};
|
||||||
use tide::{utils::After, Middleware, Next, Request, Response};
|
|
||||||
|
|
||||||
// Reference local files
|
// Reference local files
|
||||||
mod post;
|
mod post;
|
||||||
@ -150,6 +149,7 @@ async fn main() -> tide::Result<()> {
|
|||||||
app.at("/manifest.json/").get(manifest);
|
app.at("/manifest.json/").get(manifest);
|
||||||
app.at("/logo.png/").get(pwa_logo);
|
app.at("/logo.png/").get(pwa_logo);
|
||||||
app.at("/touch-icon-iphone.png/").get(iphone_logo);
|
app.at("/touch-icon-iphone.png/").get(iphone_logo);
|
||||||
|
app.at("/apple-touch-icon.png/").get(iphone_logo);
|
||||||
|
|
||||||
// Proxy media through Libreddit
|
// Proxy media through Libreddit
|
||||||
app.at("/proxy/*url/").get(proxy::handler);
|
app.at("/proxy/*url/").get(proxy::handler);
|
||||||
@ -199,13 +199,13 @@ async fn main() -> tide::Result<()> {
|
|||||||
// Search all of Reddit
|
// Search all of Reddit
|
||||||
app.at("/search/").get(search::find);
|
app.at("/search/").get(search::find);
|
||||||
|
|
||||||
// Short link for post
|
|
||||||
// .route("/{sort:best|hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
|
|
||||||
// .route("/{id:.{5,6}}/", web::get().to(post::item))
|
|
||||||
app.at("/:id/").get(|req: Request<()>| async {
|
app.at("/:id/").get(|req: Request<()>| async {
|
||||||
match req.param("id").unwrap_or_default() {
|
match req.param("id") {
|
||||||
"best" | "hot" | "new" | "top" | "rising" | "controversial" => subreddit::page(req).await,
|
// Sort front page
|
||||||
_ => post::item(req).await,
|
Ok("best") | Ok("hot") | Ok("new") | Ok("top") | Ok("rising") | Ok("controversial") => subreddit::page(req).await,
|
||||||
|
// Short link for post
|
||||||
|
Ok(id) if id.len() > 4 && id.len() < 7 => post::item(req).await,
|
||||||
|
_ => utils::error("Nothing here".to_string()).await
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{% macro render_flair(flair) -%}
|
{% macro render_flair(flair) -%}
|
||||||
{% for flair_part in flair %}
|
{% for flair_part in flair %}
|
||||||
{% if flair_part.flair_part_type == "emoji" %}<span class="emoji" style="background-image:url('{{ flair_part.value }}');"></span>
|
{% if flair_part.flair_part_type == "emoji" %}<span class="emoji" style="background-image:url('{{ flair_part.value }}');"></span>
|
||||||
{% else if flair_part.flair_part_type == "text" %}<span>{{ flair_part.value }}</span>{% endif %}
|
{% else if flair_part.flair_part_type == "text" && !flair_part.value.is_empty() %}<span>{{ flair_part.value }}</span>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user