From 4637c8b492aaeb8eee6bede3e13b4e84a6778896 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 9 Oct 2025 19:50:00 +0200 Subject: [PATCH 01/15] CHANGE example for static file and add new post for documentation --- items/2025-10-09_short_features.md | 11 ++ static/LICENSE | 202 +++++++++++++++++++++++++++++ static/pubkey.asc | 6 - 3 files changed, 213 insertions(+), 6 deletions(-) create mode 100644 items/2025-10-09_short_features.md create mode 100644 static/LICENSE delete mode 100644 static/pubkey.asc diff --git a/items/2025-10-09_short_features.md b/items/2025-10-09_short_features.md new file mode 100644 index 0000000..ee6254c --- /dev/null +++ b/items/2025-10-09_short_features.md @@ -0,0 +1,11 @@ +# Features + +- Simple - easy to understand and modify +- Posts for short and long-form content + pages like [/about/](/about/) +- theming +- separate feeds like [/feed/tutorial/](/feed/tutorial/) +- excluding feeds in config file like [/feed/draft/](/feed/draft/) +- static files like [/LICENSE](/LICENSE) + +Everything is **[open-source](https://git.uphillsecurity.com/cf7/picopaper)**! + diff --git a/static/LICENSE b/static/LICENSE new file mode 100644 index 0000000..2b146bc --- /dev/null +++ b/static/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/static/pubkey.asc b/static/pubkey.asc deleted file mode 100644 index 279d5f8..0000000 --- a/static/pubkey.asc +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -Example GPG public key file -This file will be copied as-is to the output directory - ------END PGP PUBLIC KEY BLOCK----- From 6d574b386de80e7bcdcaa444af45b2ce1a7a0a87 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 9 Oct 2025 19:59:07 +0200 Subject: [PATCH 02/15] ADD reference to demo instance #4 - picopaper.com --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 674b16a..e07faba 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ A minimal static site generator for blogs built with Python 3 and Jinja2 - Status: alpha - expect many changes - Goals: keeping it simple and easy to understand -- Demo: +- Demo: [picopaper.com](https://picopaper.com/) Show cases: +- [securitypending.com](https://securitypending.com/) --- From e0a9427307b5b4f049dae36292c10de3f34f7bfa Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Sat, 11 Oct 2025 21:54:54 +0200 Subject: [PATCH 03/15] ADD image and hr design --- theme/default/assets/style.css | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/theme/default/assets/style.css b/theme/default/assets/style.css index fb77f82..1663aa4 100644 --- a/theme/default/assets/style.css +++ b/theme/default/assets/style.css @@ -14,6 +14,14 @@ header { border-radius: 10px; } +img { + max-width: 100%; +} + +hr { + border: 1px solid #efefef; +} + h1 { margin: 0; } .blog-description { @@ -25,8 +33,6 @@ h1 { margin: 0; } .main-nav { margin-top: 15px; font-weight: bold; - display: flex; - gap: 10px; } .nav-item { From a08a7f537e0c5e4ca826ece1f4dcfc21cca35bff Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Mon, 13 Oct 2025 01:09:57 +0200 Subject: [PATCH 04/15] #11 ADD page creation for SHORT and links in main feed --- picopaper.py | 4 ++-- theme/default/templates/index.tmpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/picopaper.py b/picopaper.py index b7d5407..b3d69ff 100644 --- a/picopaper.py +++ b/picopaper.py @@ -211,9 +211,9 @@ class SSGGGenerator: for feed_name, posts in feeds.items(): self.generate_index(posts, feed_name) - # Generate individual pages for long posts and pages + # Generate individual pages for long posts, short posts, and pages for post in all_posts: - if post['type'] in ['long', 'page']: + if post['type'] in ['long', 'short', 'page']: self.generate_post_page(post) # Copy assets diff --git a/theme/default/templates/index.tmpl b/theme/default/templates/index.tmpl index 2519d4b..f1c1e01 100644 --- a/theme/default/templates/index.tmpl +++ b/theme/default/templates/index.tmpl @@ -11,7 +11,7 @@

- {% if post.type == 'long' %} + {% if post.type in ['long', 'short'] %} {{ post.title }} {% else %} {{ post.title }} From ae123ffe804fc56851f823bcc32460abaa3b130e Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Mon, 13 Oct 2025 01:23:29 +0200 Subject: [PATCH 05/15] #9 - ADD automated anchors for headers - toc module for IDs and slugified header with python + ADD dummy content for display --- ...-10-06_long_your-first-article_tutorial.md | 12 +++++++++++ picopaper.py | 21 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/items/2025-10-06_long_your-first-article_tutorial.md b/items/2025-10-06_long_your-first-article_tutorial.md index 7a08a85..4a63b0e 100644 --- a/items/2025-10-06_long_your-first-article_tutorial.md +++ b/items/2025-10-06_long_your-first-article_tutorial.md @@ -3,3 +3,15 @@ This is a `long` form articles. In the main feed, it is a simple link to the rest of the content. Please check the [official documentation](https://git.uphillsecurity.com/cf7/picopaper) for more details. + +## This is a secondary header + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Massa porta accumsan eros aliquet consequat elit tincidunt imperdiet in adipiscing diam integer risus. Dapibus bibendum adipiscing rhoncus parturient fusce ultrices in accumsan phasellus tempus est senectus felis. Donec placerat porta lobortis magna consectetur hac pretium eleifend tempor cum nulla fusce aliquet. + +Primis amet nullam dictum ridiculus neque ipsum elit volutpat mauris posuere pellentesque euismod felis. Cum nunc ullamcorper dictum metus maecenas accumsan elit purus convallis vulputate mauris sollicitudin diam. Diam iaculis aliquet eleifend sociosqu nostra massa malesuada feugiat sit penatibus dolor montes purus. Porta vulputate dictumst sodales dolor ad euismod consequat interdum mus porttitor erat torquent consequat. + +## Third header + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Massa porta accumsan eros aliquet consequat elit tincidunt imperdiet in adipiscing diam integer risus. Dapibus bibendum adipiscing rhoncus parturient fusce ultrices in accumsan phasellus tempus est senectus felis. Donec placerat porta lobortis magna consectetur hac pretium eleifend tempor cum nulla fusce aliquet. + +Primis amet nullam dictum ridiculus neque ipsum elit volutpat mauris posuere pellentesque euismod felis. Cum nunc ullamcorper dictum metus maecenas accumsan elit purus convallis vulputate mauris sollicitudin diam. Diam iaculis aliquet eleifend sociosqu nostra massa malesuada feugiat sit penatibus dolor montes purus. Porta vulputate dictumst sodales dolor ad euismod consequat interdum mus porttitor erat torquent consequat. diff --git a/picopaper.py b/picopaper.py index b3d69ff..6b5f389 100644 --- a/picopaper.py +++ b/picopaper.py @@ -24,8 +24,8 @@ class SSGGGenerator: # Setup Jinja2 self.env = Environment(loader=FileSystemLoader(self.templates_dir)) - # Setup markdown - self.md = markdown.Markdown(extensions=['extra']) + # Setup markdown with toc extension for header anchors + self.md = markdown.Markdown(extensions=['extra', 'toc']) def parse_filename(self, filename): """Parse filename format: YYYY-MM-DD_type_name[_feed].md""" @@ -47,6 +47,20 @@ class SSGGGenerator: 'filename': filename } + def add_header_anchors(self, html_content): + """Add anchor links to headers with IDs""" + # Pattern to match headers with id attributes:

Text

+ def replace_header(match): + tag = match.group(1) + header_id = match.group(2) + text = match.group(3) + # Add anchor link with # symbol + return f'<{tag} id="{header_id}">{text} #' + + # Match h2-h6 tags with id attributes + pattern = r'<(h[2-6]) id="([^"]+)">([^<]+)<\/\1>' + return re.sub(pattern, replace_header, html_content) + def read_post(self, filepath): """Read markdown file and extract title and content""" with open(filepath, 'r', encoding='utf-8') as f: @@ -63,6 +77,9 @@ class SSGGGenerator: # Convert markdown to HTML html_content = self.md.convert(content) + # Add anchor links to headers + html_content = self.add_header_anchors(html_content) + return title, html_content def collect_posts(self): From 980392c51942d863ae0d4b8e501d50a24561c77e Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Mon, 13 Oct 2025 01:27:39 +0200 Subject: [PATCH 06/15] CHANGE examples for headers + ADD information to features list --- README.md | 1 + items/2025-10-06_long_your-first-article_tutorial.md | 4 ++-- items/2025-10-09_short_features.md | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e07faba..1f79def 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Show cases: - Static files - separate feeds (used for categories, tagging, etc) `/feed/{tag}` - exclusion of feeds from main feed (drafts or system notes) +- HTML anchors for headers **Ideas**: - RSS diff --git a/items/2025-10-06_long_your-first-article_tutorial.md b/items/2025-10-06_long_your-first-article_tutorial.md index 4a63b0e..0187ff1 100644 --- a/items/2025-10-06_long_your-first-article_tutorial.md +++ b/items/2025-10-06_long_your-first-article_tutorial.md @@ -4,13 +4,13 @@ This is a `long` form articles. In the main feed, it is a simple link to the res Please check the [official documentation](https://git.uphillsecurity.com/cf7/picopaper) for more details. -## This is a secondary header +## Second Header Lorem ipsum dolor sit amet, consectetur adipiscing elit. Massa porta accumsan eros aliquet consequat elit tincidunt imperdiet in adipiscing diam integer risus. Dapibus bibendum adipiscing rhoncus parturient fusce ultrices in accumsan phasellus tempus est senectus felis. Donec placerat porta lobortis magna consectetur hac pretium eleifend tempor cum nulla fusce aliquet. Primis amet nullam dictum ridiculus neque ipsum elit volutpat mauris posuere pellentesque euismod felis. Cum nunc ullamcorper dictum metus maecenas accumsan elit purus convallis vulputate mauris sollicitudin diam. Diam iaculis aliquet eleifend sociosqu nostra massa malesuada feugiat sit penatibus dolor montes purus. Porta vulputate dictumst sodales dolor ad euismod consequat interdum mus porttitor erat torquent consequat. -## Third header +## Third Header Lorem ipsum dolor sit amet, consectetur adipiscing elit. Massa porta accumsan eros aliquet consequat elit tincidunt imperdiet in adipiscing diam integer risus. Dapibus bibendum adipiscing rhoncus parturient fusce ultrices in accumsan phasellus tempus est senectus felis. Donec placerat porta lobortis magna consectetur hac pretium eleifend tempor cum nulla fusce aliquet. diff --git a/items/2025-10-09_short_features.md b/items/2025-10-09_short_features.md index ee6254c..e521d99 100644 --- a/items/2025-10-09_short_features.md +++ b/items/2025-10-09_short_features.md @@ -6,6 +6,7 @@ - separate feeds like [/feed/tutorial/](/feed/tutorial/) - excluding feeds in config file like [/feed/draft/](/feed/draft/) - static files like [/LICENSE](/LICENSE) +- html anchors for headers like [#second-header](/your-first-article/#second-header) Everything is **[open-source](https://git.uphillsecurity.com/cf7/picopaper)**! From f369431c0f224bb7df600766c6e4bc5c0c3422e1 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Sun, 19 Oct 2025 01:53:21 +0200 Subject: [PATCH 07/15] CHANGE README to reference GH mirror and info about issue tracker --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 1f79def..1c00d7e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ A minimal static site generator for blogs built with Python 3 and Jinja2 - Status: alpha - expect many changes +- [Issue Tracker](https://git.uphillsecurity.com/cf7/picopaper/issues) - Goals: keeping it simple and easy to understand - Demo: [picopaper.com](https://picopaper.com/) @@ -157,6 +158,12 @@ To switch themes, change the `THEME` setting in `config.py` --- +## Notes + +- [Github Mirror](https://github.com/CaffeineFueled1/picopaper) + +--- + ## Security For security concerns or reports, please contact via `hello a t uphillsecurity d o t com` [gpg](https://uphillsecurity.com/gpg). From 581563e9e0200b214cf9b83010f5b01a4ac49100 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Mon, 20 Oct 2025 16:51:48 +0200 Subject: [PATCH 08/15] FIX posts path error in feeds #15 --- picopaper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/picopaper.py b/picopaper.py index 6b5f389..bd5f046 100644 --- a/picopaper.py +++ b/picopaper.py @@ -106,7 +106,7 @@ class SSGGGenerator: 'title': title, 'content': content, 'slug': parsed['name'], - 'url': f"{parsed['name']}/", + 'url': f"/{parsed['name']}/", 'feed': parsed['feed'], 'source': filepath.name } From af2f80032179d45a68d7239c1a850415eec80a91 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Mon, 20 Oct 2025 17:03:11 +0200 Subject: [PATCH 09/15] ADD /feed/ overview with counters #5 --- picopaper.py | 34 ++++++++++++++++++++++++++++++ theme/default/templates/feeds.tmpl | 20 ++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 theme/default/templates/feeds.tmpl diff --git a/picopaper.py b/picopaper.py index bd5f046..7576a38 100644 --- a/picopaper.py +++ b/picopaper.py @@ -143,6 +143,36 @@ class SSGGGenerator: print(f"✓ Generated {output_path}") + def generate_feeds_overview(self, feeds): + """Generate /feed/index.html with list of all non-excluded feeds""" + template = self.env.get_template('feeds.tmpl') + + # Prepare feed data with counts, excluding feeds in EXCLUDE_FEEDS_FROM_MAIN + feed_list = [] + for feed_name, posts in sorted(feeds.items()): + if feed_name not in self.exclude_feeds: + feed_list.append({ + 'name': feed_name, + 'count': len(posts) + }) + + title = f"Feeds - {self.blog_title}" + output_path = self.output_dir / 'feed' / 'index.html' + + html = template.render( + title=title, + blog_title=self.blog_title, + blog_description=self.blog_description, + navbar_items=self.navbar_items, + feeds=feed_list + ) + + output_path.parent.mkdir(parents=True, exist_ok=True) + with open(output_path, 'w', encoding='utf-8') as f: + f.write(html) + + print(f"✓ Generated {output_path}") + def generate_post_page(self, post): """Generate individual post page for 'long' posts""" template = self.env.get_template('post.tmpl') @@ -228,6 +258,10 @@ class SSGGGenerator: for feed_name, posts in feeds.items(): self.generate_index(posts, feed_name) + # Generate feeds overview page + if feeds: + self.generate_feeds_overview(feeds) + # Generate individual pages for long posts, short posts, and pages for post in all_posts: if post['type'] in ['long', 'short', 'page']: diff --git a/theme/default/templates/feeds.tmpl b/theme/default/templates/feeds.tmpl new file mode 100644 index 0000000..c03aae7 --- /dev/null +++ b/theme/default/templates/feeds.tmpl @@ -0,0 +1,20 @@ + + + + {% include 'meta.tmpl' %} + + + {% include 'header.tmpl' %} + +
+

Feeds

+
    + {% for feed in feeds %} +
  • {{ feed.name }} ({{ feed.count }} posts)
  • + {% endfor %} +
+
+ + {% include 'footer.tmpl' %} + + From 1b8f77cb4b9179837f465e33acdfd72316c32abc Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 23 Oct 2025 22:41:36 +0200 Subject: [PATCH 10/15] ADD feature 5 random posts at the end of a post #17 --- picopaper.py | 31 +++++++++++++++-------- theme/default/templates/post.tmpl | 2 ++ theme/default/templates/random_posts.tmpl | 23 +++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 theme/default/templates/random_posts.tmpl diff --git a/picopaper.py b/picopaper.py index 7576a38..f9184a1 100644 --- a/picopaper.py +++ b/picopaper.py @@ -24,6 +24,14 @@ class SSGGGenerator: # Setup Jinja2 self.env = Environment(loader=FileSystemLoader(self.templates_dir)) + # Add custom filter for random sampling + def random_sample(items, count): + import random + items_list = list(items) + return random.sample(items_list, min(count, len(items_list))) + + self.env.filters['random_sample'] = random_sample + # Setup markdown with toc extension for header anchors self.md = markdown.Markdown(extensions=['extra', 'toc']) @@ -118,7 +126,7 @@ class SSGGGenerator: return posts - def generate_index(self, posts, feed_name=None): + def generate_index(self, posts, feed_name=None, all_posts=None): """Generate index.html with all posts (or feed-specific index)""" template = self.env.get_template('index.tmpl') @@ -134,7 +142,8 @@ class SSGGGenerator: blog_title=self.blog_title, blog_description=self.blog_description, navbar_items=self.navbar_items, - posts=posts + posts=posts, + all_posts=all_posts or posts ) output_path.parent.mkdir(parents=True, exist_ok=True) @@ -143,7 +152,7 @@ class SSGGGenerator: print(f"✓ Generated {output_path}") - def generate_feeds_overview(self, feeds): + def generate_feeds_overview(self, feeds, all_posts=None): """Generate /feed/index.html with list of all non-excluded feeds""" template = self.env.get_template('feeds.tmpl') @@ -164,7 +173,8 @@ class SSGGGenerator: blog_title=self.blog_title, blog_description=self.blog_description, navbar_items=self.navbar_items, - feeds=feed_list + feeds=feed_list, + all_posts=all_posts or [] ) output_path.parent.mkdir(parents=True, exist_ok=True) @@ -173,7 +183,7 @@ class SSGGGenerator: print(f"✓ Generated {output_path}") - def generate_post_page(self, post): + def generate_post_page(self, post, all_posts=None): """Generate individual post page for 'long' posts""" template = self.env.get_template('post.tmpl') @@ -182,7 +192,8 @@ class SSGGGenerator: blog_title=self.blog_title, blog_description=self.blog_description, navbar_items=self.navbar_items, - post=post + post=post, + all_posts=all_posts or [] ) # Create directory for the post slug @@ -246,7 +257,7 @@ class SSGGGenerator: and p['feed'] not in self.exclude_feeds] # Generate main index with filtered feed posts - self.generate_index(feed_posts) + self.generate_index(feed_posts, all_posts=feed_posts) # Group posts by feed (include all posts, not just those in main feed) feeds = {} @@ -256,16 +267,16 @@ class SSGGGenerator: # Generate feed-specific pages for feed_name, posts in feeds.items(): - self.generate_index(posts, feed_name) + self.generate_index(posts, feed_name, all_posts=feed_posts) # Generate feeds overview page if feeds: - self.generate_feeds_overview(feeds) + self.generate_feeds_overview(feeds, all_posts=feed_posts) # Generate individual pages for long posts, short posts, and pages for post in all_posts: if post['type'] in ['long', 'short', 'page']: - self.generate_post_page(post) + self.generate_post_page(post, all_posts=feed_posts) # Copy assets self.copy_assets() diff --git a/theme/default/templates/post.tmpl b/theme/default/templates/post.tmpl index d1573bd..9191071 100644 --- a/theme/default/templates/post.tmpl +++ b/theme/default/templates/post.tmpl @@ -14,6 +14,8 @@ {{ post.content | safe }}

+ + {% include 'random_posts.tmpl' %} {% include 'footer.tmpl' %} diff --git a/theme/default/templates/random_posts.tmpl b/theme/default/templates/random_posts.tmpl new file mode 100644 index 0000000..f75e2f0 --- /dev/null +++ b/theme/default/templates/random_posts.tmpl @@ -0,0 +1,23 @@ +{% if all_posts %} +{# Filter out pages and current post, then randomly select 5 #} +{% set available_posts = all_posts | selectattr('type', 'ne', 'page') | list %} +{% if post %} + {% set available_posts = available_posts | rejectattr('slug', 'equalto', post.slug) | list %} +{% endif %} +{% if available_posts %} + {% set random_posts = available_posts | random_sample(5) %} + {% if random_posts %} +
+

More Posts

+
    + {% for p in random_posts %} +
  • + {{ p.title }} + {{ p.date }} +
  • + {% endfor %} +
+
+ {% endif %} +{% endif %} +{% endif %} From eb0f4cf5a5e19e7e574d451c0b927a8987491ca1 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 23 Oct 2025 22:44:13 +0200 Subject: [PATCH 11/15] ADD documentation of #17 --- README.md | 1 + items/2025-10-09_short_features.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 1c00d7e..e72c317 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Show cases: - separate feeds (used for categories, tagging, etc) `/feed/{tag}` - exclusion of feeds from main feed (drafts or system notes) - HTML anchors for headers +- list random posts at the bottom **Ideas**: - RSS diff --git a/items/2025-10-09_short_features.md b/items/2025-10-09_short_features.md index e521d99..78dffec 100644 --- a/items/2025-10-09_short_features.md +++ b/items/2025-10-09_short_features.md @@ -7,6 +7,7 @@ - excluding feeds in config file like [/feed/draft/](/feed/draft/) - static files like [/LICENSE](/LICENSE) - html anchors for headers like [#second-header](/your-first-article/#second-header) +- show random posts at the end of the page Everything is **[open-source](https://git.uphillsecurity.com/cf7/picopaper)**! From cc1cc4639cd4d1fd45afe7deb4245f62422f044b Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 23 Oct 2025 22:46:58 +0200 Subject: [PATCH 12/15] ADD /feed/ to navbar #16 --- config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config.py b/config.py index b7976d8..3f23cdb 100644 --- a/config.py +++ b/config.py @@ -10,6 +10,7 @@ EXCLUDE_FEEDS_FROM_MAIN = ['draft','private'] # e.g., ['python', 'drafts'] # Navigation bar items - list of dictionaries with 'text' and 'url' keys NAVBAR_ITEMS = [ {'text': 'Home', 'url': '/'}, + {'text': 'Feeds', 'url': '/feed/'}, {'text': 'About', 'url': '/about/'} ] From b623e17c5a5057858b614215a6cd3ae97d6423c8 Mon Sep 17 00:00:00 2001 From: CaffeineFueled Date: Thu, 23 Oct 2025 23:44:24 +0200 Subject: [PATCH 13/15] ADD Logo configuration for the header #14 --- config.py | 7 ++++++- images/logo.png | Bin 0 -> 4505 bytes picopaper.py | 20 ++++++++++++++++---- theme/default/assets/style.css | 13 ++++++++++++- theme/default/templates/header.tmpl | 11 ++++++++++- 5 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 images/logo.png diff --git a/config.py b/config.py index 3f23cdb..2f193d3 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,6 @@ """Configuration file for picopaper blog""" -BLOG_TITLE = "picopaper" +BLOG_TITLE = "PicoPaper.com" BLOG_DESCRIPTION = "we like simple." THEME = "default" @@ -14,3 +14,8 @@ NAVBAR_ITEMS = [ {'text': 'About', 'url': '/about/'} ] +# Logo settings +HIDE_LOGO = False +HIDE_TITLE = True +LOGO_PATH = "/images/logo.png" + diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..5f0057581acbe1155cc3f9f5bae1a3a34704fc5e GIT binary patch literal 4505 zcmZu!cQjmG*S`j%GrAdV#2|?1ofs{Kh#tKMi4vj(Q8Ky^$si%hkSBW7WH5*zf{=I! zQAcN@M~hy+dA@h8cfITT-o4g6ckkc%oqhJ*d;f9wQxhXS23i;`000d7C>=A>yXT*W znw+%eBsf+A0BFy|&_Y-5p&d_x4bjs66SI(z(0?A;+uI|VRaI3{QBfp?bkXkaE*_8n zHzyz7;0zo11B9Xq5g}-oAZHB41u!0)dyf!ONqgBV%J@QBhHnD?lOi&6_vf-Q9zO zgW1{HJ3BjMWMrgtk$7Z(?ol$6ZP z%{4GE=UhyNEIZd_wL=hs;a6@ zO-&UQ6`r1+q+)e;cFN1klM;?bqo<~(A|oR`JUmFHX>V^24-Z#XRwmW)pUxqtuBoX} zS66p;cVAmu1H@fO>7AXO1+=pOT26qT4}geBNJ#MV@&d*3 zo(>ULv`6u`?LCiR6N75=hd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184a1..700bc67 100644 --- a/picopaper.py +++ b/picopaper.py @@ -6,7 +6,7 @@ from datetime import datetime from pathlib import Path from jinja2 import Environment, FileSystemLoader import markdown -from config import BLOG_TITLE, BLOG_DESCRIPTION, THEME, EXCLUDE_FEEDS_FROM_MAIN, NAVBAR_ITEMS +from config import BLOG_TITLE, BLOG_DESCRIPTION, THEME, EXCLUDE_FEEDS_FROM_MAIN, NAVBAR_ITEMS, HIDE_LOGO, HIDE_TITLE, LOGO_PATH class SSGGGenerator: def __init__(self, items_dir='items', output_dir='output', theme=None, blog_title=None, blog_description=None): @@ -20,6 +20,9 @@ class SSGGGenerator: self.blog_description = blog_description or BLOG_DESCRIPTION self.exclude_feeds = EXCLUDE_FEEDS_FROM_MAIN self.navbar_items = NAVBAR_ITEMS + self.hide_logo = HIDE_LOGO + self.hide_title = HIDE_TITLE + self.logo_path = LOGO_PATH # Setup Jinja2 self.env = Environment(loader=FileSystemLoader(self.templates_dir)) @@ -143,7 +146,10 @@ class SSGGGenerator: blog_description=self.blog_description, navbar_items=self.navbar_items, posts=posts, - all_posts=all_posts or posts + all_posts=all_posts or posts, + hide_logo=self.hide_logo, + hide_title=self.hide_title, + logo_path=self.logo_path ) output_path.parent.mkdir(parents=True, exist_ok=True) @@ -174,7 +180,10 @@ class SSGGGenerator: blog_description=self.blog_description, navbar_items=self.navbar_items, feeds=feed_list, - all_posts=all_posts or [] + all_posts=all_posts or [], + hide_logo=self.hide_logo, + hide_title=self.hide_title, + logo_path=self.logo_path ) output_path.parent.mkdir(parents=True, exist_ok=True) @@ -193,7 +202,10 @@ class SSGGGenerator: blog_description=self.blog_description, navbar_items=self.navbar_items, post=post, - all_posts=all_posts or [] + all_posts=all_posts or [], + hide_logo=self.hide_logo, + hide_title=self.hide_title, + logo_path=self.logo_path ) # Create directory for the post slug diff --git a/theme/default/assets/style.css b/theme/default/assets/style.css index 1663aa4..9b276fc 100644 --- a/theme/default/assets/style.css +++ b/theme/default/assets/style.css @@ -12,6 +12,7 @@ header { padding: 20px; margin-bottom: 40px; border-radius: 10px; + text-align: center; } img { @@ -22,7 +23,13 @@ hr { border: 1px solid #efefef; } -h1 { margin: 0; } +h1 { + margin: 0; +} + +.header-logo { + vertical-align: middle; +} .blog-description { margin: 10px 0 0 0; @@ -33,6 +40,10 @@ h1 { margin: 0; } .main-nav { margin-top: 15px; font-weight: bold; + display: flex; + justify-content: center; + gap: 10px; + flex-wrap: wrap; } .nav-item { diff --git a/theme/default/templates/header.tmpl b/theme/default/templates/header.tmpl index 22b854c..e92c6f6 100644 --- a/theme/default/templates/header.tmpl +++ b/theme/default/templates/header.tmpl @@ -1,5 +1,14 @@
-

{{ blog_title }}

+

+ + {% if not hide_logo %} + + {% endif %} + {% if not hide_title %} + {{ blog_title }} + {% endif %} + +

{{ blog_description }}