Assorted enhancements
This commit is contained in:
@ -508,8 +508,8 @@ namespace Oqtane.Controllers
|
||||
return System.IO.File.Exists(errorPath) ? PhysicalFile(errorPath, MimeUtilities.GetMimeType(errorPath)) : null;
|
||||
}
|
||||
|
||||
[HttpGet("image/{id}/{width}/{height}/{mode?}")]
|
||||
public IActionResult GetImage(int id, int width, int height, string mode)
|
||||
[HttpGet("image/{id}/{width}/{height}/{mode?}/{rotate?}")]
|
||||
public IActionResult GetImage(int id, int width, int height, string mode, string rotate)
|
||||
{
|
||||
var file = _files.GetFile(id);
|
||||
if (file != null && file.Folder.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||
@ -520,6 +520,7 @@ namespace Oqtane.Controllers
|
||||
if (System.IO.File.Exists(filepath))
|
||||
{
|
||||
mode = (string.IsNullOrEmpty(mode)) ? "crop" : mode;
|
||||
rotate = (string.IsNullOrEmpty(rotate)) ? "0" : rotate;
|
||||
|
||||
string imagepath = filepath.Replace(Path.GetExtension(filepath), "." + width.ToString() + "x" + height.ToString() + "." + mode.ToLower() + ".png");
|
||||
if (!System.IO.File.Exists(imagepath))
|
||||
@ -528,7 +529,7 @@ namespace Oqtane.Controllers
|
||||
!string.IsNullOrEmpty(file.Folder.ImageSizes) && file.Folder.ImageSizes.ToLower().Split(",").Contains(width.ToString() + "x" + height.ToString()))
|
||||
&& Enum.TryParse(mode, true, out ResizeMode resizemode))
|
||||
{
|
||||
imagepath = CreateImage(filepath, width, height, resizemode.ToString(), imagepath);
|
||||
imagepath = CreateImage(filepath, width, height, resizemode.ToString(), rotate, imagepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -568,7 +569,7 @@ namespace Oqtane.Controllers
|
||||
return System.IO.File.Exists(errorPath) ? PhysicalFile(errorPath, MimeUtilities.GetMimeType(errorPath)) : null;
|
||||
}
|
||||
|
||||
private string CreateImage(string filepath, int width, int height, string mode, string imagepath)
|
||||
private string CreateImage(string filepath, int width, int height, string mode, string rotate, string imagepath)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -585,6 +586,11 @@ namespace Oqtane.Controllers
|
||||
})
|
||||
.BackgroundColor(new Rgba32(255, 255, 255, 0)));
|
||||
|
||||
if (rotate != "0" && int.TryParse(rotate, out int angle))
|
||||
{
|
||||
image.Mutate(x => x.Rotate(angle));
|
||||
}
|
||||
|
||||
image.Save(imagepath, new PngEncoder());
|
||||
}
|
||||
stream.Close();
|
||||
|
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Migrations.Tenant
|
||||
{
|
||||
[DbContext(typeof(TenantDBContext))]
|
||||
[Migration("Tenant.03.00.01.01")]
|
||||
public class ChangeFileNameColumnsSize : MultiDatabaseMigration
|
||||
{
|
||||
public ChangeFileNameColumnsSize(IDatabase database) : base(database)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
if (ActiveDatabase.Name != "Sqlite")
|
||||
{
|
||||
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
|
||||
// Drop the index is needed because the Name is already associated with IX_File
|
||||
fileEntityBuilder.DropForeignKey("FK_File_Folder");
|
||||
fileEntityBuilder.DropIndex("IX_File");
|
||||
fileEntityBuilder.AlterStringColumn("Name", 256);
|
||||
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
|
||||
fileEntityBuilder.AddForeignKey("FK_File_Folder");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
if (ActiveDatabase.Name != "Sqlite")
|
||||
{
|
||||
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
|
||||
fileEntityBuilder.DropIndex("IX_File");
|
||||
fileEntityBuilder.AlterStringColumn("Name", 50);
|
||||
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Oqtane</title>
|
||||
<title>@Model.Title</title>
|
||||
<base href="~/" />
|
||||
<link id="app-favicon" rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
<!-- stub the PWA manifest but defer the assignment of href -->
|
||||
|
@ -40,6 +40,7 @@ namespace Oqtane.Pages
|
||||
public RenderMode RenderMode = RenderMode.Server;
|
||||
public string HeadResources = "";
|
||||
public string BodyResources = "";
|
||||
public string Title = "";
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
@ -80,6 +81,7 @@ namespace Oqtane.Pages
|
||||
{
|
||||
RenderMode = (RenderMode)Enum.Parse(typeof(RenderMode), site.RenderMode, true);
|
||||
}
|
||||
Title = site.Name;
|
||||
}
|
||||
|
||||
// if culture not specified
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 318 B |
BIN
Oqtane.Server/wwwroot/oqtane.ico
Normal file
BIN
Oqtane.Server/wwwroot/oqtane.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Reference in New Issue
Block a user