From 6c19da667f4e8018727b38263235322bfefbcc4d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Chauvel Date: Sat, 26 Apr 2025 15:58:11 -0500 Subject: [PATCH 1/5] Adding talk brainstorming section --- conf.py | 3 ++- events.md | 7 +++++++ ext/notion.py | 33 +++++++++++++++++++++++++++++++++ index.md | 2 +- talk-brainstorming.md | 4 ++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 ext/notion.py create mode 100644 talk-brainstorming.md diff --git a/conf.py b/conf.py index 75b904c..42e05e5 100644 --- a/conf.py +++ b/conf.py @@ -215,6 +215,7 @@ "embed", "gravatar", "sketchviz", + "notion", ] myst_enable_extensions = [ @@ -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" \ No newline at end of file +ogp_image = "_static/logo/logo.png" diff --git a/events.md b/events.md index 477737f..85373b3 100644 --- a/events.md +++ b/events.md @@ -9,3 +9,10 @@ list-style: circle excerpts: --- ``` + +```{toctree} +:caption: Secciones +:hidden: true + +talk-brainstorming.md +``` diff --git a/ext/notion.py b/ext/notion.py new file mode 100644 index 0000000..d434e1f --- /dev/null +++ b/ext/notion.py @@ -0,0 +1,33 @@ +"""A directive to generate an iframe with a Notion page.""" + +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 = """ + """ From 0799a50e10217b609ed46451d5b14d0ac80dbcfe Mon Sep 17 00:00:00 2001 From: Jean-Pierre Chauvel Date: Sat, 26 Apr 2025 16:06:39 -0500 Subject: [PATCH 3/5] Update ext/notion.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ext/notion.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/notion.py b/ext/notion.py index 3e136b3..66a0c66 100644 --- a/ext/notion.py +++ b/ext/notion.py @@ -18,8 +18,17 @@ class Notion(Directive): 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=self.content[0]), format="html" + "", TEMPLATE.format(url=url), format="html" ) return [para] From a2e1c6f9f20c70e2d4fbf0df6cf8a755d8c6575e Mon Sep 17 00:00:00 2001 From: Jean-Pierre Chauvel Date: Sat, 26 Apr 2025 16:10:52 -0500 Subject: [PATCH 4/5] Update ext/notion.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ext/notion.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/notion.py b/ext/notion.py index 66a0c66..9e50271 100644 --- a/ext/notion.py +++ b/ext/notion.py @@ -28,7 +28,10 @@ def run(self): raise self.error("URL does not appear to be a valid Notion URL") para = nodes.raw( - "", TEMPLATE.format(url=url), format="html" + para = nodes.raw( +- "", TEMPLATE.format(url=url), format="html" ++ "", TEMPLATE.format(url=urllib.parse.quote(url, safe=":/?&=+")), format="html" + ) ) return [para] From 1307104e7e91d55bf962784faeb79225318f650a Mon Sep 17 00:00:00 2001 From: Jean-Pierre Chauvel Date: Sat, 26 Apr 2025 16:17:04 -0500 Subject: [PATCH 5/5] syntax error fix/reformatting --- ext/gravatar.py | 2 +- ext/notion.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ext/gravatar.py b/ext/gravatar.py index b4241e4..54a89dc 100644 --- a/ext/gravatar.py +++ b/ext/gravatar.py @@ -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] diff --git a/ext/notion.py b/ext/notion.py index 9e50271..8fbe304 100644 --- a/ext/notion.py +++ b/ext/notion.py @@ -1,5 +1,7 @@ """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 @@ -24,20 +26,24 @@ def run(self): 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: + 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( - para = nodes.raw( -- "", TEMPLATE.format(url=url), format="html" -+ "", TEMPLATE.format(url=urllib.parse.quote(url, safe=":/?&=+")), format="html" - ) + "", + TEMPLATE.format(url=urllib.parse.quote(url, safe=":/?&=+")), + format="html", ) return [para] def setup(app: Sphinx): - app.add_directive("notion",Notion) + app.add_directive("notion", Notion) return { "version": "0.1",