diff --git a/app.py b/app.py index 9be13bd..0c27e12 100644 --- a/app.py +++ b/app.py @@ -20,10 +20,22 @@ from bp import ( async def federation_context() -> dict: """Federation app context processor.""" from shared.infrastructure.context import base_context + from shared.services.navigation import get_navigation_tree + from shared.infrastructure.cart_identity import current_cart_identity ctx = await base_context() - # If user is logged in, check for ActorProfile + ctx["menu_items"] = await get_navigation_tree(g.s) + + # Cart data (consistent with all other apps) + ident = current_cart_identity() + summary = await services.cart.cart_summary( + g.s, user_id=ident["user_id"], session_id=ident["session_id"], + ) + ctx["cart_count"] = summary.count + summary.calendar_count + summary.ticket_count + ctx["cart_total"] = float(summary.total + summary.calendar_total + summary.ticket_total) + + # Actor profile for logged-in users if g.get("user"): actor = await services.federation.get_actor_by_user_id(g.s, g.user.id) ctx["actor"] = actor @@ -60,8 +72,7 @@ def create_app() -> "Quart": @app.get("/") async def home(): from quart import render_template - stats = await services.federation.get_stats(g.s) - return await render_template("federation/home.html", stats=stats) + return await render_template("_types/federation/index.html") return app diff --git a/templates/_types/federation/index.html b/templates/_types/federation/index.html new file mode 100644 index 0000000..e2caacb --- /dev/null +++ b/templates/_types/federation/index.html @@ -0,0 +1,3 @@ +{% extends '_types/root/_index.html' %} +{% block meta %}{% endblock %} +{% block content %}{% endblock %} diff --git a/templates/_types/social/header/_header.html b/templates/_types/social/header/_header.html new file mode 100644 index 0000000..df6aedb --- /dev/null +++ b/templates/_types/social/header/_header.html @@ -0,0 +1,52 @@ +{% import 'macros/links.html' as links %} +{% macro header_row(oob=False) %} + {% call links.menu_row(id='social-row', oob=oob) %} +
+ {% if actor %} + + {% else %} + + {% endif %} +
+ {% endcall %} +{% endmacro %} diff --git a/templates/_types/social/index.html b/templates/_types/social/index.html new file mode 100644 index 0000000..8eeed33 --- /dev/null +++ b/templates/_types/social/index.html @@ -0,0 +1,10 @@ +{% extends '_types/root/_index.html' %} +{% block meta %}{% endblock %} +{% block root_header_child %} + {% from '_types/root/_n/macros.html' import index_row with context %} + {% call index_row('social-header-child', '_types/social/header/_header.html') %} + {% endcall %} +{% endblock %} +{% block content %} + {% block social_content %}{% endblock %} +{% endblock %} diff --git a/templates/auth/check_email.html b/templates/auth/check_email.html index 0a5c0d6..5eb1b61 100644 --- a/templates/auth/check_email.html +++ b/templates/auth/check_email.html @@ -1,4 +1,5 @@ -{% extends "federation/base.html" %} +{% extends "_types/root/_index.html" %} +{% block meta %}{% endblock %} {% block title %}Check your email — Rose Ash{% endblock %} {% block content %}
diff --git a/templates/auth/login.html b/templates/auth/login.html index 5e9ca5a..79031e5 100644 --- a/templates/auth/login.html +++ b/templates/auth/login.html @@ -1,4 +1,5 @@ -{% extends "federation/base.html" %} +{% extends "_types/root/_index.html" %} +{% block meta %}{% endblock %} {% block title %}Login — Rose Ash{% endblock %} {% block content %}
diff --git a/templates/federation/account.html b/templates/federation/account.html index f541bc3..32c40a0 100644 --- a/templates/federation/account.html +++ b/templates/federation/account.html @@ -1,6 +1,6 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Account — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Account

diff --git a/templates/federation/actor_timeline.html b/templates/federation/actor_timeline.html index f7023d5..0c69f8a 100644 --- a/templates/federation/actor_timeline.html +++ b/templates/federation/actor_timeline.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}{{ remote_actor.display_name or remote_actor.preferred_username }} — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}
{% if remote_actor.icon_url %} diff --git a/templates/federation/base.html b/templates/federation/base.html deleted file mode 100644 index 344bffe..0000000 --- a/templates/federation/base.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - {% block title %}Rose Ash{% endblock %} - - - - - -
- {% block content %}{% endblock %} -
- - diff --git a/templates/federation/choose_username.html b/templates/federation/choose_username.html index b4543c3..259afb2 100644 --- a/templates/federation/choose_username.html +++ b/templates/federation/choose_username.html @@ -1,6 +1,6 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Choose Username — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Choose your username

diff --git a/templates/federation/compose.html b/templates/federation/compose.html index 3fdfd05..d82a031 100644 --- a/templates/federation/compose.html +++ b/templates/federation/compose.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Compose — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Compose

diff --git a/templates/federation/followers.html b/templates/federation/followers.html index c436064..07eb862 100644 --- a/templates/federation/followers.html +++ b/templates/federation/followers.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Followers — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Followers ({{ total }})

diff --git a/templates/federation/following.html b/templates/federation/following.html index 1d8c678..ca900e4 100644 --- a/templates/federation/following.html +++ b/templates/federation/following.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Following — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Following ({{ total }})

diff --git a/templates/federation/home.html b/templates/federation/home.html deleted file mode 100644 index 6e7f217..0000000 --- a/templates/federation/home.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "federation/base.html" %} -{% block title %}Rose Ash — Federation{% endblock %} -{% block content %} -
-

Rose Ash

-

Cooperative platform with ActivityPub federation.

- -
-
-
{{ stats.actors }}
-
Actors
-
-
-
{{ stats.activities }}
-
Activities
-
-
-
{{ stats.followers }}
-
Followers
-
-
-
-{% endblock %} diff --git a/templates/federation/notifications.html b/templates/federation/notifications.html index 45467a9..11eb3f8 100644 --- a/templates/federation/notifications.html +++ b/templates/federation/notifications.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Notifications — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Notifications

{% if not notifications %} diff --git a/templates/federation/profile.html b/templates/federation/profile.html index 7da00fb..2e21a08 100644 --- a/templates/federation/profile.html +++ b/templates/federation/profile.html @@ -1,6 +1,6 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}@{{ actor.preferred_username }} — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

{{ actor.display_name or actor.preferred_username }}

diff --git a/templates/federation/search.html b/templates/federation/search.html index 0ca8bdd..a294fff 100644 --- a/templates/federation/search.html +++ b/templates/federation/search.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}Search — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

Search

diff --git a/templates/federation/timeline.html b/templates/federation/timeline.html index 96f6882..74861f3 100644 --- a/templates/federation/timeline.html +++ b/templates/federation/timeline.html @@ -1,8 +1,8 @@ -{% extends "federation/base.html" %} +{% extends "_types/social/index.html" %} {% block title %}{{ "Home" if timeline_type == "home" else "Public" }} Timeline — Rose Ash{% endblock %} -{% block content %} +{% block social_content %}

{{ "Home" if timeline_type == "home" else "Public" }} Timeline

{% if actor %}