Browse Source

Change default image for Event and Organization

pull/46/head
Berkan Sasmaz 5 years ago
parent
commit
9b1d0db025
  1. 31
      src/EventHub.Web/Helpers/CoverImageHelper.cs
  2. 6
      src/EventHub.Web/Pages/Events/Components/EventsArea/_eventListSection.cshtml
  3. 10
      src/EventHub.Web/Pages/Events/Detail.cshtml
  4. 8
      src/EventHub.Web/Pages/Index.cshtml
  5. 7
      src/EventHub.Web/Pages/Organizations/Components/OrganizationsArea/_organizationListSection.cshtml
  6. 10
      src/EventHub.Web/Pages/Organizations/Profile.cshtml
  7. BIN
      src/EventHub.Web/wwwroot/assets/eh-event.png
  8. BIN
      src/EventHub.Web/wwwroot/assets/eh-organization.png

31
src/EventHub.Web/Helpers/CoverImageHelper.cs

@ -1,31 +0,0 @@
using System;
using System.Linq;
using System.Text;
using Volo.Abp;
namespace EventHub.Web.Helpers
{
public class CoverImageHelper
{
private static readonly string[] ImageColors =
{
"linear-gradient(135deg, #41003d 0%, #a10097 100%)",
"linear-gradient(135deg, #163e4b 0%, #297791 100%)",
"linear-gradient(135deg, #660040 0%, #aa006b 100%)",
"linear-gradient(135deg, #240d88 0%, #571fff 100%)",
};
public static string GetRandomColor(string articleTitle)
{
long total = articleTitle.Truncate(32).ToCharArray().Sum(c => c);
return ImageColors[total % ImageColors.Length];
}
public static string GetContentOfImage(string content)
{
content = Check.NotNullOrWhiteSpace(content, nameof(content));
return content.ToUpper();
}
}
}

6
src/EventHub.Web/Pages/Events/Components/EventsArea/_eventListSection.cshtml

@ -9,13 +9,11 @@
<div class="card">
@if (eventDto.CoverImageContent is null)
{
<div class="list-span text-center" style="background: @(CoverImageHelper.GetRandomColor(eventDto.Title))">
<span>@CoverImageHelper.GetContentOfImage(eventDto.Title).TruncateWithPostfix(30)</span>
</div>
<img abp-card-image="Top" style="max-height: 310px; min-height: 170px;" src="/assets/eh-event.png" alt="@eventDto.Title"/>
}
else
{
<img abp-card-image="Top" style="max-height: 400px; min-height: 160px;" src="@($"data:image/png;base64,{Convert.ToBase64String(eventDto.CoverImageContent)}")" alt="@eventDto.Title"/>
<img abp-card-image="Top" style="max-height: 310px; min-height: 170px;" src="@($"data:image/png;base64,{Convert.ToBase64String(eventDto.CoverImageContent)}")" alt="@eventDto.Title"/>
}
<div class="card-body">
<div class="event-container">

10
src/EventHub.Web/Pages/Events/Detail.cshtml

@ -52,15 +52,7 @@
<div class="detail-image">
@if (Model.Event.CoverImageContent == null)
{
<div class="rounded detail-span text-center" style="background: @(CoverImageHelper.GetRandomColor(Model.Event.Title))">
<span>
@CoverImageHelper.GetContentOfImage(Model.Event.Title.TruncateWithPostfix(70))
<br>
@CoverImageHelper.GetContentOfImage(Model.Event.OrganizationDisplayName.TruncateWithPostfix(80))
<br>
@CoverImageHelper.GetContentOfImage(EventDateHelper.GetDateRangeText(Model.Event.StartTime, Model.Event.EndTime))
</span>
</div>
<img src="/assets/eh-event.png" width="588" height="360" alt="@Model.Event.Title">
}
else
{

8
src/EventHub.Web/Pages/Index.cshtml

@ -121,9 +121,7 @@
<div class="col-md-5">
@if (Model.OnlineEvents[i].CoverImageContent is null)
{
<div class="rounded carousel-list-span text-center" style="background: @(CoverImageHelper.GetRandomColor(@Model.OnlineEvents[i].Title))">
<small>@CoverImageHelper.GetContentOfImage(Model.OnlineEvents[i].Title).TruncateWithPostfix(30)</small>
</div>
<img src="/assets/eh-event.png" width="187" height="218" class="card-img-left">
}
else
{
@ -151,9 +149,7 @@
<div class="col-md-5">
@if (Model.OnlineEvents[i + 1].CoverImageContent is null)
{
<div class="rounded carousel-list-span text-center" style="background: @(CoverImageHelper.GetRandomColor(@Model.OnlineEvents[i + 1].Title))">
<small>@CoverImageHelper.GetContentOfImage(Model.OnlineEvents[i + 1].Title).TruncateWithPostfix(30)</small>
</div>
<img src="/assets/eh-event.png" width="187" height="218" class="card-img-left">
}
else
{

7
src/EventHub.Web/Pages/Organizations/Components/OrganizationsArea/_organizationListSection.cshtml

@ -1,4 +1,3 @@
@using EventHub.Web.Helpers
@model List<EventHub.Organizations.OrganizationInListDto>
@foreach (var organization in Model)
@ -7,13 +6,11 @@
<div class="card">
@if (organization.ProfilePictureContent == null)
{
<div class="list-span text-center" style="background: @(CoverImageHelper.GetRandomColor(organization.Name))">
<span>@CoverImageHelper.GetContentOfImage(organization.Name).TruncateWithPostfix(40)</span>
</div>
<img src="/assets/eh-organization.png" style="max-height: 310px; min-height: 170px;" class="card-img-top" alt="@organization.Name">
}
else
{
<img src="@($"data:image/png;base64,{Convert.ToBase64String(organization.ProfilePictureContent)}")" class="card-img-top" alt="@organization.Name">
<img src="@($"data:image/png;base64,{Convert.ToBase64String(organization.ProfilePictureContent)}")" style="max-height: 310px; min-height: 170px;" class="card-img-top" alt="@organization.Name">
}
<div class="card-body">
<div class="event-container">

10
src/EventHub.Web/Pages/Organizations/Profile.cshtml

@ -1,8 +1,6 @@
@page "/organizations/{name}"
@inject IHtmlLocalizer<EventHubResource> L
@using EventHub.Localization
@using EventHub.Web.Helpers
@using EventHub.Web.Pages.Events
@using EventHub.Web.Pages.Events.Components.EventsArea
@using EventHub.Web.Pages.Organizations.Components.JoinArea
@using EventHub.Web.Pages.Organizations.Components.MembersArea
@ -22,13 +20,7 @@
<div class="detail-image">
@if (Model.Organization.ProfilePictureContent == null)
{
<div class="rounded detail-span text-center" style="background: @(CoverImageHelper.GetRandomColor(Model.Organization.Name))">
<span>
@CoverImageHelper.GetContentOfImage(Model.Organization.DisplayName.TruncateWithPostfix(80))
<br>
<small>@CoverImageHelper.GetContentOfImage("EventHub")</small>
</span>
</div>
<img src="/assets/eh-organization.png" width="996" height="300" alt="@Model.Organization.Name">
}
else
{

BIN
src/EventHub.Web/wwwroot/assets/eh-event.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

BIN
src/EventHub.Web/wwwroot/assets/eh-organization.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Loading…
Cancel
Save