pictures in the blog
This commit is contained in:
@@ -24,7 +24,6 @@ use sea_orm::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
path::{Path as StdPath, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
@@ -436,36 +435,6 @@ async fn image_upload(auth: auth::JWT, State(ctx): State<AppContext>, multipart:
|
||||
})
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
async fn admin_images(
|
||||
auth: auth::JWT,
|
||||
jar: CookieJar,
|
||||
ViewEngine(v): ViewEngine<TeraView>,
|
||||
Query(query): Query<HashMap<String, String>>,
|
||||
State(ctx): State<AppContext>,
|
||||
) -> Result<Response> {
|
||||
admin::current_admin(auth, &ctx).await?;
|
||||
let uploaded = query.get("uploaded");
|
||||
format::view(
|
||||
&v,
|
||||
"admin/images/index.html",
|
||||
json!({
|
||||
"uploaded": uploaded,
|
||||
"uploaded_url": uploaded.map(|filename| format!("/images/{filename}")),
|
||||
"lang": current_lang(&jar),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
async fn admin_image_upload(auth: auth::JWT, State(ctx): State<AppContext>, multipart: Multipart) -> Result<Response> {
|
||||
admin::current_admin(auth, &ctx).await?;
|
||||
let data = read_multipart_file(multipart, IMAGE_MAX_BYTES).await?;
|
||||
let extension = detect_image_extension(&data)?;
|
||||
let filename = store_upload(&ctx, IMAGE_STORAGE_DIR, extension, data).await?;
|
||||
format::redirect(&format!("/admin/images?uploaded={filename}"))
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
async fn image_serve(Path(filename): Path<String>, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
let filename = safe_filename(&filename)?;
|
||||
@@ -1079,8 +1048,6 @@ pub fn routes() -> Routes {
|
||||
.add("/audio/albums/{slug}/tracks", get(public_album_tracks))
|
||||
.add("/audio/tracks", get(public_tracks))
|
||||
.add("/audio/tracks/{id}/stream", get(track_stream))
|
||||
.add("/admin/images", get(admin_images))
|
||||
.add("/admin/images/upload", post(admin_image_upload).layer(DefaultBodyLimit::max(IMAGE_MAX_BYTES + 1024 * 1024)))
|
||||
.add("/admin/audio/albums", get(admin_albums))
|
||||
.add("/admin/audio/albums/create", get(admin_album_new))
|
||||
.add("/admin/audio/albums/create", post(admin_album_create).layer(DefaultBodyLimit::max(IMAGE_MAX_BYTES + 1024 * 1024)))
|
||||
|
||||
Reference in New Issue
Block a user