forked from nm3clol/nm3clol-express-app
No longer list files for which a folder contains README.md metadata describing the file.
This commit is contained in:
parent
f66c0b8673
commit
d9e0361f7c
|
@ -200,9 +200,10 @@ export default function () {
|
|||
renderSingle: false,
|
||||
unlisted: [
|
||||
".DS_Store",
|
||||
".git",
|
||||
".git*",
|
||||
"Thumbs.db",
|
||||
"README*",
|
||||
"README.*",
|
||||
"README",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -217,9 +218,10 @@ export default function () {
|
|||
renderSingle: false,
|
||||
unlisted: [
|
||||
".DS_Store",
|
||||
".git",
|
||||
".git*",
|
||||
"Thumbs.db",
|
||||
"README*",
|
||||
"README.*",
|
||||
"README",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -234,9 +236,10 @@ export default function () {
|
|||
renderSingle: false,
|
||||
unlisted: [
|
||||
".DS_Store",
|
||||
".git",
|
||||
".git*",
|
||||
"Thumbs.db",
|
||||
"README*",
|
||||
"README.*",
|
||||
"README",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -252,7 +255,11 @@ export default function () {
|
|||
renderSingle: false,
|
||||
unlisted: [
|
||||
".*", //dot files/folders
|
||||
"Thumbs.db"
|
||||
".DS_Store",
|
||||
".git*",
|
||||
"Thumbs.db",
|
||||
"README.*",
|
||||
"README",
|
||||
],
|
||||
redirects: [
|
||||
{
|
||||
|
|
|
@ -168,6 +168,28 @@ export interface ServeErrorTemplateParameters {
|
|||
err?: any;
|
||||
}
|
||||
|
||||
export const removeFilesForWhichAFolderDescribesThem = (files: PathDetails[]) => {
|
||||
let outFiles = [];
|
||||
for (const file of files) {
|
||||
if (file.type == "directory") {
|
||||
outFiles.push(file);
|
||||
} else {
|
||||
const searchFolder = path.basename(file.relative!, path.extname(file.relative!));
|
||||
let found = false;
|
||||
for (const searching of files) {
|
||||
if (searching.name == searchFolder && searching.type == "directory") {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
outFiles.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outFiles;
|
||||
}
|
||||
|
||||
export const directoryTemplate = (vals: ServeDirectoryTemplateParameters) => {
|
||||
let breadcrumbs: Breadcrumb[] = [];
|
||||
if (vals.paths.length == 1 && helpers.getDirectoryName(vals.paths[0].name)) {
|
||||
|
@ -184,7 +206,7 @@ export const directoryTemplate = (vals: ServeDirectoryTemplateParameters) => {
|
|||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
ejs.renderFile(path.join(config.viewsPath, 'directory.ejs'), { h: helpers, path, config, breadcrumbs, ...vals }, (err, str) => {
|
||||
ejs.renderFile(path.join(config.viewsPath, 'directory.ejs'), { h: helpers, path, config, breadcrumbs, directory: vals.directory, paths: vals.paths, files: removeFilesForWhichAFolderDescribesThem(vals.files) }, (err, str) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
reject(err);
|
||||
|
|
|
@ -131,15 +131,17 @@
|
|||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<ul id="files" class="list-group shadow-lg">
|
||||
<% files.forEach(function(value, index) { %>
|
||||
<li class="list-group-item list-group-item-action flex-column align-items-start">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<a href="<%= value.relative %>" title="<%= value.title %>" class="<%= value.type.replaceAll('directory', 'folder') %> <%= value.ext %>"><%= value.base %></a>
|
||||
</div>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% if (files && files.length && !(files.length == 1 && files[0].title == '..')) { %>
|
||||
<ul id="files" class="list-group shadow-lg">
|
||||
<% files.forEach(function(value, index) { %>
|
||||
<li class="list-group-item list-group-item-action flex-column align-items-start">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<a href="<%= value.relative.replaceAll('\\', '/') %>" title="<%= value.title %>" class="<%= value.type.replaceAll('directory', 'folder') %> <%= value.ext %>"><%= value.title %></a>
|
||||
</div>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } %>
|
||||
</main>
|
||||
<%- include('./includes/bottom-navbar.ejs') %>
|
||||
<%- include('./includes/bottom-scripts.ejs') %>
|
||||
|
|
Loading…
Reference in New Issue
Block a user