# Path: app/data.py
# class Projects():
# class Language():
# class Project():
# class Shelf():
# class Section():
# class Item():
#     def __init__(self) -> None:
#     def load_from_file() -> 'Projects':
#     def load(data: Dict[str, Dict[str, Dict[str, str]]]) -> 'Projects':
#     def __init__(self) -> None:
#     def load(key: str, data: Dict[str, Dict[str, str]]) -> 'Language':
#     def __init__(self) -> None:
#     def load(key: str, data: Dict[str, str]) -> 'Project':
#     def links(self) -> Dict[str, str]:
# def get_projects() -> Projects:
#     def __init__(self) -> None:
#     def load_from_file() -> 'Shelf':
#     def load(shelf_data: Dict[str, List[Dict[str, str]]]) -> 'Shelf':
#     def __init__(self) -> None:
#     def load(name: str, data: List[Dict[str, str]]) -> 'Section':
#     def __init__(self) -> None:
#     def load(data: Dict[str, str]) -> 'Item':
# def get_shelf() -> Shelf:
# 
# Path: app/note_util.py
# MARKDOWN_EXTRAS = [
#     'code-friendly',
#     'fenced-code-blocks',
#     'smarty-pants',
#     'tables',
# ]
# TIMEZONE = ZoneInfo(os.environ['DISPLAY_TIMEZONE'])
# NOTES_DIRECTORY = 'notes'
# REFERENCE_DIRECTORY = 'reference'
# class Note(object):
#     def __init__(self) -> None:
#     def __eq__(self, other: Any) -> bool:
#     def __repr__(self) -> str:
#     def get_note_file_data(note_file: str) -> Optional["Note"]:
#     def parse_time(timestamp_str: str) -> datetime.datetime:
#     def parse_markdown(markdown: str) -> str:
#     def write_note(self) -> None:
# def prune_note_files(note_files: List[str]) -> List[str]:
#     def is_valid_note(note_file: str) -> bool:
# def get_note_files(directory: str) -> List[str]:
# def get_notes(directory: str) -> List[Note]:
# def get_note_from_slug(directory: str, slug: str) -> Optional[Note]:


from typing import Any
from urllib.parse import urljoin
from feedgen.feed import FeedGenerator
from flask import (
    Blueprint,
    Response,
    abort,
    redirect,
    render_template,
    request,
    url_for,
)
from varsnap import varsnap
from app import data, note_util

@handlers.route("/atom.xml")
def atom_feed() -> Any:
    fg = FeedGenerator()
    fg.title('albertyw.com')
    fg.id(request.url)
    fg.author(name='Albert Wang', email='me@albertyw.com')
    fg.link(href=request.url, rel='self')
    fg.link(href=request.url_root, rel='alternate')
    fg.language('en')
    fg.updated(note_util.get_notes(note_util.NOTES_DIRECTORY)[0].time)
    for post in list(note_util.get_notes(note_util.NOTES_DIRECTORY))[:5]:
        url = url_for('handlers.note', slug=post.slug)
        url = urljoin(request.url_root, url)

        fe = fg.add_entry()
        fe.title(post.title)
        fe.id(url)
        fe.content(post.note, type='html')
        fe.author(name='Albert Wang', email='me@albertyw.com')
        fe.source(url)
        fe.updated(post.time)
        fe.link(href=url)
    return Response(fg.atom_str(pretty=True), mimetype='application/atom+xml')


@varsnap
def sitemap_urls() -> Any:
    for post in list(note_util.get_notes(note_util.NOTES_DIRECTORY)):
        yield url_for('handlers.note', slug=post.slug, _external=True)

# Path: app/data.py
# class Projects():
# class Language():
# class Project():
# class Shelf():
# class Section():
# class Item():
#     def __init__(self) -> None:
#     def load_from_file() -> 'Projects':
#     def load(data: Dict[str, Dict[str, Dict[str, str]]]) -> 'Projects':
#     def __init__(self) -> None:
#     def load(key: str, data: Dict[str, Dict[str, str]]) -> 'Language':
#     def __init__(self) -> None:
#     def load(key: str, data: Dict[str, str]) -> 'Project':
#     def links(self) -> Dict[str, str]:
# def get_projects() -> Projects:
#     def __init__(self) -> None:
#     def load_from_file() -> 'Shelf':
#     def load(shelf_data: Dict[str, List[Dict[str, str]]]) -> 'Shelf':
#     def __init__(self) -> None:
#     def load(name: str, data: List[Dict[str, str]]) -> 'Section':
#     def __init__(self) -> None:
#     def load(data: Dict[str, str]) -> 'Item':
# def get_shelf() -> Shelf:
# 
# Path: app/note_util.py
# MARKDOWN_EXTRAS = [
#     'code-friendly',
#     'fenced-code-blocks',
#     'smarty-pants',
#     'tables',
# ]
# TIMEZONE = ZoneInfo(os.environ['DISPLAY_TIMEZONE'])
# NOTES_DIRECTORY = 'notes'
# REFERENCE_DIRECTORY = 'reference'
# class Note(object):
#     def __init__(self) -> None:
#     def __eq__(self, other: Any) -> bool:
#     def __repr__(self) -> str:
#     def get_note_file_data(note_file: str) -> Optional["Note"]:
#     def parse_time(timestamp_str: str) -> datetime.datetime:
#     def parse_markdown(markdown: str) -> str:
#     def write_note(self) -> None:
# def prune_note_files(note_files: List[str]) -> List[str]:
#     def is_valid_note(note_file: str) -> bool:
# def get_note_files(directory: str) -> List[str]:
# def get_notes(directory: str) -> List[Note]:
# def get_note_from_slug(directory: str, slug: str) -> Optional[Note]:


# Path: app/routes.py
from typing import Any
from urllib.parse import urljoin
from feedgen.feed import FeedGenerator
from flask import (
    Blueprint,
    Response,
    abort,
    redirect,
    render_template,
    request,
    url_for,
)
from varsnap import varsnap
from app import data, note_util


@handlers.route("/atom.xml")
def atom_feed() -> Any:
    fg = FeedGenerator()
    fg.title('albertyw.com')
    fg.id(request.url)
    fg.author(name='Albert Wang', email='me@albertyw.com')
    fg.link(href=request.url, rel='self')
    fg.link(href=request.url_root, rel='alternate')
    fg.language('en')
    fg.updated(note_util.get_notes(note_util.NOTES_DIRECTORY)[0].time)
    for post in list(note_util.get_notes(note_util.NOTES_DIRECTORY))[:5]:
        url = url_for('handlers.note', slug=post.slug)
        url = urljoin(request.url_root, url)

        fe = fg.add_entry()
        fe.title(post.title)
        fe.id(url)
        fe.content(post.note, type='html')
        fe.author(name='Albert Wang', email='me@albertyw.com')
        fe.source(url)
        fe.updated(post.time)
        fe.link(href=url)
    return Response(fg.atom_str(pretty=True), mimetype='application/atom+xml')


@varsnap
def sitemap_urls() -> Any:
    for post in list(note_util.get_notes(note_util.NOTES_DIRECTORY)):
        yield url_for('handlers.note', slug=post.slug, _external=True)

    for post in list(note_util.get_notes(note_util.REFERENCE_DIRECTORY)):