Compare commits

...

4 commits

Author SHA1 Message Date
xenofem 55fa969bea zip: set minimum version field back to 4.5
I'm not sure what the deal is, it sounds like the UTF-8 bit flag is
6.3, but linux's zip utilities don't support 6.3 and do support the
bit flag, so *shrug*
2022-04-27 21:58:11 -04:00
xenofem 43cffcd54c fix styling on disabled buttons 2022-04-27 21:47:52 -04:00
xenofem 7191b4df96 smarter websocket url inference, show a full url for downloads 2022-04-27 21:47:36 -04:00
xenofem 9545ceb4f4 make favicon version of logo 2022-04-27 21:27:03 -04:00
8 changed files with 81 additions and 49 deletions

View file

@ -0,0 +1,48 @@
struct transbeamPrefs {
real triangleRadius;
real borderInset;
real circleRadius;
real bigBeamRadius;
real smallBeamRadius;
real beamCount;
real beamAngle;
real starterBeamAngle;
}
void drawTransbeam(transbeamPrefs prefs) {
unravel prefs;
pen transBlue = rgb("55cdfc");
pen transPink = rgb("f7a8b8");
pen bigBeamColor = transPink;
pen smallBeamColor = transBlue;
path borderTriangle = dir(90)--dir(210)--dir(330)--cycle;
path outerBorder = scale(triangleRadius)*borderTriangle;
fill(outerBorder, white);
path beam(real angle, real innerRadius, real outerRadius) {
return arc((0,0), outerRadius, angle/2, -angle/2)--arc((0,0), innerRadius, -angle/2, angle/2)--cycle;
}
path bigBeam = beam(beamAngle, circleRadius, bigBeamRadius);
path smallBeam = beam(beamAngle, circleRadius, smallBeamRadius);
for (int i = 0; i < beamCount; ++i) {
if (i > 0) {
fill(rotate(360*i/beamCount)*bigBeam, bigBeamColor);
}
fill(rotate(360*(i+0.5)/beamCount)*smallBeam, smallBeamColor);
}
pair starterBeamTrianglePoint(real angle) {
pair circlePoint = circleRadius*dir(angle);
return intersectionpoint(circlePoint--(circlePoint+(triangleRadius,0)), outerBorder);
}
fill(starterBeamTrianglePoint(-starterBeamAngle/2)--arc((0,0), circleRadius, -starterBeamAngle/2, starterBeamAngle/2)--starterBeamTrianglePoint(starterBeamAngle/2)--cycle, bigBeamColor);
draw(outerBorder, transPink+(2*borderInset));
draw(scale(triangleRadius-borderInset)*borderTriangle, transBlue+borderInset);
}

View file

@ -0,0 +1,13 @@
import "transbeam-common.asy" as transbeam;
transbeamPrefs prefs;
prefs.triangleRadius = 100;
prefs.borderInset = 14;
prefs.circleRadius = 12;
prefs.bigBeamRadius = 36;
prefs.smallBeamRadius = 36;
prefs.beamCount = 3;
prefs.beamAngle = 40;
prefs.starterBeamAngle = 80;
drawTransbeam(prefs);

View file

@ -1,43 +1,13 @@
real triangleRadius = 100;
real borderInset = 6;
import "transbeam-common.asy" as transbeam;
real circleRadius = 12;
real bigBeamRadius = 36;
real smallBeamRadius = 25;
real beamCount = 12;
real beamAngle = 7;
real starterBeamAngle = 16;
transbeamPrefs prefs;
prefs.triangleRadius = 100;
prefs.borderInset = 6;
prefs.circleRadius = 12;
prefs.bigBeamRadius = 36;
prefs.smallBeamRadius = 25;
prefs.beamCount = 12;
prefs.beamAngle = 7;
prefs.starterBeamAngle = 16;
pen transBlue = rgb("55cdfc");
pen transPink = rgb("f7a8b8");
pen bigBeamColor = transPink;
pen smallBeamColor = transBlue;
path borderTriangle = dir(90)--dir(210)--dir(330)--cycle;
path outerBorder = scale(triangleRadius)*borderTriangle;
fill(outerBorder, white);
path beam(real angle, real innerRadius, real outerRadius) {
return arc((0,0), outerRadius, angle/2, -angle/2)--arc((0,0), innerRadius, -angle/2, angle/2)--cycle;
}
path bigBeam = beam(beamAngle, circleRadius, bigBeamRadius);
path smallBeam = beam(beamAngle, circleRadius, smallBeamRadius);
for (int i = 0; i < beamCount; ++i) {
if (i > 0) {
fill(rotate(360*i/beamCount)*bigBeam, bigBeamColor);
}
fill(rotate(360*(i+0.5)/beamCount)*smallBeam, smallBeamColor);
}
pair starterBeamTrianglePoint(real angle) {
pair circlePoint = circleRadius*dir(angle);
return intersectionpoint(circlePoint--(circlePoint+(triangleRadius,0)), outerBorder);
}
fill(starterBeamTrianglePoint(-starterBeamAngle/2)--arc((0,0), circleRadius, -starterBeamAngle/2, starterBeamAngle/2)--starterBeamTrianglePoint(starterBeamAngle/2)--cycle, bigBeamColor);
draw(outerBorder, transPink+(2*borderInset));
draw(scale(triangleRadius-borderInset)*borderTriangle, transBlue+borderInset);
drawTransbeam(prefs);

View file

@ -87,7 +87,7 @@ impl UploadedFile {
/// through "Extra field length".
fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> {
let mut fields = vec![
63, 0, // Minimum version required to extract: 6.3 for UTF-8 filenames
45, 0, // Minimum version required to extract: 4.5 for ZIP64
0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor
0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames
0, 0, // Compression method: none
@ -138,7 +138,7 @@ impl UploadedFile {
fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> {
let mut header = vec![
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
63, 3, // Made by a Unix system supporting version 6.3
45, 3, // Made by a Unix system supporting version 4.5
];
header.append(&mut self.shared_header_fields(Some(hash)));
append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes
@ -169,8 +169,8 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec<u8> {
];
append_0(&mut eocd, 7); // pad out the rest of the size field
eocd.append(&mut vec![
63, 3, // Made by a Unix system supporting version 6.3
63, 0, // Minimum version 6.3 to extract
45, 3, // Made by a Unix system supporting version 4.5
45, 0, // Minimum version 4.5 to extract
]);
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
// Number of central directory records, on this disk and in total

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -9,8 +9,8 @@
<body>
<div>
<label>
<span class="fake_button" id="file_input_message">Select files to upload...</span>
<input type="file" multiple id="file_input"/>
<span class="fake_button" id="file_input_message">Select files to upload...</span>
</label>
</div>
<button id="upload" disabled>Upload</button>

View file

@ -17,8 +17,9 @@ button:hover, .fake_button:hover {
background-color: #aaa;
}
button:disabled, button:disabled:hover, .fake_button:disabled, .fake_button:disabled:hover {
button:disabled, input:disabled + .fake_button {
color: #aaa;
background-color: #eee;
border-color: #ddd;
cursor: not-allowed;
}

View file

@ -106,11 +106,11 @@ uploadButton.addEventListener('click', (e) => {
totalBytes = files.reduce((acc, file) => acc + file.size, 0);
socket = new WebSocket(`ws://${window.location.host}/upload`);
socket = new WebSocket(`${window.location.protocol === 'http:' ? 'ws' : 'wss'}://${window.location.host}/upload`);
socket.addEventListener('open', sendMetadata);
socket.addEventListener('message', (msg) => {
if (bytesSent === 0 && msg.data.match(/^[A-Za-z0-9]+$/)) {
downloadLink.textContent = msg.data;
downloadLink.textContent = `${window.location.origin}/download/${msg.data}`;
sendData();
} else if (msg.data === 'ack') {
sendData();