ofpinewood / pineblog

A light-weight blogging engine written in ASP.NET Core MVC Razor Pages, using Entity Framework Core or MongoDb.
MIT License
64 stars 11 forks source link
aspnetcore blog blogging-engine entity-framework mongodb mvc-razor-pages

PineBlog PineBlog

Build Status NuGet Badge License: MIT

PineBlog is a light-weight blogging engine written in ASP.NET Core MVC Razor Pages, using Entity Framework Core or MongoDb. It is highly extendable, customizable and easy to integrate in an existing web application.

PineBlog screenshot

Features

More about the features: features

What is not included

Because PineBlog is very light-weight it is not a complete web application, it needs to be integrated in an existing web application or you need to create a basic web application for it. There are a few things PineBlog depends on, but that it does not provide.

Note: The admin pages require that authentication/authorization has been setup in your website, the admin area has a AuthorizeFilter with the default policy set to all pages in that area folder.

Where can I get it?

You can install the Opw.PineBlog metapackage from the console.

> dotnet add package Opw.PineBlog

The Opw.PineBlog metapackage includes the following packages.

For using MongoDb, see Using MongoDb on how to setup that.

Getting started

You add the PineBlog services and the Razor Pages UI in the Startup.cs of your application.

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddPineBlog(Configuration);

    services.AddRazorPages().AddPineBlogRazorPages();
    // or services.AddMvcCore().AddPineBlogRazorPages();
    // or services.AddMvc().AddPineBlogRazorPages();
    ...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

    // Make sure you enable static file serving
    app.UseStaticFiles();

    ...
    app.UseEndpoints(endpoints =>
    {
        // make sure to add the endpoint mapping for both RazorPages and Controllers
        endpoints.MapRazorPages();
        endpoints.MapControllers();
    });
    ...
}

NOTE: Make sure you enable static file serving app.UseStaticFiles();, to enable the serving of the css and javascript from the Opw.PineBlog.RazorPages packages.

See Customizing the layout on how to setup the layout pages, css and javascript.

Configuration

And a few properties need to be configured before you can run your web application with PineBlog.

{
    "ConnectionStrings": {
        "DefaultConnection": "Server=inMemory; Database=pineblog-db;"
    },
    "PineBlogOptions": {
        "Title": "PineBlog",
        "Description": "A blogging engine based on ASP.NET Core MVC Razor Pages and Entity Framework Core",
        "ItemsPerPage": 5,
        "CreateAndSeedDatabases": true,
        "ConnectionStringName": "DefaultConnection",
        "AzureStorageConnectionString": "UseDevelopmentStorage=true",
        "AzureStorageBlobContainerName": "pineblog",
        "FileBaseUrl": "http://127.0.0.1:10000/devstoreaccount1"
    }
}

Blog Settings ConfigurationProvider

To be able to update the blog settings from the admin pages, you need to add the PineBlog IConfigurationProviders to the IConfigurationBuilder in the Program.cs. Add config.AddPineBlogEntityFrameworkCoreConfiguration(reloadOnChange: true); to ConfigureAppConfiguration(..) on the IWebHostBuilder.

WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    .ConfigureAppConfiguration((hostingContext, config) => {
        config.AddPineBlogEntityFrameworkCoreConfiguration(reloadOnChange: true);
    });

Documentation

For more information, please check the documentation.

For technical background information, check the blog: ofpinewood.com.

Samples

Check the code :nerd_face:

Usage

PineBlog is used on the following website:

Contributing

We accept fixes and features! Here are some resources to help you get started on how to contribute code or new content.


Copyright © 2024, Of Pine Wood. Created by Peter van den Hout. Released under the terms of the MIT license.