mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 03:37:28 +01:00
Fix authors in JSONFeed
Unfortunately, the only working validator I found can only validate live URLs
This commit is contained in:
parent
f8abcaa7c6
commit
9062f49992
@ -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",
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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")
|
||||
|
@ -25,7 +25,8 @@
|
||||
{{ post["content_html"] | escape }}
|
||||
</content>
|
||||
<author>
|
||||
<name>{{ post["author"] }}</name>
|
||||
<name>{{ post["author"]["name"] }}</name>
|
||||
<uri>{{ post["author"]["url"] }}</uri>
|
||||
</author>
|
||||
{% for tag in post["tags"] %}
|
||||
<category term="{{ tag | escape }}" />
|
||||
|
Loading…
Reference in New Issue
Block a user