29 lines
871 B
Python
29 lines
871 B
Python
import os, subprocess
|
|
from pathlib import Path
|
|
from classes import *
|
|
from config import Config
|
|
from logger import logger
|
|
|
|
def create_content(filename):
|
|
filename = Path(f"{Config.CONTENT_DIR}/{filename}.md")
|
|
if not filename.exists():
|
|
logger.debug(f"Creating new content {filename}")
|
|
new_content_item = ContentItem(filename)
|
|
new_content_item.create_content()
|
|
|
|
def edit_content(filename):
|
|
logger.debug(f"Editing content {filename}")
|
|
editor = os.environ.get('EDITOR', 'vim')
|
|
# Create the content file if not exists
|
|
if not Path(f"{Config.CONTENT_DIR}/{filename}.md").exists():
|
|
create_content(filename)
|
|
filename = Path(f"{Config.CONTENT_DIR}/{filename}.md")
|
|
subprocess.call([editor, filename])
|
|
|
|
def init_site():
|
|
site = Site()
|
|
site.init_site()
|
|
|
|
def build_site():
|
|
site = Site()
|
|
site.build() |