Merge remote-tracking branch 'origin/master'

This commit is contained in:
Leonardo Cavaletti 2021-02-06 15:55:46 +00:00
commit 125203a580
4 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -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]),

View File

@ -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

View File

@ -264,6 +264,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
@ -345,6 +350,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",
@ -466,8 +475,9 @@ 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;"}
"a", attrs={"href": table_row_href, "style": "cursor: pointer; color: inherit; text-decoration: none; fill: inherit;"}
)
row_target_span.wrap(row_link_wrapper)
@ -557,8 +567,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: