5 Commits

Author SHA1 Message Date
9caf08a277 changelog for v2.0.1
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2025-03-18 08:24:46 -05:00
8aabd93273 don't copy .files into the SSG output dir
they may be vim swap files and that kind of garbage

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2025-03-18 08:20:58 -05:00
6d7987cfae don't require the host to be in the Image tag
now that we know our base host via config, we can stop hardcoding it in
each Image tag

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2025-03-18 08:13:18 -05:00
abc05ee4e8 fix how my email address displays in gitea
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2025-03-17 13:22:30 -05:00
f623ffdd7c don't refer to my manual uploads now that I push to PyPI
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2025-03-17 13:13:25 -05:00
9 changed files with 40 additions and 6 deletions

View File

@@ -2,6 +2,14 @@
Included is a summary of changes to the project, by version. Details can be found in the commit history. Included is a summary of changes to the project, by version. Details can be found in the commit history.
## v2.0.1
### Improvements
* The `Image` tag in Markdown files no longer requires the full URL to be specified. Now `Config.BASE_HOST` is
prepended to the tag value, which should be the full path to the image.
* `.files` are skipped when copying files to the SSG output directory.
## v2.0.0 ## v2.0.0
### Features ### Features

View File

@@ -4,8 +4,7 @@ A lightweight static site generator for Markdown-based sites.
## Installation and Usage ## Installation and Usage
I recommend getting a release from <https://git.incorporeal.org/bss/incorporeal-cms/releases> and Something like the following should suffice:
installing the Python package in a virtualenv. Something like the following should suffice:
``` ```
% virtualenv --python=python3.9 env-py3.9 % virtualenv --python=python3.9 env-py3.9
@@ -53,7 +52,7 @@ out and discuss issues and features and whatnot.
## Author and Licensing ## Author and Licensing
Written by and copyright (C) 2025 Brian S. Stephan <bss@incorporeal.org>. Written by and copyright (C) 2025 Brian S. Stephan (bss@incorporeal.org).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -90,7 +90,7 @@ def handle_markdown_file_path(path: str) -> str:
return template.render(title=page_title, return template.render(title=page_title,
config=Config, config=Config,
description=get_meta_str(md, 'description'), description=get_meta_str(md, 'description'),
image=get_meta_str(md, 'image'), image=Config.BASE_HOST + get_meta_str(md, 'image'),
content=content, content=content,
base_url=Config.BASE_HOST + instance_resource_path_to_request_path(path), base_url=Config.BASE_HOST + instance_resource_path_to_request_path(path),
navs=parent_navs, navs=parent_navs,

View File

@@ -97,6 +97,9 @@ class StaticSiteGenerator(object):
# process and copy files # process and copy files
for file_ in files: for file_ in files:
if file_[0] == '.':
cprint(f"skipping {file_}", 'yellow')
continue
self.build_file_in_destination(source_dir, base_dir, file_, dest_dir, convert_markdown) self.build_file_in_destination(source_dir, base_dir, file_, dest_dir, convert_markdown)
def build_subdir_in_destination(self, source_dir: str, base_dir: str, subdir: str, dest_dir: str) -> None: def build_subdir_in_destination(self, source_dir: str, base_dir: str, subdir: str, dest_dir: str) -> None:

View File

@@ -5,9 +5,9 @@ SPDX-License-Identifier: GPL-3.0-only
<html lang="en"> <html lang="en">
<title>{{ title }}</title> <title>{{ title }}</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta property="og:url" content="{{ base_url }}">
{% if title %}<meta property="og:title" content="{{ title }}">{% endif %} {% if title %}<meta property="og:title" content="{{ title }}">{% endif %}
{% if description %}<meta property="og:description" content="{{ description }}">{% endif %} {% if description %}<meta property="og:description" content="{{ description }}">{% endif %}
<meta property="og:url" content="{{ base_url }}">
{% if image %}<meta property="og:image" content="{{ image }}">{% endif %} {% if image %}<meta property="og:image" content="{{ image }}">{% endif %}
<meta name="twitter:card" content="summary_large_image"> <meta name="twitter:card" content="summary_large_image">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">

View File

@@ -63,3 +63,16 @@ def test_figures_are_rendered():
'<span></span></figure>') in data '<span></span></figure>') in data
assert '<figure><img alt="just a logo" src="bss-square-no-bg.png" /></figure>' in data assert '<figure><img alt="just a logo" src="bss-square-no-bg.png" /></figure>' in data
os.chdir(HERE) os.chdir(HERE)
def test_og_image():
"""Test that the og:image meta tag is present as expected."""
with tempfile.TemporaryDirectory() as tmpdir:
src_dir = os.path.join(HERE, 'instance')
ssg = StaticSiteGenerator(src_dir, tmpdir)
os.chdir(os.path.join(src_dir, 'pages'))
ssg.build_file_in_destination(os.path.join(HERE, 'instance', 'pages'), '', 'more-metadata.md', tmpdir, True)
with open(os.path.join(tmpdir, 'more-metadata.html'), 'r') as graphviz_output:
data = graphviz_output.read()
assert ('<meta property="og:image" content="http://example.org/test.img') in data

View File

@@ -0,0 +1 @@
this is ignored

View File

@@ -1,6 +1,6 @@
Title: title for the page Title: title for the page
Description: description of this page Description: description of this page
made even longer made even longer
Image: http://buh.com/test.img Image: /test.img
hello hello

View File

@@ -88,3 +88,13 @@ def test_build_in_destination():
assert os.path.exists(os.path.join(tmpdir, 'index.html')) assert os.path.exists(os.path.join(tmpdir, 'index.html'))
assert os.path.exists(os.path.join(tmpdir, 'subdir', 'index.md')) assert os.path.exists(os.path.join(tmpdir, 'subdir', 'index.md'))
assert os.path.exists(os.path.join(tmpdir, 'subdir', 'index.html')) assert os.path.exists(os.path.join(tmpdir, 'subdir', 'index.html'))
def test_build_in_destination_ignores_dot_files():
"""Test the ability to walk a source and populate the destination."""
with tempfile.TemporaryDirectory() as tmpdir:
src_dir = os.path.join(HERE, 'instance')
generator = ssg.StaticSiteGenerator(src_dir, tmpdir)
generator.build_in_destination(os.path.join(src_dir, 'pages'), tmpdir)
assert not os.path.exists(os.path.join(tmpdir, '.ignored-file.md'))