Metadata-Version: 2.5
Name: zensical-feeds
Version: 0.2.0
Summary: Publish Zensical articles and events as an RSS feed and a subscribable iCalendar (.ics) feed
Project-URL: Homepage, https://github.com/hcientist/Zensical-Feeds
Project-URL: Issues, https://github.com/hcientist/Zensical-Feeds/issues
Author-email: Michael Stewart <stewarmc@jmu.edu>
License-Expression: MIT
License-File: LICENSE
Keywords: feed,icalendar,ics,mkdocs,rss,static-site,zensical
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Documentation
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Requires-Dist: markdown>=3.5
Requires-Dist: pyyaml>=6.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Requires-Dist: tzdata; sys_platform == 'win32'
Provides-Extra: dev
Requires-Dist: feedparser>=6.0; extra == 'dev'
Requires-Dist: icalendar>=6.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: recurring-ical-events>=3.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# zensical-feeds

Publish the articles and events in a [Zensical] project as an **RSS 2.0 feed**
and a **subscribable iCalendar (`.ics`) feed**, generated straight from the
front matter of your Markdown files.

Events land in both feeds: in RSS so readers see them announced, and in the
calendar so people can subscribe once and get every event you publish from
then on.

```plain text
docs/blog/spring-cleanup.md  ─┐
docs/events/potluck.md       ─┼─►  site/feed_rss.xml
docs/events/board-meeting.md ─┘    site/events.ics
```

## Why this is a companion package, not a Zensical plugin

Zensical does not have a public plugin API yet. Its compatibility docs are
explicit about it — *"To allow for it to mature, we are currently holding back
on releasing a public API"* — and the module system that will replace
MkDocs-style plugins is [still in progress][roadmap]. There are no MkDocs
hooks either: the config loader only maps a fixed allowlist of known plugins
into the Rust core.

So this is a small CLI you run after `zensical build`. The collector and the
two writers know nothing about the command line, and everything goes through
[`zensical_feeds.generate()`][api] — when the module API lands, the adapter is
a few lines rather than a rewrite.

## Install

```sh
pip install zensical-feeds
```

## Use

```sh
zensical build          # build the site as usual
zensical-feeds          # write the feeds into site/
```

Or in one step:

```sh
zensical-feeds build --with-build
```

Then add the autodiscovery links so browsers and readers find the feeds:

```sh
zensical-feeds init     # writes overrides/main.html
```

...and point the theme at the overrides directory:

```toml
[project.theme]
custom_dir = "overrides"
```

### Commands

| Command | What it does |
| --- | --- |
| `zensical-feeds build` | Generate the feeds into `site_dir` (the default command) |
| `zensical-feeds check` | Validate config and front matter, write nothing, exit non-zero on a problem |
| `zensical-feeds init` | Write a `main.html` override carrying the feed `<link>` tags |

Useful flags: `-f/--config-file` to point at a config, `-d/--site-dir` to write
somewhere else, `--with-build` to run `zensical build` first, `-v/--verbose` to
list every entry that was picked up.

## Front matter

A document joins the feeds when it carries a `date` (an article), an `event`
(a calendar entry), or both. Everything else is ordinary documentation and is
left alone — no opt-in configuration required.

### An article

```yaml
---
title: Spring cleanup went well
date: 2026-04-14
description: Sixty people, four dumpsters, one very tired quartermaster.
categories: [news]
authors: [tgm]
---
```

### An event

```yaml
---
title: Fall potluck
date: 2026-08-01                 # when it was announced
event:
  start: 2026-10-11 17:30        # local time in feeds.timezone
  end: 2026-10-11 21:00
  location: Dining hall
  status: confirmed              # tentative | confirmed | cancelled
---
```

### An all-day, repeating event

```yaml
---
title: Board meeting
event:
  start: 2026-09-01              # a bare date means all-day
  end: 2026-09-02                # the last day, inclusive
  rrule: FREQ=MONTHLY;BYDAY=1MO
  exdates: [2026-12-07]
---
```

### Multiple occurrences on one page

When a single page describes several distinct dates — a workshop series, a
multi-session course, a set of tryout dates — list them under `event`:

```yaml
---
title: Wilderness first-aid workshop
event:
  - start: 2026-09-13 09:00
    end: 2026-09-13 16:00
    location: Health lodge
  - start: 2026-10-11 09:00
    end: 2026-10-11 16:00
    location: Health lodge
  - start: 2026-11-08 09:00
    end: 2026-11-08 16:00
    location: Health lodge
---
```

Each item in the list becomes its own calendar event with a unique UID, so
subscribers see every date in their calendar. All occurrences share the same
page URL, title, and summary. In RSS, each occurrence appears as a separate
item ordered by its start date.

An event page without a `date` is published as of the moment the event starts,
so the RSS ordering stays sensible without inventing a timestamp.

### Every recognized key

| Key | Meaning |
| --- | --- |
| `title` | Entry title. Falls back to the first `# headline`, then the filename |
| `date` | Publication date. `date: {created: ..., updated: ...}` also works |
| `updated` | Last modification, used for the feed timestamps |
| `description` | Feed summary. Without it, the body up to `<!-- more -->` is used |
| `categories`, `tags` | Merged into RSS `<category>` and iCalendar `CATEGORIES` |
| `authors` | Names, or ids resolved against a Material-style `.authors.yml` |
| `image` | Illustration, emitted as `<media:content>` |
| `draft` | `true` keeps the page out of the feeds |
| `feeds` | `false` to skip both feeds, or `{rss: false, ics: true}` to pick |
| `event.start` | Date (all-day) or date-time. **Required** for an event |
| `event.end` | For all-day events this is the last day, inclusive |
| `event.all_day` | Override the date-vs-datetime inference |
| `event.location` | Free text, becomes `LOCATION` |
| `event.rrule` | A raw RFC 5545 recurrence rule, e.g. `FREQ=WEEKLY;COUNT=6` |
| `event.exdates` | Dates to skip |
| `event.status` | `tentative`, `confirmed` or `cancelled` |
| `event.organizer` | An email address or a name |
| `event.geo` | `[lat, lon]`, becomes `GEO` |

## Configuration

Everything is optional — with no `[feeds]` table at all you get
`site/feed_rss.xml` and `site/events.ics`. Add the table to `zensical.toml` to
change that:

```toml
[feeds]
timezone = "America/New_York"   # how naive front matter times are read
match = ["blog/**/*.md", "events/**/*.md"]
exclude = ["**/index.md"]
drafts = false
summary_words = 60

[feeds.rss]
enabled = true
output = "feed_rss.xml"
title = "Camp Shenandoah news"
description = "Announcements and upcoming events"
limit = 50                      # 0 for no limit
include = "all"                 # all | articles | events
content = "summary"             # summary | full (adds <content:encoded>)
ttl = 60
image = "assets/logo.png"

[feeds.ics]
enabled = true
output = "events.ics"
name = "Camp Shenandoah events"
description = "Everything on the calendar"
limit = 0
past_days = 365                 # drop events that ended over a year ago
refresh_interval = "PT1H"
default_duration_minutes = 60   # for events with a start but no end
```

MkDocs projects work too: the same settings go under a top-level `feeds:` key
in `mkdocs.yml` (or under `extra:`), and the site metadata is read from there.

Unknown settings are an error rather than a shrug — a typo in a feed setting
is a silently missing feature otherwise.

## Notes on the output

**The feeds are deterministic.** Channel timestamps and `DTSTAMP` come from
the entries, not from the clock, so rebuilding an unchanged site produces
byte-identical files. Committing the built site or syncing it with `rsync`
does not churn.

**Calendar UIDs are stable.** They are derived from the entry URL (plus the
occurrence index for multi-occurrence events), so editing an event updates it
for everyone already subscribed instead of creating a duplicate.

**Timezones are written properly.** Naive front matter times are read in
`feeds.timezone` and written as `TZID=` values, with a real `VTIMEZONE`
component derived from the system timezone database — so recurring events do
not drift an hour across a daylight-saving boundary. Times written with an
explicit UTC offset are emitted in UTC instead.

**Relative links survive.** Links and images in summaries are rewritten to
absolute URLs, because no feed reader resolves them.

## Development

```sh
pip install -e ".[dev]"
pytest
```

## License

MIT — see [LICENSE](LICENSE).

[Zensical]: https://zensical.org
[roadmap]: https://zensical.org/about/roadmap/
[api]: src/zensical_feeds/api.py
