From 2920ced903eefe989b6041c8632de5b6fbc16c67 Mon Sep 17 00:00:00 2001 From: evilchili Date: Tue, 2 Aug 2022 22:49:01 -0700 Subject: [PATCH] fix bugs in cli --- deadsands/site_tools/cli.py | 20 +++++++++++--------- deadsands/site_tools/content_manager.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/deadsands/site_tools/cli.py b/deadsands/site_tools/cli.py index 470fea4..92dc618 100644 --- a/deadsands/site_tools/cli.py +++ b/deadsands/site_tools/cli.py @@ -6,17 +6,19 @@ import sys import typer import webbrowser +import site_tools as st + from enum import Enum from livereload import Server from pelican import main as pelican_main -from site_tools import SETTINGS, DEV_SETTINGS_FILE_BASE, PUB_SETTINGS_FILE_BASE from site_tools.content_manager import create + CONFIG = { - 'settings_base': DEV_SETTINGS_FILE_BASE, - 'settings_publish': PUB_SETTINGS_FILE_BASE, + 'settings_base': st.DEV_SETTINGS_FILE_BASE, + 'settings_publish': st.PUB_SETTINGS_FILE_BASE, # Output path. Can be absolute or relative to tasks.py. Default: 'output' - 'deploy_path': SETTINGS['OUTPUT_PATH'], + 'deploy_path': st.SETTINGS['OUTPUT_PATH'], # Remote server configuration 'ssh_user': 'greg', 'ssh_host': 'froghat.club', @@ -69,7 +71,7 @@ def serve() -> None: clean() cached_build() server = Server() - theme_path = SETTINGS['THEME'] + theme_path = st.SETTINGS['THEME'] watched_globs = [ CONFIG['settings_base'], '{}/templates/**/*.html'.format(theme_path), @@ -77,7 +79,7 @@ def serve() -> None: content_file_extensions = ['.md', '.rst'] for extension in content_file_extensions: - content_glob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension) + content_glob = '{0}/**/*{1}'.format(st.SETTINGS['PATH'], extension) watched_globs.append(content_glob) static_file_extensions = ['.css', '.js'] @@ -88,7 +90,7 @@ def serve() -> None: for glob in watched_globs: server.watch(glob, cached_build) - if OPEN_BROWSER_ON_SERVE: + if st.OPEN_BROWSER_ON_SERVE: webbrowser.open(url) server.serve(host=CONFIG['host'], port=CONFIG['port'], @@ -143,8 +145,8 @@ def new( category = 'regions' case _: category = content_type - click.edit(filename=create(content_type, title, template_dir, category, - template or content_type)) + click.edit(filename=create(content_type.value, title, template_dir, + category, template or content_type.value)) if __name__ == '__main__': diff --git a/deadsands/site_tools/content_manager.py b/deadsands/site_tools/content_manager.py index e9724df..e2cdc6d 100644 --- a/deadsands/site_tools/content_manager.py +++ b/deadsands/site_tools/content_manager.py @@ -11,7 +11,7 @@ def create(content_type: str, title: str, template_dir: str, """ Return the path to a new source file. """ - base_path = Path(__file__).parent.absolute() + base_path = Path.cwd() def _slugify(s): return slugify(s, regex_subs=SETTINGS['SLUG_REGEX_SUBSTITUTIONS'])