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. 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. Serve a Markdown folder as a web blog.
The folder should have the following structure: The folder should have the following structure:
. .
-> config.yaml [recommended]
-> markdown -> markdown
-> article-1.md -> article-1.md
-> article-2.md -> article-2.md
@ -34,28 +35,41 @@ The folder should have the following structure:
-> image-1.png -> image-1.png
-> image-2.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: positional arguments:
path Base path for the blog dir Base path for the blog (default: current directory)
options: options:
-h, --help show this help message and exit -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 --host HOST Bind host/address
--port PORT Bind port (default: 8000) --port PORT Bind port (default: 8000)
--debug Enable debug mode (default: False) --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 ## Markdown files
Articles are Markdown files stored under `pages`. For an article to be correctly rendered, Articles are Markdown files stored under `pages`. For an article to be correctly rendered,
@ -100,4 +114,3 @@ $$
## RSS syndacation ## RSS syndacation
RSS feeds for the blog are provided under the `/rss` URL. RSS feeds for the blog are provided under the `/rss` URL.

View file

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

View file

@ -2,6 +2,7 @@ import argparse
import os import os
import sys import sys
def get_args(): def get_args():
parser = argparse.ArgumentParser(description='''Serve a Markdown folder as a web blog. 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-1.png
-> image-2.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) ''', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('dir', nargs='?', default='.', help='Base path for the blog (default: current directory)') parser.add_argument('dir', nargs='?', default='.', help='Base path for the blog (default: current directory)')

View file

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

View file

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