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 # 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 ## 0.2.16
- Removed `alt` attribute from LaTeX rendered `<img>` tags. It may generate - 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 language: en-US
# Show/hide the header (default: true) # Show/hide the header (default: true)
header: true header: true
# Enable/disable the short RSS feed (default: false)
short_feed: false
categories: categories:
- category1 - category1
@ -133,4 +135,9 @@ $$
RSS feeds for the blog are provided under the `/rss` URL. 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`. 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 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 import os
from typing import List
import yaml import yaml
from dataclasses import dataclass from dataclasses import dataclass, field
@dataclass @dataclass
class Config: class Config:
title = 'Blog' title = "Blog"
description = '' description = ""
link = '/' link = "/"
home_link = '/' home_link = "/"
language = 'en-US' language = "en-US"
logo = '/img/icon.png' logo = "/img/icon.png"
header = True header = True
content_dir = '.' content_dir = "."
categories = None categories: List[str] = field(default_factory=list)
short_feed = False
basedir = os.path.abspath(os.path.dirname(__file__)) basedir = os.path.abspath(os.path.dirname(__file__))
templates_dir = os.path.join(basedir, 'templates') templates_dir = os.path.join(basedir, "templates")
static_dir = os.path.join(basedir, 'static') static_dir = os.path.join(basedir, "static")
default_css_dir = os.path.join(static_dir, 'css') default_css_dir = os.path.join(static_dir, "css")
default_js_dir = os.path.join(static_dir, 'js') default_js_dir = os.path.join(static_dir, "js")
default_fonts_dir = os.path.join(static_dir, 'fonts') default_fonts_dir = os.path.join(static_dir, "fonts")
default_img_dir = os.path.join(static_dir, 'img') default_img_dir = os.path.join(static_dir, "img")
config = Config() config = Config()
def init_config(content_dir='.', config_file='config.yaml'): def init_config(content_dir=".", config_file="config.yaml"):
cfg = {} cfg = {}
config.content_dir = content_dir config.content_dir = content_dir
if os.path.isfile(config_file): 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) cfg = yaml.safe_load(f)
if cfg.get('title'): if cfg.get("title"):
config.title = cfg['title'] config.title = cfg["title"]
if cfg.get('description'): if cfg.get("description"):
config.description = cfg['description'] config.description = cfg["description"]
if cfg.get('link'): if cfg.get("link"):
config.link = cfg['link'] config.link = cfg["link"]
if cfg.get('home_link'): if cfg.get("home_link"):
config.home_link = cfg['home_link'] config.home_link = cfg["home_link"]
if cfg.get('logo') is not None: if cfg.get("logo") is not None:
config.logo = cfg['logo'] config.logo = cfg["logo"]
if cfg.get('language'): if cfg.get("language"):
config.language = cfg['language'] config.language = cfg["language"]
if cfg.get('header') is False: if cfg.get("header") is False:
config.header = 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: # vim:sw=4:ts=4:et: