From 60e08a6c0a227fcb875b5c8c3be1583283f13f10 Mon Sep 17 00:00:00 2001 From: Joonatan Jakobson <52051107+joonatanjak@users.noreply.github.com> Date: Thu, 19 Nov 2020 02:43:00 +0200 Subject: [PATCH 1/7] Fix subpage links in tables This makes the subpage links in tables not look like default HTML links. --- loconotion/notionparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index a9eec07..d1be1fe 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -464,7 +464,7 @@ class Parser: table_row_href = "/" + table_row_block_id.replace("-", "") row_target_span = table_row.find("span") row_link_wrapper = soup.new_tag( - "a", attrs={"href": table_row_href, "style": "cursor: pointer;"} + "a", attrs={"href": table_row_href, "style": "cursor: pointer; color: inherit; text-decoration: none; fill: inherit;"} ) row_target_span.wrap(row_link_wrapper) From 92473cdc45ac418357136b124dd877b21116ec98 Mon Sep 17 00:00:00 2001 From: Joonatan Jakobson <52051107+joonatanjak@users.noreply.github.com> Date: Thu, 19 Nov 2020 23:57:11 +0200 Subject: [PATCH 2/7] Fix subpage links in tables for Safari The `pointer-events: none;` style tag will make the link unclickable by some browsers (tested on iOS and MacOS Safari). This pull request adds a line of code, which will delete this tag. --- loconotion/notionparser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index d1be1fe..31a3477 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -463,6 +463,7 @@ class Parser: table_row_block_id = table_row["data-block-id"] table_row_href = "/" + table_row_block_id.replace("-", "") row_target_span = table_row.find("span") + row_target_span["style"] = row_target_span["style"].replace("pointer-events: none;","") row_link_wrapper = soup.new_tag( "a", attrs={"href": table_row_href, "style": "cursor: pointer; color: inherit; text-decoration: none; fill: inherit;"} ) From a3d22a24e84cda251e2d8bc56d26cbe8a65a53ff Mon Sep 17 00:00:00 2001 From: Evan Savage Date: Wed, 25 Nov 2020 08:19:33 -0500 Subject: [PATCH 3/7] Support for Notion inline "alias" links These use an SVG icon, and (for now, at least) sometimes have the full "https://www.notion.so" domain in the `href`. Made a small CSS patch to deal with the SVG icon getting too much height by default, and updated the subpage detection to handle these `href` values. --- bundles/loconotion.css | 6 ++++++ loconotion/notionparser.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bundles/loconotion.css b/bundles/loconotion.css index 5f1893d..8328746 100644 --- a/bundles/loconotion.css +++ b/bundles/loconotion.css @@ -34,6 +34,12 @@ div[role="button"]:not(.notion-record-icon):hover { padding-right: unset !important; } +/* pull alias arrows back inline */ +svg.alias { + display: inline-block !important; + height: auto !important; +} + @media only screen and (max-width: 960px) { /* normalizes banner / page title width */ .notion-scroller > div:not([class]), diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index 31a3477..48a7541 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -555,8 +555,10 @@ class Parser: # find sub-pages and clean slugs / links sub_pages = [] for a in soup.findAll("a"): - if a["href"].startswith("/"): + sub_page_href = a["href"] + if sub_page_href.startswith("/"): sub_page_href = "https://www.notion.so" + a["href"] + if sub_page_href.startswith("https://www.notion.so/"): # if the link is an anchor link, # check if the page hasn't already been parsed if "#" in sub_page_href: From 707bc4cd8165f4c001ae2fc92989ffda85be7604 Mon Sep 17 00:00:00 2001 From: Ahmet Safa Orhan Date: Tue, 15 Dec 2020 08:11:35 +0300 Subject: [PATCH 4/7] Bump up chrome driver version Bump up chrome driver version to match the latest stable google chrome --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1f7ecaa..7582417 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get install -y google-chrome-stable # RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb # RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install # Set up Chromedriver Environment variables -ENV CHROMEDRIVER_VERSION 85.0.4183.38 +ENV CHROMEDRIVER_VERSION 87.0.4280.88 ENV CHROMEDRIVER_DIR /chromedriver RUN mkdir $CHROMEDRIVER_DIR # Download and install Chromedriver From a404b5a34f703fc5671aaf61d8f2496e3a872d12 Mon Sep 17 00:00:00 2001 From: Alain Hernandez Date: Sat, 19 Dec 2020 18:58:51 -0500 Subject: [PATCH 5/7] Run dark mode script hack based on configuration parameter --- loconotion/notionparser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index 48a7541..dd12b8e 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -261,6 +261,11 @@ class Parser: ) return + # light theme is on by default + # enable dark mode based on https://fruitionsite.com/ dark mode hack + if self.config.get('theme') == 'dark': + self.driver.execute_script("__console.environment.ThemeStore.setState({ mode: 'dark' });") + # scroll at the bottom of the notion-scroller element to load all elements # continue once there are no changes in height after a timeout # don't do this if the page has a calendar databse on it or it will load forever From 90f5abaa06d103c588f2569881fb3f9df4479361 Mon Sep 17 00:00:00 2001 From: Alain Hernandez Date: Sat, 19 Dec 2020 18:59:28 -0500 Subject: [PATCH 6/7] dark mode docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ed24184..1b25f7c 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,9 @@ name = "Notion Test Site" # of the generated site, and loconotion will parse all sub-pages present on the page page = "https://www.notion.so/Loconotion-Example-Page-03c403f4fdc94cc1b315b9469a8950ef" +# optionally apply notion's dark mode, remove the line below to use the default light mode +theme = "dark" + ## Global Site Settings ## # this [site] table defines override settings for the whole site # later on we will see how to define settings for a single page From 93d36eb338568c7a7df9fb97797cd2d8cdba7ab1 Mon Sep 17 00:00:00 2001 From: Alain Hernandez Date: Sat, 19 Dec 2020 19:09:53 -0500 Subject: [PATCH 7/7] Remove collection selectors since they don't work anyways This is specifically the selectors next to collections (List, gallery, timeline, etc.) --- loconotion/notionparser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index 48a7541..8d17506 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -342,6 +342,10 @@ class Parser: for vendors_css in soup.find_all("link", href=lambda x: x and "vendors~" in x): vendors_css.decompose() + # collection selectors (List, Gallery, etc.) don't work, so remove them + for collection_selector in soup.findAll("div", {"class": "notion-collection-view-select"}): + collection_selector.decompose() + # clean up the default notion meta tags for tag in [ "description",