Slightly improve the media experience (#452)
* Slightly improve the media experience - Use a grid to display the list of media - Add icons for non-image media preview - Paginate the gallery - Add links to the gallery in the editor and in the profile settings to make it more discoverable when you need it Fixes #432 * Allow video and audio tags in SafeString Otherwise we can't display their preview, nor show them in articles Also show controls by default for these two elements * Show fallback images for audio and unknown files, to make them more visible * Add a new constructor to SafeString when the input is trusted and doesn't need to be escaped. And use it to generate media previews. * Make it possible to insert video/audio in articles
This commit is contained in:
+10
-7
@@ -5,14 +5,17 @@ use rocket_i18n::I18n;
|
||||
use std::fs;
|
||||
use plume_models::{Error, db_conn::DbConn, medias::*, users::User};
|
||||
use template_utils::Ructe;
|
||||
use routes::errors::ErrorPage;
|
||||
use routes::{Page, errors::ErrorPage};
|
||||
|
||||
#[get("/medias")]
|
||||
pub fn list(user: User, conn: DbConn, intl: I18n) -> Result<Ructe, ErrorPage> {
|
||||
let medias = Media::for_user(&*conn, user.id)?;
|
||||
#[get("/medias?<page>")]
|
||||
pub fn list(user: User, conn: DbConn, intl: I18n, page: Option<Page>) -> Result<Ructe, ErrorPage> {
|
||||
let page = page.unwrap_or_default();
|
||||
let medias = Media::page_for_user(&*conn, &user, page.limits())?;
|
||||
Ok(render!(medias::index(
|
||||
&(&*conn, &intl.catalog, Some(user)),
|
||||
medias
|
||||
&(&*conn, &intl.catalog, Some(user.clone())),
|
||||
medias,
|
||||
page.0,
|
||||
Page::total(Media::count_for_user(&*conn, &user)? as i32)
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -109,7 +112,7 @@ pub fn delete(id: i32, user: User, conn: DbConn) -> Result<Redirect, ErrorPage>
|
||||
if media.owner_id == user.id {
|
||||
media.delete(&*conn)?;
|
||||
}
|
||||
Ok(Redirect::to(uri!(list)))
|
||||
Ok(Redirect::to(uri!(list: page = _)))
|
||||
}
|
||||
|
||||
#[post("/medias/<id>/avatar")]
|
||||
|
||||
Reference in New Issue
Block a user