Implemented Profile Page

This commit is contained in:
Mia Rose Winter 2024-02-04 16:44:06 +01:00
parent c0325f67b9
commit bc17910739
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
12 changed files with 480 additions and 35 deletions

View file

@ -40,21 +40,26 @@
@Localizer["Submit"]
</button>
</EditForm>
<a class="btn btn-secondary mt-3 w-full" href="/profile/@User.Id">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
<path fill-rule="evenodd" d="M18.685 19.097A9.723 9.723 0 0 0 21.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 0 0 3.065 7.097A9.716 9.716 0 0 0 12 21.75a9.716 9.716 0 0 0 6.685-2.653Zm-12.54-1.285A7.486 7.486 0 0 1 12 15a7.486 7.486 0 0 1 5.855 2.812A8.224 8.224 0 0 1 12 20.25a8.224 8.224 0 0 1-5.855-2.438ZM15.75 9a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" clip-rule="evenodd" />
</svg>
@Localizer["Profile_Link_Label"]
</a>
@code {
[Parameter]
public required ApplicationUser? User { get; set; }
public required ApplicationUser User { get; set; }
[SupplyParameterFromForm(FormName = "about-me")]
private InputModel Model { get; set; } = new();
protected override void OnInitialized() {
Model.AboutTheAuthor ??= User?.AboutTheAuthor;
Model.Biography ??= User?.Biography;
Model.AboutTheAuthor ??= User.AboutTheAuthor;
Model.Biography ??= User.Biography;
}
private async Task OnValidSubmit(EditContext obj) {
if (User is null) return;
if (Model.Biography is not null) {
User.BiographyHtml = MarkdownUtilities.Parse(Model.Biography);
User.Biography = Model.Biography;

View file

@ -44,25 +44,31 @@
</article>
@if (!string.IsNullOrWhiteSpace(Article.Author.AboutTheAuthor)) {
<section class="mb-2">
<div class="card sm:card-side card-compact bg-secondary text-secondary-content rounded shadow">
<figure class="shrink-0">
<img class="sm:max-h-56" src="/api/user/pfp/@Article.Author.Id" alt="" width="800">
</figure>
<div class="card-body sm:border-l-2 border-current">
<h2 class="card-title">About The Author</h2>
<h3><strong>@Article.Author.Name</strong></h3>
<p>
@Article.Author.AboutTheAuthor
</p>
<div class="card-actions flex gap-2 flex-wrap">
@foreach (var link in Article.Author.Links) {
<UserLinkComponent Link="link" class="badge hover:badge-outline flex gap-2 p-4" />
}
</div>
</div>
</div>
</section>
<section class="mb-2">
<div class="card sm:card-side card-compact bg-secondary text-secondary-content rounded shadow">
<figure class="shrink-0">
<img class="sm:max-h-56" src="/api/user/pfp/@Article.Author.Id?size=400" alt="" width="800">
</figure>
<div class="card-body sm:border-l-2 border-current">
<h2 class="card-title">About The Author</h2>
<h3><strong>@Article.Author.Name</strong></h3>
<p>
@Article.Author.AboutTheAuthor
</p>
<div class="card-actions flex gap-2 flex-wrap">
@foreach (var link in Article.Author.Links) {
<UserLinkComponent Link="link" class="badge hover:badge-outline flex gap-2 p-4" />
}
<a class="badge hover:badge-outline flex gap-2 p-4" href="/profile/@Article.Author.Id">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
<path fill-rule="evenodd" d="M18.685 19.097A9.723 9.723 0 0 0 21.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 0 0 3.065 7.097A9.716 9.716 0 0 0 12 21.75a9.716 9.716 0 0 0 6.685-2.653Zm-12.54-1.285A7.486 7.486 0 0 1 12 15a7.486 7.486 0 0 1 5.855 2.812A8.224 8.224 0 0 1 12 20.25a8.224 8.224 0 0 1-5.855-2.438ZM15.75 9a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" clip-rule="evenodd" />
</svg>
@Localizer["AboutTheAuthor_Profile_Label"]
</a>
</div>
</div>
</div>
</section>
}
<div class="flex gap-2 flex-wrap">

View file

@ -0,0 +1,81 @@
@page "/profile/{id:guid}"
@using Wave.Data
@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<UserView> Localizer
<PageTitle>@(TitlePrefix + @Localizer["Title"] + " | " + (User?.FullName ?? Localizer["NotFound_Title"]))</PageTitle>
@if (User is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1>
<p class="my-3">@Localizer["NotFound_Description"]</p>
<a class="btn btn-primary" href="/">@Localizer["NotFound_BackToHome_Label"]</a>
} else {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
<section class="flex flex-col md:flex-row gap-x-8">
<div class="shrink-0 md:w-40 lg:w-56">
<ProfilePictureComponent ProfileId="@User.Id" Size="400" />
</div>
<div>
<h2 class="text-2xl lg:text-4xl mb-3">@User.FullName</h2>
<p class="my-3">@User.AboutTheAuthor</p>
<div class="flex gap-2 flex-wrap">
@foreach (var link in User.Links) {
<UserLinkComponent Link="link" class="badge hover:badge-outline flex gap-2 p-4" />
}
</div>
</div>
</section>
<hr class="my-3" />
<section>
<h2 class="text-2xl lg:text-4xl mb-3">@Localizer["Biography"]</h2>
<div class="prose prose-sm lg:prose-base prose-neutral max-w-none">
@((MarkupString) User.BiographyHtml)
</div>
</section>
<hr class="my-3" />
<section>
<h2 class="text-2xl lg:text-4xl mb-3">@Localizer["Articles"]</h2>
<ArticleTileArray>
@foreach (var article in User.Articles) {
<ArticleTile Article="article" />
}
</ArticleTileArray>
</section>
}
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[Parameter]
public Guid? Id { get; set; }
private ApplicationUser? User { get; set; }
private List<Article> Articles { get; set; } = [];
protected override async Task OnInitializedAsync() {
await using var context = await ContextFactory.CreateDbContextAsync();
// Find user
if (Id is not null) {
User = await context.Users.Include(u => u.Articles)
.ThenInclude(a => a.Categories)
.FirstOrDefaultAsync(u => u.Id == Id.ToString());
}
// Validate access to user
if (User is not null && User.Articles.Count > 0) {
} else {
User = null;
}
}
}

View file

@ -1,17 +1,19 @@
@using Wave.Data
<div class="rounded bg-base-200 text-base-content flex content-center w-full sm:w-56">
<div class="w-16 h-16">
<ProfilePictureComponent Size="200" ProfileId="@Profile.Id" />
</div>
<a href="/profile/@Profile.Id">
<div class="rounded bg-base-200 text-base-content flex content-center w-full sm:w-56">
<div class="w-16 h-16">
<ProfilePictureComponent Size="200" ProfileId="@Profile.Id" />
</div>
<div class="flex flex-col p-2">
<span class="truncate">@Profile.Name</span>
@if (RoleTag is not null) {
<span class="badge badge-sm badge-primary">@RoleTag</span>
}
</div>
</div>
<div class="flex flex-col p-2">
<span class="truncate">@Profile.Name</span>
@if (RoleTag is not null) {
<span class="badge badge-sm badge-primary">@RoleTag</span>
}
</div>
</div>
</a>
@code {
[Parameter]

View file

@ -165,4 +165,7 @@ Ich koche seit dem jungen Alter von 7...</value>
<data name="Links_Submit" xml:space="preserve">
<value>Hinzufügen</value>
</data>
<data name="Profile_Link_Label" xml:space="preserve">
<value>Profil Öffnen</value>
</data>
</root>

View file

@ -165,4 +165,7 @@ I started cooking at the young age of 7...</value>
<data name="Links_Submit" xml:space="preserve">
<value>Add</value>
</data>
<data name="Profile_Link_Label" xml:space="preserve">
<value>Go to Profile</value>
</data>
</root>

View file

@ -128,4 +128,7 @@
<data name="Meta_Description" xml:space="preserve">
<value>{1} Weiterlesen auf {0}.</value>
</data>
<data name="AboutTheAuthor_Profile_Label" xml:space="preserve">
<value>Profil</value>
</data>
</root>

View file

@ -128,4 +128,7 @@
<data name="Meta_Description" xml:space="preserve">
<value>{1} Continue reading on {0}. </value>
</data>
<data name="AboutTheAuthor_Profile_Label" xml:space="preserve">
<value>Profile</value>
</data>
</root>

View file

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Profil</value>
</data>
<data name="NotFound_Title" xml:space="preserve">
<value>Benutzer nicht gefunden</value>
</data>
<data name="NotFound_Description" xml:space="preserve">
<value>Den Benutzer nach dem Sie suchen konnte nicht gefunden werden oder hat keine Artikel verfasst.</value>
</data>
<data name="NotFound_BackToHome_Label" xml:space="preserve">
<value>Zurück zur Startseite</value>
</data>
<data name="Biography" xml:space="preserve">
<value>Biographie</value>
</data>
<data name="Articles" xml:space="preserve">
<value>Artikel</value>
</data>
</root>

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Profile</value>
</data>
<data name="NotFound_Title" xml:space="preserve">
<value>User not found</value>
</data>
<data name="NotFound_Description" xml:space="preserve">
<value>The User you are looking for could not be found or is not an Author of any articles.</value>
</data>
<data name="NotFound_BackToHome_Label" xml:space="preserve">
<value>Back to Startpage</value>
</data>
<data name="Biography" xml:space="preserve">
<value>Biography</value>
</data>
<data name="Articles" xml:space="preserve">
<value>Articles</value>
</data>
</root>

File diff suppressed because one or more lines are too long