*+ More env flags listed in readme

*! Async requests for category pictures

With async requests in place HTTP2 should be defaulted more often now
It is recommended now however to enable it with the reverse proxy of choice
This commit is contained in:
shockrah 2022-01-28 13:39:19 -08:00
parent c2eb93d3af
commit 683dcffd6f
4 changed files with 28 additions and 27 deletions

View File

@ -23,6 +23,12 @@ There are a few environment variables that can be configured:
* `THUMBS_DIR`: default = `/media/thumbnails`
* `SITE_NAME`: default = _Clippable_
* `SITE_DESC`: default = _Short clips_
* `SITE_URL`: default = `#`
## Building the backend
Currently the project relies on Rust Nightly to build due to a requirement in

View File

@ -1,5 +0,0 @@
server {
root /var/www/clippable;
index index.html;
server_name clippable.shockrah.xyz;
}

View File

@ -74,22 +74,20 @@ function category_ready_handler(e?: Event) : Event {
if(document.readyState != 'complete') { return e }
let xml = new XMLHttpRequest()
const endpoint = window.location.origin + '/api' + window.location.pathname
xml.open('GET', endpoint, false)
xml.send()
if(xml.getResponseHeader('Content-Type') == 'application/json') {
let raw = JSON.parse(xml.responseText)
console.log(raw)
xml.onload = function() {
if(this.getResponseHeader('Content-Type') == 'application/json') {
let raw = JSON.parse(this.responseText)
for(const cat_raw of raw) {
let cat = new VideoMeta(cat_raw)
cat.as_div()
console.log(cat)
}
} else {
console.log(xml.getResponseHeader('Content-Type'))
}
}
const endpoint = window.location.origin + '/api' + window.location.pathname
xml.open('GET', endpoint, true)
xml.send()
return e
}

View File

@ -78,18 +78,20 @@ function ready_handler(e?: Event) : Event {
const endpoint = window.location.origin + '/api/categories'
let xml = new XMLHttpRequest()
// TODO: change this to an async request
xml.open('GET', endpoint, false) // sync request
xml.send(null) // nothing required for stuff
if(xml.getResponseHeader('Content-Type') == 'application/json') {
let raw = JSON.parse(xml.responseText)
xml.onload = function() {
if(this.getResponseHeader('Content-Type') == 'application/json') {
let raw = JSON.parse(this.responseText)
for(const cat_raw of raw) {
let cat = new Category(cat_raw)
cat.as_div()
}
} else {
console.log(xml.getResponseHeader('Content-Type'))
}
}
// Fire request
xml.open('GET', endpoint, true) // sync request
xml.send(null) // nothing required for stuff
return e
}