Fazil Altinel
3 years ago
1 changed files with 38 additions and 0 deletions
@ -0,0 +1,38 @@ |
|||||
|
import os |
||||
|
import logging |
||||
|
import argparse |
||||
|
import datetime |
||||
|
|
||||
|
from feedgen.feed import FeedGenerator |
||||
|
|
||||
|
|
||||
|
def main(args): |
||||
|
print(f'feed-md started with arguments {args}') |
||||
|
all_md_files = [os.path.join(dp, f) for dp, dn, filenames in os.walk(args.dir) for f in filenames if os.path.splitext(f)[1].lower() == args.format] |
||||
|
fg = FeedGenerator() |
||||
|
fg.title("altinel.dev Notes") |
||||
|
fg.link(href="https://altinel.dev/notes/", rel="alternate") |
||||
|
fg.description("This page is my notebook. It has no specific content characteristic.") |
||||
|
fg.language('en') |
||||
|
for post in sorted(all_md_files, key=os.path.getmtime): |
||||
|
if "Template" not in post and "First Page" not in post: |
||||
|
fe = fg.add_entry() |
||||
|
dir_name, file_name = os.path.split(post) |
||||
|
full_file = f"{dir_name.split('/')[-1]}/{file_name}" |
||||
|
title = file_name.split(".")[0] |
||||
|
fe.title(title) |
||||
|
id = f"https://altinel.dev/notes/{dir_name.split('/')[-1]}/#{title.replace(' ', '%20')}.md" |
||||
|
fe.id(id) |
||||
|
fe.link(href=id) |
||||
|
fe.description(f"Read {id}") |
||||
|
fg.rss_file(os.path.join(args.outdir, 'rss.xml')) |
||||
|
|
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
parser = argparse.ArgumentParser() |
||||
|
parser.add_argument('--dir', type=str) |
||||
|
parser.add_argument('--format', type=str, default='.md') |
||||
|
parser.add_argument('--outdir', type=str, default='./') |
||||
|
args, unknown_args = parser.parse_known_args() |
||||
|
|
||||
|
main(args) |
Loading…
Reference in new issue