docs refactor and minor fixes

This commit is contained in:
Fabio Manganiello 2022-01-11 23:38:28 +01:00
parent a91b564305
commit 3531726f2c
5 changed files with 37 additions and 37 deletions

View file

@ -1,4 +1,4 @@
# mdblog
# madblog
This project provides a minimal blogging platform based on Markdown files.
@ -17,13 +17,14 @@ $ madness
```
```
usage: madblog [-h] [--host HOST] [--port PORT] [--debug] [path]
usage: madblog [-h] [--config CONFIG] [--host HOST] [--port PORT] [--debug] [dir]
Serve a Markdown folder as a web blog.
The folder should have the following structure:
.
-> config.yaml [recommended]
-> markdown
-> article-1.md
-> article-2.md
@ -34,28 +35,41 @@ The folder should have the following structure:
-> image-1.png
-> image-2.png
-> ...
-> css [optional]
-> custom-1.css
-> custom-2.css
-> ...
-> fonts [optional]
-> custom-1.ttf
-> custom-1.css
-> ...
-> templates [optional]
-> index.html [for a custom index template]
-> article.html [for a custom article template]
positional arguments:
path Base path for the blog
dir Base path for the blog (default: current directory)
options:
-h, --help show this help message and exit
--config CONFIG Path to a configuration file (default: config.yaml in the blog root directory)
--host HOST Bind host/address
--port PORT Bind port (default: 8000)
--debug Enable debug mode (default: False)
```
## Configuration
The application will look for a `config.yaml` file in the current directory if none was
specified through the `-c` command-line option. The structure is the following:
```yaml
title: Blog title
description: Blog description
link: https://link.to.your.blog
# Use home_link if you have a different home/portal address
# than your blog, otherwise it's the same as `link`
home_link: https://link.to.home
# Path/URL to the logo (default: /img/icon.png)
logo: /path/or/url/here
# Blog language (for the RSS feed)
language: en-US
categories:
- category1
- category2
- category3
```
## Markdown files
Articles are Markdown files stored under `pages`. For an article to be correctly rendered,
@ -100,4 +114,3 @@ $$
## RSS syndacation
RSS feeds for the blog are provided under the `/rss` URL.

View file

@ -1,13 +1,11 @@
import datetime
import os
import re
from glob import glob
from typing import Optional
from flask import Flask, abort, render_template
from flask import Flask, abort
from markdown import markdown
from .config import config
from .latex import MarkdownLatex

View file

@ -2,6 +2,7 @@ import argparse
import os
import sys
def get_args():
parser = argparse.ArgumentParser(description='''Serve a Markdown folder as a web blog.
@ -19,17 +20,6 @@ The folder should have the following structure:
-> image-1.png
-> image-2.png
-> ...
-> css [optional]
-> custom-1.css
-> custom-2.css
-> ...
-> fonts [optional]
-> custom-1.ttf
-> custom-1.css
-> ...
-> templates [optional]
-> index.html [for a custom index template]
-> article.html [for a custom article template]
''', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('dir', nargs='?', default='.', help='Base path for the blog (default: current directory)')

View file

@ -1,6 +1,5 @@
import os
import yaml
from typing import Optional
from dataclasses import dataclass

View file

@ -53,7 +53,7 @@ def rss_route():
<title>{title}</title>
<link>{link}</link>
<description>{description}</description>
<category>{",".join(categories)}</category>
<category>{categories}</category>
<image>
<url>{link}/img/icon.png</url>
<title>{title}</title>
@ -68,7 +68,7 @@ def rss_route():
title=config.title,
description=config.description,
link=config.link,
categories=config.categories,
categories=','.join(config.categories),
language=config.language,
last_pub_date=pages[0]['published'].strftime('%a, %d %b %Y %H:%M:%S GMT'),
items='\n\n'.join([