Compare commits

...

6 commits

Author SHA1 Message Date
Ewen b1db8a51a4 fix: minimal doc for production 2024-05-14 08:46:59 +02:00
Ewen 91881fa177 fix(backend): RSS validation 2024-05-14 08:41:42 +02:00
Ewen 6b1d9924be wip: production 2024-05-14 08:39:17 +02:00
Ewen 9dcb3079b1 wip: production 2024-05-14 07:47:40 +02:00
Ewen a7d95c1461 wip: production 2024-05-14 07:46:10 +02:00
Ewen 032faae19c wip: production 2024-05-14 07:45:41 +02:00
8 changed files with 44 additions and 12 deletions

10
.env.example Normal file
View file

@ -0,0 +1,10 @@
# Frontend configuration
VITE_API_ENDPOINT=http://yourdomain.tld/api/
# Traefik configuration, if needed
TRAEFIK_HOST=yourdomain.tld
TRAEFIK_CERTRESOLVER=letsencrypt
# Backend configuration
FLASK_SECRET_KEY="changeme!"
FLASK_DEBUG=False

View file

@ -36,9 +36,12 @@ You will need to have Docker and Docker Compose installed.
Clone the repository, go to its root and run `docker-compose -f docker-compose.dev.yml up -d`.
To use the backend directly, go to the page [http://localhost:8080/api/feed/](http://localhost:8080/api/feed/) and start adding parameters!
### For production
### Using Docker, for production
You will also need Docker and Docker Compose.
Copy `.env.example` to `.env` and edit the latter. Tweak your reverse proxy (in my case, Traefik). Then, run `docker compose up -d`.
*To do*
## Examples

View file

@ -59,7 +59,7 @@ def parse_page():
response.headers["Content-Type"] = "application/json"
return response
else:
rss_xml = render_template("rss.xml", feed=feed, build_date=datetime.now())
rss_xml = render_template("rss.xml", feed=feed, build_date=datetime.now().astimezone())
response = make_response(rss_xml)
response.headers["Content-Type"] = "application/rss+xml"
return response

View file

@ -12,7 +12,7 @@ class FeedItem:
self.link = link
self.author = author
if item_datetime:
self.item_datetime = item_datetime.isoformat()
self.item_datetime = item_datetime.strftime("%a, %d %b %Y %H:%M:%S %z")
else:
self.item_datetime = None
@ -74,7 +74,7 @@ def scrape(request, args):
title_class = {"class": args.get("titleClass")}
title = article.find(args.get("title"), title_class)
if title:
title = title.get_text()
title = title.get_text().strip()
content_tag = "p"
content_class = {}
@ -121,7 +121,7 @@ def scrape(request, args):
author=author
)
if item.title is not None:
if item.title is not None and item.title != "":
feed.items.append(item)
# Sort by datetime if any

View file

@ -5,7 +5,7 @@
<atom:link href="{{ request.url }}" rel="self" type="application/rss+xml"/>
<link>{{ request.url }}</link>
<description>A feed generated from {{ feed.url }} with Rudibridge</description>
<lastBuildDate>{{ build_date.strftime("%a, %d %b %Y %T") }} +0000</lastBuildDate>
<lastBuildDate>{{ build_date.strftime("%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate>
{% for item in feed.items %}
<item>
{% if item.title %}

View file

@ -20,3 +20,5 @@ services:
target: frontend-dev
ports:
- 5173:5173
volumes:
- ./frontend:/app

View file

@ -6,6 +6,8 @@ services:
context: ./api
dockerfile: Dockerfile
target: final
ports:
- 8080:8080
frontend:
env_file:
@ -16,7 +18,22 @@ services:
target: final
args:
- VITE_API_ENDPOINT=${VITE_API_ENDPOINT}
ports:
- 5173:5173
volumes:
- ./frontend/nginx/nginx.conf:/etc/nginx/nginx.conf
networks:
- traefik_net
- default
labels:
- "traefik.enable=true"
- "traefik.http.routers.rudibridge.rule=Host(`${TRAEFIK_HOST}`)"
- "traefik.http.routers.rudibridge.entrypoints=http"
- "traefik.http.routers.rudibridgetls.rule=Host(`${TRAEFIK_HOST}`)"
- "traefik.http.routers.rudibridgetls.entrypoints=https"
- "traefik.http.routers.rudibridgetls.tls=true"
- "traefik.http.routers.rudibridgetls.tls.certresolver=${TRAEFIK_CERTRESOLVER}"
- "traefik.http.routers.rudibridgetls.tls.domains[0].main=${TRAEFIK_HOST}"
- "traefik.docker.network=traefik_net"
networks:
traefik_net:
external: true

View file

@ -13,7 +13,7 @@ CMD ["pnpm", "run", "dev", "--host", "0.0.0.0"]
FROM frontend-requirements as build
ARG VITE_API_ENDPOINT
ENV VITE_API_ENDPOINT=${VITE_API_ENDPOINT}}
ENV VITE_API_ENDPOINT=${VITE_API_ENDPOINT}
WORKDIR /app
COPY . ./
RUN pnpm run build