* Fixing broken 'missing thumbnail' default
* Fixing frontend TS to accomodate for new thumbnail uri path's
This commit is contained in:
parent
254da1ae90
commit
d924c2359a
@ -7,11 +7,12 @@ pub async fn get(file: PathBuf) -> Option<NamedFile> {
|
|||||||
let clips_dir = thumbs_dir();
|
let clips_dir = thumbs_dir();
|
||||||
|
|
||||||
// Only serve jpg's and png's through this route
|
// Only serve jpg's and png's through this route
|
||||||
return match file.extension() {
|
let file_path = Path::new(&clips_dir).join(file);
|
||||||
|
if file_path.is_file() {
|
||||||
|
return match file_path.extension() {
|
||||||
Some(ext) => {
|
Some(ext) => {
|
||||||
if ext == "jpg" || ext == "png" || ext == "jpeg" {
|
if ext == "jpg" || ext == "png" || ext == "jpeg" {
|
||||||
println!("Found it");
|
NamedFile::open(file_path).await.ok()
|
||||||
NamedFile::open(Path::new(&clips_dir).join(file)).await.ok()
|
|
||||||
} else {
|
} else {
|
||||||
println!("bad extension");
|
println!("bad extension");
|
||||||
None
|
None
|
||||||
@ -19,4 +20,8 @@ pub async fn get(file: PathBuf) -> Option<NamedFile> {
|
|||||||
},
|
},
|
||||||
None => None
|
None => None
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let path = Path::new("static/cantfindshit.gif");
|
||||||
|
return NamedFile::open(path).await.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
ts/index.ts
12
ts/index.ts
@ -1,13 +1,13 @@
|
|||||||
class Category {
|
class Category {
|
||||||
name: string
|
name: string
|
||||||
thumbnail_b64: string|null
|
thumbnail: string|null
|
||||||
constructor(raw: any) {
|
constructor(raw: any) {
|
||||||
this.name = raw['name']
|
this.name = raw['name']
|
||||||
this.thumbnail_b64 = raw['thumbnail']
|
this.thumbnail= raw['thumbnail']
|
||||||
|
|
||||||
// Setting some defaults
|
// Setting some defaults
|
||||||
if(!this.name) { this.name = null }
|
if(!this.name) { this.name = null }
|
||||||
if(!this.thumbnail_b64) { this.thumbnail_b64 = null }
|
if(!this.thumbnail) { this.thumbnail= null }
|
||||||
}
|
}
|
||||||
|
|
||||||
title_link() : HTMLHeadingElement {
|
title_link() : HTMLHeadingElement {
|
||||||
@ -19,7 +19,7 @@ class Category {
|
|||||||
link.text = this.name
|
link.text = this.name
|
||||||
} else {
|
} else {
|
||||||
link.href = '#'
|
link.href = '#'
|
||||||
link.text = 'this nigga eatin beans'
|
link.text = this.name + 'ft. No thumbnail'
|
||||||
}
|
}
|
||||||
|
|
||||||
container.appendChild(link)
|
container.appendChild(link)
|
||||||
@ -33,8 +33,8 @@ class Category {
|
|||||||
nail.className = 'pure-img'
|
nail.className = 'pure-img'
|
||||||
|
|
||||||
// Modern browser's should be able to cache this request
|
// Modern browser's should be able to cache this request
|
||||||
if(!(this.thumbnail_b64 == null || this.thumbnail_b64.length == 0)) {
|
if(!(this.thumbnail == null || this.thumbnail.length == 0)) {
|
||||||
nail.setAttribute('src', `data:image/jpg;base64,${this.thumbnail_b64}`)
|
nail.setAttribute('src', `${this.thumbnail}`)
|
||||||
} else{
|
} else{
|
||||||
nail.setAttribute('src', '/static/cantfindshit.gif')
|
nail.setAttribute('src', '/static/cantfindshit.gif')
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"setup": "mkdir -p api/static/js",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
Loading…
Reference in New Issue
Block a user