fix bugs in cli
This commit is contained in:
parent
eb1aac20c6
commit
2920ced903
|
@ -6,17 +6,19 @@ import sys
|
||||||
import typer
|
import typer
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
|
import site_tools as st
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from livereload import Server
|
from livereload import Server
|
||||||
from pelican import main as pelican_main
|
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
|
from site_tools.content_manager import create
|
||||||
|
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
'settings_base': DEV_SETTINGS_FILE_BASE,
|
'settings_base': st.DEV_SETTINGS_FILE_BASE,
|
||||||
'settings_publish': PUB_SETTINGS_FILE_BASE,
|
'settings_publish': st.PUB_SETTINGS_FILE_BASE,
|
||||||
# Output path. Can be absolute or relative to tasks.py. Default: 'output'
|
# 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
|
# Remote server configuration
|
||||||
'ssh_user': 'greg',
|
'ssh_user': 'greg',
|
||||||
'ssh_host': 'froghat.club',
|
'ssh_host': 'froghat.club',
|
||||||
|
@ -69,7 +71,7 @@ def serve() -> None:
|
||||||
clean()
|
clean()
|
||||||
cached_build()
|
cached_build()
|
||||||
server = Server()
|
server = Server()
|
||||||
theme_path = SETTINGS['THEME']
|
theme_path = st.SETTINGS['THEME']
|
||||||
watched_globs = [
|
watched_globs = [
|
||||||
CONFIG['settings_base'],
|
CONFIG['settings_base'],
|
||||||
'{}/templates/**/*.html'.format(theme_path),
|
'{}/templates/**/*.html'.format(theme_path),
|
||||||
|
@ -77,7 +79,7 @@ def serve() -> None:
|
||||||
|
|
||||||
content_file_extensions = ['.md', '.rst']
|
content_file_extensions = ['.md', '.rst']
|
||||||
for extension in content_file_extensions:
|
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)
|
watched_globs.append(content_glob)
|
||||||
|
|
||||||
static_file_extensions = ['.css', '.js']
|
static_file_extensions = ['.css', '.js']
|
||||||
|
@ -88,7 +90,7 @@ def serve() -> None:
|
||||||
for glob in watched_globs:
|
for glob in watched_globs:
|
||||||
server.watch(glob, cached_build)
|
server.watch(glob, cached_build)
|
||||||
|
|
||||||
if OPEN_BROWSER_ON_SERVE:
|
if st.OPEN_BROWSER_ON_SERVE:
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
|
||||||
server.serve(host=CONFIG['host'], port=CONFIG['port'],
|
server.serve(host=CONFIG['host'], port=CONFIG['port'],
|
||||||
|
@ -143,8 +145,8 @@ def new(
|
||||||
category = 'regions'
|
category = 'regions'
|
||||||
case _:
|
case _:
|
||||||
category = content_type
|
category = content_type
|
||||||
click.edit(filename=create(content_type, title, template_dir, category,
|
click.edit(filename=create(content_type.value, title, template_dir,
|
||||||
template or content_type))
|
category, template or content_type.value))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -11,7 +11,7 @@ def create(content_type: str, title: str, template_dir: str,
|
||||||
"""
|
"""
|
||||||
Return the path to a new source file.
|
Return the path to a new source file.
|
||||||
"""
|
"""
|
||||||
base_path = Path(__file__).parent.absolute()
|
base_path = Path.cwd()
|
||||||
|
|
||||||
def _slugify(s):
|
def _slugify(s):
|
||||||
return slugify(s, regex_subs=SETTINGS['SLUG_REGEX_SUBSTITUTIONS'])
|
return slugify(s, regex_subs=SETTINGS['SLUG_REGEX_SUBSTITUTIONS'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user