Add a simple index page that explains the usage

This commit is contained in:
Paul van Tilburg 2022-05-24 11:04:27 +02:00
parent fb02ddd242
commit 8afd4b17ba
Signed by: paul
GPG Key ID: C6DE073EDA9EEC4D
4 changed files with 682 additions and 39 deletions

691
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ chrono = { version = "0.4.19", features = ["serde"] }
color-eyre = "0.6.1"
reqwest = { version = "0.11.10", features = ["json"] }
rocket = { version = "0.5.0-rc.2", features = ["json"] }
rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["tera"] }
rss = "2.0.1"
tempfile = "3"
tokio = { version = "1.6.1", features = ["process"] }

View File

@ -15,6 +15,7 @@ use rocket::http::uri::Absolute;
use rocket::response::Redirect;
use rocket::serde::{Deserialize, Serialize};
use rocket::{get, routes, uri, Build, Responder, Rocket, State};
use rocket_dyn_templates::{context, Template};
use rss::extension::itunes::{
ITunesCategoryBuilder, ITunesChannelExtensionBuilder, ITunesItemExtensionBuilder,
};
@ -158,9 +159,16 @@ async fn feed(backend: &str, username: &str, config: &State<Config>) -> Option<R
Some(feed)
}
/// Returns a simple index page that explains the usage.
#[get("/")]
pub(crate) async fn index(config: &State<Config>) -> Template {
Template::render("index", context! { url: &config.url })
}
/// Sets up Rocket.
pub fn setup() -> Rocket<Build> {
rocket::build()
.mount("/", routes![download, feed])
.mount("/", routes![download, feed, index])
.attach(AdHoc::config::<Config>())
.attach(Template::fairing())
}

19
templates/index.html.tera Normal file
View File

@ -0,0 +1,19 @@
<h1>Welcome to Podbringer</h1>
<p>
Podbringer currently has no front-end or web interface yet that can help you
use it. Until then, you just have to enter the right service-specific RSS feed
URL in your favorite podcast client to start using it.
</p>
<p>
Given the Mixcloud URL <https://www.mixcloud.com/myfavouriteband/>, the URL you
need to use for Podbringer is comprised of the following parts:
<pre>
https://my.domain.tld/podbringer/feed/mixcloud/myfavouriteband
|------------------------------| |-------||--------------|
The Podbringer location URL Service User @ service
</pre>
</p>
<p>
The Podbringer location URL of this instance is: {{ url }}
</p>