mirror of
https://github.com/nielsAD/autoindex.git
synced 2026-05-06 15:06:57 +02:00
Asynchronous js loading
This commit is contained in:
50
README.md
50
README.md
@@ -32,3 +32,53 @@ Usage
|
||||
#### Example
|
||||
|
||||
`./autoindex -a=":4000" -i=5m -d=/tmp/autoindex.db -cached -r=/mnt/storage`
|
||||
|
||||
|
||||
Behind nginx
|
||||
------------
|
||||
|
||||
Example configuration for running `autoindex` behind an `nginx` proxy.
|
||||
|
||||
```
|
||||
upstream autoindex {
|
||||
server 127.0.0.1:4000;
|
||||
keepalive 8;
|
||||
}
|
||||
|
||||
map $request_uri $request_basename {
|
||||
~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename;
|
||||
}
|
||||
|
||||
map $request_uri $idx_path {
|
||||
~/(?<captured_request_path>[^?]*)(?<captured_request_args>\?.*)?$ $captured_request_path/$cap$
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name _;
|
||||
|
||||
root /opt/autoindex/public;
|
||||
|
||||
location / {
|
||||
rewrite ^/(.*)/$ /$1 permanent;
|
||||
try_files $uri /index.html;
|
||||
expires 1y;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
http2_push /idx/$idx_path;
|
||||
expires 1d;
|
||||
}
|
||||
|
||||
location ^~ /dl/ {
|
||||
limit_rate 1m;
|
||||
add_header Content-Disposition 'attachment; filename="$request_basename"';
|
||||
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
|
||||
}
|
||||
|
||||
location ~ ^(/idx/|/urllist.txt) {
|
||||
proxy_pass https://autoindex;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<title>Archive - toom.io</title>
|
||||
<link rel="shortcut icon" href="/favicon.ico?201809121" />
|
||||
<link rel="stylesheet" type="text/css" href="/style.css?201809141">
|
||||
<script src="/script.js?201809141"></script>
|
||||
<script src="/script.js?201809161" async></script>
|
||||
</head>
|
||||
<body class=loading>
|
||||
<header>
|
||||
|
||||
@@ -85,8 +85,7 @@ function setPath(crumbs, files, q, path, query) {
|
||||
req.open("GET", "/idx/" + path + query, true);
|
||||
req.send();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
function onLoad() {
|
||||
const path = document.getElementById("path");
|
||||
const files = document.getElementById("files");
|
||||
const search = document.getElementById("search");
|
||||
@@ -102,4 +101,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
const s = q.value ? "?r=1&q=" + encodeURIComponent(q.value) : "";
|
||||
setPath(path, files, q, document.location.pathname, s);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (document.readyState === "loading")
|
||||
document.addEventListener("DOMContentLoaded", onLoad);
|
||||
else
|
||||
onLoad();
|
||||
|
||||
Reference in New Issue
Block a user