Skip to content

Commit

Permalink
Merge pull request #819 from EdiWang/feature/gravatar-profile-pic
Browse files Browse the repository at this point in the history
Gravatar as profile picture
  • Loading branch information
EdiWang authored Sep 17, 2024
2 parents 563434c + 5f895fc commit acf1898
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/Moonglade.Configuration/GeneralSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public class GeneralSettings : IBlogSettings
[MaxLength(64)]
public string AvatarUrl { get; set; }

[Display(Name = "Use my Gravatar as profile picture")]
public bool UseGravatarAsProfilePicture { get; set; }

public TimeSpan TimeZoneUtcOffset { get; set; }

[Required]
Expand Down
16 changes: 16 additions & 0 deletions src/Moonglade.Web/Pages/Settings/General.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,22 @@
</div>
</div>
</div>

<div class="settings-entry row align-items-center py-3 px-2 border-top">
<div class="col-auto">
<i class="bi-person-circle settings-entry-icon"></i>
</div>
<div class="col">
<label asp-for="ViewModel.UseGravatarAsProfilePicture" class="form-check-label"></label>
<div class="form-text">@SharedLocalizer["Please make sure you have setup Gravatar with your email address"]</div>
</div>
<div class="col-md-5 text-end">
<div class="form-check form-switch form-control-lg">
<input type="hidden" name="UseGravatarAsProfilePicture" value="false">
<input type="checkbox" name="UseGravatarAsProfilePicture" value="true" class="form-check-input" @(Model.ViewModel.UseGravatarAsProfilePicture ? "checked" : null)>
</div>
</div>
</div>

<div class="settings-entry row align-items-center py-3 px-2 border-top">
<div class="col-auto">
Expand Down
8 changes: 2 additions & 6 deletions src/Moonglade.Web/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
@using Moonglade.Utils
@using Microsoft.AspNetCore.Localization
@using System.Globalization
@inject IConfiguration Configuration
@{
var useOwnerEmailAsAvatar = bool.Parse(Configuration["Experimental:UseOwnerEmailAsAvatar"]!);
}

@{
if (string.IsNullOrEmpty(BlogConfig.GeneralSettings.AvatarUrl))
Expand Down Expand Up @@ -176,7 +172,7 @@
{
<section class="profile-mobile d-block d-sm-none d-print-none">
<div class="card-background-container">
@if(useOwnerEmailAsAvatar)
@if(BlogConfig.GeneralSettings.UseGravatarAsProfilePicture)
{
<gravatar class="card-bkimg" email="@BlogConfig.GeneralSettings.OwnerEmail" size="256" />
}
Expand All @@ -188,7 +184,7 @@
<div class="blogger-intro-content">
<div class="row">
<div class="col-3">
@if (useOwnerEmailAsAvatar)
@if (BlogConfig.GeneralSettings.UseGravatarAsProfilePicture)
{
<gravatar class="rounded-circle blogger-head-pic"
size="256"
Expand Down
11 changes: 3 additions & 8 deletions src/Moonglade.Web/Pages/Shared/_WidgetsProfile.cshtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
@inject IConfiguration Configuration
@{
var useOwnerEmailAsAvatar = bool.Parse(Configuration["Experimental:UseOwnerEmailAsAvatar"]!);
}

<section class="blog-info-desktop-lg text-light d-none d-lg-block">
<section class="blog-info-desktop-lg text-light d-none d-lg-block">
<div class="card-background-container">
@if(useOwnerEmailAsAvatar)
@if (BlogConfig.GeneralSettings.UseGravatarAsProfilePicture)
{
<gravatar class="card-bkimg" email="@BlogConfig.GeneralSettings.OwnerEmail" size="256" />
}
Expand All @@ -15,7 +10,7 @@
}
</div>
<div class="blog-info-photo-text text-center">
@if (useOwnerEmailAsAvatar)
@if (BlogConfig.GeneralSettings.UseGravatarAsProfilePicture)
{
<gravatar class="rounded-circle blogger-head-pic"
size="256"
Expand Down
6 changes: 6 additions & 0 deletions src/Moonglade.Web/Resources/Program.de-DE.resx
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,10 @@
<data name="It is your responsibility to ensure the safety and security of your own browsing experience." xml:space="preserve">
<value>Es liegt in Ihrer Verantwortung, Ihr Surferlebnis sicher zu halten.</value>
</data>
<data name="Use my Gravatar as profile picture" xml:space="preserve">
<value>Verwende meinen Gravatar als deinen Avatar</value>
</data>
<data name="Please make sure you have setup Gravatar with your email address" xml:space="preserve">
<value>Bitte stellen Sie sicher, dass Sie sich mit Ihrer E-Mail-Adresse für Gravatar angemeldet haben</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Moonglade.Web/Resources/Program.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -873,4 +873,10 @@
<data name="Your personal information and computer system may be at risk when visiting external websites." xml:space="preserve">
<value>当访问外部网站时,您的个人信息和计算机系统可能会面临风险。</value>
</data>
<data name="Use my Gravatar as profile picture" xml:space="preserve">
<value>使用我的 Gravatar 作为头像</value>
</data>
<data name="Please make sure you have setup Gravatar with your email address" xml:space="preserve">
<value>请确保你已经使用你的 Email 注册了 Gravatar</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Moonglade.Web/Resources/Program.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,10 @@
<data name="It is your responsibility to ensure the safety and security of your own browsing experience." xml:space="preserve">
<value>您有責任確保自己的瀏覽體驗安全。</value>
</data>
<data name="Use my Gravatar as profile picture" xml:space="preserve">
<value>使用我的 Gravatar 作為頭像</value>
</data>
<data name="Please make sure you have setup Gravatar with your email address" xml:space="preserve">
<value>請確保你已經使用你的 Email 註冊了 Gravatar</value>
</data>
</root>
3 changes: 1 addition & 2 deletions src/Moonglade.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
}
},
"Experimental": {
"SetLastModifiedHeaderForPages": true,
"UseOwnerEmailAsAvatar": false
"SetLastModifiedHeaderForPages": true
},
"Logging": {
"LogLevel": {
Expand Down

0 comments on commit acf1898

Please sign in to comment.