refactor: take improvements from the edge browser (#289)
This commit is contained in:
parent
743db47f90
commit
c352dab470
5 changed files with 31 additions and 15 deletions
|
@ -217,6 +217,7 @@ body {
|
|||
|
||||
.save-btn {
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@ -48,7 +48,7 @@
|
|||
d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708l3-3z" />
|
||||
</svg>
|
||||
</label>
|
||||
<input type="file" id="file" name="file" multiple>
|
||||
<input type="file" id="file" title="Upload files" name="file" multiple>
|
||||
</div>
|
||||
<div class="control new-folder hidden" title="New folder">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16">
|
||||
|
@ -74,7 +74,7 @@
|
|||
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<input id="search" name="q" type="text" maxlength="128" autocomplete="off" tabindex="1">
|
||||
<input id="search" title="Searching for folders or files" name="q" type="text" maxlength="128" autocomplete="off" tabindex="1">
|
||||
<input type="submit" hidden />
|
||||
</form>
|
||||
<div class="toolbox-right">
|
||||
|
@ -122,7 +122,7 @@
|
|||
</div>
|
||||
<div class="editor-page hidden">
|
||||
<div class="not-editable hidden"></div>
|
||||
<textarea class="editor hidden" cols="10"></textarea>
|
||||
<textarea id="editor" class="editor hidden" title="Edit file" cols="10"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -257,7 +257,7 @@ function addBreadcrumb(href, uri_prefix) {
|
|||
}
|
||||
const encodedName = encodedStr(name);
|
||||
if (i === 0) {
|
||||
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="${path}"><svg width="16" height="16" viewBox="0 0 16 16"><path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5z"/></svg></a>`);
|
||||
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="${path}" title="Root"><svg width="16" height="16" viewBox="0 0 16 16"><path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5z"/></svg></a>`);
|
||||
} else if (i === len - 1) {
|
||||
$breadcrumb.insertAdjacentHTML("beforeend", `<b>${encodedName}</b>`);
|
||||
} else {
|
||||
|
|
|
@ -15,9 +15,9 @@ use async_zip::{Compression, ZipDateTime, ZipEntryBuilder};
|
|||
use chrono::{LocalResult, TimeZone, Utc};
|
||||
use futures::TryStreamExt;
|
||||
use headers::{
|
||||
AcceptRanges, AccessControlAllowCredentials, AccessControlAllowOrigin, ContentLength,
|
||||
ContentType, ETag, HeaderMap, HeaderMapExt, IfModifiedSince, IfNoneMatch, IfRange,
|
||||
LastModified, Range,
|
||||
AcceptRanges, AccessControlAllowCredentials, AccessControlAllowOrigin, CacheControl,
|
||||
ContentLength, ContentType, ETag, HeaderMap, HeaderMapExt, IfModifiedSince, IfNoneMatch,
|
||||
IfRange, LastModified, Range,
|
||||
};
|
||||
use hyper::header::{
|
||||
HeaderValue, AUTHORIZATION, CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_RANGE, CONTENT_TYPE,
|
||||
|
@ -646,13 +646,15 @@ impl Server {
|
|||
*res.body_mut() = Body::from(INDEX_JS);
|
||||
res.headers_mut().insert(
|
||||
"content-type",
|
||||
HeaderValue::from_static("application/javascript"),
|
||||
HeaderValue::from_static("application/javascript; charset=UTF-8"),
|
||||
);
|
||||
}
|
||||
"index.css" => {
|
||||
*res.body_mut() = Body::from(INDEX_CSS);
|
||||
res.headers_mut()
|
||||
.insert("content-type", HeaderValue::from_static("text/css"));
|
||||
res.headers_mut().insert(
|
||||
"content-type",
|
||||
HeaderValue::from_static("text/css; charset=UTF-8"),
|
||||
);
|
||||
}
|
||||
"favicon.ico" => {
|
||||
*res.body_mut() = Body::from(FAVICON_ICO);
|
||||
|
@ -666,7 +668,11 @@ impl Server {
|
|||
}
|
||||
res.headers_mut().insert(
|
||||
"cache-control",
|
||||
HeaderValue::from_static("max-age=2592000, public"),
|
||||
HeaderValue::from_static("public, max-age=31536000, immutable"),
|
||||
);
|
||||
res.headers_mut().insert(
|
||||
"x-content-type-options",
|
||||
HeaderValue::from_static("nosniff"),
|
||||
);
|
||||
Ok(true)
|
||||
} else {
|
||||
|
@ -1027,6 +1033,12 @@ impl Server {
|
|||
};
|
||||
res.headers_mut()
|
||||
.typed_insert(ContentLength(output.as_bytes().len() as u64));
|
||||
res.headers_mut()
|
||||
.typed_insert(CacheControl::new().with_no_cache());
|
||||
res.headers_mut().insert(
|
||||
"x-content-type-options",
|
||||
HeaderValue::from_static("nosniff"),
|
||||
);
|
||||
if head_only {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ fn asset_js(server: TestServer) -> Result<(), Error> {
|
|||
assert_eq!(resp.status(), 200);
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"application/javascript"
|
||||
"application/javascript; charset=UTF-8"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -46,7 +46,10 @@ fn asset_css(server: TestServer) -> Result<(), Error> {
|
|||
);
|
||||
let resp = reqwest::blocking::get(url)?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_eq!(resp.headers().get("content-type").unwrap(), "text/css");
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"text/css; charset=UTF-8"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,7 @@ fn asset_js_with_prefix(
|
|||
assert_eq!(resp.status(), 200);
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"application/javascript"
|
||||
"application/javascript; charset=UTF-8"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue