diff --git a/franca.py b/franca.py index 2d5cc13..2a54452 100644 --- a/franca.py +++ b/franca.py @@ -4,7 +4,7 @@ import shutil from pathlib import Path from watchdog.observers import Observer -from watchdog.events import FileSystemEventHandler +from watchdog.events import PatternMatchingEventHandler from jinja2 import Environment, FileSystemLoader, select_autoescape import yaml import frontmatter @@ -38,7 +38,11 @@ running = False # нужно для проверки # класс для watchdog # Во время разработки, при обнаружении изменений в папках content и themes/{config['theme']}, # перегенерировать папку public -class Develop(FileSystemEventHandler): +class Develop(PatternMatchingEventHandler): + def __init__(self): + PatternMatchingEventHandler.__init__(self, patterns=['*.md', '*.css'], + ignore_directories=True, case_sensitive=False) + def on_modified(self, event): print(f'event type: {event.event_type} path : {event.src_path}') franca() @@ -185,7 +189,8 @@ def franca(prod=False): robots_content += "\nDisallow: /" write_file('public/robots.txt', robots_content) - if prod: + global running + if not running: if 'pagefind' in config: os.system("npx pagefind --source public") # build search index