Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent old files from being in the build #35

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion htmd/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
36 changes: 35 additions & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Loading