Added `short_feed` configuration flag.

This commit is contained in:
Fabio Manganiello 2023-05-01 23:18:46 +02:00
parent afc4e09784
commit 150af7f868
3 changed files with 47 additions and 31 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## 0.2.18
- Added `short_feed` configuration flag to permanently disable returning the
full content of the articles in the RSS feed.
## 0.2.16
- Removed `alt` attribute from LaTeX rendered `<img>` tags. It may generate

View File

@ -72,6 +72,8 @@ logo: /path/or/url/here
language: en-US
# Show/hide the header (default: true)
header: true
# Enable/disable the short RSS feed (default: false)
short_feed: false
categories:
- category1
@ -133,4 +135,9 @@ $$
RSS feeds for the blog are provided under the `/rss` URL.
By default, the whole HTML-rendered content of an article is returned under `rss.channel.item.description`.
If you only want to include the short description of an article in the feed, use `/rss?short` instead.
If you want the short feed (i.e. without the fully rendered article as a
description) to be always returned, then you can specify `short_feed=true` in
your configuration.

View File

@ -1,57 +1,61 @@
import os
from typing import List
import yaml
from dataclasses import dataclass
from dataclasses import dataclass, field
@dataclass
class Config:
title = 'Blog'
description = ''
link = '/'
home_link = '/'
language = 'en-US'
logo = '/img/icon.png'
title = "Blog"
description = ""
link = "/"
home_link = "/"
language = "en-US"
logo = "/img/icon.png"
header = True
content_dir = '.'
categories = None
content_dir = "."
categories: List[str] = field(default_factory=list)
short_feed = False
basedir = os.path.abspath(os.path.dirname(__file__))
templates_dir = os.path.join(basedir, 'templates')
static_dir = os.path.join(basedir, 'static')
default_css_dir = os.path.join(static_dir, 'css')
default_js_dir = os.path.join(static_dir, 'js')
default_fonts_dir = os.path.join(static_dir, 'fonts')
default_img_dir = os.path.join(static_dir, 'img')
templates_dir = os.path.join(basedir, "templates")
static_dir = os.path.join(basedir, "static")
default_css_dir = os.path.join(static_dir, "css")
default_js_dir = os.path.join(static_dir, "js")
default_fonts_dir = os.path.join(static_dir, "fonts")
default_img_dir = os.path.join(static_dir, "img")
config = Config()
def init_config(content_dir='.', config_file='config.yaml'):
def init_config(content_dir=".", config_file="config.yaml"):
cfg = {}
config.content_dir = content_dir
if os.path.isfile(config_file):
with open(config_file, 'r') as f:
with open(config_file, "r") as f:
cfg = yaml.safe_load(f)
if cfg.get('title'):
config.title = cfg['title']
if cfg.get('description'):
config.description = cfg['description']
if cfg.get('link'):
config.link = cfg['link']
if cfg.get('home_link'):
config.home_link = cfg['home_link']
if cfg.get('logo') is not None:
config.logo = cfg['logo']
if cfg.get('language'):
config.language = cfg['language']
if cfg.get('header') is False:
if cfg.get("title"):
config.title = cfg["title"]
if cfg.get("description"):
config.description = cfg["description"]
if cfg.get("link"):
config.link = cfg["link"]
if cfg.get("home_link"):
config.home_link = cfg["home_link"]
if cfg.get("logo") is not None:
config.logo = cfg["logo"]
if cfg.get("language"):
config.language = cfg["language"]
if cfg.get("header") is False:
config.header = False
if cfg.get("short_feed"):
config.short_feed = True
config.categories = cfg.get('categories', [])
config.categories = cfg.get("categories", [])
# vim:sw=4:ts=4:et: