Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement replies #402

Merged
merged 23 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8aa2ae7
fix: link to the activity id
tripledoublev Oct 28, 2024
ec7e22e
Update activity_pub.yml with corrected link to the activity id
tripledoublev Oct 28, 2024
5376bca
Refactor post.html to include activity_pub interactions and replies
tripledoublev Oct 28, 2024
03f0ec6
Include activity_pub interactions and replies
tripledoublev Oct 28, 2024
a04d052
Merge branch 'staging' into implement-replies
tripledoublev Nov 26, 2024
ff48a6b
Disable non-functional interaction section in ActivityPub template
tripledoublev Nov 27, 2024
4efcc9c
Add conditional rendering for interactions in ActivityPub template
tripledoublev Nov 27, 2024
7929bef
fix: toot card was missing
fauno Nov 28, 2024
6c1e92c
Merge pull request #413 from fauno/implement-replies
tripledoublev Nov 28, 2024
da981e7
Commit ActivityPub Data
github-actions[bot] Nov 28, 2024
6de693a
Add sutty-liquid gem for enhanced Liquid template support
tripledoublev Dec 2, 2024
69b29a7
Convert bootstrap classes to tachyon classes
tripledoublev Dec 2, 2024
aa8df04
refactor: streamline activity interactions and improve rendering logic
tripledoublev Dec 2, 2024
c068b41
Stles for AP replies
tripledoublev Dec 2, 2024
302ed03
fix: adjust margin classes for improved layout in toot card
tripledoublev Dec 2, 2024
0ba8fb7
Add activity_pub to the main SCSS imports
tripledoublev Dec 2, 2024
3ef5e7b
Remove unnecessary horizontal rule and adjust styling for combined in…
tripledoublev Dec 2, 2024
5a47f96
Remove unused ActivityPub modal components
tripledoublev Dec 3, 2024
023950f
Add padding-top to activity_pub image for improved spacing
tripledoublev Dec 3, 2024
e5ad601
Update ActivityPub actor URLs to use production domain
tripledoublev Dec 3, 2024
76c4e0e
Fix conditional attributes for external links to improve security
tripledoublev Dec 3, 2024
a078865
Set fallback alt text for images in picture component
tripledoublev Dec 3, 2024
ae37cd1
Add locale configuration to site settings
tripledoublev Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem "html-proofer"
gem 'nokogiri'
gem 'ruby-brs'
gem "webrick", "~> 1.8"
gem 'sutty-liquid', '~> 0.12.2'

group :jekyll_plugins do
gem "jekyll-feed",
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rss: "/feed.xml"
url: "https://hypha.coop"
lang: "en"
footer: Hypha Worker Co-operative Inc.<br>Ontario Corporation No. 5019866
locale: "en"

description: >-
We cultivate collective growth and meaningful livelihoods through learning and building technologies together.
Expand Down
11 changes: 11 additions & 0 deletions _includes/activity_pub/actor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% comment %}
Render actor's name if it's available, otherwise just return the link.

@param actor [ActivityDrop] Actor
{% endcomment %}

{% if include.actor.available %}
<span class="word-wrap">{{ include.actor.name | strip_html }}</span>
{% else %}
<span class="word-wrap">{{ include.actor }}</span>
{% endif %}
28 changes: 28 additions & 0 deletions _includes/activity_pub/actor_mention.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% comment %}
@param actor [ActivityDrop] Actor
@param without_link [Boolean] Don't link
{% endcomment %}

{% if include.actor.available %}
{% assign id = include.actor.id | strip_html %}
{% assign instance_hostname = id | split: '/' %}
{% assign instance_hostname = instance_hostname[2] %}

{% capture mention %}
@<span>{{- include.actor.preferredUsername | strip_html -}}@{{- instance_hostname -}}</span>
{% endcapture %}

{% capture mention %}
<span class="h-card word-wrap pl2" translate="no">
{% if include.without_link %}
<span class="mention">{{- mention -}}</span>
{% else %}
{% include external_link.html class="u-url mention" href=id text=mention %}
{% endif %}
</span>
{% endcapture %}

{{ mention | normalize_whitespace }}
{% else %}
{{ include.actor }}
{% endif %}
16 changes: 16 additions & 0 deletions _includes/activity_pub/button_bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{%- comment -%}
Botonera para botones de íconos.

@param :uri [String] La URL sobre la que se interactua
@param :profile [ActivityDrop] Actor
{%- endcomment -%}

{% assign uri = include.uri | default: include.url | default: 'YOU FORGOT THIS PARAM' | strip_html %}
{% assign actions = site.data.actions.actions %}

<div class="flex">
{% for action in actions %}
{% assign fa = action.icon %}
{% include activity_pub/login_modal.html action=action fa=fa uri=uri profile=include.profile description=action.title %}
{% endfor %}
</div>
28 changes: 28 additions & 0 deletions _includes/activity_pub/cards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- comment -%}
Nested cards

@param :profile [ActivityDrop] Actor
@param :activity [ActivityDrop] Note
@param :replies [ActivityDrop] Collection
{%- endcomment -%}

{%
include activity_pub/toot_card.html
profile=include.profile
activity=include.activity
component_class="my-3"
%}

{% if include.replies.available %}
{% assign replies = include.replies.all_items | sort: 'published' %}
{% for reply in replies %}
<blockquote class="bl b--moon-gray bw3 pl3">
{%
include activity_pub/cards.html
profile=reply.attributedTo
activity=reply
replies=reply.replies
%}
</blockquote>
{% endfor %}
{% endif %}
73 changes: 73 additions & 0 deletions _includes/activity_pub/interactions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% comment %}
@param activity [ActivityDrop]
{% endcomment %}

<!-- Initialize variables -->
{% assign items = site.i18n.fediverse_interactions %}
{% assign reactions = '' | split: ',' %}
{% assign activities = '' | split: ',' %}

<!-- Filter replies -->
{% if page.activity.replies.available %}
{% assign activities = page.activity.replies.all_items | where_exp: "item", "item.inReplyTo" | sort: 'published' %}
{% endif %}

<!-- Optional: Filter and sort reactions if needed -->
{% assign reactions = reactions | sort: 'published' %}

<!-- Combine replies and reactions if necessary -->
{% assign all_interactions = activities %}

<!-- Render Replies -->
{% unless activities == empty %}
<div class="w-100" data-controller="tabs" data-tabs-hide-class="hide" data-tabs-show-class="show">

<!-- Conversations (Replies Only) -->
<div class="w-100 dn" data-tabs-target="tab" id="conversation">
{% unless activities == empty %}
{% for activity in activities %}
<div class="activity-card">
<div class="activity-content">
{% include activity_pub/cards.html activity=activity profile=activity.attributedTo replies=activity.replies %}
</div>
</div>
{% endfor %}
{% else %}
<p class="f1 lh-title">
{{ site.i18n.no_interactions_yet.conversation }}
</p>
{% endunless %}
</div>

<!-- Reactions Tab -->
<div class="w-100 dn dn" data-tabs-target="tab" id="reactions">
{% unless reactions == empty %}
{% include activity_pub/reactions.html reactions=reactions %}
{% else %}
<p class="f1 lh-title">
{{ site.i18n.no_interactions_yet.reactions }}
</p>
{% endunless %}
</div>

<!-- Combined Interactions (Replies Only) -->
<div class="w-100 show bt bw2 b--light-gray mt5" data-tabs-target="tab" id="both">
<h2 style="font-size: 2.25rem; margin-top: 4rem;">
Replies from the Fediverse
</h2>
{% unless all_interactions == empty %}
{% for interaction in all_interactions %}
{% if interaction.inReplyTo %}
<div class="interaction-card">
{% include activity_pub/cards.html activity=interaction profile=interaction.attributedTo replies=interaction.replies %}
</div>
{% endif %}
{% endfor %}
{% else %}
<p class="f1 lh-title">
{{ site.i18n.no_interactions_yet.both }}
</p>
{% endunless %}
</div>
</div>
{% endunless %}
42 changes: 42 additions & 0 deletions _includes/activity_pub/reaction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{%- comment -%}
Reacción

@param :activity [String] Reacción de le usuarie
@param :fa [String] nombre del ícono que usa fork-awesome
@param :actor [String] Usuarie
{%- endcomment -%}

{% assign published = include.activity.published | strip_html %}

<div class="flex">
<div class="flex flex flex-column gray ph2 tr">
{% include date.html date=published format=site.i18n.date.format %}
</div>
<div class="flex flex-column ph2 flex-grow-1">
{% if include.previous.actor == include.activity.actor %}
<div class="flex">
<p class="transparent hover-bg-transparent">
{% include activity_pub/actor.html actor=include.activity.actor %}
</p>
</div>
<div class="flex">
<p class="transparent hover-bg-transparent">
{% include activity_pub/actor_mention.html actor=include.activity.actor without_link=true %}
</p>
</div>
{% else %}
<div class="flex">
<p class="">{% include activity_pub/actor.html actor=include.activity.actor %}</p>
</div>
<div class="flex">
{% include activity_pub/actor_mention.html actor=include.activity.actor %}
</div>
{% endif %}
</div>
<div class="flex flex-column self-center ph2 f4 lh-copy">
{% assign icon = include.activity.type | equals: 'Announce' | ternary: 'retweet', 'star-o' %}
{% assign description = site.i18n.activities[include.activity.type] %}

{%- include fa.html icon=icon class="lead" description=description -%}
</div>
</div>
17 changes: 17 additions & 0 deletions _includes/activity_pub/reactions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{%- comment -%}
Reacciones

@param :reactions [Array] Reacciones
@param :actor [String] Usuarie
{%- endcomment -%}

{% for reaction in include.reactions %}
{% assign minus = forloop.index0 | minus: 1 %}
{% assign previous = include.reactions[minus] %}

{%
include activity_pub/reaction.html
activity=reaction
previous=previous
%}
{% endfor %}
23 changes: 23 additions & 0 deletions _includes/activity_pub/replying_to.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{%- comment -%}
Texto + enlace al post/artículo al cual se responde

@param :activity [ActivityDrop] Activity
{%- endcomment -%}

{% if include.activity.available %}
{%- capture uri -%}
{%- include activity_pub/url.html activity=include.activity -%}
{%- endcapture -%}

{% capture text %}
{{- include.activity.name | default: include.activity.summary | strip_html | default: site.i18n.reply.link_text -}}
{% endcapture %}

<div class="pv5 pr5">
<span class="f2 lh-title">
{{- site.i18n.reply.text -}}
</span>

{% include external_link.html href=uri class="h2" text=text %}
</div>
{% endif %}
94 changes: 94 additions & 0 deletions _includes/activity_pub/toot_card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{%- comment -%}
Toot card

@param :component_class [String] Las clases del componente
@param :profile [String]
@param :activity [String]
{%- endcomment -%}

{% assign extra_class = include.activity.attachment | size | equals: 1 | ternary: 'col', 'col-6' %}

<div class="flex flex flex-column flex">
<div class="flex items-center">
{%
include embed_responsive.html
x=1
y=1
src=include.profile.icon.url
alt=include.profile.icon.name
width=40
embed_class="mr-2 w-49px"
img_class="h-100 object-fit-cover"
%}

<div class="flex flex-row">
<p>{% include activity_pub/actor.html actor=include.profile %}</p>
<p>{% include activity_pub/actor_mention.html actor=include.profile %}</p>
</div>
</div>
<div class="flex-auto w-100 ml3">
{% capture content %}
<div class="content mt0">
{{ include.activity.content | sanitize_html }}
</div>

{% unless include.activity.attachment == empty %}
<div class="flex flex-wrap nl1 nr1 mt0">
{% for attachment in include.activity.attachment %}
{% if attachment.mediaType == "video/mp4" %}
{% include activity_pub/video_modal.html video=attachment extra=extra_class %}
{% else %}
{% include activity_pub/image_modal.html image=attachment extra=extra_class %}
{% endif %}
{% endfor %}
</div>
{% endunless %}
{% endcapture %}

{% if include.activity.sensitive %}
{% capture summary_title %}
<strong>{{ site.i18n.sensitive }}:</strong> {{ include.activity.summary }}
{% endcapture %}

{%
include details.html
element_title=summary_title
element_text=content
summary_class="align-items-center btn-lg btn-secondary p-2 text-left f-16"
component_class="my-3"
font_size="ml3 lead"
%}
{% else %}
{{ content }}
{% endif %}

<div class="flex gray justify-between mv2 items-center">
{%- assign timestamp_field = include.activity.updated | ternary: 'updated', 'published' -%}
{%- assign timestamp = include.activity[timestamp_field] -%}

{%- capture timestamp -%}
{% include date.html date=timestamp format=site.i18n.date_time.format %}
{%- endcapture -%}

{%- capture uri -%}
{%- include activity_pub/url.html activity=include.activity -%}
{%- endcapture -%}

{% include external_link.html href=uri text=timestamp %}

<div>
{% if include.activity.shares.totalItems %}
{%- include fa.html icon="retweet" class="px-1" description=site.i18n.total_shares content=include.activity.shares.totalItems -%}
{% endif %}

{% if include.activity.likes.totalItems %}
{%- include fa.html icon="star-o" class="px-1" description=site.i18n.total_likes content=include.activity.likes.totalItems -%}
{% endif %}
</div>

{%- include fa.html icon="globe" description=site.i18n.globe -%}
</div>

{% include activity_pub/button_bar.html uri=include.activity.id profile=include.profile %}
</div>
</div>
8 changes: 8 additions & 0 deletions _includes/activity_pub/url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- comment -%}
Finds the URL

@param activity [ActivityDrop]
{%- endcomment -%}

{%- assign uri = include.activity.url | find: 'rel', 'canonical' -%}
{{- uri.href | default: include.activity.url | default: include.activity.id | strip_html -}}
16 changes: 16 additions & 0 deletions _includes/activity_pub/video_modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{%- comment -%}
Modal con imagen

@param :image [Image] la imagen que queremos en el modal, contiene url y alt text
{%- endcomment -%}

{% capture body %}
<video controls="" src="{{include.video.url}}"></video>
{% endcapture %}

<div class="ph1" data-controller="modal">
<div class="aspect-ratio aspect-ratio--16x9">
<video class="pointer min-w-100 w-100 aspect-ratio--object cover" data-action="click-&gt;modal#show" src="{{include.video.url}}"></video>
</div>
{% include activity_pub/generic_modal.html header_class="text-white" body=body body_class="d-flex justify-content-center" footer_class="d-none" content_class="background-transparent border-0" %}
</div>
Loading
Loading