diff --git a/.gitignore b/.gitignore index 76a0bf1..3a3bab4 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,42 @@ -_site -.sass-cache -Gemfile.lock +# Python +__pycache__/ +*.py[cod] +*$py.class +.pytest_cache/ + +# Jekyll +_site/ +.sass-cache/ +.jekyll-cache/ +.jekyll-metadata + +# Development environments +.env +.venv +venv/ +ENV/ + +# IDEs and editors +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# Dependency directories +node_modules/ +jspm_packages/ + +# Build output +dist/ +build/ + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Miscellaneous +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/__pycache__/test_update_post_authors.cpython-312-pytest-8.4.0.pyc b/__pycache__/test_update_post_authors.cpython-312-pytest-8.4.0.pyc new file mode 100644 index 0000000..6f64dd9 Binary files /dev/null and b/__pycache__/test_update_post_authors.cpython-312-pytest-8.4.0.pyc differ diff --git a/__pycache__/update_post_authors.cpython-312-pytest-8.4.0.pyc b/__pycache__/update_post_authors.cpython-312-pytest-8.4.0.pyc new file mode 100644 index 0000000..d0bad10 Binary files /dev/null and b/__pycache__/update_post_authors.cpython-312-pytest-8.4.0.pyc differ diff --git a/__pycache__/update_post_authors.cpython-312.pyc b/__pycache__/update_post_authors.cpython-312.pyc new file mode 100644 index 0000000..a25aa9e Binary files /dev/null and b/__pycache__/update_post_authors.cpython-312.pyc differ diff --git a/_config.yml b/_config.yml index be54b6e..d836082 100644 --- a/_config.yml +++ b/_config.yml @@ -2,6 +2,12 @@ baseurl: "/" # The subpath of your site. Use "" if you're hosting a blog at the url: "http://ellekasai.github.io" # the base hostname & protocol for your site title: "Co-Lab" +# Author configuration +author: + name: "Anonymous" + bio: "Default site author" + avatar: "/images/default-avatar.jpg" + # This is used by feed.xml. Uncomment if you want to use it. # description: "..." @@ -27,7 +33,8 @@ defaults: type: "posts" values: layout: "post" + author: "Anonymous" # Excerpt settings -excerpt_separator: -show_excerpts: true +excerpt_separator: " +show_excerpts: true \ No newline at end of file diff --git a/_layouts/post.html b/_layouts/post.html index cabc486..56b721e 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,46 +1,22 @@ --- layout: default --- - -
-

{{ page.title }}

- {% include post-header.html %} -
-
- {{ content }} -
-
- {% include post-footer.html %} -
-{% if site.data.theme.show_post_navs %} - {% if page.previous or page.next %} -
- {% if page.previous %} -
-

- Older - · - View Archive ({{ site.posts.size }}) -

-

{{ page.previous.title }}

- {% assign prev_excerpt = page.previous.content | replace: '_By Al Morris_', '' | replace: 'By Al Morris', '' | replace: '*By Al Morris*', '' | strip_html | truncatewords: 25 %} -

{{ prev_excerpt }}

-
- {% endif %} - {% if page.next %} -
-

- Newer - {% unless page.previous %} - · - View Archive ({{ site.posts.size }}) - {% endunless %} -

-

{{ page.next.title }}

- {% assign next_excerpt = page.next.content | replace: '_By Al Morris_', '' | replace: 'By Al Morris', '' | replace: '*By Al Morris*', '' | strip_html | truncatewords: 25 %} -

{{ next_excerpt }}

-
+
+
+

{{ page.title }}

+
- {% endif %} -{% endif %} +

+ + +
+ {{ content }} +
+ \ No newline at end of file diff --git a/test_update_post_authors.py b/test_update_post_authors.py new file mode 100644 index 0000000..35d3dcb --- /dev/null +++ b/test_update_post_authors.py @@ -0,0 +1,40 @@ +import os +import re +import unittest +from update_post_authors import update_post_frontmatter + +class TestPostAuthorUpdate(unittest.TestCase): + def setUp(self): + # Create a temporary test markdown file + self.test_file = '_posts/test_post.md' + with open(self.test_file, 'w') as f: + f.write('''--- +layout: post +title: Test Post +date: 2024-01-01 +--- +Test content''') + + def test_update_frontmatter(self): + update_post_frontmatter(self.test_file) + + # Read the updated file + with open(self.test_file, 'r') as f: + content = f.read() + + # Use regex to parse front matter + front_matter_match = re.match(r'^---\n(.*?\n)---', content, re.DOTALL) + self.assertIsNotNone(front_matter_match) + + front_matter = front_matter_match.group(1) + + # Check author is added + self.assertIn('author: Anonymous', front_matter) + + def tearDown(self): + # Remove test file + if os.path.exists(self.test_file): + os.remove(self.test_file) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/update_post_authors.py b/update_post_authors.py new file mode 100644 index 0000000..7ce1d49 --- /dev/null +++ b/update_post_authors.py @@ -0,0 +1,39 @@ +import os +import re + +def update_post_frontmatter(file_path): + with open(file_path, 'r') as f: + content = f.read() + + # Regex to handle front matter parsing + front_matter_match = re.match(r'^---\n(.*?\n)---', content, re.DOTALL) + + if front_matter_match: + front_matter = front_matter_match.group(1) + + # Check if author is already present + if 'author:' not in front_matter: + # Add author line + updated_front_matter = front_matter.rstrip() + '\nauthor: Anonymous\n' + + # Replace the original front matter + updated_content = re.sub( + r'^---\n.*?---', + f'---\n{updated_front_matter}---', + content, + flags=re.DOTALL + ) + + with open(file_path, 'w') as f: + f.write(updated_content) + print(f"Updated {file_path} with default author") + +def main(): + posts_dir = '_posts' + for filename in os.listdir(posts_dir): + if filename.endswith('.md'): + file_path = os.path.join(posts_dir, filename) + update_post_frontmatter(file_path) + +if __name__ == '__main__': + main() \ No newline at end of file