#!/usr/bin/env python3 """ Vite - A simple and minimal static site generator. """ import sys import pathlib import os import jinja2 import time import http.server import socketserver from markdown2 import markdown_path from huepy import * from distutils.dir_util import copy_tree from vite import vite try: sys.path.append(os.getcwd()) import config except FileNotFoundError: print(bad('Error: config.py not found')) # constants PAGES_PATH = 'pages/' BUILD_PATH = 'build/' TEMPL_PATH = 'templates/' TEMPL_FILE = TEMPL_PATH + config.template PORT = 1911 def create_project(path): try: abs_path = pathlib.Path(path).resolve() cur_path = pathlib.Path('.').resolve() os.makedirs(os.path.join(path, 'build')) os.mkdir(os.path.join(path, 'pages')) os.mkdir(os.path.join(path, 'templates')) os.mkdir(os.path.join(path, 'static')) create_config(path) os.symlink(os.path.join(cur_path, 'make.py'), os.path.join(abs_path, 'make.py')) create_template(path) print(good('Created project directory at %s.' % (abs_path))) except FileExistsError: print(bad('Error: specified path exists.')) def create_config(path): with open(os.path.join(path, 'config.py'), 'w') as f: f.write("""# config.py - Vite's configuration script title = '' author = '' header = '' footer = '' template = 'index.html' # default is index.html """) def create_template(path): with open(os.path.join(path, 'templates', 'index.html'), 'w') as f: f.write("""
{{ header }} {{ title }}
{{ body }}