diff --git a/CHANGELOG.md b/CHANGELOG.md index b37123f..562c71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,19 @@ ## [4.0.1] - ### Added - `python -m htmd` will now work +- `styles` block in `_layout.html` template +- `scripts` block in `_layout.html` template +- draft: build to add draft to build +- `preview --drafts` to view site as if all drafts are published ### Changed -- +- Ignore Frozen-Flask MissingURLGeneratorWarning +- `htmd preview` will reload when static files change +- Drafts will be served with /draft/ URL prefix ### Fixed - `htmd preview` will only serve pages - `htmd preview` will show 404 for authors that don't exist +- build draft without published +- errors when a config folder did not exist ## [4.0.0] - 2024-01-27 ### Added diff --git a/htmd/site.py b/htmd/site.py index 0aeb8c8..a874ee7 100644 --- a/htmd/site.py +++ b/htmd/site.py @@ -92,7 +92,9 @@ def get_project_dir() -> Path: app.config['FREEZER_DESTINATION'] = ( project_dir / app.config['BUILD_FOLDER'] ) -app.config['FREEZER_REMOVE_EXTRA_FILES'] = False +app.config['FREEZER_REMOVE_EXTRA_FILES'] = True +# Allow build to be version controlled +app.config['FREEZER_DESTINATION_IGNORE'] = ['.git*', '.hg*'] app.config['FLATPAGES_EXTENSION'] = app.config['POSTS_EXTENSION'] if Path(app.static_folder).is_dir(): diff --git a/tests/test_build.py b/tests/test_build.py index cf66fc9..8790261 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -6,7 +6,7 @@ from click.testing import CliRunner from htmd.cli import build -from utils import remove_fields_from_post, SUCCESS_REGEX +from utils import remove_fields_from_post, set_example_to_draft, SUCCESS_REGEX def test_build(run_start: CliRunner) -> None: @@ -234,3 +234,37 @@ def test_build_without_templates(run_start: CliRunner) -> None: result = run_start.invoke(build) assert result.exit_code == 0 assert re.search(SUCCESS_REGEX, result.output) + + +def test_build_drafts_removed_from_build(run_start: CliRunner) -> None: + path_list = [ + Path('build') / '2014' / 'index.html', + Path('build') / '2014' / '10' / 'index.html', + Path('build') / '2014' / '10' / '30' / 'index.html', + Path('build') / '2014' / '10' / '30' / 'example' / 'index.html', + ] + # create example post in build + run_start.invoke(build) + for path in path_list: + assert path.is_file() + + set_example_to_draft() + run_start.invoke(build) + for path in path_list: + assert path.is_file() is False + + +def test_build_vcs_repo(run_start: CliRunner) -> None: + path_list = [ + Path('build') / '.git', + Path('build') / '.hg', + ] + run_start.invoke(build) + for path in path_list: + path.mkdir() + with (path / 'keep').open('w') as keep_file: + keep_file.write('keep') + + run_start.invoke(build) + for path in path_list: + assert path.is_dir()