-
Notifications
You must be signed in to change notification settings - Fork 15
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
Adding UriAugmenterService in order to augment Url generation. #56
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d13dcd3
Url Augmentation Services in order to take a given Url built from con…
jefffischer-episerver 2b8db19
Adding documentation on how to swap out IUriAugmenterService for your…
jefffischer-episerver ee43743
Integrating PR feedback.
jefffischer-episerver d490e46
Removing docs per PR.
jefffischer-episerver f7baab1
Fixing README.md.
jefffischer-episerver ae97e54
Fixing README path.
jefffischer-episerver 383cd14
Utilize nameof instead of string literal.
jefffischer-episerver f90a8ed
Remove ServiceConfiguration on DefaultUriAugmenterService.
jefffischer-episerver d571701
Redoing implementation of SitemapOptions method for replacing service…
jefffischer-episerver 0c28ff0
Calling optionAction directly like in ProductFeed.
jefffischer-episerver 51d35f9
I just saw you wanted the default set in Options. Makes sense, DRYs t…
jefffischer-episerver 0904d71
Removing period.
jefffischer-episerver cc3bb49
Forgot to update the README.md.
jefffischer-episerver f5a9ca6
Update README.md
jeff-fischer-optimizely 2a1c2b2
Update sandbox/Foundation/src/Foundation/Infrastructure/Cms/Services/…
jeff-fischer-optimizely 8f12984
PR issue resolutions.
jefffischer-episerver a2a0776
Merge branch 'master' of https://github.com/jeff-fischer-optimizely/g…
jefffischer-episerver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ndation/src/Foundation/Infrastructure/Cms/Services/SitemapUriParameterAugmenterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using EPiServer; | ||
using EPiServer.Core; | ||
using EPiServer.DataAbstraction; | ||
using Foundation.Features.People.PersonItemPage; | ||
using Geta.Optimizely.Sitemaps; | ||
using Geta.Optimizely.Sitemaps.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Foundation.Infrastructure.Cms.Services | ||
{ | ||
public class SitemapUriParameterAugmenterService : IUriAugmenterService | ||
{ | ||
private readonly IContentTypeRepository _contentTypeRepository; | ||
private readonly IContentModelUsage _contentModelUsage; | ||
private readonly IContentRepository _contentRepository; | ||
|
||
public SitemapUriParameterAugmenterService(IContentTypeRepository contentTypeRepository, IContentModelUsage contentModelUsage, IContentRepository contentRepository) | ||
{ | ||
_contentTypeRepository = contentTypeRepository; | ||
_contentModelUsage = contentModelUsage; | ||
_contentRepository = contentRepository; | ||
} | ||
|
||
public IEnumerable<Uri> GetAugmentUris(IContent content, CurrentLanguageContent languageContentInfo, Uri fullUri) | ||
{ | ||
if (content is PageData pageContent) | ||
{ | ||
if (pageContent.PageTypeName == nameof(Features.People.PersonListPage)) | ||
{ | ||
var fullUriString = fullUri.ToString(); | ||
|
||
var personPageType = _contentTypeRepository.Load<PersonPage>(); | ||
var usages = _contentModelUsage.ListContentOfContentType(personPageType).Select(c => _contentRepository.Get<PersonPage>(c.ContentLink)); | ||
// Group all of the results by the querystring parameters that drive the page. | ||
var nameSectorLocations = usages.GroupBy(k => new { k.Name, k.Sector, k.Location }); | ||
|
||
// Enumerate the total set of expected name/sectors/locations in ordr for them to be indexed. | ||
foreach (var nameSectorLocation in nameSectorLocations) | ||
{ | ||
var augmentedUri = new Uri($"{fullUriString}?name={nameSectorLocation.Key.Name}§or={nameSectorLocation.Key.Sector}&location={nameSectorLocation.Key.Location}"); | ||
yield return augmentedUri; | ||
} | ||
} | ||
else | ||
{ | ||
yield return fullUri; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
src/Geta.Optimizely.Sitemaps/Configuration/SitemapOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
namespace Geta.Optimizely.Sitemaps.Configuration | ||
using System; | ||
using Geta.Optimizely.Sitemaps.Services; | ||
|
||
namespace Geta.Optimizely.Sitemaps.Configuration | ||
{ | ||
public class SitemapOptions | ||
{ | ||
public bool EnableRealtimeSitemap { get; set; } = false; | ||
public bool EnableRealtimeCaching { get; set; } = true; | ||
public bool EnableLanguageDropDownInAdmin { get; set; } = false; | ||
|
||
public Type UriAugmenterService { get; set; } = typeof(DefaultUriAugmenterService); | ||
|
||
public void SetAugmenterService<T>() where T : class, IUriAugmenterService | ||
{ | ||
UriAugmenterService = typeof(T); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Geta.Optimizely.Sitemaps/Services/DefaultUriAugmenterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using EPiServer.Core; | ||
using EPiServer.ServiceLocation; | ||
|
||
namespace Geta.Optimizely.Sitemaps.Services | ||
{ | ||
public class DefaultUriAugmenterService : IUriAugmenterService | ||
{ | ||
public IEnumerable<Uri> GetAugmentUris(IContent content, CurrentLanguageContent languageContentInfo, Uri fullUri) | ||
{ | ||
yield return fullUri; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Geta.Optimizely.Sitemaps/Services/IUriAugmenterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Optimizely.Sitemaps.Services | ||
{ | ||
public interface IUriAugmenterService | ||
{ | ||
/// <summary> | ||
/// Allows sitemap implementer an easy facility to take a simple url and expand it in a number of ways, includig parameterizing it with QueryStrings. | ||
/// </summary> | ||
/// <param name="content">Original content of page URL being created</param> | ||
/// <param name="languageContentInfo">Language for URI</param> | ||
/// <param name="originUri">Origin URI to be included in sitemap</param> | ||
/// <returns>Must include origin to be included in sitemap</returns> | ||
IEnumerable<Uri> GetAugmentUris(IContent content, CurrentLanguageContent languageContentInfo, Uri originUri); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.