예제 #1
0
def generate_custom_pages(rel_dir_path='.'):
    """
    Generate custom pages
    """
    dir_path = os.path.join('pages', rel_dir_path)
    os.makedirs(os.path.join(_deploy_dir, rel_dir_path), exist_ok=True)
    for file in os.listdir(dir_path):
        if file.startswith('.'):
            # is hidden file
            continue

        if os.path.isdir(os.path.join(dir_path, file)):
            generate_custom_pages(os.path.join(rel_dir_path, file))
            continue

        rel_file_path = os.path.join(rel_dir_path, file)
        filename, ext = os.path.splitext(rel_file_path)
        if ext == '.md' or ext == '.markdown':
            # is markdown file, need render
            rel_file_path = '.'.join((filename, 'html'))
            with open(os.path.join(_deploy_dir, rel_file_path), 'w', encoding='utf-8') as f:
                f.write(
                    handler.custom_page('/'.join(os.path.split(rel_file_path)).replace('./', '')))
        else:
            # is common static file, just copy
            shutil.copy(os.path.join('pages', rel_file_path),
                        os.path.join(_deploy_dir, rel_file_path))
예제 #2
0
def generate_custom_pages(rel_dir_path='.'):
    """
    Generate custom pages
    """
    dir_path = os.path.join('pages', rel_dir_path)
    os.makedirs(os.path.join(_deploy_dir, rel_dir_path), exist_ok=True)
    for file in os.listdir(dir_path):
        if file.startswith('.'):
            # is hidden file
            continue

        if os.path.isdir(os.path.join(dir_path, file)):
            generate_custom_pages(os.path.join(rel_dir_path, file))
            continue

        rel_file_path = os.path.join(rel_dir_path, file)
        filename, ext = os.path.splitext(rel_file_path)
        if ext == '.md' or ext == '.markdown':
            # is markdown file, need render
            rel_file_path = '.'.join((filename, 'html'))
            with open(os.path.join(_deploy_dir, rel_file_path), 'w', encoding='utf-8') as f:
                f.write(
                    handler.custom_page('/'.join(os.path.split(rel_file_path)).replace('./', '')))
        else:
            # is common static file, just copy
            shutil.copy(os.path.join('pages', rel_file_path),
                        os.path.join(_deploy_dir, rel_file_path))
예제 #3
0
파일: app.py 프로젝트: cuteluo1983/blog-a
def custom_page(custom_page_path):
    return handler.custom_page(custom_page_path)
예제 #4
0
파일: app.py 프로젝트: BlogTANG/blog-a
def custom_page(custom_page_path):
    return handler.custom_page(custom_page_path)