Compare commits

...

3 Commits

Author SHA1 Message Date
blank X 3d1624532a
Bump version to 0.3.0 2021-05-03 15:55:53 +07:00
blank X e2d6aae494
Scale images and videos to fit screen 2021-05-03 15:53:40 +07:00
blank X 782ac4e86c
Add support for /gallery links 2021-05-03 14:55:07 +07:00
4 changed files with 7 additions and 3 deletions

2
Cargo.lock generated
View File

@ -375,7 +375,7 @@ dependencies = [
[[package]]
name = "imgurx"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"quick-xml",
"reqwest",

View File

@ -1,6 +1,6 @@
[package]
name = "imgurx"
version = "0.2.0"
version = "0.3.0"
authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018"

View File

@ -30,6 +30,9 @@ async fn async_main(port: u16) {
let album_path = warp::path!("a" / String)
.and(client.clone())
.and_then(handle_album);
let gallery_path = warp::path!("gallery" / String)
.and(client.clone())
.and_then(handle_album);
let media_path = warp::path!(String).and(client).and_then(handle_media);
let root_handler = warp::path::end().map(|| warp::reply::html(
format!("<html><head><title>ImgurX v{0}</title><style>body {{ background-color: black; color: black; text-align: center; }}\ndiv {{ border: 1px solid #008; background: #eef; padding: 0.5em 1em 0.5em 1em; }}</style></head><body><div><b><a href=\"https://gitlab.com/blankX/imgurx\" style=\"text-decoration: none;\">ImgurX v{0}</a></b><br>An alternative JS-less Imgur frontend</div></body></html>", env!("CARGO_PKG_VERSION"))
@ -41,6 +44,7 @@ async fn async_main(port: u16) {
));
let routes = warp::filters::method::get().and(
album_path
.or(gallery_path)
.or(index_handler)
.or(media_path)
.or(root_handler)

View File

@ -69,7 +69,7 @@ pub fn generate_html(album: Result<Album, Error>) -> (u16, Vec<u8>) {
let elem = BytesStart::owned(b"style".to_vec(), 5);
writer.write_event(Event::Start(elem)).unwrap();
let elem = BytesText::from_plain_str("body { background-color: black; color: white; text-align: center; }\ndiv { border: 1px solid #fcc; background: #fee; padding: 0.5em 1em 0.5em 1em; color: black; }");
let elem = BytesText::from_plain_str("body { background-color: black; color: white; text-align: center; }\ndiv { border: 1px solid #fcc; background: #fee; padding: 0.5em 1em 0.5em 1em; color: black; }\nimg, video { max-width: 100%; height: auto; object-fit: contain; }");
writer.write_event(Event::Text(elem)).unwrap();
let elem = BytesEnd::owned(b"style".to_vec());