Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: umbraco/Umbraco-CMS
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: contrib
Choose a base ref
...
head repository: umbraco/Umbraco-CMS
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v13/dev
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Mar 18, 2025

  1. Render folders before files in static files picker. (#18701)

    AndyButland authored Mar 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    eb97962 View commit details
  2. Fixes issue with macro rendering in an RTE when GUIDs are used for ba…

    …ckoffice document routes (#18691)
    
    * Fixes issue with macro rendering in an RTE when GUIDs are used for backoffice document routes.
    
    * Fixed null reference error.
    AndyButland authored Mar 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5570583 View commit details

Commits on Mar 19, 2025

  1. Bumped version to 13.9.0-rc.

    AndyButland committed Mar 19, 2025
    Copy the full SHA
    68acc2a View commit details

Commits on Mar 20, 2025

  1. Make preview check for delivery API content case insensitive. (#18731)

    AndyButland authored Mar 20, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    eb91f4f View commit details
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.DeliveryApi;

namespace Umbraco.Cms.Api.Delivery.Services;
@@ -11,5 +11,5 @@ public RequestPreviewService(IHttpContextAccessor httpContextAccessor)
}

/// <inheritdoc />
public bool IsPreview() => GetHeaderValue("Preview") == "true";
public bool IsPreview() => string.Equals(GetHeaderValue("Preview"), "true", StringComparison.OrdinalIgnoreCase);
}
46 changes: 41 additions & 5 deletions src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ public ActionResult<IEnumerable<MacroParameter>> GetMacroParameters(int macroId)
[HttpGet]
public async Task<IActionResult> GetMacroResultAsHtmlForEditor(string macroAlias, int pageId,
[FromQuery] IDictionary<string, object> macroParams) =>
await GetMacroResultAsHtml(macroAlias, pageId, macroParams);
await GetMacroResultAsHtml(macroAlias, pageId.ToString(), macroParams);

/// <summary>
/// Gets a rendered macro as HTML for rendering in the rich text editor.
@@ -98,11 +98,24 @@ public async Task<IActionResult> GetMacroResultAsHtmlForEditor(string macroAlias
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[NonAction]
[Obsolete("This endpoint is no longer used.")]
public async Task<IActionResult> GetMacroResultAsHtmlForEditor(MacroParameterModel model) =>
await GetMacroResultAsHtml(model.MacroAlias, model.PageId.ToString(), model.MacroParams);

/// <summary>
/// Gets a rendered macro as HTML for rendering in the rich text editor.
/// Using HTTP POST instead of GET allows for more parameters to be passed as it's not dependent on URL-length
/// limitations like GET.
/// The method using GET is kept to maintain backwards compatibility
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> GetMacroResultAsHtmlForEditor(MacroParameterModel2 model) =>
await GetMacroResultAsHtml(model.MacroAlias, model.PageId, model.MacroParams);

private async Task<IActionResult> GetMacroResultAsHtml(string? macroAlias, int pageId,
IDictionary<string, object>? macroParams)
private async Task<IActionResult> GetMacroResultAsHtml(string? macroAlias, string pageId, IDictionary<string, object>? macroParams)
{
IMacro? m = macroAlias is null ? null : _macroService.GetByAlias(macroAlias);
if (m == null)
@@ -111,11 +124,11 @@ private async Task<IActionResult> GetMacroResultAsHtml(string? macroAlias, int p
}

IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
IPublishedContent? publishedContent = umbracoContext.Content?.GetById(true, pageId);
IPublishedContent? publishedContent = GetPagePublishedContent(pageId, umbracoContext);

//if it isn't supposed to be rendered in the editor then return an empty string
//currently we cannot render a macro if the page doesn't yet exist
if (pageId == -1 || publishedContent == null || m.DontRender)
if (publishedContent == null || m.DontRender)
{
//need to create a specific content result formatted as HTML since this controller has been configured
//with only json formatters.
@@ -149,6 +162,21 @@ private async Task<IActionResult> GetMacroResultAsHtml(string? macroAlias, int p
}
}

private static IPublishedContent? GetPagePublishedContent(string pageId, IUmbracoContext umbracoContext)
{
if (int.TryParse(pageId, NumberStyles.Integer, CultureInfo.InvariantCulture, out int pageIdAsInt))
{
return umbracoContext.Content?.GetById(true, pageIdAsInt);
}

if (Guid.TryParse(pageId, out Guid pageIdAsGuid))
{
return umbracoContext.Content?.GetById(true, pageIdAsGuid);
}

return null;
}

[HttpPost]
public IActionResult CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model)
{
@@ -180,13 +208,21 @@ public IActionResult CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFi
return Ok();
}

[Obsolete("This model is no longer used and has been replaced with MacroParameterModel2 that changes the type of the PageId property.")]
public class MacroParameterModel
{
public string? MacroAlias { get; set; }
public int PageId { get; set; }
public IDictionary<string, object>? MacroParams { get; set; }
}

public class MacroParameterModel2
{
public string? MacroAlias { get; set; }
public string PageId { get; set; } = string.Empty;
public IDictionary<string, object>? MacroParams { get; set; }
}

public class CreatePartialViewMacroWithFileModel
{
public string? Filename { get; set; }
20 changes: 10 additions & 10 deletions src/Umbraco.Web.BackOffice/Trees/StaticFilesTreeController.cs
Original file line number Diff line number Diff line change
@@ -98,16 +98,6 @@ private void AddRootFolder(string directory, FormCollection queryStrings, TreeNo

private void AddPhysicalFiles(string path, FormCollection queryStrings, TreeNodeCollection nodes)
{
IEnumerable<string> files = _fileSystem.GetFiles(path)
.Where(x => x.StartsWith(AppPlugins) || x.StartsWith(Webroot));

foreach (var file in files)
{
var name = Path.GetFileName(file);
TreeNode node = CreateTreeNode(WebUtility.UrlEncode(file), path, queryStrings, name, Constants.Icons.DefaultIcon, false);
nodes.Add(node);
}

IEnumerable<string> directories = _fileSystem.GetDirectories(path);

foreach (var directory in directories)
@@ -117,6 +107,16 @@ private void AddPhysicalFiles(string path, FormCollection queryStrings, TreeNode
TreeNode node = CreateTreeNode(WebUtility.UrlEncode(directory), path, queryStrings, name, Constants.Icons.Folder, hasChildren);
nodes.Add(node);
}

IEnumerable<string> files = _fileSystem.GetFiles(path)
.Where(x => x.StartsWith(AppPlugins) || x.StartsWith(Webroot));

foreach (var file in files)
{
var name = Path.GetFileName(file);
TreeNode node = CreateTreeNode(WebUtility.UrlEncode(file), path, queryStrings, name, Constants.Icons.DefaultIcon, false);
nodes.Add(node);
}
}

private void AddWebRootFiles(string path, FormCollection queryStrings, TreeNodeCollection nodes)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Http;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Api.Delivery.Services;

namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Cms.Api.Delivery.Services;

[TestFixture]
public class RequestPreviewServiceTests
{
[TestCase(null, false)]
[TestCase("", false)]
[TestCase("false", false)]
[TestCase("true", true)]
[TestCase("True", true)]
public void IsPreview_Returns_Expected_Result(string? headerValue, bool expected)
{
var httpContext = new DefaultHttpContext();
httpContext.Request.Headers["Preview"] = headerValue;

var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
httpContextAccessorMock
.Setup(x => x.HttpContext)
.Returns(httpContext);
var sut = new RequestPreviewService(httpContextAccessorMock.Object);

var result = sut.IsPreview();

Assert.AreEqual(expected, result);
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "13.8.0-rc",
"version": "13.9.0-rc",
"assemblyVersion": {
"precision": "build"
},