support for commercial modules, themes, translations
This commit is contained in:
parent
ffe724b32d
commit
ffcc229c78
|
@ -77,7 +77,11 @@ else
|
||||||
<td>
|
<td>
|
||||||
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> by: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] |
|
||||||
|
@SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> |
|
||||||
|
@SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> |
|
||||||
|
@SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong> |
|
||||||
|
@SharedLocalizer["Search.Price"]: <strong>@((context.Price == 0) ? "FREE" : context.Price.ToString("$#,##0.00") )</strong>
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: middle;">
|
<td style="vertical-align: middle;">
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetLanguage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetLanguage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
@ -184,7 +188,7 @@ else
|
||||||
|
|
||||||
private async Task LoadTranslations()
|
private async Task LoadTranslations()
|
||||||
{
|
{
|
||||||
_packages = await PackageService.GetPackagesAsync("translation", _search, _price);
|
_packages = await PackageService.GetPackagesAsync("translation", _search, _price, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void PriceChanged(ChangeEventArgs e)
|
private async void PriceChanged(ChangeEventArgs e)
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
private async Task LoadModuleDefinitions()
|
private async Task LoadModuleDefinitions()
|
||||||
{
|
{
|
||||||
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
_packages = await PackageService.GetPackagesAsync("module", _search, _price);
|
_packages = await PackageService.GetPackagesAsync("module", _search, _price, "");
|
||||||
|
|
||||||
if (_packages != null)
|
if (_packages != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ else
|
||||||
private bool UpgradeAvailable(string packagename, string version)
|
private bool UpgradeAvailable(string packagename, string version)
|
||||||
{
|
{
|
||||||
var upgradeavailable = false;
|
var upgradeavailable = false;
|
||||||
if (_packages != null)
|
if (!string.IsNullOrEmpty(packagename) && _packages != null)
|
||||||
{
|
{
|
||||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||||
if (package != null)
|
if (package != null)
|
||||||
|
|
|
@ -34,7 +34,11 @@
|
||||||
<td>
|
<td>
|
||||||
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> @SharedLocalizer["Search.By"]: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
<h3 style="display: inline;"><a href="@context.ProductUrl" target="_new">@context.Name</a></h3> @SharedLocalizer["Search.By"]: <strong><a href="@context.OwnerUrl" target="new">@context.Owner</a></strong><br />
|
||||||
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)<br />
|
||||||
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] | @SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> | @SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> | @SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong>
|
<strong>@(String.Format("{0:n0}", context.Downloads))</strong> @SharedLocalizer["Search.Downloads"] |
|
||||||
|
@SharedLocalizer["Search.Released"]: <strong>@context.ReleaseDate.ToString("MMM dd, yyyy")</strong> |
|
||||||
|
@SharedLocalizer["Search.Version"]: <strong>@context.Version</strong> |
|
||||||
|
@SharedLocalizer["Search.Source"]: <strong>@context.PackageUrl</strong> |
|
||||||
|
@SharedLocalizer["Search.Price"]: <strong>@((context.Price == 0) ? "FREE" : context.Price.ToString("$#,##0.00") )</strong>
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: middle;">
|
<td style="vertical-align: middle;">
|
||||||
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
|
||||||
|
@ -126,7 +130,7 @@
|
||||||
private async Task LoadThemes()
|
private async Task LoadThemes()
|
||||||
{
|
{
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
_packages = await PackageService.GetPackagesAsync("theme", _search, _price);
|
_packages = await PackageService.GetPackagesAsync("theme", _search, _price, "");
|
||||||
|
|
||||||
if (_packages != null)
|
if (_packages != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ else
|
||||||
private bool UpgradeAvailable(string packagename, string version)
|
private bool UpgradeAvailable(string packagename, string version)
|
||||||
{
|
{
|
||||||
var upgradeavailable = false;
|
var upgradeavailable = false;
|
||||||
if (_packages != null)
|
if (!string.IsNullOrEmpty(packagename) && _packages != null)
|
||||||
{
|
{
|
||||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||||
if (package != null)
|
if (package != null)
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Package> packages = await PackageService.GetPackagesAsync("framework");
|
List<Package> packages = await PackageService.GetPackagesAsync("framework", "", "", "");
|
||||||
if (packages != null)
|
if (packages != null)
|
||||||
{
|
{
|
||||||
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
|
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Oqtane.Services
|
||||||
public interface IPackageService
|
public interface IPackageService
|
||||||
{
|
{
|
||||||
Task<List<Package>> GetPackagesAsync(string type);
|
Task<List<Package>> GetPackagesAsync(string type);
|
||||||
Task<List<Package>> GetPackagesAsync(string type, string search, string price);
|
Task<List<Package>> GetPackagesAsync(string type, string search, string price, string package);
|
||||||
Task<Package> GetPackageAsync(string packageId, string version);
|
Task<Package> GetPackageAsync(string packageId, string version);
|
||||||
Task DownloadPackageAsync(string packageId, string version, string folder);
|
Task DownloadPackageAsync(string packageId, string version, string folder);
|
||||||
Task InstallPackagesAsync();
|
Task InstallPackagesAsync();
|
||||||
|
|
|
@ -22,12 +22,12 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
public async Task<List<Package>> GetPackagesAsync(string type)
|
public async Task<List<Package>> GetPackagesAsync(string type)
|
||||||
{
|
{
|
||||||
return await GetPackagesAsync(type, "", "");
|
return await GetPackagesAsync(type, "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Package>> GetPackagesAsync(string type, string search, string price)
|
public async Task<List<Package>> GetPackagesAsync(string type, string search, string price, string package)
|
||||||
{
|
{
|
||||||
return await GetJsonAsync<List<Package>>($"{Apiurl}?type={type}&search={WebUtility.UrlEncode(search)}&price={price}");
|
return await GetJsonAsync<List<Package>>($"{Apiurl}?type={type}&search={WebUtility.UrlEncode(search)}&price={price}&package={package}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Package> GetPackageAsync(string packageId, string version)
|
public async Task<Package> GetPackageAsync(string packageId, string version)
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace Oqtane.Controllers
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/<controller>?type=x&search=y&license=z
|
// GET: api/<controller>?type=x&search=y&price=z&package=a
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(Roles = RoleNames.Host)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public async Task<IEnumerable<Package>> Get(string type, string search, string price)
|
public async Task<IEnumerable<Package>> Get(string type, string search, string price, string package)
|
||||||
{
|
{
|
||||||
// get packages
|
// get packages
|
||||||
List<Package> packages = new List<Package>();
|
List<Package> packages = new List<Package>();
|
||||||
|
@ -45,7 +45,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Add("Referer", HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value);
|
client.DefaultRequestHeaders.Add("Referer", HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value);
|
||||||
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.PackageId, Constants.Version));
|
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.PackageId, Constants.Version));
|
||||||
packages = await GetJson<List<Package>>(client, Constants.PackageRegistryUrl + $"/api/registry/packages/?id={_configManager.GetInstallationId()}&type={type.ToLower()}&version={Constants.Version}&search={search}&price={price}");
|
packages = await GetJson<List<Package>>(client, Constants.PackageRegistryUrl + $"/api/registry/packages/?id={_configManager.GetInstallationId()}&type={type.ToLower()}&version={Constants.Version}&search={search}&price={price}&package={package}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return packages;
|
return packages;
|
||||||
|
|
|
@ -186,41 +186,45 @@ namespace Oqtane.Infrastructure
|
||||||
|
|
||||||
public bool UninstallPackage(string PackageName)
|
public bool UninstallPackage(string PackageName)
|
||||||
{
|
{
|
||||||
// get manifest with highest version
|
if (!string.IsNullOrEmpty(PackageName))
|
||||||
string packagename = "";
|
|
||||||
string[] packages = Directory.GetFiles(Path.Combine(_environment.ContentRootPath, "Packages"), PackageName + "*.log");
|
|
||||||
if (packages.Length > 0)
|
|
||||||
{
|
{
|
||||||
packagename = packages[packages.Length - 1]; // use highest version
|
// get manifest with highest version
|
||||||
}
|
string packagename = "";
|
||||||
|
string[] packages = Directory.GetFiles(Path.Combine(_environment.ContentRootPath, "Packages"), PackageName + "*.log");
|
||||||
if (!string.IsNullOrEmpty(packagename))
|
if (packages.Length > 0)
|
||||||
{
|
|
||||||
// use manifest to clean up file resources
|
|
||||||
List<string> assets = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(packagename));
|
|
||||||
assets.Reverse();
|
|
||||||
foreach (string asset in assets)
|
|
||||||
{
|
{
|
||||||
// legacy support for assets that were stored as absolute paths
|
packagename = packages[packages.Length - 1]; // use highest version
|
||||||
string filepath = asset.StartsWith("\\") ? Path.Combine(_environment.ContentRootPath, asset.Substring(1)) : asset;
|
}
|
||||||
if (File.Exists(filepath))
|
|
||||||
|
if (!string.IsNullOrEmpty(packagename))
|
||||||
|
{
|
||||||
|
// use manifest to clean up file resources
|
||||||
|
List<string> assets = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(packagename));
|
||||||
|
assets.Reverse();
|
||||||
|
foreach (string asset in assets)
|
||||||
{
|
{
|
||||||
File.Delete(filepath);
|
// legacy support for assets that were stored as absolute paths
|
||||||
if (!Directory.EnumerateFiles(Path.GetDirectoryName(filepath)).Any())
|
string filepath = asset.StartsWith("\\") ? Path.Combine(_environment.ContentRootPath, asset.Substring(1)) : asset;
|
||||||
|
if (File.Exists(filepath))
|
||||||
{
|
{
|
||||||
Directory.Delete(Path.GetDirectoryName(filepath));
|
File.Delete(filepath);
|
||||||
|
if (!Directory.EnumerateFiles(Path.GetDirectoryName(filepath)).Any())
|
||||||
|
{
|
||||||
|
Directory.Delete(Path.GetDirectoryName(filepath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// clean up package asset manifests
|
// clean up package asset manifests
|
||||||
foreach(string asset in packages)
|
foreach (string asset in packages)
|
||||||
{
|
{
|
||||||
File.Delete(asset);
|
File.Delete(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,10 +241,6 @@ namespace Oqtane.Repository
|
||||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||||
moduledefinition.ControlTypeTemplate = modulecontroltype.Namespace + "." + Constants.ActionToken + ", " + modulecontroltype.Assembly.GetName().Name;
|
moduledefinition.ControlTypeTemplate = modulecontroltype.Namespace + "." + Constants.ActionToken + ", " + modulecontroltype.Assembly.GetName().Name;
|
||||||
moduledefinition.AssemblyName = assembly.GetName().Name;
|
moduledefinition.AssemblyName = assembly.GetName().Name;
|
||||||
if (string.IsNullOrEmpty(moduledefinition.PackageName))
|
|
||||||
{
|
|
||||||
moduledefinition.PackageName = Utilities.GetTypeName(moduledefinition.ModuleDefinitionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,10 +101,6 @@ namespace Oqtane.Repository
|
||||||
theme.Themes = new List<ThemeControl>();
|
theme.Themes = new List<ThemeControl>();
|
||||||
theme.Containers = new List<ThemeControl>();
|
theme.Containers = new List<ThemeControl>();
|
||||||
theme.AssemblyName = assembly.FullName.Split(",")[0];
|
theme.AssemblyName = assembly.FullName.Split(",")[0];
|
||||||
if (string.IsNullOrEmpty(theme.PackageName))
|
|
||||||
{
|
|
||||||
theme.PackageName = Utilities.GetTypeName(theme.ThemeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.WriteLine($"Oqtane Info: Registering Theme {theme.ThemeName}");
|
Debug.WriteLine($"Oqtane Info: Registering Theme {theme.ThemeName}");
|
||||||
themes.Add(theme);
|
themes.Add(theme);
|
||||||
|
|
|
@ -12,7 +12,8 @@ namespace [Owner].[Module]
|
||||||
Version = "1.0.0",
|
Version = "1.0.0",
|
||||||
ServerManagerType = "[ServerManagerType]",
|
ServerManagerType = "[ServerManagerType]",
|
||||||
ReleaseVersions = "1.0.0",
|
ReleaseVersions = "1.0.0",
|
||||||
Dependencies = "[Owner].[Module].Shared.Oqtane"
|
Dependencies = "[Owner].[Module].Shared.Oqtane",
|
||||||
|
PackageName = "[Owner].[Module]"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ namespace [Owner].[Theme]
|
||||||
public Theme Theme => new Theme
|
public Theme Theme => new Theme
|
||||||
{
|
{
|
||||||
Name = "[Theme]",
|
Name = "[Theme]",
|
||||||
Version = "1.0.0"
|
Version = "1.0.0",
|
||||||
|
PackageName = "[Owner].[Theme]"
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user