From a447633d634160f4ad867b4ea1cce5404dd5fc6d Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 14:17:36 +0200 Subject: [PATCH 01/22] Switch html endpoint responses to Jinja templates --- prophet/view.py | 23 ++++++----------------- templates/index.html | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 templates/index.html diff --git a/prophet/view.py b/prophet/view.py index fbfcf59..cfb63b2 100644 --- a/prophet/view.py +++ b/prophet/view.py @@ -1,13 +1,16 @@ # pyright: reportUnusedFunction=false -from fastapi import FastAPI +from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse +from fastapi.templating import Jinja2Templates from prophet.domain.improvement_repo import IImprovementRepo from prophet.infra.improvement_pickle_repo import ImprovementPickleRepo repo: IImprovementRepo = ImprovementPickleRepo() +templates = Jinja2Templates(directory="templates") + def define_routes(app: FastAPI): @app.get("/improvements", response_class=HTMLResponse) @@ -51,19 +54,5 @@ def define_routes(app: FastAPI): ) @app.get("/", response_class=HTMLResponse) - def root_route(): - return """ - - - - The Pollen Prophet - - - -

The Pollen Prophet

-

Making funny since 2025 what ought not bee.

-
- - - """ + def root_route(request: Request): + return templates.TemplateResponse(request=request, name="index.html") diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..8116d04 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,18 @@ + + + + The Pollen Prophet + + + + +

The Pollen Prophet

+

Making funny since 2025 what ought not bee.

+
+ + From 39cfa19ebf36602408b7052fa190f3caa277387c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 14:33:31 +0200 Subject: [PATCH 02/22] Put future ideas in README --- README.md | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0ba63e1..c4e2b39 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,9 @@ # Pollen Prophet -RSS: https://babylonbee.com/feed +## Ideas - Subscribe today. - -Access comments and our fully-featured social platform. -Sign up Now -Shop The Bee -[Banner Ad] -Trending Articles -10 Dating Red Flags Women Should Look Out For - Article image -Lifestyle · Jun 3, 2025 · 154 -10 Dating Red Flags Women Should Look Out For -The dating scene is tough these days. With everyone using dating apps to meet and hook up, it's important for women to be careful about the guys they ... -10 Really Gay Things You Can Do To Celebrate Pride Month - Article image -Worldviews · Jun 2, 2025 · 191 -10 Really Gay Things You Can Do To Celebrate Pride Month -It's that time of year again, when the rainbows are flying everywhere you look, and super gay things are happening in more places than just Dodgers ga... -Hamas Agrees To Surrender If Europe Will Take Greta Thunberg Back - Article image -World · Jun 3, 2025 · 87 -Hamas Agrees To Surrender If Europe Will Take Greta Thunberg Back -GAZA - The tables were turned on the infamous terrorist organization today, with horrified Hamas agreeing to a full and unconditional surrender to Isr... -The Lord Strengthens Elon One Last Time To Push Pillars Of Congress Over And Bring Government Crashing Down - Article image -Politics · Jun 3, 2025 · 73 -The Lord Strengthens Elon One Last Time To Push Pillars Of Congress Over And Bring Government Crashing Down - - -Improve on the following satirical headline. The headline should be funny, can involve current political events and should have an edge to it. -Original: 'Hamas Agrees To Surrender If Europe Will Take Greta Thunberg Back' - -Which of the previous headlines would you select as the best headline to present on a satirical news-website? +- switch on-the-fly between original and improvements +- vote-mode for the best suggestion + - when opening the article shows all suggestions made + - user can vote for the best one and the one with the most votes becomes the new headline +- associated image generation? From 17b602a1a578a3200630804d21de7c0192fe786c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 15:40:49 +0200 Subject: [PATCH 03/22] Switch list endpoints to jinja templates --- prophet/view.py | 40 +++++++------------------------- templates/list_improvements.html | 11 +++++++++ templates/list_originals.html | 11 +++++++++ 3 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 templates/list_improvements.html create mode 100644 templates/list_originals.html diff --git a/prophet/view.py b/prophet/view.py index cfb63b2..d8e5e2d 100644 --- a/prophet/view.py +++ b/prophet/view.py @@ -14,43 +14,19 @@ templates = Jinja2Templates(directory="templates") def define_routes(app: FastAPI): @app.get("/improvements", response_class=HTMLResponse) - def list_improvements(): + def list_improvements(request: Request): improved = repo.get_all() - return ( - """ """ - + "\n".join( - f""" -
-
- -
-
{item.title}
-
{item.summary}
-
""" - for item in sorted( - improved, key=lambda i: i.original.date, reverse=True - ) - ) + return templates.TemplateResponse( + request=request, + name="list_improvements.html", + context={"articles": improved}, ) @app.get("/originals", response_class=HTMLResponse) - def list_originals(): + def list_originals(request: Request): improved = repo.get_all() - return ( - """ """ - + "\n".join( - f""" -
-
- -
-
{item.original.title}
-
{item.original.summary}
-
""" - for item in sorted( - improved, key=lambda i: i.original.date, reverse=True - ) - ) + return templates.TemplateResponse( + request=request, name="list_originals.html", context={"articles": improved} ) @app.get("/", response_class=HTMLResponse) diff --git a/templates/list_improvements.html b/templates/list_improvements.html new file mode 100644 index 0000000..95dc896 --- /dev/null +++ b/templates/list_improvements.html @@ -0,0 +1,11 @@ + + +{% for article in articles %} +
+
{{article.title}}
+
+ +
+
{{article.summary}}
+
+{% endfor %} diff --git a/templates/list_originals.html b/templates/list_originals.html new file mode 100644 index 0000000..36ab5d2 --- /dev/null +++ b/templates/list_originals.html @@ -0,0 +1,11 @@ + + +{% for article in articles %} +
+
{{article.original.title}}
+
+ +
+
{{article.original.summary}}
+
+{% endfor %} From 48c345c53a5edc6d957bed5ded75b95670d0606a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 16:46:38 +0200 Subject: [PATCH 04/22] Reset global css --- static/style.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/static/style.css b/static/style.css index c731e2a..9821602 100644 --- a/static/style.css +++ b/static/style.css @@ -1,3 +1,13 @@ +* { + margin: 0; + padding: 0; +} + +body { + font-family: monospace; + background: #f4f4f9; +} + .card { border: 1px solid #ccc; padding: 10px; From 66311c36aeef4ef6bbe37a68c9ab0dc0e08d605d Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 17:44:49 +0200 Subject: [PATCH 05/22] Implement simple floating button --- static/style.css | 73 ++++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 43 ++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/static/style.css b/static/style.css index 9821602..b9c65be 100644 --- a/static/style.css +++ b/static/style.css @@ -20,3 +20,76 @@ body { font-size: 24px; margin-bottom: 5px; } + +.fab-holder { + position: fixed; + bottom: 50px; + right: 50px; + z-index: 999; + cursor: pointer; +} + +.fab-icon-holder { + width: 50px; + height: 50px; + border-radius: 100%; + background: #016fb9; + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); +} + +.fab-icon-holder:hover { + opacity: 0.8; +} + +.fab-icon-holder .icon { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + font-style: 25px; + color: #ffffff; +} + +.main-btn { + width: 60px; + height: 60px; + background: #df73ff; +} + +.fab-options { + list-style-type: none; + margin: 0; + position: absolute; + bottom: 70px; + right: 0; + + opacity: 0; + transition: all 0.3s ease; + transform: scale(0); + transform-origin: 85% bottom; +} + +.main-btn:hover + .fab-options, +.fab-options:hover { + opacity: 1; + transform: scale(1); +} + +.fab-options li { + display: flex; + justify-content: flex-end; + padding: 5px; +} + +.fab-label { + padding: 2px 5px; + align-self: center; + user-select: none; + white-space: nowrap; + border-radius: 3px; + font-size: 16px; + background-color: #666666; + color: #ffffff; + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); + margin-right: 10px; +} diff --git a/templates/index.html b/templates/index.html index 8116d04..78eb690 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,6 +3,8 @@ The Pollen Prophet + + @@ -14,5 +16,46 @@ hx-trigger="load" id="content" > +
+
+
+ +
+
+
    +
  • + Show Originals +
    +
    + +
    +
    +
  • +
  • + About +
    +
    + +
    +
    +
  • +
  • + Feedback +
    +
    + +
    +
    +
  • + + + + + + + + +
+
From e17137260ca3b3bf8c290744e03a719d95b57a0c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 20:45:58 +0200 Subject: [PATCH 06/22] Extract floating button from main template --- templates/floating_button.html | 41 +++++++++++++++++++++++++++++++++ templates/index.html | 42 +--------------------------------- 2 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 templates/floating_button.html diff --git a/templates/floating_button.html b/templates/floating_button.html new file mode 100644 index 0000000..8b5ad6c --- /dev/null +++ b/templates/floating_button.html @@ -0,0 +1,41 @@ +
+
+
+ +
+
+
    +
  • + Show Originals +
    +
    + +
    +
    +
  • +
  • + About +
    +
    + +
    +
    +
  • +
  • + Feedback +
    +
    + +
    +
    +
  • + + + + + + + + +
+
diff --git a/templates/index.html b/templates/index.html index 78eb690..98a8bf5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,46 +16,6 @@ hx-trigger="load" id="content" > -
-
-
- -
-
-
    -
  • - Show Originals -
    -
    - -
    -
    -
  • -
  • - About -
    -
    - -
    -
    -
  • -
  • - Feedback -
    -
    - -
    -
    -
  • - - - - - - - - -
-
+ {% include "floating_button.html" %} From 881f77caff79bdf63bf20d48ba96b65ed81335d4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 21:06:40 +0200 Subject: [PATCH 07/22] Wire floating button to show article list versions --- templates/floating_button.html | 18 +++++++++--------- templates/list_improvements.html | 2 -- templates/list_originals.html | 2 -- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/templates/floating_button.html b/templates/floating_button.html index 8b5ad6c..f506e65 100644 --- a/templates/floating_button.html +++ b/templates/floating_button.html @@ -5,7 +5,7 @@
    -
  • +
  • Show Originals
    @@ -13,6 +13,14 @@
  • +
  • + Show Improved +
    +
    + +
    +
    +
  • About
    @@ -29,13 +37,5 @@
  • - - - - - - - -
diff --git a/templates/list_improvements.html b/templates/list_improvements.html index 95dc896..a92244b 100644 --- a/templates/list_improvements.html +++ b/templates/list_improvements.html @@ -1,5 +1,3 @@ - - {% for article in articles %}
{{article.title}}
diff --git a/templates/list_originals.html b/templates/list_originals.html index 36ab5d2..83035cd 100644 --- a/templates/list_originals.html +++ b/templates/list_originals.html @@ -1,5 +1,3 @@ - - {% for article in articles %}
{{article.original.title}}
From ba578b3c22192311807c8664c2eafb0d24e05966 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 21:07:32 +0200 Subject: [PATCH 08/22] Add alpinejs dependency --- templates/index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/index.html b/templates/index.html index 98a8bf5..861b5b8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,6 +4,10 @@ The Pollen Prophet + From e5ab5dfc4806f1759962d59e6928165bf7dbad39 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 21:29:22 +0200 Subject: [PATCH 09/22] Enable toggling button to switch between originals/improvements --- static/style.css | 8 ++++++++ templates/floating_button.html | 20 +++++++++++++++----- templates/index.html | 17 ++++++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/static/style.css b/static/style.css index b9c65be..c6e739a 100644 --- a/static/style.css +++ b/static/style.css @@ -8,6 +8,10 @@ body { background: #f4f4f9; } +.hidden { + display: none; +} + .card { border: 1px solid #ccc; padding: 10px; @@ -81,6 +85,10 @@ body { padding: 5px; } +.fab-options li.hidden { + display: none; +} + .fab-label { padding: 2px 5px; align-self: center; diff --git a/templates/floating_button.html b/templates/floating_button.html index f506e65..c86d108 100644 --- a/templates/floating_button.html +++ b/templates/floating_button.html @@ -1,23 +1,33 @@ -
+
    -
  • +
  • Show Originals
    - +
  • -
  • +
  • Show Improved
    - +
  • diff --git a/templates/index.html b/templates/index.html index 861b5b8..0e36661 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,12 +14,15 @@

    The Pollen Prophet

    Making funny since 2025 what ought not bee.

    -
    - {% include "floating_button.html" %} +
    +
    + {% include "floating_button.html" %} +
    From 203aa79470918da00d8cacd867060da53933405a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 8 Jun 2025 22:50:31 +0200 Subject: [PATCH 10/22] Switch to minified htmx --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 0e36661..79f2a8a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,7 +2,7 @@ The Pollen Prophet - +