Fix observer' screen

This commit is contained in:
Digital Studium 2023-10-14 18:46:50 +03:00
parent d29570739b
commit 98912ac09b
1 changed files with 8 additions and 3 deletions

View File

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