diff --git a/Oqtane.Client/Modules/Admin/Files/ModuleInfo.cs b/Oqtane.Client/Modules/Admin/Files/ModuleInfo.cs
new file mode 100644
index 00000000..880d6d14
--- /dev/null
+++ b/Oqtane.Client/Modules/Admin/Files/ModuleInfo.cs
@@ -0,0 +1,19 @@
+using Oqtane.Documentation;
+using Oqtane.Models;
+using Oqtane.Shared;
+
+namespace Oqtane.Modules.Admin.Files
+{
+ [PrivateApi("Mark this as private, since it's not very useful in the public docs")]
+ public class ModuleInfo : IModule
+ {
+ public ModuleDefinition ModuleDefinition => new ModuleDefinition
+ {
+ Name = "File Management",
+ Description = "File Management",
+ Version = Constants.Version,
+ Categories = "Admin",
+ ServerManagerType = "Oqtane.Modules.Admin.Files.Manager.FileManager, Oqtane.Server"
+ };
+ }
+}
diff --git a/Oqtane.Server/Infrastructure/Jobs/SearchIndexJob.cs b/Oqtane.Server/Infrastructure/Jobs/SearchIndexJob.cs
index 0374a850..b791d956 100644
--- a/Oqtane.Server/Infrastructure/Jobs/SearchIndexJob.cs
+++ b/Oqtane.Server/Infrastructure/Jobs/SearchIndexJob.cs
@@ -90,7 +90,7 @@ namespace Oqtane.Infrastructure
EntityId = page.PageId.ToString(),
Title = !string.IsNullOrEmpty(page.Title) ? page.Title : page.Name,
Description = string.Empty,
- Body = $"{page.Name} {page.Title}",
+ Body = string.Empty,
Url = $"{(!string.IsNullOrEmpty(page.Path) && !page.Path.StartsWith("/") ? "/" : "")}{page.Path}",
Permissions = $"{EntityNames.Page}:{page.PageId}",
ContentModifiedBy = page.ModifiedBy,
@@ -141,7 +141,7 @@ namespace Oqtane.Infrastructure
}
catch (Exception ex)
{
- log += ex.Message + "
";
+ log += $"Error Indexing Module {pageModule.Module.ModuleDefinition.Name} - {ex.Message}
";
}
}
}
@@ -156,7 +156,7 @@ namespace Oqtane.Infrastructure
EntityId = pageModule.ModuleId.ToString(),
Title = pageModule.Title,
Description = string.Empty,
- Body = $"{pageModule.Title}",
+ Body = string.Empty,
Url = $"{(!string.IsNullOrEmpty(page.Path) && !page.Path.StartsWith("/") ? "/" : "")}{page.Path}",
Permissions = $"{EntityNames.Module}:{pageModule.ModuleId},{EntityNames.Page}:{pageModule.PageId}",
ContentModifiedBy = pageModule.ModifiedBy,
diff --git a/Oqtane.Server/Modules/Admin/Files/Manager/FileManager.cs b/Oqtane.Server/Modules/Admin/Files/Manager/FileManager.cs
new file mode 100644
index 00000000..2f600b3a
--- /dev/null
+++ b/Oqtane.Server/Modules/Admin/Files/Manager/FileManager.cs
@@ -0,0 +1,82 @@
+using Oqtane.Models;
+using Oqtane.Repository;
+using Oqtane.Documentation;
+using Oqtane.Interfaces;
+using System.Collections.Generic;
+using System;
+using System.Threading.Tasks;
+using Oqtane.Shared;
+using System.IO;
+
+namespace Oqtane.Modules.Admin.Files.Manager
+{
+ public class FileManager : ISearchable
+ {
+ private readonly IFolderRepository _folderRepository;
+ private readonly IFileRepository _fileRepository;
+ private const string DocumentExtensions = ".txt,.htm,.html";
+
+ public FileManager(IFolderRepository folderRepository, IFileRepository fileRepository)
+ {
+ _folderRepository = folderRepository;
+ _fileRepository = fileRepository;
+ }
+
+ public async Task> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
+ {
+ await Task.CompletedTask;
+
+ var searchContents = new List();
+
+ var folders = _folderRepository.GetFolders(pageModule.Module.SiteId);
+ foreach ( var folder in folders)
+ {
+ bool changed = false;
+ bool removed = false;
+
+ if (folder.ModifiedOn >= lastIndexedOn)
+ {
+ changed = true;
+ removed = folder.IsDeleted.Value;
+ }
+
+ var files = _fileRepository.GetFiles(folder.FolderId);
+ foreach (var file in files)
+ {
+ if (file.ModifiedOn >= lastIndexedOn || changed)
+ {
+ var path = folder.Path + file.Name;
+
+ var body = "";
+ if (DocumentExtensions.Contains(Path.GetExtension(file.Name)))
+ {
+ // get the contents of the file
+ body = System.IO.File.ReadAllText(_fileRepository.GetFilePath(file));
+ }
+
+ var searchContent = new SearchContent
+ {
+ SiteId = folder.SiteId,
+ EntityName = EntityNames.File,
+ EntityId = file.FileId.ToString(),
+ Title = path,
+ Description = string.Empty,
+ Body = body,
+ Url = $"{Constants.FileUrl}{folder.Path}{file.Name}",
+ Permissions = $"{EntityNames.Folder}:{folder.FolderId}",
+ ContentModifiedBy = file.ModifiedBy,
+ ContentModifiedOn = file.ModifiedOn,
+ AdditionalContent = string.Empty,
+ CreatedOn = DateTime.UtcNow,
+ IsDeleted = (removed || file.IsDeleted.Value)
+ };
+ searchContents.Add(searchContent);
+ }
+
+ }
+ }
+
+ return searchContents;
+ }
+ }
+}
diff --git a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs
index 550c7104..6c61c25e 100644
--- a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs
+++ b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs
@@ -53,7 +53,7 @@ namespace Oqtane.Modules.HtmlText.Manager
{
await Task.CompletedTask;
- var searchContentList = new List();
+ var searchContents = new List();
var htmltexts = _htmlText.GetHtmlTexts(pageModule.ModuleId);
if (htmltexts != null && htmltexts.Any())
@@ -61,7 +61,7 @@ namespace Oqtane.Modules.HtmlText.Manager
var htmltext = htmltexts.OrderByDescending(item => item.CreatedOn).First();
if (htmltext.CreatedOn >= lastIndexedOn)
{
- searchContentList.Add(new SearchContent
+ searchContents.Add(new SearchContent
{
Title = pageModule.Module.Title,
Description = string.Empty,
@@ -72,7 +72,7 @@ namespace Oqtane.Modules.HtmlText.Manager
}
}
- return searchContentList;
+ return searchContents;
}
public void ImportModule(Module module, string content, string version)
diff --git a/Oqtane.Server/Providers/DatabaseSearchProvider.cs b/Oqtane.Server/Providers/DatabaseSearchProvider.cs
index 46d17484..96fa1b1f 100644
--- a/Oqtane.Server/Providers/DatabaseSearchProvider.cs
+++ b/Oqtane.Server/Providers/DatabaseSearchProvider.cs
@@ -45,7 +45,7 @@ namespace Oqtane.Providers
Title = searchContent.Title,
Description = searchContent.Description,
Body = searchContent.Body,
- Url = searchContent.Url,
+ Url = Utilities.TenantUrl(searchQuery.Alias, searchContent.Url),
Permissions = searchContent.Permissions,
ContentModifiedBy = searchContent.ContentModifiedBy,
ContentModifiedOn = searchContent.ContentModifiedOn,
diff --git a/Oqtane.Server/Services/SearchService.cs b/Oqtane.Server/Services/SearchService.cs
index 032af075..76d21431 100644
--- a/Oqtane.Server/Services/SearchService.cs
+++ b/Oqtane.Server/Services/SearchService.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
using Oqtane.Models;
using Oqtane.Repository;
using Oqtane.Security;
@@ -18,18 +17,15 @@ namespace Oqtane.Services
private readonly IServiceProvider _serviceProvider;
private readonly ISettingRepository _settingRepository;
private readonly IPermissionRepository _permissionRepository;
- private readonly ILogger _logger;
public SearchService(
IServiceProvider serviceProvider,
ISettingRepository settingRepository,
- IPermissionRepository permissionRepository,
- ILogger logger)
+ IPermissionRepository permissionRepository)
{
_settingRepository = settingRepository;
_permissionRepository = permissionRepository;
_serviceProvider = serviceProvider;
- _logger = logger;
}
public async Task GetSearchResultsAsync(SearchQuery searchQuery)