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

Adding UriAugmenterService in order to augment Url generation. #56

Merged
merged 17 commits into from
Oct 11, 2022

Conversation

jeff-fischer-optimizely
Copy link
Contributor

Some of the pages are not as simple as standard pages that need to be added to the sitemap. The Url needs to be augmented in order to be correctly indexed by google as the page requires Url parameters in order to correctly display data.

The UriAugmenterService takes an IContent, CurrentLanguageContent and Uri and turns it into an IEnumerable in order to take a single Uri and convert it into many possible Uris that are required to be indexed.

Additionally, this PR includes several files that were on disk (.gitignore, .md and nuget.config) into the solution for easy modification and fixes an uncompiled Regular Expression which will cause unnecessary excessive JIT compilation.

…tent and expand it into several QueryString parameterizedd Urls.
… own implementation.

Adding NullUriAugmenterService to AddSitmaps services extension.
Including documentation into solution.
Copy link
Member

@marisks marisks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add examples of a custom AugmentService in the documentation.

Geta.Optimizely.Sitemaps.sln Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Enhancing README.md with example UriAugmenterService.
Adding options and integrating options into Foundation project.
Renaming NullUriAugmenterService to DefaultUriAugmenterService.
@jeff-fischer-optimizely
Copy link
Contributor Author

I tried to do the deployment for the Foundation project, but couldn't get it to deploy for some reason.

@valdisiljuconoks valdisiljuconoks added the good first issue Good for newcomers label Sep 28, 2022
@marisks
Copy link
Member

marisks commented Sep 29, 2022

@jeff-fischer-optimizely This is a standard Foundation project, if you follow Optimizely's instructions, it should work.
What exactly failed?

@jeff-fischer-optimizely
Copy link
Contributor Author

jeff-fischer-optimizely commented Sep 29, 2022

It turned out to be a whole series of issues. Here are the ones that I can remember:

  1. Running setup.cmd has a missing column within AspNetUsers table. Resolved by running this script after setup.cmd:
    ALTER TABLE dbo.AspNetUsers
    ADD NewsLetter bit NOT NULL DEFAULT(0)

  2. When starting up Geta after the deployment, the Url for the site was null which caused exceptions in the job execution. I had to figure out the source of the issues and go and click Save within the Sitemap admin section of the UI to resolve the error.

  3. I got an additional exception generating a sitemap because one of the ContentReferences handed into GenerateXmlElements was null. I consequently added this check in that method:
    if (ContentReference.IsNullOrEmpty(contentReference))
    {
    continue;
    }

  4. From what I can tell, the IServiceCollection AddSitemaps configuration extension method's Action setupAction does not appear to get called at any point. I initially added my uriAugmenterServiceFactory onto the SitemapOptions, but at no point was the action called so my service was not getting added to the container. So, I abandoned that in favor of having it be a method overload within of AddSitemaps. Now updated in my PR.

  5. I tried to utilize PersonListPage as an example of the UriAugmenter, but it turns out that page isn't actually rendered on the site and isn't being included in the sitemap. I'm out of time, otherwise I'd try and rewrite it to another page. So, ultimately, the example that I wrote up is never hit because the an instance of this page type isn't in the root. But, it illustrates the usage anyway.

I have successfully tested it now, but it just doesn't hit the section for PersonListpage within the custom UriAugmenterService.

Thanks,
Jeff

Remove UriAugmenterServiceImplementationFactory on SitemapOptions.
Redo the Startup AddSitemaps call after changing AddSitemaps extension method overloads.
Minor updates to SitemapUriParameterAugmenterService logic.
README.md Outdated Show resolved Hide resolved
sandbox/Foundation/src/Foundation/Startup.cs Outdated Show resolved Hide resolved
@marisks
Copy link
Member

marisks commented Oct 4, 2022

@jeff-fischer-optimizely I do not see any changes from the previous review.

… to show how the optionsAction does not appear to be getting called.
README.md Outdated Show resolved Hide resolved
@jeff-fischer-optimizely
Copy link
Contributor Author

Hey @marisks, let me know if there are any other updates and I'll put them together. Hoping to wrap this up ASAP.

src/Geta.Optimizely.Sitemaps/XML/SitemapXmlGenerator.cs Outdated Show resolved Hide resolved
src/Geta.Optimizely.Sitemaps/XML/SitemapXmlGenerator.cs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Co-authored-by: Māris Krivtežs <[email protected]>
…SitemapUriParameterAugmenterService.cs

Co-authored-by: Māris Krivtežs <[email protected]>
README updates to provide procedure for adding UriAugmenterService.
@marisks marisks changed the base branch from master to augmenter October 11, 2022 06:41
@marisks marisks merged commit f20905c into Geta:augmenter Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants