Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
"embed",
"gravatar",
"sketchviz",
"notion",
]

myst_enable_extensions = [
Expand Down Expand Up @@ -433,4 +434,4 @@
"image": "_static/logo/logo.png",
}
# Ensures og:image meta tag generation which is not always generated by sphinxext.opengraph
ogp_image = "_static/logo/logo.png"
ogp_image = "_static/logo/logo.png"
7 changes: 7 additions & 0 deletions events.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ list-style: circle
excerpts:
---
```

```{toctree}
:caption: Secciones
:hidden: true

talk-brainstorming.md
```
2 changes: 1 addition & 1 deletion ext/gravatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(self):

data = {}
if klass is not None:
data['classes'] = klass
data["classes"] = klass

image = nodes.image(alt=alt, classes=klass, uri=url)
return [image]
Expand Down
52 changes: 52 additions & 0 deletions ext/notion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""A directive to generate an iframe with a Notion page."""

import urllib.parse

from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx.application import Sphinx
from sphinx.util import logging

logger = logging.getLogger(__name__)

TEMPLATE: str = """
<iframe src="{url}" width="100%" height="1200" frameborder="0" allowfullscreen>
</iframe>
"""


class Notion(Directive):
has_content = True
final_argument_whitespace = False

def run(self):
if not self.content:
raise self.error("Notion directive requires a URL")
if len(self.content) > 1:
raise self.error("Notion directive only accepts a single URL")
url = self.content[0]
# Basic validation that it's a Notion URL
if (
not url.startswith(
("https://notion.site", "https://www.notion.so")
)
and "notion" not in url
):
raise self.error("URL does not appear to be a valid Notion URL")

para = nodes.raw(
"",
TEMPLATE.format(url=urllib.parse.quote(url, safe=":/?&=+")),
format="html",
)
return [para]


def setup(app: Sphinx):
app.add_directive("notion", Notion)

return {
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Revisa nuestras normas de como integrarte en la comunidad de Python Perú.
```

```{toctree}
:caption: Secciónes
:caption: Secciones
:hidden: true

about.md
Expand Down
4 changes: 4 additions & 0 deletions talk-brainstorming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Brainstorming de Charlas

```{notion} https://forested-roadrunner-0a7.notion.site/ebd/1e114afe2a67809c9ff0eb9429b1d3c7?v=1e114afe2a6780d88e41000c2debb2b5
```