Giter Club home page Giter Club logo

ediwang / moonglade Goto Github PK

View Code? Open in Web Editor NEW
502.0 15.0 138.0 19.29 MB

The ASP.NET Core blog system of https://edi.wang, runs on Microsoft Azure

Home Page: https://edi.wang

License: GNU General Public License v3.0

C# 54.07% HTML 35.17% CSS 4.71% JavaScript 4.36% PowerShell 1.43% Dockerfile 0.14% TSQL 0.11%
azure azure-app-service aspnet-core entity-framework-core azure-sql-database azure-application-insights azure-blob-storage azure-frontdoor blog sql-server

moonglade's Introduction

Moonglade Blog

Docker Linux x64 Man hours

A personal blog system that optimized for Microsoft Azure. Designed for developers, enabling most common blogging features including posts, comments, categories, archive, tags and pages.

📦 Deployment

  • Use stable code from Release branch rather than master branch.

  • HTTPS is required, and it is recommended to enable HTTP/2 support on your web server.

Full Deploy on Azure

This is the way https://edi.wang is deployed, by taking advantage of as many Azure services as possible, the blog can run very fast and secure.

There is no automated script to deploy it, you need to manually create all the resources.

image

Quick Deploy on Azure (App Service on Linux)

Use automated deployment script to get your Moonglade up and running in 10 minutes with minimal Azure components, follow instructions here

Quick Deploy with Docker-Compose

Simply go the the root folder of this repo and run:

docker-compose build
docker-compose up

That's it! Now open: Browser: http://localhost:8080

🐵 Development

Tools Alternative
Visual Studio 2022 Visual Studio Code with .NET 8.0 SDK
SQL Server 2022 SQL Server LocalDB, PostgreSQL or MySQL

Setup Database

You can choose from SQL Server, PostgreSQL or MySQL. Update your database connection string in appsettings.json, ConnectionStrings section.

Database DatabaseType MoongladeDatabase Example
Microsoft SQL Server SqlServer Server=(localdb)\\MSSQLLocalDB;Database=moonglade;Trusted_Connection=True;
MySQL MySql Server=localhost;Port=3306;Database=moonglade;Uid=root;Pwd=***;
PostgreSQL PostgreSql User ID=***;Password=***;Host=localhost;Port=5432;Database=moonglade;Pooling=true;

Build Source

Build and run ./src/Moonglade.sln

  • Home page: https://localhost:1055
  • Admin: https://localhost:1055/admin
    • Default username: admin
    • Default password: admin123

⚙ Configuration

This section discuss environment settings in appsettings.json. For blog settings, please use "/admin/settings" UI.

Authentication

Moonglade is using local account by default, you can manage accounts in /admin/settings/account. You can also use Microsoft Entra ID to login. See Wiki document for setup Microsoft Entra ID.

Image Storage

ImageStorage controls how blog post images are stored.

Azure Blob Storage (Preferred)

You need to create an Azure Blob Storage with container level permission.

{
  "Provider": "azurestorage"
  "AzureStorageSettings": {
    "ConnectionString": "YOUR CONNECTION STRING",
    "ContainerName": "YOUR CONTAINER NAME"
  }
}

When configured the image storage to use Azure Blob, you can take advantage of CDN for your image resources. Just enable CDN in admin settings, the blog will get images from CDN.

You need to hava an Minio Server.

"Provider": "miniostorage"
"MinioStorageSettings": {
  "EndPoint": "Minio Server Endpoint(eg:localhost:9600)",
  "AccessKey": "Your Access Key",
  "SecretKey": "Your Secret Key",
  "BucketName": "Your BucketName",
  "WithSSL": false
}

File System (Not Recommended)

You can also choose File System for image storage if you don't have a cloud option.

{
  "Provider": "filesystem",
  "FileSystemPath": "C:\\UploadedImages"
}

Comment Moderator

Setup Moonglade.ContentSecurity Azure Function to enable comment moderation.

"ContentModerator": {
  "Provider": "",
  "ApiEndpoint": "",
  "ApiKey": ""
}

Email Notification

Setup Moonglade.Email Azure Function to enable email notification for new comments, new replies and pingbacks. Then enable notification in admin portal.

"Email": {
  "ApiEndpoint": "",
  "ApiKey": ""
}

Others

🎉 Blog Protocols or Standards

Name Feature Status Service Endpoint
RSS Subscription Supported /rss
Atom Subscription Supported /atom
OPML Subscription Supported /opml
Open Search Search Supported /opensearch
Pingback Social Supported /pingback
Reader View Reader mode Supported N/A
FOAF Social Supported /foaf.xml
RSD Service Discovery Deprecated N/A
MetaWeblog Blogging Deprecated N/A
Dublin Core Metadata SEO Basic Support N/A
BlogML Blogging Not planned
APML Social Not planned
Trackback Social Not planned

免责申明

对于**用户,我们有一份特定的免责申明。请确保你已经阅读并理解其内容:

moonglade's People

Contributors

anduin2017 avatar deliay avatar ediwang avatar hueifeng avatar kipergil avatar nugetninja avatar saigkill avatar weihanli avatar wenhyan avatar zhiyongpeng avatar zhuangkh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moonglade's Issues

[Non-Prod] EF Lazy-load Exception for some posts

InvalidOperationException: Error generated for warning 'Microsoft.EntityFrameworkCore.Infrastructure.DetachedLazyLoadingWarning: An attempt was made to lazy-load navigation property 'Comment' on detached entity of type 'PostProxy'. Lazy-loading is not supported for detached entities or entities that are loaded with 'AsNoTracking()'.'. This exception can be suppressed or logged by passing event ID 'CoreEventId.DetachedLazyLoadingWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://localhost:5001/post/2019/4/3/use-environment-specific-nlogconfig-in-aspnet-core'

Expected behavior
Page is loaded with correct post content

Screenshots
image

Additional context
Related to Repository pattern code refact

Code PostService.GetPost(string url) is too SB

Use RegEx to refact this SB Code:

public Response<Post> GetPost(string url)
{
    try
    {
        // https://domain/post/yyyy/MM/dd/slug

        // TODO: There must be a nicer way to do this
        var uri = new Uri(url);
        if (uri.Segments.Length < 5)
        {
            return null;
        }

        var yyyy = Convert.ToInt32(uri.Segments[2].Replace("/", string.Empty));
        var mm = Convert.ToInt32(uri.Segments[3].Replace("/", string.Empty));
        var dd = Convert.ToInt32(uri.Segments[4].Replace("/", string.Empty));
        var slug = uri.Segments[5];

        var post = GetPost(yyyy, mm, dd, slug.Trim());
        return post;
    }
    catch (Exception ex)
    {
        return new FailedResponse<Post>((int)ResponseFailureCode.GeneralException, ex.Message, ex);
    }
}

Local Authentication Provider will break [ValidateAntiForgeryToken]

Describe the bug
Local Authentication Provider will make 400 error when posting data to actions with ValidateAntiForgeryToken attribute

To Reproduce
Steps to reproduce the behavior:

  1. Configure the blog to use Local authentication provider
  2. Login to admin portal
  3. Try delete a post
  4. Server return 400 error because of ValidateAntiForgeryToken is not passed

Expected behavior
POST requests work with ValidateAntiForgeryToken

Remove unnecessary include in GetSubscribedPosts()

[2019-02-17 13:25:14.8645][RD00155DB89807][Warn][Microsoft.EntityFrameworkCore.Query] The Include operation for navigation '[p].PostPublish' is unnecessary and was ignored because the navigation is not reachable in the final query results. See https://go.microsoft.com/fwlink/?linkid=850303 for more information.
[2019-02-17 13:25:14.8645][RD00155DB89807][Warn][Microsoft.EntityFrameworkCore.Query] The Include operation for navigation '[p].PostCategory.Category' is unnecessary and was ignored because the navigation is not reachable in the final query results. See https://go.microsoft.com/fwlink/?linkid=850303 for more information.

Change log file location

Current log is in application root directory, which should be read only.

Research: Find a good location to store log files.

first Input for email configuration

hai Edi,
i use your source code to learning to create blog for myself. i got some error.
its about encryption.
please check. first time Email configuration, i see that password not encrypt.

thank you
test1

Use Microsoft.Azure.Storage.Blob

Package WindowsAzure.Storage is no longer updated, as:
https://www.nuget.org/packages/WindowsAzure.Storage/

NOTE: As of version 9.4.0, this library has been split into multiple parts and replaced: See https://www.nuget.org/packages/Microsoft.Azure.Storage.Blob/, https://www.nuget.org/packages/Microsoft.Azure.Storage.File/, https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/, and https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/.
For table support, see https://www.nuget.org/packages/Microsoft.Azure.CosmosDB.Table/.
This client library enables working with the Microsoft Azure storage services which include the blob and file service for storing binary and text data, the table service for storing structured non-relational data, and the queue service for storing messages that may be accessed by a client.
For this release see notes - https://github.com/Azure/azure-storage-net/blob/master/README.md and https://github.com/Azure/azure-storage-net/blob/master/changelog.txt
Microsoft Azure Storage team's blog - https://blogs.msdn.com/b/windowsazurestorage/

Disallow Invalid Chars for Tag Name

Currently, the tag names are normalized in Utils.TagNormalizeSourceTable, which some chars don't make sense:

(, ), {, }, @, #

They need to be disallowed rather than normalized

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.