Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http 2.0.0 #160

Merged
merged 182 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
9e6fcd1
Clean up and fix file_length_impl for blockdevs on linux
nabijaczleweli Sep 4, 2023
75c6f07
ETag: generation and If-None-Match:/If-Modified-Since: for read requests
nabijaczleweli Sep 5, 2023
37bbea4
Fix directory uploads on Chromium, which returns up to 100 files at a…
nabijaczleweli Oct 27, 2023
6662d10
Remove pre-counting step and just ++remaining_files before sending th…
nabijaczleweli Oct 27, 2023
4cac7c5
Have a live read-out of outstanding requests too
nabijaczleweli Oct 27, 2023
7e368b8
macos has unix permissions
nabijaczleweli Oct 27, 2023
a59b521
Use X-Last-Modified header in PUTs to set mtime on created files
nabijaczleweli Oct 27, 2023
e47669d
Log the requested modified time in-line
nabijaczleweli Oct 27, 2023
1cf4b72
Remove unneeded Borrow::borrow() call
nabijaczleweli Nov 29, 2023
be7de13
Implement blockdev size detexion generically (Linux/{Net,Free}BSD/Ope…
nabijaczleweli Dec 28, 2023
bc41cb4
Validate the http_blkgetsize() illumos gate port
nabijaczleweli Jan 7, 2024
875baea
Proper overflow handling on OpenBSD
nabijaczleweli Mar 12, 2024
448f96f
Flatten build.rs
nabijaczleweli Mar 12, 2024
d151f6e
Avoid NAME_MAX when deciding on temporary directory
nabijaczleweli Mar 12, 2024
62027be
Debug print 💀
nabijaczleweli Mar 12, 2024
248d439
We don't care about is_remove for PROPPATCH
nabijaczleweli May 8, 2024
6df27cc
Accept a/c/mtime changes in WebDAV (Windows client) and executablenes…
nabijaczleweli May 8, 2024
d3f4e8c
Accept X-OC_MTIME header (Total Commander Android WebDAV)
nabijaczleweli May 8, 2024
d6ac96f
Update encoding blacklist (most pressingly with lz4 :v)
nabijaczleweli May 8, 2024
a6514ef
Use current req_p instead of stored req_p (which may no longer exist)…
nabijaczleweli May 8, 2024
bbed9e8
Dicument X-OX-MTime
nabijaczleweli May 8, 2024
64f121f
Add --encoded-filesystem, --encoded-generated, and --encoded-prune to…
nabijaczleweli May 9, 2024
2d973a9
Actually remove the temporary upload file instead of letting it feste…
nabijaczleweli May 9, 2024
c594ca3
Don't parse generated reponse charset every time
nabijaczleweli May 9, 2024
7419e7a
No atomic statics fuckin goofy ass
nabijaczleweli May 10, 2024
c297271
Fix all-CPUs-100%ing on Ctrl-C on Win32
nabijaczleweli May 10, 2024
e1bb29b
clang-format real
nabijaczleweli May 10, 2024
a6292ca
No need to check exists if we're deleting anyway
nabijaczleweli May 10, 2024
466ca66
AVIF :)
nabijaczleweli May 12, 2024
1927f70
Replace the single-use lazy-static regexes for option parsing with tr…
nabijaczleweli May 12, 2024
3ebfe11
Move run-time parsing, allocation, and base64ification of assets to a…
nabijaczleweli May 12, 2024
76e9458
Move XML and Brotli config from lazy_statics to trivial inlineable fu…
nabijaczleweli May 12, 2024
8b1d70b
Replace single-use unicase and run-time parsing with a singular optim…
nabijaczleweli May 12, 2024
9e3e1cf
lazy_static for ln(1024) => inline const
nabijaczleweli May 12, 2024
a81e456
Outline text/html;charset=utf-8 to function (rustfmt fails to break t…
nabijaczleweli May 12, 2024
9e75edb
Simply remember what the allowed methods are instead of reinventing i…
nabijaczleweli May 12, 2024
a464061
OsStr Windows/Unix :/
nabijaczleweli May 12, 2024
07b1830
Load umask in constructor
nabijaczleweli May 12, 2024
a65b272
Parse supported encodings sanely, thus killing lazy_static
nabijaczleweli May 12, 2024
b982429
Useless lazysort that yielded inefficient cur = format!({}, cur loop
nabijaczleweli May 12, 2024
4f8ab96
Pre-inject assets into HTMLs at build time
nabijaczleweli May 12, 2024
a865809
Pre-parse the HTMLs, allocating only one string for formatting
nabijaczleweli May 12, 2024
9586e2f
Fix first directory's icons with -wd at / being full-width instead of…
nabijaczleweli May 12, 2024
2e414a1
Don't hash the whole file each time
nabijaczleweli May 12, 2024
e717b31
Fully-buffer (i.e. not 8k :v) I/O for hashing and compression
nabijaczleweli May 12, 2024
e822746
vendor iron-0.6.1
nabijaczleweli May 12, 2024
0584eda
Fully-buffer File Responses: io::copy() ought to use sendfile() here …
nabijaczleweli May 12, 2024
c8c5ffb
Inline Mime()s
nabijaczleweli May 13, 2024
f472c1f
Simply accept &'static Handler as a Handler
nabijaczleweli May 13, 2024
93ef182
And now we can just clean the temp dirs :)
nabijaczleweli May 13, 2024
3037879
And get rid of the Arc (and reformat)
nabijaczleweli May 13, 2024
4cfb895
No TypeMap
nabijaczleweli May 13, 2024
6b7cbd8
We have to work around the automatic mimetype detexion, kill it
nabijaczleweli May 13, 2024
677c007
Vendored iron log dep deletion
nabijaczleweli May 13, 2024
22d8872
Again iron with the Content-Type muddling
nabijaczleweli May 13, 2024
054d96c
Borrow the URL path and escape it once only
nabijaczleweli May 13, 2024
c5c7b25
Don't reallocate for escaping/reencode if not needed
nabijaczleweli May 13, 2024
b726638
Vendor hyper 0.10.16
nabijaczleweli May 15, 2024
e2426c1
Start threads on demand, up to the limit, then decay on inactivity (b…
nabijaczleweli May 16, 2024
bbc1955
crossbeam my beloved
nabijaczleweli May 16, 2024
d7ae221
format :v
nabijaczleweli May 16, 2024
a9bca0a
Delete hyper client
nabijaczleweli May 16, 2024
0c63fc6
Properly protect free_threads against panic in worker
nabijaczleweli May 16, 2024
de4f880
cargo documentation recommends a broken format
nabijaczleweli May 16, 2024
ec93678
Crank down brotli encoding strength (defaults to 11, which is max! al…
nabijaczleweli May 16, 2024
2659e7b
Canonicalise all Encodings we care about, store the Encoding(Type) as…
nabijaczleweli May 16, 2024
248ea51
Don't require allocating Server header
nabijaczleweli May 16, 2024
52d2796
We produce one RangeUnit only ever in Accept-Ranges
nabijaczleweli May 16, 2024
49a56c4
ContentEncoding SmallVec :)
nabijaczleweli May 16, 2024
2aec32f
Don't clone custom header names
nabijaczleweli May 17, 2024
5c99cea
Kill log for hyper too
nabijaczleweli May 17, 2024
689fe43
Don't require allocation for the WebDAV requests
nabijaczleweli May 17, 2024
381597a
Don't clone Allow header
nabijaczleweli May 17, 2024
c78d921
Don't clone headers for TRACE
nabijaczleweli May 17, 2024
2a4889f
Don't needlessly clone name
nabijaczleweli May 17, 2024
efdedca
Return literal instead of parsing text/xml;charset=utf-8
nabijaczleweli May 17, 2024
23cd2b6
Unbreak Win32 PROPFIND (by not returning <Win32FileAttributes> twice,…
nabijaczleweli May 17, 2024
58898a8
Add -Q/--quiet-time to remove [%F %T] prefix
nabijaczleweli May 17, 2024
ee3343e
Trim away some unused hyper bits
nabijaczleweli May 17, 2024
666a3ac
More hyper clear-outs
nabijaczleweli May 17, 2024
25ba250
Trim away language-tags dep (exe 500kB smaller)
nabijaczleweli May 17, 2024
d10bfe1
what da CowStr doin
nabijaczleweli May 17, 2024
5d1677d
Don't double-embed upload.js/manage.js in the exe
nabijaczleweli May 17, 2024
91f11f3
kms
nabijaczleweli May 17, 2024
4dc92ee
nabijaczleweli May 18, 2024
b2439b4
Iterator flattening music
nabijaczleweli May 18, 2024
c5e3ee4
Real 'static moments (also https://github.com/rust-lang/rust/issues/9…
nabijaczleweli May 18, 2024
e3b93c2
.. + 1 => ..=
nabijaczleweli May 18, 2024
6cc5a25
os-str-generic deletion
nabijaczleweli May 18, 2024
5fbd4f1
Re-save favicon.png (this compresses it to 1460 bytes). Use this new …
nabijaczleweli May 18, 2024
e677f0f
Recompress rename (206 -> 192 bytes)
nabijaczleweli May 18, 2024
51064cc
Don't do bzip2 encoding. From my logs I can tell no-one has ever used…
nabijaczleweli May 18, 2024
0876b9b
Also allow zstd encoding explicitly
nabijaczleweli May 18, 2024
abc575a
Vendor rfsapi 0.2.0
nabijaczleweli May 18, 2024
41ae0f9
Use vendored rfsapi
nabijaczleweli May 18, 2024
b266e11
Headers have Cow<'static, [u8]> instead of Vec<u8>
nabijaczleweli May 18, 2024
dcd24ed
Header PtrMap HashMap -> VecMap
nabijaczleweli May 18, 2024
0af886b
More robust listener when something dies maybe?
nabijaczleweli May 18, 2024
5c36161
-m takes OsStr (because it's for paths)
nabijaczleweli May 18, 2024
c7c30c6
Free unused bits of Options
nabijaczleweli May 18, 2024
754e835
extern crate os_str_generic;
nabijaczleweli May 18, 2024
501825b
Static Condvar instead of leaking
nabijaczleweli May 19, 2024
a419540
Write-lock filesystem cache before deleting files
nabijaczleweli May 19, 2024
7e4f7f6
Literal application/json;charset=utf-8 Mime
nabijaczleweli May 19, 2024
d944b46
Don't have Literals with empty strings
nabijaczleweli May 19, 2024
5f8517a
Don't allocate the nonexistent status, we always have the canonical r…
nabijaczleweli May 19, 2024
f7c8189
Don't allocate length as string
nabijaczleweli May 19, 2024
cdee6b3
Delete temp file on drop
nabijaczleweli May 19, 2024
a35e050
Fix panic always yielding double panic
nabijaczleweli May 19, 2024
c72479e
Don't read the whole thing into a buffer for closed range request
nabijaczleweli May 19, 2024
f2477fb
Use coherent file size data for opened ranges
nabijaczleweli May 19, 2024
3df48fe
WriteZero isn't an error, it's normal with truncated Content-Lengths
nabijaczleweli May 19, 2024
39b2246
Don't reallocate Range header value
nabijaczleweli May 19, 2024
1643340
Use the same buffer for recursive PROPFINDs
nabijaczleweli May 19, 2024
6dc1c8e
Don't panic on PROPFIND Depth: infinity when encountering non-directo…
nabijaczleweli May 19, 2024
dff8874
enumerate() instead of next(), iter
nabijaczleweli May 21, 2024
2d5023c
Don't pretend to allocate the file encoding as a String
nabijaczleweli May 22, 2024
a23ede0
Pull up arrayvec (already blake3's) and don't allocate in AddressWriter
nabijaczleweli May 22, 2024
db03ce3
Don't require the extension to be UTF-8
nabijaczleweli May 22, 2024
d48d06c
Use fmt padding instead of Spaces() wrapper
nabijaczleweli May 22, 2024
e25906f
Unify PUT symlink isolation with GET's (i.e., return 404 and don't read)
nabijaczleweli May 22, 2024
e95600f
Copy from request to PUTted file directly IF it doesn't already exist…
nabijaczleweli May 22, 2024
7558ad3
UNIX port
nabijaczleweli May 22, 2024
13e1b5a
Buffer reads for PUTs
nabijaczleweli May 22, 2024
45b4a98
macintosh port
nabijaczleweli May 24, 2024
7c6d768
Use BufReader on platforms without sendfile(2)
nabijaczleweli May 24, 2024
cec73d9
Correctly trim up-path for index when multibyte
nabijaczleweli May 26, 2024
0626391
Don't allocate for human-readable size
nabijaczleweli May 26, 2024
22d5924
Trim away useless attributes in generated responses
nabijaczleweli May 26, 2024
ca1e2c8
Format all generated responses into a continuous buffer
nabijaczleweli May 26, 2024
d0318e7
rustfmt
nabijaczleweli May 26, 2024
f710d87
Replace date.js (lol javascripttoolbox.com is dead please call me for…
nabijaczleweli May 26, 2024
6cdc752
Kill FORMAT too :v
nabijaczleweli May 26, 2024
6b69a1c
onload => DOMContentLoaded for all listeners
nabijaczleweli May 26, 2024
d1898e3
Localising UTC stamps in 1000-file directory on Android 14 Browser.ap…
nabijaczleweli May 26, 2024
f945289
In a similar vein, move the click event listeners to onclick. Suggest…
nabijaczleweli May 26, 2024
afe106a
Compare earlier
nabijaczleweli May 26, 2024
56b2e93
<meta name application-name and generator => <meta generator http $ve…
nabijaczleweli May 26, 2024
73f3a95
Reduce mobile listings by 17% (same rendering)
nabijaczleweli May 26, 2024
ce6c5f9
tabindex=-1 links in desktop index except the filename
nabijaczleweli May 26, 2024
54634cf
File id (#-anchor) in index changed to be filename but tr " _
nabijaczleweli May 26, 2024
d52b5d0
Don't reallocate each filename twice to replace & and <
nabijaczleweli May 26, 2024
044a31c
Escape " in filename for link (previously unreachable)
nabijaczleweli May 26, 2024
5a7304d
Fix deletions with new mobile tree
nabijaczleweli May 26, 2024
41d6ff8
Return and report intelligible errors for PUTs (this unfortunately me…
nabijaczleweli May 26, 2024
f534ea4
Fix f945289f5d8d29ad57fa08a9ad66403839287817
nabijaczleweli May 26, 2024
46a21e2
linebreak :v
nabijaczleweli May 26, 2024
4d687dd
Trim pre-computed HTML lines; this doesn't affect readability but doe…
nabijaczleweli May 26, 2024
45b68f2
Draw new confirm image that matches the style better (and is 102 inst…
nabijaczleweli May 26, 2024
cf902c1
Re-save favicon.ico (for embedding in .exe) as ICO{single 128x PNG}@1…
nabijaczleweli May 27, 2024
c81df16
Remove <link rel=icon>'s type=
nabijaczleweli May 27, 2024
98d12fc
global format
nabijaczleweli May 27, 2024
487af01
Restore mobile create-directory
nabijaczleweli May 27, 2024
930abd9
Actually trim initial whitespace from js too
nabijaczleweli May 27, 2024
aaa9ded
clang format fucked it up again
nabijaczleweli May 28, 2024
e76e92f
with autofocus :/
nabijaczleweli May 28, 2024
99538ed
Allow retrying creating after error
nabijaczleweli May 28, 2024
325cb51
Fucked it up
nabijaczleweli May 28, 2024
9a79f6d
Create directory colspan
nabijaczleweli May 28, 2024
93d2fe0
real
nabijaczleweli May 29, 2024
0478dd7
Re-compress instead of panicking if encoded file is gone (like on /tm…
nabijaczleweli May 29, 2024
26e36cc
Clicking on Create directory in the Manage column shouldn't fail by M…
nabijaczleweli May 29, 2024
fa101ba
Flatten Error to just be a string. Try next port on EADDRINUSE, not i…
nabijaczleweli May 29, 2024
0f7301e
Kill hyper's accidental Cargo.lock
nabijaczleweli May 30, 2024
d9fc08a
Patch RUSTSEC-2021-0078 in vendored hyper
nabijaczleweli May 30, 2024
a3ae6fc
Patch RUSTSEC-2021-0079
nabijaczleweli May 30, 2024
60f0726
Ignore RUSTSEC-2020-0071: we do not setenv ever
nabijaczleweli May 30, 2024
d7a3d2c
Ignore unmaintained warnings
nabijaczleweli May 30, 2024
25d01fd
Ignore RUSTSEC-2021-0145: we don't use a custom allocator
nabijaczleweli May 30, 2024
4b22b6a
Use git traitobject, which has RUSTSEC-2020-0027 fixed
nabijaczleweli May 30, 2024
c5b4966
Ignore RUSTSEC-2022-0022: our version of hyper simply never uses mem:…
nabijaczleweli May 30, 2024
332d737
Adapt mobile background-color to dark theme
nabijaczleweli Jun 1, 2024
7338d06
Highlight :target in indices
nabijaczleweli Jun 1, 2024
548cfe1
Avoid a file called file_upload overriding the upload input
nabijaczleweli Jun 1, 2024
523f91c
Change id=parent_dir to id=... Add id=.. to mobile listing
nabijaczleweli Jun 1, 2024
ea94cc8
Change new_directory id to new"directory id to protect files called "…
nabijaczleweli Jun 1, 2024
6eceb96
Also //ify error
nabijaczleweli Jun 1, 2024
daf471f
Inline single-use pre-list class. Remove useless div
nabijaczleweli Jun 1, 2024
4a41b3d
Clean out mobile CSS
nabijaczleweli Jun 1, 2024
c3b164f
Bump version to 2.0.0
nabijaczleweli Jun 2, 2024
e451dd3
Commit to no-crates.io (https://github.com/thecoshman/http/pull/160#i…
nabijaczleweli Jun 2, 2024
269dc9b
Commit to git-only installation. Note Debian repository installation
nabijaczleweli Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/thecoshman/http/issues/140
[advisories]
ignore = ["RUSTSEC-2021-0078", "RUSTSEC-2021-0079", "RUSTSEC-2020-0071", "RUSTSEC-2021-0139", "RUSTSEC-2023-0081", "RUSTSEC-2021-0144", "RUSTSEC-2021-0145", "RUSTSEC-2020-0027", "RUSTSEC-2022-0022"]
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Needed for st_dev/st_ino on windows ("windows_by_handle")
# available since 2019 in 1.38: https://github.com/rust-lang/rust/commit/c69f367bafb3a2f90d44fe54fc20d57996fa294a
[env]
RUSTC_BOOTSTRAP = "1"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
!Cargo.toml
!rustfmt.toml
!build.rs
!build-ioctl.c
!http-manifest.rc
!install.*
!*.md
!.cargo
!.cargo/**
!src
!src/**
!assets
!assets/**
!vendor
!vendor/**
36 changes: 16 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ keywords = ["http", "server", "https", "webdav", "directory"]
categories = ["network-programming", "web-programming::http-server"]
license = "MIT"
build = "build.rs"
# Remember to also update in appveyor.yml
version = "1.13.2"
# Remember to also update in appveyor.yml and the http-crates.io branch
version = "2.0.0"
# Remember to also update in http.md
authors = ["thecoshman <rust@thecoshman.com>",
"nabijaczleweli <nabijaczleweli@nabijaczleweli.xyz>",
Expand All @@ -24,56 +24,52 @@ authors = ["thecoshman <rust@thecoshman.com>",
[dependencies]
hyper-native-tls = "0.3"
percent-encoding = "2.1"
lazy_static = "1.4"
serde_json = "0.9"
serde_json = "1.0"
mime_guess = "1.8"
tabwriter = "1.1"
itertools = "0.8"
lazysort = "0.2"
unicase = "2.4"
arrayvec = "0.7"
walkdir = "2.2"
base64 = "0.10"
blake3 = "1.3"
flate2 = "1.0"
rfsapi = "0.1"
xml-rs = "0.8"
bzip2 = "0.4"
ctrlc = "3.1"
regex = "1.2"
serde = "0.9"
serde = "1.0"
clap = "2.33"
libc = "0.2"
rand = "0.7"
time = "0.1"

[dependencies.trivial_colours]
version = "0.3"
default-features = false

[dependencies.rfsapi]
path = "vendor/rfsapi-0.2.0"

[dependencies.cidr]
version = "0.1"
default-features = false

[dependencies.brotli]
version = "3.3"
default-features = false
features = ["std"]
version = "6.0"
features = ["simd"]

[dependencies.iron]
version = "0.6"
path = "vendor/iron-0.6.1"
features = ["hyper-native-tls"]

[patch.crates-io.hyper]
path = "vendor/hyper-0.10.16"

[target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3"
features = ["fileapi"]

[target.'cfg(not(target_os = "windows"))'.dependencies.os-str-generic]
version = "0.2"

[target.'cfg(not(any(target_os = "windows", target_os = "macos")))'.dependencies.libc]
version = "0.2"

[build-dependencies]
embed-resource = "1.3"
base64 = "0.10"

[target.'cfg(not(any(target_os = "windows", target_os = "macos")))'.build-dependencies.cc]
version = "1.0"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ See [the manpage](http.md) for full list.
If you have `cargo` installed (you're a Rust developer) all you need to do is:

```sh
cargo install https
cargo install --git https://github.com/thecoshman/http
```
(the `https` crates.io package *was* http, but [is now unpublishable](//github.com/thecoshman/http/pull/160#issuecomment-2143877822))

Which will install `http` and `httplz` (identical, disable one or another if they clash) in the folder where all other binaries go.

Expand Down Expand Up @@ -80,4 +81,4 @@ The idea is to make a program that can compile down to a simple binary that can
* [x] If an index file isn't provided, one will be generated (in memory, no touching the disk, why would you do that you dirty freak you), that will list the current files and folders (and then sub directories will have index files generated as required)
* [x] Changes made to files should be reflected instantly, as I don't see why anything would be cached... you request a file, a file will be looked for

It's not going to be a 'production ready' tool, it's a quick and dirty way of hosting a folder, so whilst I'll try to make it secure, it is not going to be a serious goal.
~~It's not going to be a 'production ready' tool, it's a quick and dirty way of hosting a folder, so whilst I'll try to make it secure, it is not going to be a serious goal.~~
14 changes: 7 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image:
- Visual Studio 2022

version: 1.13.2-{build}
version: 2.0.0-{build}

skip_tags: false

Expand All @@ -27,21 +27,21 @@ build: off
build_script:
- git submodule update --init --recursive
- cargo build --verbose --release
- cp target\release\http.exe http-v1.13.2.exe
- strip --strip-all --remove-section=.comment --remove-section=.note http-v1.13.2.exe
- makensis -DHTTP_VERSION=v1.13.2 install.nsi
- cp target\release\http.exe http-v2.0.0.exe
- strip --strip-all --remove-section=.comment --remove-section=.note http-v2.0.0.exe
- makensis -DHTTP_VERSION=v2.0.0 install.nsi

test: off
test_script:
- cargo test --verbose --release

artifacts:
- path: http-v1.13.2.exe
- path: http v1.13.2 installer.exe
- path: http-v2.0.0.exe
- path: http v2.0.0 installer.exe

deploy:
provider: GitHub
artifact: /http.*v1.13.2.*\.exe/
artifact: /http.*v2.0.0.*\.exe/
auth_token:
secure: ZTXvCrv9y01s7Hd60w8W7NaouPnPoaw9YJt9WhWQ2Pep8HLvCikt9Exjkz8SGP9P
on:
Expand Down
17 changes: 8 additions & 9 deletions assets/adjust_tz.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"use strict";

window.addEventListener("load", function() {
const FORMAT = "yyyy-MM-dd HH:mm:ss";

window.addEventListener("DOMContentLoaded", function() {
let modtime_h = document.getElementsByTagName("th")[2];
if(modtime_h)
modtime_h.innerText = modtime_h.innerText.replace("(UTC)", "").trim();
modtime_h.innerText = modtime_h.innerText.replace(" (UTC)", "");

let timestamps = document.getElementsByClassName("datetime");
Array.from(timestamps).forEach(function(r) {
let dt = r.innerText.replace("UTC", "").trim();
r.innerText = Date.parseString(dt, FORMAT).format(FORMAT)
});
let timestamps = document.getElementsByTagName("time");
for(let r of timestamps) {
let dt = new Date(parseInt(r.getAttribute("ms")));
dt.setMinutes(dt.getMinutes() - dt.getTimezoneOffset())
r.innerText = dt.toISOString().slice(0, 19).replace("T", " ");
}
});
10 changes: 0 additions & 10 deletions assets/date.js

This file was deleted.

42 changes: 17 additions & 25 deletions assets/directory_listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="application-name" content="http">
<meta name="author" content="http developers">
<meta name="generator" content="{generator}">
<meta name="description" content="Directory listing of {0}">
<meta name="color-scheme" content="light dark">
<link href="{favicon}" rel="icon" type="image/x-icon" />
<script type="text/javascript">{date}</script>
<script type="text/javascript">{adjust_tz}</script>
{1}
<link rel="icon" href="{favicon}" />
<script>{adjust_tz}</script>
{1}{2}{3}
<title>Directory listing — {0}</title>
<style type="text/css">
<style>
abbr[title] {
border-bottom: none;
text-decoration: none;
}

.pre-list {
margin-bottom: 0;
}

table {
border-collapse: collapse;
}
Expand All @@ -41,7 +35,7 @@
padding-left: 5pt;
}

tr:nth-child(n+4) td:nth-child(5) a {
td:nth-child(5) a {
display: inline-block;
}

Expand All @@ -54,8 +48,8 @@
height: 1em;
}

tr:hover {
background-color: #eee;
tr:hover, tr:target {
background-color: #80808080;
}

tr {
Expand Down Expand Up @@ -116,20 +110,18 @@
</style>
</head>
<body>
<div>
<p class="pre-list">The requested directory {0} contains the following files:</p>
<table>
<tr><th></th> <th>Name</th> <th>Last modified (UTC)</th> <th>Size</th> {5}</tr>
{2}
{6}
{3}
</table>
</div>
<p style="margin-bottom: 0;">The requested directory {0} contains the following files:</p>
<table>
<tr><th></th> <th>Name</th> <th>Last modified (UTC)</th> <th>Size</th> {7}</tr>
{4}
{8}
{5}
</table>
<p></p>
{4}
{6}
<hr />
<p>
<a href="https://github.com/thecoshman/http">Host These Things Please</a> — a basic HTTP server for hosting a folder fast and simply
<a href="//github.com/thecoshman/http">Host These Things Please</a> — a basic HTTP server for hosting a folder fast and simply
</p>
</body>
</html>
69 changes: 20 additions & 49 deletions assets/directory_listing_mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,34 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="application-name" content="http">
<meta name="author" content="http developers">
<meta name="generator" content="{generator}">
<meta name="description" content="Directory listing of {0}">
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1,width=device-width">
<meta name="color-scheme" content="light dark">
<link href="{favicon}" rel="icon" type="image/x-icon" />
<script type="text/javascript">{date}</script>
<script type="text/javascript">{adjust_tz}</script>
{2}
<link rel="icon" href="{favicon}" />
<script>{adjust_tz}</script>
{1}{2}{3}
<title>Directory listing — {0}</title>
<style type="text/css">
.list {
<style>
body > * {
display: block;
padding-left: 15px;
padding-right: 15px;
padding: 7px 15px;
border-bottom: solid 1px #00000050;
}

.heading {
background-color: #0000000F;
}

.entry.top, .heading.top-border {
border-top: solid 1px #00000050;
}

.top {
padding-top: 7px;
}

.manage {
float: right;
body > *:target {
background-color: #80808080;
}

.bottom {
padding-bottom: 7px;
}

.datetime {
float: left;
font-size: 75%;
.heading {
background-color: #8080801E;
}

.size {
.manage, .size {
float: right;
font-size: 75%;
}

.marker {
opacity: 0;
time, .size {
font-size: 75%;
}

Expand All @@ -64,10 +43,6 @@
word-wrap: break-word;
}

#newdir_input > input[type="text"] {
margin-left: 0.5em;
}

.dir_icon:before {
content: url('{dir_icon}');
margin-right: 0.5em;
Expand Down Expand Up @@ -100,7 +75,7 @@

.new_dir_icon:before {
content: url('{new_dir_icon}');
margin-right: 0.5em;
margin-right: 0.5rem;
}

.delete_file_icon:before {
Expand All @@ -125,15 +100,11 @@
</style>
</head>
<body>
<div>
<a href="{1}{0}" class="list heading top bottom">{0}</a>
{3}
{6}
{4}
</div>
<a href="{0}" class="heading">{0}</a>
{4}
{7}
{5}
<a href="https://github.com/thecoshman/http" class="list heading top top-border bottom">
Host These Things Please — a basic HTTP server for hosting a folder fast and simply
</a>
{6}
<a href="//github.com/thecoshman/http" class="heading">Host These Things Please — a basic HTTP server for hosting a folder fast and simply</a>
</body>
</html>
Loading