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

Added an option to define a folder for client assets used in custom criteria, avoiding issue with build removing them from the package's App_Plugins folder. #3

Merged
merged 1 commit into from
Feb 26, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@

$scope.editDefinitionDetail = function (definitionDetail) {
editingNew = false;
var templateUrl = "/App_Plugins/PersonalisationGroups/Criteria/" + convertAliasToFolderName(definitionDetail.alias) + "/definition.editor.html";

var clientAssetsFolder = getCriteriaByAlias(definitionDetail.alias).clientAssetsFolder;
if (!clientAssetsFolder) {
clientAssetsFolder = "PersonalisationGroups/Criteria";
}

var templateUrl = "/App_Plugins/" + clientAssetsFolder + "/" + convertAliasToFolderName(definitionDetail.alias) + "/definition.editor.html";

editorService.open(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.AuthenticationStatus
/// <summary>
/// Implements a personalisation group criteria based on whether the user is logged on or not
/// </summary>
public class AuthenticationStatusPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class AuthenticationStatusPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IAuthenticationStatusProvider _authenticationStatusProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.Continent
/// <summary>
/// Implements a personalisation group criteria based on the country derived from the vistor's IP address
/// </summary>
public class ContinentPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class ContinentPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IIpProvider _ipProvider;
private readonly IGeoLocationProvider _geoLocationProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// <summary>
/// Implements a personalisation group criteria based on the country derived from the vistor's IP address
/// </summary>
public class CountryPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class CountryPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly ICountryCodeProvider _countryCodeProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// <summary>
/// Implements a personalisation group criteria based on the day of the week
/// </summary>
public class DayOfWeekPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class DayOfWeekPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IDateTimeProvider _dateTimeProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public interface IPersonalisationGroupCriteria
/// </summary>
string Description { get; }

/// <summary>
/// Gets the client assets folder
/// </summary>
string ClientAssetsFolder { get; }

/// <summary>
/// Checks whether the attributes of the current site visitor match the provided definition
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.MemberGroup
/// <summary>
/// Implements a personalisation group criteria based on the presence, absence or value of a session key
/// </summary>
public class MemberGroupPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class MemberGroupPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IMemberGroupProvider _memberGroupProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.MemberType
/// <summary>
/// Implements a personalisation group criteria based on the presence, absence or value of a session key
/// </summary>
public class MemberTypePersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class MemberTypePersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IMemberTypeProvider _memberTypeProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.MonthOfYear
/// <summary>
/// Implements a personalisation group criteria based on the month of the year
/// </summary>
public class MonthOfYearPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class MonthOfYearPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IDateTimeProvider _dateTimeProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.NumberOfVisits
/// <summary>
/// Implements a personalisation group criteria based on the whether certain pages (node Ids) have been viewed
/// </summary>
public class NumberOfVisitsPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class NumberOfVisitsPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
internal static string CriteriaAlias = "numberOfVisits";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.PagesViewed
/// <summary>
/// Implements a personalisation group criteria based on the whether certain pages (node Ids) have been viewed
/// </summary>
public class PagesViewedPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class PagesViewedPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
internal static string CriteriaAlias = "pagesViewed";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria
/// </summary>
public abstract class PersonalisationGroupCriteriaBase
{
public virtual string ClientAssetsFolder => "PersonalisationGroups/Criteria";

protected static bool MatchesValue(string valueFromContext, string valueFromDefinition)
{
if (valueFromContext == null)
Expand Down Expand Up @@ -58,7 +60,7 @@ protected bool CompareValues(string value, string definitionValue, Comparison co
return StringCompare(value, definitionValue, comparison);
}

private bool DateCompare(string value, string definitionValue, Comparison comparison, out bool comparisonMade)
private static bool DateCompare(string value, string definitionValue, Comparison comparison, out bool comparisonMade)
{
if (DateTime.TryParse(value, out DateTime dateValue) && DateTime.TryParse(definitionValue, out DateTime dateDefinitionValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.Region
/// <summary>
/// Implements a personalisation group criteria based on the country derived from the vistor's IP address
/// </summary>
public class RegionPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class RegionPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IIpProvider _ipProvider;
private readonly IGeoLocationProvider _geoLocationProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Our.Umbraco.PersonalisationGroups.Criteria.TimeOfDay
/// <summary>
/// Implements a personalisation group criteria based on the time of the day
/// </summary>
public class TimeOfDayPersonalisationGroupCriteria : IPersonalisationGroupCriteria
public class TimeOfDayPersonalisationGroupCriteria : PersonalisationGroupCriteriaBase, IPersonalisationGroupCriteria
{
private readonly IDateTimeProvider _dateTimeProvider;

Expand Down
2 changes: 1 addition & 1 deletion PersonalisationGroups/UmbracoPersonalisationGroups.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ContentTargetFolders>.</ContentTargetFolders>
<TargetFramework>net5.0</TargetFramework>
<PackageId>UmbracoPersonalisationGroups</PackageId>
<Version>3.0.0</Version>
<Version>3.1.0-alpha001</Version>
<Authors>Andy Butland</Authors>
<Description>An Umbraco package supporting personalisation of content to different groups of site visitors.</Description>
<Copyright>2021 Andy Butland</Copyright>
Expand Down
Loading