I've finally had some time to continue working on my new CMS/Blogging Engine, and here are some notes about it.
Why C# and .NET?
I happen to enjoy working with C# and .NET, and ever since the creation of the Core line, have been excited by the CLI (Command Line Interface) options along with cross platform options for Mac and Linux. Throw into that mix the excellent editor that is Visual Studio Code, and I have a happy little backyard to play in.
Professionally I work with C#, .NET and Visual Studio, primarily on Windows.
Personally I enjoy the CLI, VS Code and alternatives to Windows. Make no mistake I am currently writing this inside a Windows 11 VM running on a Windows desktop running Windows 10. It's not that I dislike Windows, but I love options.
In my professional work I deploy to either Azure or AWS in complex systems, but for my personal work I like less expensive options.
Since my sites don't get much traffic, I can host them all on one Linux VM that costs about $10 a month. I could easily use a $5 VM, but sometimes I just like to live large in a way that only a $10 VM makes possible.
One of the killer features of .NET, in my opinion, is LINQ (Language Integrated Query).
LINQ lets me query in-memory collections just as easily as a database. In fact, it makes it pretty darned easy to switch from an in-memory collection to a database without changing much code. If I use the repository pattern, I can encapsulate all the data-store specific code in one spot and thanks to the magic of interfaces, swap between different repositories without changing the code outside the repository.
Why LINQ is Key
For GatorSmile I wanted to have as close to the Static Website Generator experience of a simple runtime as possible.
I also wanted to keep the content stored in a files in a Git repository benefit.
So here's how GatorSmile works:
When GatorSmile launches, it's repository reads the directory of content and loads all the posts into an in-memory list.
Queries against that list are all done via LINQ.
This means if I want to, it would be easy-peasy to extract an interface for the repository and implement a variety of repositories for SQL Server, Oracle, MongoDB, or just about any other data store.
Problem with .NET
OK, so it can't all be Cheetos and Cheerwine.
Why is it that WordPress is hugely successful in the world at large, and there aren't any .NET based CMS/blog-engines with relevant market share?
WordPress is built with PHP which is dyanmically interpreted.
Normally I'm a fan of strongly typed, compiled languages, BUT PHP and WordPress have a giant advantage here, namely WordPress themes can modify the functioning of the site and not just the look.
Since .NET and ASP.NET have to be compiled and then deployed, it is much more complicated to achieve what WordPress themes can achieve.
What are you going to do about? That's what I'd like to know.
I can't really make ASP.NET be an interpreted language, but I can make things a bit more self contained in your content repository.
If you aren't familiar with .NET (you probably wouldn't be reading this for one thing), in an ASP.NET project their is one folder for your Views and one folder for your plain ole files like images called wwwroot.
This means that by default, your views are tied to your source code. If I were to distribute GatorSmile for other people to use it, they would have to live with my views. That means they get MY HTML and could only modify it if they fork my repo and change the views.
I hate that.
So what if we moved EVERYTHING related to your site into that wwwroot folder?
I mean your database of files that represent your content, your views, your configuration… everything?
Then you could make that directory it's own Git repository.
Now you could change the views (HTML, etc.) to match your site, not my GatorSmile variant.
Well that's exactly what I've done.
I can't make .NET interpreted, so you still need a compile step, but now setting up a new site can consist of:
- Clone GatorSmile CMS onto your VM
- Create a repository for your wwwroot folder and clone that into your GatorSmile project as its wwwroot
- Compile your GatorSmile project so that your views are the ones bundled up into the DLLs
- Set up a GitHub webhook so that when you publish any new content to your wwwroot repository it will automatically be added to your site
- Any time there is an update to GatorSmile, you can
git pullthat into your directory and
dotnet publishinto your site
Testing the Theory
So to test this process, I'm updating my GalacticBeacon site to use GatorSmile as well.
This gives me two very different sites using the same underlying CMS.
If you're curious, GalaticBeacon is the site for my creative endeavors like photography, comics, and writing.
Warning: I'm not very good that those things, I just enjoy them.
More to come as I continue to work on GatorSmile and prepare to release it to the world.