raw content display
parent
a4936286dc
commit
869ed215a3
|
@ -184,6 +184,14 @@ class Object:
|
|||
|
||||
return content
|
||||
|
||||
@cached_property
|
||||
def raw_content(self) -> str | None:
|
||||
raw_content = self.ap_object.get("content")
|
||||
if not raw_content:
|
||||
return None
|
||||
|
||||
return markdown(raw_content)
|
||||
|
||||
@property
|
||||
def summary(self) -> str | None:
|
||||
return self.ap_object.get("summary")
|
||||
|
|
22
app/main.py
22
app/main.py
|
@ -1531,6 +1531,28 @@ async def serve_proxy_media_resized(
|
|||
)
|
||||
|
||||
|
||||
@app.get("/raw_object")
|
||||
async def serve_raw_object(
|
||||
request: Request,
|
||||
ap_id: str,
|
||||
db_session: AsyncSession = Depends(get_db_session),
|
||||
) -> PlainTextResponse:
|
||||
requested_object = await boxes.get_anybox_object_by_ap_id(db_session, ap_id)
|
||||
if not requested_object or requested_object.is_deleted:
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
if not hasattr(requested_object, 'source'):
|
||||
return PlainTextResponse(
|
||||
requested_object.ap_object.get("content"),
|
||||
headers={"Content-Type": "text/plain"},
|
||||
)
|
||||
|
||||
return PlainTextResponse(
|
||||
requested_object.source,
|
||||
headers={"Content-Type": "text/plain"},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/attachments/{content_hash}/{filename}")
|
||||
async def serve_attachment(
|
||||
content_hash: str,
|
||||
|
|
|
@ -510,8 +510,17 @@
|
|||
<nav class="flexbox activity-bar margin-top-20">
|
||||
<ul>
|
||||
<li>
|
||||
<div><a href="{{ wm_reply.url }}" rel="nofollow" class="object-permalink u-url u-uid">permalink</a></div>
|
||||
<div>
|
||||
<a href="{{ wm_reply.url }}" rel="nofollow" class="object-permalink u-url u-uid">permalink</a>
|
||||
</div>
|
||||
</li>
|
||||
{% if is_admin and object.is_from_outbox %}
|
||||
<li>
|
||||
<div>
|
||||
<a href="{{ BASE_URL }}/raw_object?ap_id={{ object.ap_id | safe }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">raw</a>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<time class="dt-published" datetime="{{ wm_reply.published_at.replace(microsecond=0).isoformat() }}" title="{{ wm_reply.published_at.replace(microsecond=0).isoformat() }}">{{ wm_reply.published_at | timeago }}</time>
|
||||
</li>
|
||||
|
@ -657,8 +666,17 @@
|
|||
<nav class="flexbox activity-bar">
|
||||
<ul>
|
||||
<li>
|
||||
<div><a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">permalink</a></div>
|
||||
<div>
|
||||
<a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">permalink</a>
|
||||
</div>
|
||||
</li>
|
||||
{% if is_admin and object.is_from_outbox %}
|
||||
<li>
|
||||
<div>
|
||||
<a href="{{ BASE_URL }}/raw_object?ap_id={{ object.ap_id | safe }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">raw</a>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if object.is_from_outbox and is_object_page and not is_admin and not request.url.path.startswith("/remote_interaction") %}
|
||||
<li>
|
||||
|
|
Loading…
Reference in New Issue