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

[FEATURE] serveIndex: use serve-index for serving the application index #253

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 82 additions & 0 deletions lib/middleware/indexDesign/directory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Index of {directory}</title>
<style>{style}</style>
<script>
function $(id) {
const el = "string" == typeof id
? document.getElementById(id)
: id;

el.on = function(event, fn) {
if ("content loaded" === event) {
event = window.attachEvent ? "load" : "DOMContentLoaded";
}
el.addEventListener
? el.addEventListener(event, fn, false)
: el.attachEvent("on" + event, fn);
};

el.all = function(selector) {
return $(el.querySelectorAll(selector));
};

el.each = function(fn) {
for (let i = 0; i < el.length; ++i) {
fn($(el[i]), i);
}
};

el.getClasses = function() {
return this.getAttribute("class").split(/\s+/);
};

el.addClass = function(name) {
const classes = this.getAttribute("class");
el.setAttribute("class", classes
? classes + " " + name
: name);
};

el.removeClass = function(name) {
const classes = this.getClasses().filter(function(curr) {
return curr !== name;
});
this.setAttribute("class", classes.join(" "));
};

return el;
}

function search() {
let str = $("search").value.toLowerCase();
let links = $("files").all("a");

links.each(function(link) {
let text = link.textContent.toLowerCase();

if (".." === text) return;
if (str.length && ~text.indexOf(str)) {
link.addClass("highlight");
} else {
link.removeClass("highlight");
}
});
}

$(window).on("content loaded", function() {
$("search").on("keyup", search);
});
</script>
</head>
<body class="directory">
<label for="search"></label><input id="search" type="text" placeholder="Search" autocomplete="off"/>
<div id="wrapper">
<h1><a href="/">~</a>{linked-path}</h1>
{files}
</div>
</body>
</html>
Binary file added lib/middleware/indexDesign/icons/application_xp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/cd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/controller.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/drive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/film.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_attach.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_excel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_find.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_go.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/middleware/indexDesign/icons/page_lightning.png
Binary file added lib/middleware/indexDesign/icons/page_link.png
Binary file added lib/middleware/indexDesign/icons/page_paintbrush.png
Binary file added lib/middleware/indexDesign/icons/page_paste.png
Binary file added lib/middleware/indexDesign/icons/page_red.png
Binary file added lib/middleware/indexDesign/icons/page_refresh.png
Binary file added lib/middleware/indexDesign/icons/page_save.png
Binary file added lib/middleware/indexDesign/icons/page_white.png
Binary file added lib/middleware/indexDesign/icons/page_white_add.png
Binary file added lib/middleware/indexDesign/icons/page_white_c.png
Binary file added lib/middleware/indexDesign/icons/page_white_cd.png
Binary file added lib/middleware/indexDesign/icons/page_white_code.png
Binary file added lib/middleware/indexDesign/icons/page_white_copy.png
Binary file added lib/middleware/indexDesign/icons/page_white_cup.png
Binary file added lib/middleware/indexDesign/icons/page_white_dvd.png
Binary file added lib/middleware/indexDesign/icons/page_white_edit.png
Binary file added lib/middleware/indexDesign/icons/page_white_find.png
Binary file added lib/middleware/indexDesign/icons/page_white_gear.png
Binary file added lib/middleware/indexDesign/icons/page_white_get.png
Binary file added lib/middleware/indexDesign/icons/page_white_go.png
Binary file added lib/middleware/indexDesign/icons/page_white_h.png
Binary file added lib/middleware/indexDesign/icons/page_white_key.png
Binary file added lib/middleware/indexDesign/icons/page_white_link.png
Binary file added lib/middleware/indexDesign/icons/page_white_php.png
Binary file added lib/middleware/indexDesign/icons/page_white_put.png
Binary file added lib/middleware/indexDesign/icons/page_white_ruby.png
Binary file added lib/middleware/indexDesign/icons/page_white_star.png
Binary file added lib/middleware/indexDesign/icons/page_white_text.png
Binary file added lib/middleware/indexDesign/icons/page_white_tux.png
Binary file added lib/middleware/indexDesign/icons/page_white_word.png
Binary file added lib/middleware/indexDesign/icons/page_white_zip.png
Binary file added lib/middleware/indexDesign/icons/page_word.png
Binary file added lib/middleware/indexDesign/icons/page_world.png
258 changes: 258 additions & 0 deletions lib/middleware/indexDesign/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
* {
margin: 0;
padding: 0;
outline: 0;
}

body {
padding: 80px 100px;
font: 13px "Helvetica Neue", "Lucida Grande", "Arial";
background: #ECE9E9 -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ECE9E9));
background: #ECE9E9 -moz-linear-gradient(top, #fff, #ECE9E9);
background-repeat: no-repeat;
color: #555;
-webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
font-size: 22px;
color: #343434;
}
h1 em, h2 em {
padding: 0 5px;
font-weight: normal;
}
h1 {
font-size: 60px;
}
h2 {
margin-top: 10px;
}
h3 {
margin: 5px 0 10px 0;
padding-bottom: 5px;
border-bottom: 1px solid #eee;
font-size: 18px;
}
ul li {
list-style: none;
}
ul li:hover {
cursor: pointer;
color: #2e2e2e;
}
ul li .path {
padding-left: 5px;
font-weight: bold;
}
ul li .line {
padding-right: 5px;
font-style: italic;
}
ul li:first-child .path {
padding-left: 0;
}
p {
line-height: 1.5;
}
a {
color: #555;
text-decoration: none;
}
a:hover {
color: #303030;
}
#stacktrace {
margin-top: 15px;
}
.directory h1 {
margin-bottom: 15px;
font-size: 18px;
}
ul#files {
width: 100%;
height: 100%;
overflow: hidden;
}
ul#files li {
float: left;
width: 30%;
line-height: 25px;
margin: 1px;
}
ul#files li a {
display: block;
height: 25px;
border: 1px solid transparent;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
overflow: hidden;
white-space: nowrap;
}
ul#files li a:focus,
ul#files li a:hover {
background: rgba(255,255,255,0.65);
border: 1px solid #ececec;
}
ul#files li a.highlight {
-webkit-transition: background .4s ease-in-out;
background: #ffff4f;
border-color: #E9DC51;
}
#search {
display: block;
position: fixed;
top: 20px;
right: 20px;
width: 90px;
-webkit-transition: width ease 0.2s, opacity ease 0.4s;
-moz-transition: width ease 0.2s, opacity ease 0.4s;
-webkit-border-radius: 32px;
-moz-border-radius: 32px;
-webkit-box-shadow: inset 0px 0px 3px rgba(0, 0, 0, 0.25), inset 0px 1px 3px rgba(0, 0, 0, 0.7), 0px 1px 0px rgba(255, 255, 255, 0.03);
-moz-box-shadow: inset 0px 0px 3px rgba(0, 0, 0, 0.25), inset 0px 1px 3px rgba(0, 0, 0, 0.7), 0px 1px 0px rgba(255, 255, 255, 0.03);
-webkit-font-smoothing: antialiased;
text-align: left;
font: 13px "Helvetica Neue", Arial, sans-serif;
padding: 4px 10px;
border: none;
background: transparent;
margin-bottom: 0;
outline: none;
opacity: 0.7;
color: #888;
}
#search:focus {
width: 120px;
opacity: 1.0;
}

/*views*/
#files span {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
text-indent: 10px;
}
#files .name {
background-repeat: no-repeat;
}
#files .icon .name {
text-indent: 28px;
}

/*tiles*/
.view-tiles .name {
width: 100%;
background-position: 8px 5px;
}
.view-tiles .size,
.view-tiles .date {
display: none;
}

/*details*/
ul#files.view-details li {
float: none;
display: block;
width: 90%;
}
ul#files.view-details li.header {
height: 25px;
background: #000;
color: #fff;
font-weight: bold;
}
.view-details .header {
border-radius: 5px;
}
.view-details .name {
width: 60%;
background-position: 8px 5px;
}
.view-details .size {
width: 10%;
}
.view-details .date {
width: 30%;
}
.view-details .size {
text-align: center;
}
.view-details .date {
text-align: right;
}

/*mobile*/
@media (max-width: 768px) {
body {
font-size: 13px;
line-height: 16px;
padding: 0;
}
#search {
position: static;
width: 100%;
font-size: 2em;
line-height: 1.8em;
text-indent: 10px;
border: 0;
border-radius: 0;
padding: 10px 0;
margin: 0;
}
#search:focus {
width: 100%;
border: 0;
opacity: 1;
}
.directory h1 {
font-size: 2em;
line-height: 1.5em;
color: #fff;
background: #000;
padding: 15px 10px;
margin: 0;
}
ul#files {
border-top: 1px solid #cacaca;
}
ul#files li {
float: none;
width: auto !important;
display: block;
border-bottom: 1px solid #cacaca;
font-size: 2em;
line-height: 1.2em;
text-indent: 0;
margin: 0;
}
ul#files li:nth-child(odd) {
background: #e0e0e0;
}
ul#files li a {
height: auto;
border: 0;
border-radius: 0;
padding: 15px 10px;
}
ul#files li a:focus,
ul#files li a:hover {
border: 0;
}
#files .header,
#files .size,
#files .date {
display: none !important;
}
#files .name {
float: none;
display: inline-block;
width: 100%;
text-indent: 0;
background-position: 0 50%;
}
#files .icon .name {
text-indent: 41px;
}
}
Loading