This time you could see two great demos in our post! One is about the GitHub Actions integration for Orchard Core and the other one is about a new addition for YesSql. But first, let's check out the latest improvements of Orchard Core, like the new Media Slugify feature or the Synchronization Latency Option!
Orchard Core updates
How to enable Razor templates in my theme?
It's just a few additional lines to the Orchard Core documentation, but we thought we should mention this change because it's a very common mistake that developers would like to use Razor in their custom themes instead of Liquid but the Razor code in the cshtml files doesn't do anything.
New feature to slugify media folders and files to make them SEO-friendly
Let's set up your site using the Blog recipe then navigate to the admin UI of Orchard Core. Head to Configuration -> Features to find the new one, called Media Slugify, and enable it. The media slugify module slugifies new folders and files to make them SEO-friendly.
Now navigate to Content -> Media Library and try to upload something to the Media Library. And let's say that the name of the file that you would like to upload is something like this is a Szép kép.jpg. You can see that the filename contains several spaces and some special chars too. If you upload this image, the feature will slugify the name of the image and the result will be this-is-a-szep-kep.jpg. And the same applies to the folder names too. Check out the following gif to see what will happen if you upload files and create a folder with special characters when the module is disabled or enabled.
If you would like to read more about this new feature, this will be your page on the Orchard Core documentation.
Using Docker with Orchard Core
Orchard Core's source code repository includes a Dockerfile which will allow you to create your own Docker images and containers. It can be quite useful for Orchard Core developers when needing to test PR's. It allows them to deploy locally quickly in some testing environments. There is a new page in the Orchard Core documentation with examples that will be shown for that context. Docker can also be used for more complex usage (ex: production deployment) but this documentation doesn't aim to explain that in detail. For more advanced examples we strongly suggest reading docker and docker-compose documentation.
Synchronization Latency Option
This is about being able to set how long you are OK to wait before refreshing your document cache. Let's say you have multi-node and the document updates on one node. It will be in the Redis cache, but you don't check for the new values every request, we can just say this is the grace period for which I don't want to check the cache. Like I would only check it every second even if I have one million requests per second, one million times we will get the value from the cache, but the next one will say: OK, I need to get something to be refreshed from the Redis cache. It was set to one second by default. Check the
GetInternalAsync method of the
DocumentManager, where we get the
SynchronizationLatency property of the
DocumentOptions. You can set the values of the
DocumentOption using app settings.
GitHub Actions allows you to use service containers, so basically just loading a Docker image and exposing it as a service to your main container that runs your tests. This is basically the same as Docker Compose when you have multiple containers running concurrently. What's need is that by using the Orchard environment variables, be able to run the functional tests for each database type to make sure the CMS works on all of those.
If you open up the GitHub repository of Orchard Core, you will find several yml files in the .github/workflows folder. The one you can see here is called functional_all_db.yml that runs the functional tests on all databases. The first job here will run the Cypress script called mvc:test on the latest version of Ubuntu. If you aren't familiar with Cypress and Cypress test, you could see a demo about that in this This week in Orchard post.
And there are a lot more tests in the workflows folder, check them out if you are interested in running tests!
To run the actions manually, we can go to the Actions tab of the GitHub repository of Orchard Core where you can see all the workflows defined in these yml files, like Release - CI, Functional Tests - all Databases, etc.
Select the Functional Tests - all Databases one and then click one of the results to see the actual jobs. And you can see all the steps in the job with the time it needed to complete with detailed execution results.
And there are a lot more to see and speak about here. If you would like to know more, you should definitely check out this recording on YouTube!
YesSql: Fixing subclass support
Let's navigate to the GitHub repository of YesSql and open the CoreTests.cs file in the test/YesSql.Test folder and find the
ShouldQuerySubClasses unit test.
Here you can see a
Circle and a
Square class, these are both inherit from
Shape. After we are creating some new instances of the
Shape we do some queries and say give me the Squares and Circles.
The new thing is in this line:
Assert.Equal(3, await session.Query<Shape, ShapeIndex>(filterType: false).CountAsync());
Here we say list all the
Shape types. And there will be three of them: two Squares and one Circle. So, now you can query by the base type to get inheritance inside that and it was not working before. And in this case, the index is just to store the name of the type that you are storing, just to be sure that it's the correct type.
If you would like to see the recording of this new feature, head to YouTube now!
News from the community
Our full Orchard Core tutorial series, the Dojo Course 3 is here!
After a long wait, the new Orchard Core version of our legendary Dojo Course tutorial series is here, the Dojo Course 3!
Are you a newcomer and want to learn Orchard Core from the ground up, both from a user's and a developer's perspective? Are you somewhat familiar with Orchard Core but would like to get up to speed and become an Orchard pro? Look no further, check out Dojo Course 3! Dojo Course 3 guides you from the very basics of Orchard Core all up to be able to write your own themes and modules, utilizing various APIs of Orchard. We're publishing a tutorial video every day for 40 days starting on 1 December. So, this is your 40 days of Orchard :).
And now we have published every video that is about the admin UI features of Orchard Core. From video 19., we will check the structural overview of the Orchard Core source, and then we will start coding! If you are really interested in the coding part, the upcoming 20 videos are specially for you.
If you're looking for our previous Orchard 1.x tutorial series check out Dojo Course 2.
A new website using Orchard Core: Cornish Mining World Heritage
If you are interested in more websites using Orchard and Orchard Core, don't forget to visit Show Orchard. Show Orchard is a website for showing representative Orchard CMS (and now Orchard Core) websites all around the internet. It was started by Ryan Drew Burnett, but since he doesn't work with Orchard anymore, as announced earlier it is now maintained by our team at Lombiq Technologies.
Orchard Dojo Newsletter
Lombiq's Orchard Dojo Newsletter has 176 subscribers! 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!