Added --clean-style argument

This commit is contained in:
Leonardo Cavaletti 2020-05-27 08:54:29 +01:00
parent 7a8bad823a
commit bc9cce4298
4 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,4 @@
// re-implement toggle blocks
const showToggle = (content, arrow) => {
arrow.style.transform = "rotateZ(180deg)";
content.style.display = "block";
@ -26,6 +27,8 @@ for (let i = 0; i < toggleButtons.length; i++) {
}
}
// sets all iframes' parent container opacity to 1
// originally notion has a callback to do that on iframe loaded
const pendingIframes = document.getElementsByTagName("iframe");
for (let i = 0; i < pendingIframes.length; i++) {
pendingIframes.item(i).parentElement.style.opacity = 1;
@ -59,12 +62,15 @@ for (let i = 0; i < pendingIframes.length; i++) {
// pendingIframe.appendChild(iframe);
// }
// hide search box on inline databases
// couldn't find a reliable way to do this in css
const collectionSearchBoxes = document.getElementsByClassName("collectionSearch");
for (let i = 0; i < collectionSearchBoxes.length; i++) {
const collectionSearchBox = collectionSearchBoxes.item(i).parentElement;
collectionSearchBox.style.display = "none";
}
// re-implement anchor links
const anchorLinks = document.querySelectorAll("a.loconotion-anchor-link");
for (let i = 0; i < anchorLinks.length; i++) {
const anchorLink = anchorLinks.item(i);

View File

@ -39,6 +39,11 @@ def main():
action="store_true",
help="Delete all previously cached files for the site before generating it",
)
argparser.add_argument(
"--clean-style",
action="store_true",
help="Delete only previously cached .css files for the site before generating it",
)
argparser.add_argument(
"--non-headless",
action="store_true",

View File

@ -61,6 +61,13 @@ class Parser:
log.info(f"Removing previously cached files in '{self.dist_folder}'")
except OSError as e:
log.error(f"Cannot remove '{self.dist_folder}': {e}")
elif self.args.get("clean_style", False):
try:
log.info(f"Removing previously cached style files in '{self.dist_folder}'")
for style_file in glob.glob(str(self.dist_folder / "*.css")):
os.remove(style_file)
except OSError as e:
log.error(f"Cannot remove syle files in '{self.dist_folder}': {e}")
# create the output folder if necessary
self.dist_folder.mkdir(parents=True, exist_ok=True)

View File

@ -1,7 +1,7 @@
[tool.poetry]
name = "loconotion"
version = "0.1.0"
description = ""
description = "Generate static websites from Notion.so pages"
authors = ["Leonardo Cavaletti <impeto.blu@gmail.com>"]
[tool.poetry.dependencies]