diff --git a/app/blueprints/feeds/__init__.py b/app/blueprints/feeds/__init__.py index 69f2f2db..c97d579a 100644 --- a/app/blueprints/feeds/__init__.py +++ b/app/blueprints/feeds/__init__.py @@ -50,7 +50,11 @@ def _get_new_packages_feed(feed_url: str) -> dict: "language": "en", "title": f"New: {package.title}", "content_html": render_markdown(package.desc) if package.desc else None, - "author": package.author.display_name, + "author": { + "name": package.author.display_name, + "avatar": package.author.get_profile_pic_url(absolute=True), + "url": abs_url_for("users.profile", username=package.author.username), + }, "url": package.get_url("packages.view", absolute=True), "summary": package.short_desc, "date_published": package.approved_at.isoformat(timespec="seconds") + "Z", @@ -72,7 +76,11 @@ def _get_releases_feed(query, feed_url: str): "language": "en", "title": f"{release.title} - {release.package.title}", "content_html": render_markdown(release.release_notes) if release.release_notes else None, - "author": release.package.author.display_name, + "author": { + "name": release.package.author.display_name, + "avatar": release.package.author.get_profile_pic_url(absolute=True), + "url": abs_url_for("users.profile", username=release.package.author.username), + }, "url": release.package.get_url("packages.view_release", id=release.id, absolute=True), "summary": release.summary, "date_published": release.created_at.isoformat(timespec="seconds") + "Z", diff --git a/app/models/packages.py b/app/models/packages.py index 748b1246..14373488 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -1099,11 +1099,11 @@ class PackageRelease(db.Model): release_notes = db.Column(db.UnicodeText, nullable=True, default=None) @property - def summary(self) -> typing.Optional[str]: - if self.release_notes is None: - return None - if self.release_notes.startswith("-") or self.release_notes.startswith("*"): - return None + def summary(self) -> str: + if self.release_notes is None or \ + self.release_notes.startswith("-") or \ + self.release_notes.startswith("*"): + return self.title return self.release_notes.split("\n")[0] diff --git a/app/models/users.py b/app/models/users.py index 516e868b..b7909fba 100644 --- a/app/models/users.py +++ b/app/models/users.py @@ -17,6 +17,7 @@ import datetime import enum +from flask import current_app from flask_babel import lazy_gettext from flask_login import UserMixin from sqlalchemy import desc, text @@ -246,11 +247,17 @@ class User(db.Model, UserMixin): def can_access_todo_list(self): return Permission.APPROVE_NEW.check(self) or Permission.APPROVE_RELEASE.check(self) - def get_profile_pic_url(self): + def get_profile_pic_url(self, absolute: bool = False): if self.profile_pic: - return self.profile_pic + if absolute: + return current_app.config["BASE_URL"] + self.profile_pic + else: + return self.profile_pic elif self.rank == UserRank.BOT: - return "/static/bot_avatar.png" + if absolute: + return current_app.config["BASE_URL"] + "/static/bot_avatar.png" + else: + return "/static/bot_avatar.png" else: from app.utils.gravatar import get_gravatar return get_gravatar(self.email or f"{self.username}@content.minetest.net") diff --git a/app/templates/feeds/json_to_atom.xml b/app/templates/feeds/json_to_atom.xml index 252c980d..e23a6144 100644 --- a/app/templates/feeds/json_to_atom.xml +++ b/app/templates/feeds/json_to_atom.xml @@ -25,7 +25,8 @@ {{ post["content_html"] | escape }} - {{ post["author"] }} + {{ post["author"]["name"] }} + {{ post["author"]["url"] }} {% for tag in post["tags"] %}