A simplistic blogging system
NanoBlog is a blogging system on file basis, therefore it doesn't use a database, scripting or cookies. Configuration of the page structure is done via app settings (appsettings.json or environment variables).
Updating the blog works as following:
- Creating, reading, updating or deleting the posts & asset files via API and storing them on the file system.
- Composing all files into HTML pages (or, if pagination is disabled, into a single one) which then can be served by a webserver.
- Copying all asset files into the export directory so that they can be accessed.
{
"PageTemplate": "<html><body>{POSTS}<br>{NAVIGATION}</body></html>", // Template for the whole page
"PagePlaceholderPosts": "{POSTS}", // Placeholder that can be used in PageTemplate to determine, where the posts will be
"PagePlaceholderNavigation": "{NAVIGATION}", // Placeholder that can be used in PageTemplate to determine, where the navigation will be
"PostTemplate": "<div class='post' id='{NAME}'>{CONTENT}</div>", // Template for a single post (of a page)
"PostPlaceholderContent": "{CONTENT}", // Placeholder that can be used in PostTemplate to determine, where the post content will be
"PostPlaceholderName": "{NAME}", // Placeholder that can be used in PostTemplate to determine, where the post file name content will be (Use for e. g. html ids)
"PostPlaceholderDate": "{DATE}", // Placeholder that can be used in PostTemplate to determine, where the creation date (based on file name prefix) will be
"PostDateFormat": "yyyy-MM-dd HH:mm K", // Format of the date that is in "PostPlaceholderDate"
"UsePagination": true, // Determine whether pagination should be in use
"PageSize": 20, // If UsePagination is true, determines how many posts will be included in a single page
"PostDirectory": "blog-files/posts", // Determines where the posts should be stored / read from
"AssetDirectory": "blog-files/assets", // Determines where the assets should be stored / read from
"ExportDirectory": "blog-export", // Determines where the blog files should be exported to
"KeepExportFiles": [], // Any file name that is placed here won't be deleted on re-exporting the blog (Use for e. g. privacy policy sites)
"AuthenticationToken": null // Token that has to be sent (by Authentication: Bearer header) for every request to be authenticated
}
- Pagination is available. The page size must be configured. (
UsePagination
andPageSize
in config) Hint: As this blog is designed like other micro-blogging platforms, the posts are ordered by descending creation date and the pages work like an archive so that e.g. /archive/0/ always contains the first x posts. - Contents are separated into folders:
- Config
PostDirectory
determines, where posts are stored. - Config
AssetDirectory
determines, where assets (currently: png, jpeg, gif, svg) are stored. Assets are checked for valid mime type be extension and content.
- Config
- The resulting file(s) will be exported into the export directory that is defined by config
ExportDirectory
. - The resulting export is structured as:
ExportDirectory
(by config)assets
- ...All the uploaded assets
archive
0..n
index.html
(page with old posts)
index.html
(page with the most recent posts)
- The API is secured via bearer token. This token must be configured with
AuthenticationToken
, otherwise NanoBlog won't start. Make sure to use a long and secure token! Also make sure that possible brute forcing is prevented by firewall, IPS and rate limiting.
Selector | Description |
---|---|
nav#pagination |
Identifies the pagination container |
li#nav-previous-page |
Identifies the link list item that refers to the previous page |
li#nav-current-page |
Identifies the link list item that refers to the current page |
li#nav-following-page |
Identifies the link list item that refers to the following page |
cd docker/
cp .env.example .env
- Configure by updating .env
docker compose up
cd NanoBlog/
cp appsettings.json appsettings.Development.json
- Configure by updating appsettings.Development.json
dotnet run .
If you want to give me any relevant information to this project, feel free to either create an issue or write me a mail. Also, see SECURITY.md
MIT, see LICENSE