Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor clean-up #52

Merged
merged 3 commits into from
Apr 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This file may be overwritten by automation. Only values allowed here are VersionPrefix and VersionSuffix. -->
<Project>
<PropertyGroup>
<VersionPrefix>1.7.1</VersionPrefix>
<VersionPrefix>1.7.2</VersionPrefix>
<VersionSuffix Condition="'$(Configuration)' == 'Debug'">devbuild</VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Alloy.Mvc.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
<PackageReference Include="EPiServer.CMS" Version="12.29.0" />
<PackageReference Include="Wangkanai.Detection" Version="8.7.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Alloy.Mvc._1.Helpers;
using Alloy.Mvc._1.Models.Blocks;
using Alloy.Mvc._1.Models.Pages;
using Alloy.Mvc._1.Models.ViewModels;
using EPiServer.Web;
using EPiServer.Web.Mvc;
using EPiServer.Web.Mvc.Html;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;

Expand Down Expand Up @@ -62,7 +62,7 @@ private HtmlString GetLinkUrl(ContactBlock contactBlock)
var linkMap = _permanentLinkMapper.Find(new UrlBuilder(linkUrl));
if (linkMap != null && !ContentReference.IsNullOrEmpty(linkMap.ContentReference))
{
return new HtmlString(Url.PageLinkUrl(linkMap.ContentReference));
return new HtmlString(Url.ContentUrl(linkMap.ContentReference));
}

return new HtmlString(contactBlock.LinkUrl.ToString());
Expand Down
52 changes: 0 additions & 52 deletions templates/Alloy.Mvc/Helpers/UrlHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,61 +1,9 @@
using EPiServer.ServiceLocation;
using EPiServer.Web.Routing;
using Microsoft.AspNetCore.Mvc;

namespace Alloy.Mvc._1.Helpers;

public static class UrlHelpers
{
/// <summary>
/// Returns the target URL for a ContentReference. Respects the page's shortcut setting
/// so if the page is set as a shortcut to another page or an external URL that URL
/// will be returned.
/// </summary>
public static string PageLinkUrl(this IUrlHelper urlHelper, ContentReference contentLink)
{
if (ContentReference.IsNullOrEmpty(contentLink))
{
return string.Empty;
}

var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var page = contentLoader.Get<PageData>(contentLink);

return PageLinkUrl(urlHelper, page);
}

/// <summary>
/// Returns the target URL for a page. Respects the page's shortcut setting
/// so if the page is set as a shortcut to another page or an external URL that URL
/// will be returned.
/// </summary>
public static string PageLinkUrl(this IUrlHelper urlHelper, PageData page)
{
var urlResolver = urlHelper.ActionContext.HttpContext.RequestServices.GetRequiredService<UrlResolver>();
switch (page.LinkType)
{
case PageShortcutType.Normal:
case PageShortcutType.FetchData:
return urlResolver.GetUrl(page.ContentLink);

case PageShortcutType.Shortcut:
if (page.Property["PageShortcutLink"] is PropertyPageReference shortcutProperty &&
!ContentReference.IsNullOrEmpty(shortcutProperty.ContentLink))
{
return urlHelper.PageLinkUrl(shortcutProperty.ContentLink);
}
break;

case PageShortcutType.External:
return page.LinkURL;
case PageShortcutType.Inactive:
break;
default:
break;
}
return string.Empty;
}

/// <summary>
/// Returns the URL anchor target for a page with shortcut settings
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@*Link the teaser block only if a link has been set and not displayed in preview*@
@using (Html.BeginConditionalLink(
!ContentReference.IsNullOrEmpty(Model.Link) && !(Html.ViewContext.IsPreviewMode()),
Url.PageLinkUrl(Model.Link),
Url.ContentUrl(Model.Link),
Model.Heading))
{
<div class="img-wrapper mb-3" epi-property="@Model.Image">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@*Link the teaser block only if a link has been set and not displayed in preview*@
@using (Html.BeginConditionalLink(
!ContentReference.IsNullOrEmpty(Model.Link) && !(Html.ViewContext.IsPreviewMode()),
Url.PageLinkUrl(Model.Link),
Url.ContentUrl(Model.Link),
Model.Heading))
{
<h2 epi-property="@Model.Heading">@Model.Heading</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
else
{
<div class="archive-item @string.Join(" ", page.GetThemeCssClassNames())">
<a href="@Url.PageLinkUrl(page)">
<a href="@Url.ContentUrl(page.ContentLink)">
<div class="row">
<div class="col-4">
@if (page is SitePageData sitePage && sitePage.PageImage != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@model SitePageData

<div>
@using (Html.BeginConditionalLink(Model.HasTemplate(), Url.PageLinkUrl(Model), Model.PageName, null, Url.PageLinkTarget(Model)))
@using (Html.BeginConditionalLink(Model.HasTemplate(), Url.ContentUrl(Model.ContentLink), Model.PageName, null, Url.PageLinkTarget(Model)))
{
<div class="img-wrapper mb-3">
@Html.DisplayFor(m => m.PageImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img class="pb-3 pb-lg-0" src="@Url.ContentUrl(Model.PageImage)" />
</div>
<div class="col-sm-12 col-lg-6">
@using (Html.BeginConditionalLink(Model.HasTemplate(), Url.PageLinkUrl(Model), Model.PageName, null, Url.PageLinkTarget(Model)))
@using (Html.BeginConditionalLink(Model.HasTemplate(), Url.ContentUrl(Model.ContentLink), Model.PageName, null, Url.PageLinkTarget(Model)))
{
<h2>@Model.PageName</h2>
<p>@Model.TeaserText</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/Cms.Empty/Cms.Empty.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
<PackageReference Include="EPiServer.CMS" Version="12.29.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion templates/Cms.Item/Cms.Item.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
<PackageReference Include="EPiServer.CMS" Version="12.29.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion templates/Commerce.Empty/Commerce.Empty.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
<PackageReference Include="EPiServer.CMS" Version="12.29.0" />
<PackageReference Include="EPiServer.Commerce" Version="14.15.3" />
</ItemGroup>

Expand Down
Loading