Wire the client to PrivaPub: one sign-in, real feeds, a globe, nerd stats
One sign-in for both of PrivaPub's APIs: the root logs in on /clientapi, picks a persona, and each persona gets its own Mastodon token in exchange for the JWT (PersonaExchange). HttpService picks credentials and JSON by route (JWT and camelCase for /clientapi, the persona token and snake_case for /api, nothing for /oauth), retries a refused persona token once, and records every request for the nerd stats. The feed page is three columns: navigation with a persona switcher, the feed with a tab per kind (home, local, federated, nearby, communities and circles, direct, notifications, favourites, bookmarks, hashtags), and a 3D globe that looks at the spherical mean of the posts in view and draws a pulse and an arc to a hovered one. Posts sit at their own place, their event's venue, the reader (located posts) or their author's server as PrivaPub publishes it. Cards favourite, boost, bookmark, reply, mute, block and delete; the composer posts with a content warning, visibility, media and alt text, or as a located post. Older pages load as the end nears; newer ones are polled while visible. Nerd stats in tooltips: provenance, author and server, place, media, counts, paging, the globe's camera and frame rate. The mock (Faker, MessagesService, the Message models and store) and the OIDC template leftovers are gone. Strings in English and Italian. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
f41ebf2160
commit
827ecb770e
56 files changed
+5367
-832
No files matched your search
+62
-47
@@ -9,23 +9,33 @@
|
||||
<div class="absolute bg-base-100 md:relative top-full md:top-auto mt-2 w-52 md:w-full overflow-y-auto rounded-lg neo-raised neo-sm md:shadow-none! z-50 @menuToggle md:block">
|
||||
<div class="flex flex-col gap-3 p-3 md:p-4">
|
||||
|
||||
<div class="flex gap-3 p-3 md:p-4 neo-raised neo-xs rounded-xl bg-cover bg-no-repeat bg-right" style="background-image:linear-gradient(to left, var(--color-base-100) 55%, transparent), url('@(CascadingState.User.BackgroundUrl)');">
|
||||
<a class="block h-8 w-8 md:h-12 md:w-12 flex-none" href="@CascadingState.User.ProfileUrl" title="@CascadingState.User.UserName">
|
||||
<img alt="@CascadingState.User.UserName" class="h-8 w-8 md:h-12 md:w-12 object-cover rounded-full neo-raised neo-2xs" src="@(CascadingState.User.PictureUrl ?? "/imgs/icon-192.png")" />
|
||||
</a>
|
||||
<div class="flex flex-col w-full min-w-0 gap-2">
|
||||
<p class="shrink truncate">
|
||||
<b title="@CascadingState.User.DisplayName">
|
||||
@CascadingState.User.DisplayName
|
||||
</b>
|
||||
</p>
|
||||
<p class="flex-1 min-w-6 truncate text-xs">
|
||||
<a class="underline" href="@CascadingState.User.ProfileUrl" title="@CascadingState.User.UserName">
|
||||
@CascadingState.User.UserName
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<DDropdown @bind-IsOpen="isPersonaMenuOpen" CloseOnContentClick="true" class="w-full rounded-xl bg-cover bg-no-repeat bg-right"
|
||||
TriggerClass="flex w-full gap-3 p-3 md:p-4 neo-raised neo-xs rounded-xl text-left cursor-pointer"
|
||||
ContentClass="mt-2 flex flex-col gap-2 p-2 rounded-box w-full" title="@Localizer["Switch persona"]"
|
||||
style="@PersonaBackground">
|
||||
<Trigger>
|
||||
<img alt="" class="h-8 w-8 md:h-12 md:w-12 flex-none object-cover rounded-full neo-raised neo-2xs"
|
||||
src="@(CascadingState.Persona?.Avatar ?? "imgs/icon-192.png")" />
|
||||
<span class="flex flex-col w-full min-w-0 gap-1">
|
||||
<b class="truncate" title="@CascadingState.Persona?.Name">@(CascadingState.Persona?.Name ?? Localizer["No persona"])</b>
|
||||
<span class="truncate text-xs opacity-70">@(CascadingState.Persona is { } persona ? "@" + persona.Acct : null)</span>
|
||||
</span>
|
||||
<i class="ion-md-swap self-center opacity-60"></i>
|
||||
</Trigger>
|
||||
<ChildContent>
|
||||
@foreach (var persona in CascadingState.Personas)
|
||||
{
|
||||
<DButton Size="DSize.Sm" class="justify-start whitespace-nowrap" Active="persona.Id == CascadingState.PersonaId"
|
||||
Disabled="IsDefaultDisabled || persona.Id == CascadingState.PersonaId" OnClick="() => SwitchPersona(persona.Id)">
|
||||
<img alt="" class="h-5 w-5 object-cover rounded-full" src="@(persona.PictureURL ?? "imgs/icon-192.png")" />
|
||||
<span class="truncate">@(persona.Name ?? persona.UserName)</span>
|
||||
</DButton>
|
||||
}
|
||||
</ChildContent>
|
||||
</DDropdown>
|
||||
}
|
||||
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="/" Match="NavLinkMatch.All">
|
||||
<i class="ion-md-home"></i>
|
||||
@@ -35,34 +45,26 @@
|
||||
<i class="ion-md-settings"></i>
|
||||
<span>@Localizer["Settings"]</span>
|
||||
</NavLink>
|
||||
@*<AuthorizeView>
|
||||
<Authorized>
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="administration">
|
||||
@Localizer["Administration"]
|
||||
</NavLink>
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="logout">
|
||||
@Localizer["Logout"]
|
||||
</NavLink>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="login">
|
||||
@Localizer["Login"]
|
||||
</NavLink>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>*@
|
||||
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="administration">
|
||||
<i class="ion-md-switch text-error"></i>
|
||||
<span>@Localizer["Administration"]</span>
|
||||
</NavLink>
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="login">
|
||||
<i class="ion-md-log-in text-success"></i>
|
||||
<span>@Localizer["Login"]</span>
|
||||
</NavLink>
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="logout">
|
||||
<i class="ion-md-log-out text-error"></i>
|
||||
<span>@Localizer["Logout"]</span>
|
||||
</NavLink>
|
||||
<AuthorizeView Policy="@Policies.IsAdmin">
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="administration">
|
||||
<i class="ion-md-switch text-error"></i>
|
||||
<span>@Localizer["Administration"]</span>
|
||||
</NavLink>
|
||||
</AuthorizeView>
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="logout">
|
||||
<i class="ion-md-log-out text-error"></i>
|
||||
<span>@Localizer["Logout"]</span>
|
||||
</NavLink>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NavLink ActiveClass="btn-active" class="btn justify-start" href="login">
|
||||
<i class="ion-md-log-in text-success"></i>
|
||||
<span>@Localizer["Login"]</span>
|
||||
</NavLink>
|
||||
}
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<DButton Size="DSize.Sm" Shape="DButtonShape.Circle" class="flex-none" OnClick="ResetToOriginalColour"
|
||||
@@ -94,8 +96,8 @@
|
||||
|
||||
<div class="md:hidden">
|
||||
<a class="block rounded-full neo-raised neo-2xs" href="settings">
|
||||
<img alt="@CascadingState.User.UserName" class="object-cover w-[30px] h-[30px] rounded-full"
|
||||
src="@CascadingState.User.PictureUrl">
|
||||
<img alt="@CascadingState.Persona?.Name" class="object-cover w-[30px] h-[30px] rounded-full"
|
||||
src="@(CascadingState.Persona?.Avatar ?? "imgs/icon-192.png")">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -103,6 +105,11 @@
|
||||
|
||||
@code {
|
||||
string menuToggle = "hidden";
|
||||
bool isPersonaMenuOpen;
|
||||
|
||||
string PersonaBackground => CascadingState.Persona?.Header is { Length: > 0 } header && !header.Contains("/missing-")
|
||||
? $"background-image:linear-gradient(to left, var(--color-base-100) 55%, transparent), url('{header}');"
|
||||
: null;
|
||||
|
||||
// The toggle and the slider work on the variant that is showing; with system theming that is the OS's choice.
|
||||
bool IsDark => CascadingState.Status.IsDarkTheme();
|
||||
@@ -110,10 +117,18 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
IsLoading = false;
|
||||
if (!CascadingState.Status.IsMobileMedia())
|
||||
menuToggle = default;
|
||||
}
|
||||
|
||||
async Task SwitchPersona(string personaId)
|
||||
{
|
||||
var result = await CascadingState.SwitchPersona(personaId);
|
||||
if (result.IsInvalid)
|
||||
Toast.AddResponseError(result);
|
||||
}
|
||||
|
||||
private void ToggleNavMenu()
|
||||
{
|
||||
menuToggle = menuToggle is { Length: > 0 } ? default : "hidden";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
@code {
|
||||
@* Where AuthorizeRouteView sends a reader who is not signed in: the login page, which comes back here afterwards. *@
|
||||
@code {
|
||||
[Inject] NavigationManager Navigation { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}");
|
||||
Navigation.NavigateTo($"login?returnUrl={Uri.EscapeDataString(Navigation.ToBaseRelativePath(Navigation.Uri))}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user