implement justified layout
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
[package]
|
||||
name = "backend"
|
||||
version = "0.1.0"
|
||||
authors = ["Johannes Heuel <johannes.heuel@rwth-aachen.de>"]
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = " "
|
||||
default-run = "backend"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
actix-web-lab = "^0"
|
||||
|
||||
@@ -27,4 +27,4 @@ pub fn create_picture<'a>(conn: &PgConnection, new_picture: NewPicture) -> usize
|
||||
.values(&new_picture)
|
||||
.execute(conn)
|
||||
.expect("Error saving new picture")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ extern crate diesel;
|
||||
#[macro_use]
|
||||
extern crate diesel_migrations;
|
||||
|
||||
use std::mem::swap;
|
||||
|
||||
use actix_files as fs;
|
||||
use actix_web::{Responder, Result};
|
||||
use actix_web_lab::web::spa;
|
||||
use backend::establish_connection;
|
||||
use actix_web::{
|
||||
// get, middleware, post, web, App, Error, HttpRequest, HttpResponse, HttpServer,
|
||||
get,
|
||||
@@ -16,6 +15,9 @@ use actix_web::{
|
||||
App,
|
||||
HttpServer,
|
||||
};
|
||||
use actix_web::{Responder, Result};
|
||||
use actix_web_lab::web::spa;
|
||||
use backend::establish_connection;
|
||||
use diesel::prelude::*;
|
||||
use diesel::r2d2::{self, ConnectionManager};
|
||||
|
||||
@@ -42,10 +44,19 @@ async fn get_pictures(pool: web::Data<DbPool>) -> Result<impl Responder> {
|
||||
|
||||
let pics: Vec<OutputPicture> = pics
|
||||
.iter()
|
||||
.map(|x| OutputPicture {
|
||||
thumbnail: x.thumbnail.clone(),
|
||||
width: x.width.try_into().unwrap(),
|
||||
height: x.height.try_into().unwrap(),
|
||||
.map(|x| {
|
||||
let mut w: u32 = x.width.try_into().unwrap();
|
||||
let mut h: u32 = x.height.try_into().unwrap();
|
||||
if let Some(o) = &x.orientation {
|
||||
if o == "Rotate 270 CW" {
|
||||
swap(&mut w, &mut h);
|
||||
}
|
||||
}
|
||||
OutputPicture {
|
||||
thumbnail: x.thumbnail.clone(),
|
||||
width: w,
|
||||
height: h,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user