GitXplorerGitXplorer
n

min-rss-gen

public
0 stars
0 forks
2 issues

Commits

List of commits on branch master.
Unverified
c5dd4c91ca86efe88d45fbf63bff670046e5db85

refactor code and add docstrings for all functions

committed 5 years ago
Unverified
e0efaf6bfb0f88033f13a83b0db10d4df2be7b55

yield elements instead of generator

committed 5 years ago
Unverified
83b74f189be24ce39149adb308f995dbb3f4f50f

yield elements instead of generator

committed 5 years ago
Unverified
da63ea059985d125ce8a79c7782bb590324d251d

version bump

committed 5 years ago
Unverified
99edc8561749e2f4216328afaca80d7157836b94

refactoring code and setting line-length to 80

committed 5 years ago
Verified
72a47dbfc6a8c3d51e0b44c0fa45bd87f5c3226b

Update README.md

nnwalsh1995 committed 5 years ago

README

The README file for this repository.

min-rss-gen

A minimal RSS 2.0 generator. Follows guidelines from https://validator.w3.org/feed/docs/rss2.html

XML Implementations

Accepts any implementation that fulfills Python's ElementTree API. Due to this, lxml is supported.

Installation

pip install min-rss

Usage

The following script powers the RSS feed at https://nwalsh1995.github.io/rss.xml

from min_rss_gen.generator import start_rss, gen_item

import xml.etree.ElementTree
from glob import glob
from pathlib import PurePath

SITE = "https://nwalsh1995.github.io"
RSS_FILENAME = "rss.xml"
rss_items = []


# Generate all items
for f in glob("**/*.html", recursive=True):
    path = PurePath(f)
    title = path.with_suffix("").name.replace("-", " ").title()
    rss_items.append(gen_item(title=title, link=f"{SITE}/{str(path)}"))


# Generate the <rss> XML element and subelements.
rss_xml_element = start_rss(title="nwalsh1995.github.io", link="nwalsh1995.github.io", description="A collection of thoughts.", items=rss_items)

# You can add custom subelements onto the returned <rss> element if you choose.

with open(RSS_FILENAME, "wb") as f:
    f.write(xml.etree.ElementTree.tostring(rss_xml_element))