Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,14 @@ private IActionResult Download(string id, string filePath, bool view)
};
}

if (view)
{
return new FileStreamResult(File.OpenRead(physicalPath), Utils.GetMimeTypeForFileExtension(physicalPath));
}
//if (view)
//{
// return new FileStreamResult(File.OpenRead(physicalPath), Utils.GetMimeTypeForFileExtension(physicalPath));
//}

return new PhysicalFileResult(physicalPath, Utils.GetMimeTypeForFileExtension(physicalPath))
{
FileDownloadName = Path.GetFileName(physicalPath),
FileDownloadName = view ? null : Path.GetFileName(physicalPath),
EnableRangeProcessing = true
};
}
Expand Down Expand Up @@ -825,6 +825,7 @@ private IActionResult FilePreview(string id, string filePath)
};
}

var basePath = _httpContextAccessor.HttpContext?.Request.PathBase.Value?.TrimEnd('/') ?? "";
switch (Path.GetExtension(physicalPath).ToLower().Trim())
{
case ".png" or ".jpg" or ".webp" or ".gif" or ".svg" or ".jpeg" or ".apng" or ".avif" or ".ico" or ".bmp" or ".tif" or ".tiff":
Expand All @@ -834,31 +835,31 @@ private IActionResult FilePreview(string id, string filePath)
EnableRangeProcessing = true
};
case ".zip" or ".rar" or ".tar" or ".7z" or ".gzip" or ".7zip":
return new RedirectResult("/hgofilemanager/images/zip.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/zip.png") { Permanent = true };
case ".js" or ".jsx":
return new RedirectResult("/hgofilemanager/images/js.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/js.png") { Permanent = true };
case ".php":
return new RedirectResult("/hgofilemanager/images/php.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/php.png") { Permanent = true };
case ".html" or ".htm" or ".cshtml":
return new RedirectResult("/hgofilemanager/images/html.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/html.png") { Permanent = true };
case ".css":
return new RedirectResult("/hgofilemanager/images/css.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/css.png") { Permanent = true };
case ".json":
return new RedirectResult("/hgofilemanager/images/json.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/json.png") { Permanent = true };
case ".txt":
return new RedirectResult("/hgofilemanager/images/txt.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/txt.png") { Permanent = true };
case ".pdf":
return new RedirectResult("/hgofilemanager/images/pdf.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/pdf.png") { Permanent = true };
case ".mp4":
return new RedirectResult("/hgofilemanager/images/mp4.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/mp4.png") { Permanent = true };
case ".mp3":
return new RedirectResult("/hgofilemanager/images/mp3.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/mp3.png") { Permanent = true };
case ".exe":
return new RedirectResult("/hgofilemanager/images/exe.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/exe.png") { Permanent = true };
case ".dll":
return new RedirectResult("/hgofilemanager/images/dll.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/dll.png") { Permanent = true };
default:
return new RedirectResult("/hgofilemanager/images/file.png") { Permanent = true };
return new RedirectResult(basePath + "/hgofilemanager/images/file.png") { Permanent = true };
}
}
}
61 changes: 26 additions & 35 deletions src/HGO.ASPNetCore.FileManager/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Extensions
{
public static void AddHgoFileManager(this IServiceCollection services)
{
services.AddControllersWithViews().AddRazorRuntimeCompilation(c=> c.FileProviders.Add(new EmbeddedFileProvider(typeof(FileManagerComponent)
services.AddControllersWithViews().AddRazorRuntimeCompilation(c => c.FileProviders.Add(new EmbeddedFileProvider(typeof(FileManagerComponent)
.GetTypeInfo().Assembly, "HGO.ASPNetCore.FileManager")));
services.AddSession();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
Expand Down Expand Up @@ -42,54 +42,48 @@ public static HtmlString RenderHgoFileManagerJavaScripts(this RazorPageBase razo
excludelist.AddRange(exclude);
}

var basePath = razorPage.ViewContext.HttpContext.Request.PathBase.HasValue
? razorPage.ViewContext.HttpContext.Request.PathBase.Value.TrimEnd('/')
: "";
var scripts = "";
if (!excludelist.Any(p => p.ToLower() == "js.cookie"))
{
scripts +=
"<script src='hgofilemanager/js.cookie/js.cookie.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/js.cookie/js.cookie.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "fontawesome"))
{
scripts +=
"<script src='hgofilemanager/fontawesome/js/fontawesome.min.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/fontawesome/js/fontawesome.min.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "lozad.js"))
{
scripts +=
"<script src='hgofilemanager/lozad.js/lozad.min.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/lozad.js/lozad.min.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "jsTree"))
{
scripts +=
"<script src='hgofilemanager/jsTree/jstree.min.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/jsTree/jstree.min.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "viselect"))
{
scripts +=
"<script src='hgofilemanager/viselect/viselect.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/viselect/viselect.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "split.js"))
{
scripts +=
"<script src='hgofilemanager/split.js/split.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/split.js/split.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "dropzone"))
{
scripts +=
"<script src='hgofilemanager/dropzone/dropzone.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/dropzone/dropzone.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "context-js"))
{
scripts +=
"<script src='hgofilemanager/context-js/context/context.min.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/context-js/context/context.min.js'></script>\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "toastify"))
{
scripts +=
"<script src='hgofilemanager/toastify/toastify.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/toastify/toastify.js'></script>\r\n";
}

scripts += "<script src='hgofilemanager/HgoFileManager.js'></script>\r\n";
scripts += $"<script src='{basePath}/hgofilemanager/HgoFileManager.js'></script>\r\n";
return new HtmlString(scripts);
}

Expand All @@ -101,46 +95,43 @@ public static HtmlString RenderHgoFileManagerCss(this RazorPageBase razorPage, b
excludelist.AddRange(exclude);
}

var styles = "";
var basePath = razorPage.ViewContext.HttpContext.Request.PathBase.HasValue
? razorPage.ViewContext.HttpContext.Request.PathBase.Value.TrimEnd('/')
: "";
var styles = $"<script>window.HGOFM_BASEPATH = '{basePath}';</script>\r\n";
if (!excludelist.Any(p => p.ToLower() == "jsTree"))
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/jsTree/themes/default/style.min.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/jsTree/themes/default/style.min.css' type='text/css' />\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "dropzone"))
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/dropzone/dropzone.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/dropzone/dropzone.css' type='text/css' />\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "fontawesome"))
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/fontawesome/css/all.min.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/fontawesome/css/all.min.css' type='text/css' />\r\n";
}
if (!excludelist.Any(p => p.ToLower() == "context-js"))
{
if (darkMode)
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/context-js/context/skins/kali_dark.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/context-js/context/skins/kali_dark.css' type='text/css' />\r\n";
}
else
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/context-js/context/skins/kali_light.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/context-js/context/skins/kali_light.css' type='text/css' />\r\n";
}
}
if (!excludelist.Any(p => p.ToLower() == "toastify"))
{
styles +=
"<link rel='stylesheet' href='hgofilemanager/toastify/toastify.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/toastify/toastify.css' type='text/css' />\r\n";
}

styles += "<link rel='stylesheet' href='hgofilemanager/HgoFileManager.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/HgoFileManager.css' type='text/css' />\r\n";

if (darkMode)
{
styles += "<link rel='stylesheet' href='hgofilemanager/HgoFileManager-dark.css' type='text/css' />\r\n";
styles += $"<link rel='stylesheet' href='{basePath}/hgofilemanager/HgoFileManager-dark.css' type='text/css' />\r\n";
razorPage.ViewContext.HttpContext.Session.SetString("HgoFileManagerTheme", "Dark");
}

Expand Down
104 changes: 52 additions & 52 deletions src/HGO.ASPNetCore.FileManager/hgofilemanager/HgoFileManager.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,67 +128,67 @@
}
}

.hgo-fm-menu .button-continer {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
align-content: center;
align-items: center;
}
.hgo-fm-menu .button-continer {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
align-content: center;
align-items: center;
}

.hgo-fm-menu .input-continer {
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
align-content: center;
}
.hgo-fm-menu .input-continer {
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
align-content: center;
}

.hgo-fm-menu input {
border-radius: 30px;
box-shadow: 0 3px 20px 0 rgba(0,0,0,.07);
border: solid 1px #fff;
background-color: #fff;
padding: 3px 10px;
color: #727272;
flex: auto;
transition: all .25s linear;
margin: 3px;
}

.hgo-fm-menu input {
border-radius: 30px;
box-shadow: 0 3px 20px 0 rgba(0,0,0,.07);
border: solid 1px #fff;
background-color: #fff;
padding: 3px 10px;
color: #727272;
flex: auto;
.hgo-fm-menu input:focus-visible {
border: solid 1px #aab9ff;
transition: all .25s linear;
margin: 3px;
outline: none;
}

.hgo-fm-menu input:focus-visible {
border: solid 1px #aab9ff;
transition: all .25s linear;
outline: none;
}
.hgo-fm-menu hr {
height: 12px;
width: 1px;
margin: 0px 3px;
}

.hgo-fm-menu hr {
height: 12px;
width: 1px;
margin: 0px 3px;
}
.hgo-fm-menu button {
border-radius: 5px;
border: solid 1px #d1d1d1;
margin: 3px;
transition: all .25s linear;
color: #3e5a70;
font-size: 16px;
}

.hgo-fm-menu button {
border-radius: 5px;
border: solid 1px #d1d1d1;
margin: 3px;
.hgo-fm-menu button:hover:enabled {
background: rgba(46, 115, 252, 0.11);
border: 1px solid rgb(0 93 255 / 36%);
transition: all .25s linear;
color: #3e5a70;
font-size: 16px;
}

.hgo-fm-menu button:hover:enabled {
background: rgba(46, 115, 252, 0.11);
border: 1px solid rgb(0 93 255 / 36%);
transition: all .25s linear;
}

.hgo-fm-menu button:disabled {
color: #cdcdcd;
}
.hgo-fm-menu button:disabled {
color: #cdcdcd;
}
/*---- Menu/Nav Bar end ----------------------*/

/*---- footer breadcrumb start ----------------------*/
Expand Down Expand Up @@ -272,7 +272,7 @@

.hgo-fm-tree .jstree-icon.jstree-themeicon {
background-size: cover;
background-image: url(/hgofilemanager/images/folder.png);
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEUAAAD/yigfXxocAAAAAXRSTlMAQObYZgAAAEBJREFUeF7t0LENwCAQxdBDFFmb0W6UG4GSzhFffGUDqrh6teNGMIQGKXQoYwoPrANlMIw0auNHR+WH5mOBigu9rcsJrN38ucEAAAAASUVORK5CYII=');
background-position: center;
}

Expand Down
Loading