This week in Orchard - 10/25/2019

Gábor Domonkos's avatar
Documentation, This week in Orchard

This week we are coming with a cool demo of presenting the newest improvements of an upcoming Orchard Core module that will add sitemaps to your site! But first, don't forget to check the documentation of Orchard Core, we have a lot of additional lines here!

On Orchard Core

Updating OpenId docs about how to use the certificate on Azure

When you would like to enable authentication of external applications using the OpenID Connect/OAuth 2.0 standards, you have to configure the certificates too. You can generate and store your certificate on Windows and/or IIS, but you can also upload the certificate on an Azure hosted site. This little addition to the docs will help you with that.

CommitTransactionTask workflow activity

When you have two concurrent updates that depend on each other, you need to commit the previous transaction, that you can follow up with the next one and the first one can continue and get another one. So, when you have two nested transactions to each other, you could create a deadlock, that is very specific to SQLite. Now there is a new Task available when you are creating workflows. The CommitTransaction activity is about committing the current transaction by calling the CommitAsync method of the ISession implementation.

Add OrchardCore.Email docs

We have the OrchardCore.Email module, that allows you to send emails using SMTP. You can configure the settings for this module by using the appsettings.json file. Now you will find documentation about how you need to fill this JSON file and also with some description about the meaning of the values.

Add role description

Now you can provide a description of a role when you are creating a new one or editing an existing one. It will make your life easier in the future if you have more roles and want to stores what are the current roles used for. Now we have documentation about what are the predefined roles used for and how to configure the roles through a recipe step.

Four Orchard Core samples for Orchard Core

Dody Gunawinata maintains a repository in GitHub that contains 305 samples for ASP.NET Core with projects about how to use Blazor, foundational ASP.NET Core samples and so on. This repository also contains 4 samples that show the different capabilities of Orchard Core. These are:

  • Routing - MVC: This sample shows how routing works in an Orchard Core Framework app.
  • Routing - Razor Pages: This sample shows how routing works in an Orchard Core Framework app when you are using Razor Pages.
  • Static files: This sample shows how to use static files in the module.
  • Multi tenant: This sample shows how Orchard Core Framework handles multi tenancy and how each tenant has its own configuration file.

If you are interested in these samples or other ASP.NET Core samples you should definitely check this great and huge collection to learn something new!

Scanning the code of Orchard Core for bugs

PVS-Studio performs static code analysis and generates a report that helps a programmer find and fix bugs. PVS-Studio performs a wide range of code checks, and it is also useful in finding misprints and Copy-Paste errors. The authors of this project published an article about reviewing the results of a second check of the Orchard Core with this static analyzer.

The current version of Orchard Core is made up of 2,767 .cs files, i.e. it's about one thousand files smaller. The downsizing and renaming of the repository suggest that the developers have isolated the project's core (commit 966), which is 108,287 LOC long. The analyzer issued 153 warnings: 33 first-level and 70 second-level ones.

You should definitely check this article, you can learn a lot and write better code! Do you write a performance-intensive code? Then help us build the nerdiest .NET thing! Drop us a line to [email protected] and we'll ask a few questions about the challenges you encounter, and in exchange, we'll show you how to make a chip out of your programs.

Demos

Sitemaps module

A few weeks ago we wrote about an upcoming module for Orchard Core: the Sitemaps module. Since then this feature improved a lot and will be released soon. Let's recap the latest changes of the module!

First of all, when you navigate to the Configuration/Features on the admin site, you will see that there are three different Sitemaps modules:

  • Sitemaps: Provides dynamic sitemap generation services.
  • Sitemaps for Decoupled Razor Pages: Provides decoupled razor pages support for dynamic sitemap generation.
  • Localized Content Item Sitemaps: Provides support for localized content item sitemaps.

Let's check them one by one with a site that we set up using the Blog recipe. When you enable the Sitemaps module you can head to Configuration/Sitemaps and click on the Add Sitemap button. Here you will see two notions: the Sitemap Content Types, that add sitemap entries for each one of the selected content types and the Sitemap Index, which adds a sitemap index that acts as a container for other sitemaps. You can create a new Sitemap Content Type, that will lead you to a familiar page where you can select which content type you want to include in the index, among with the change frequency, priority and the number of content items to include.

The other is called Sitemap Index. In the editor of the Sitemap Index, you can select which sitemap will this index contains. Because for now we have only one (called My Blog Posts) select this one. Hit Save and View this Sitemap Index.

You can see that this index contains our only one sitemap with the last modified date of it and the location. By using sitemap indexes, you can provide a collection of sitemaps to search engines. For example, when using Google, all formats limit a single sitemap to 50MB (uncompressed) and 50,000 URLs. If you have more than 50,000 blog posts, you have to create two Sitemap Content Types. The first one will take the first 50,000 one and the second one is the rest. And your Sitemap Index will include these two Sitemap Content Types.

Now let's move on and enable the Localized Content Item Sitemaps. To test this, first, attach the Localization Part to our Blog Post content type and create two blog posts, one in Hungarian and one in English. Now head back to the admin of the Sitemaps module and View our My Blog Posts Sitemap Content Type.

You see that our sitemap provides more information to search engines. First of all, you can see that both the English and Hungarian versions of our blog post have been included in the sitemap. These come with the hreflang attribute. If you have multiple versions of a page for different languages or regions, tell Google about these different variations using the hreflang attribute. The loc is still used and that points to the version of the content item that was created using the default culture.

Finally, enable the Sitemaps for Decoupled Razor Pages feature. For this, we will add a new content type, called DecoupledBlogPost. This content type will not have any parts or fields attached. To be able to provide a sitemap for decoupled Razor pages, first, configure the SitemapsRazorPagesOptions for our content type in the Startup.cs file of our module.

services.Configure<SitemapsRazorPagesOptions>(options =>
{
options.ConfigureContentType("DecoupledBlogPost", typeOptions =>
{
typeOptions.PageName = "DBlogPost";
typeOptions.RouteValues = (contentItem) =>
{
return new { area = "OrchardCore.Sitemaps", slug = contentItem.ContentItemId };
};
});
});

Here you can see that a DBlogPost.cshtml file sits in the Pages folder and we just simply put this into the OrchardCore.Sitemaps module. We will pass the ContentItemId as a slug for our page. Now let's see the content of the Razor page:

@page "/blogpost/{slug}"
<h1>This is the blog post.</h1>
<h2>Slug: @Slug</h2>

@functions
{
[FromRoute]
public string Slug { get; set; }
}

Now head back to the admin and create two new Decoupled Blog Post. After let's create a new Sitemap Content Type, called Decoupled Blog Posts, that will (surprisingly) index the Decoupled Blog Post content types. After you saved this sitemap, hit View!

Here we are with the two Decoupled Blog Posts that have the ContentItemId in the URL. We haven't attached the Localization Part to this one, so the hreflang attribute will not be used here. Now open one of those blog posts!

And here comes our decoupled blog post that is using The Blog Theme for rendering the content of this item.

This feature is still under development and can be found in this branch. Big thanks again to Dean Marcussen for this great contribution!

On Lombiq

Lombiq Orchard Visual Studio Extension updated

The Lombiq Orchard Visual Studion Extension just got some VS 2019 compatibility updates. There was a warning message that said One or more extensions were loaded using deprecated APIs. Check it out if you aren't using it already, you're missing out on quite some productivity boost!

Orchard Dojo Newsletter

Now we have 100 subscribers of the Lombiq's Orchard Dojo Newsletter! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

No Comments

Add a Comment