Upgraded web projects to .NET 5. Added error handling to ImageGallerBlock, fixes #37

This commit is contained in:
Håkan Edling 2021-01-07 13:12:35 +01:00
Родитель 2720d97c90
Коммит 43557e5cf7
4 изменённых файлов: 46 добавлений и 40 удалений

Просмотреть файл

@ -1,26 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Piranha" Version="8.4.2" /> <PackageReference Include="Piranha" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.AspNetCore" Version="8.4.1" /> <PackageReference Include="Piranha.AspNetCore" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLite) != False" Include="Piranha.AspNetCore.Identity.SQLite" Version="8.4.0" /> <PackageReference Condition="$(UseSQLite) != False" Include="Piranha.AspNetCore.Identity.SQLite" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.AspNetCore.Identity.SQLServer" Version="8.4.0" /> <PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.AspNetCore.Identity.SQLServer" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseMySql) == True" Include="Piranha.AspNetCore.Identity.MySql" Version="8.4.0" /> <PackageReference Condition="$(UseMySql) == True" Include="Piranha.AspNetCore.Identity.MySql" Version="9.0.0-beta1" />
<PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.AspNetCore.Identity.PostgreSql" Version="8.4.0" /> <PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.AspNetCore.Identity.PostgreSql" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.AttributeBuilder" Version="8.4.0" /> <PackageReference Include="Piranha.AttributeBuilder" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseBlobStorage) == True" Include="Piranha.Azure.BlobStorage" Version="8.4.0" /> <PackageReference Condition="$(UseBlobStorage) == True" Include="Piranha.Azure.BlobStorage" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLite) != False" Include="Piranha.Data.EF.SQLite" Version="8.4.0" /> <PackageReference Condition="$(UseSQLite) != False" Include="Piranha.Data.EF.SQLite" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.Data.EF.SQLServer" Version="8.4.0" /> <PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.Data.EF.SQLServer" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseMySql) == True" Include="Piranha.Data.EF.MySql" Version="8.4.0" /> <PackageReference Condition="$(UseMySql) == True" Include="Piranha.Data.EF.MySql" Version="9.0.0-beta1" />
<PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.Data.EF.PostgreSql" Version="8.4.0" /> <PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.Data.EF.PostgreSql" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.ImageSharp" Version="8.4.0" /> <PackageReference Include="Piranha.ImageSharp" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseBlobStorage) != True" Include="Piranha.Local.FileStorage" Version="8.4.0" /> <PackageReference Condition="$(UseBlobStorage) != True" Include="Piranha.Local.FileStorage" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.Manager" Version="8.4.1" /> <PackageReference Include="Piranha.Manager" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.Manager.TinyMCE" Version="8.4.0" /> <PackageReference Include="Piranha.Manager.TinyMCE" Version="9.0.0-beta1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Просмотреть файл

@ -2,19 +2,22 @@
@using Piranha.Extend.Blocks @using Piranha.Extend.Blocks
@{ @{
var unique = "gallery-" + Guid.NewGuid().ToString(); var unique = "gallery-" + Guid.NewGuid().ToString();
var images = Model.Items
.Where(i => i.GetType() == typeof(ImageBlock) && ((ImageBlock)i).Body.HasValue)
.ToList();
} }
<div id="@unique" class="carousel slide gallery-block" data-ride="carousel"> <div id="@unique" class="carousel slide gallery-block" data-ride="carousel">
<ol class="carousel-indicators"> <ol class="carousel-indicators">
@for (var n = 0; n < Model.Items.Count; n++) @for (var n = 0; n < images.Count; n++)
{ {
<li data-target="#@unique" data-slide-to="@n" class="@(n == 0 ? "active" : "")"></li> <li data-target="#@unique" data-slide-to="@n" class="@(n == 0 ? "active" : "")"></li>
} }
</ol> </ol>
<div class="carousel-inner"> <div class="carousel-inner">
@foreach (var item in Model.Items) @foreach (var item in images)
{ {
<div class="carousel-item @(item == Model.Items.First() ? "active" : "")"> <div class="carousel-item @(item == images.First() ? "active" : "")">
<img src="@Url.Content(WebApp.Media.ResizeImage(((ImageBlock)item).Body.Media, 1100, 450))" class="d-block w-100"> <img src="@Url.Content(WebApp.Media.ResizeImage(((ImageBlock)item).Body.Media, 1100, 450))" class="d-block w-100">
</div> </div>
} }

Просмотреть файл

@ -2,19 +2,22 @@
@using Piranha.Extend.Blocks @using Piranha.Extend.Blocks
@{ @{
var unique = "gallery-" + Guid.NewGuid().ToString(); var unique = "gallery-" + Guid.NewGuid().ToString();
var images = Model.Items
.Where(i => i.GetType() == typeof(ImageBlock) && ((ImageBlock)i).Body.HasValue)
.ToList();
} }
<div id="@unique" class="carousel slide gallery-block" data-ride="carousel"> <div id="@unique" class="carousel slide gallery-block" data-ride="carousel">
<ol class="carousel-indicators"> <ol class="carousel-indicators">
@for (var n = 0; n < Model.Items.Count; n++) @for (var n = 0; n < images.Count; n++)
{ {
<li data-target="#@unique" data-slide-to="@n" class="@(n == 0 ? "active" : "")"></li> <li data-target="#@unique" data-slide-to="@n" class="@(n == 0 ? "active" : "")"></li>
} }
</ol> </ol>
<div class="carousel-inner"> <div class="carousel-inner">
@foreach (var item in Model.Items) @foreach (var item in images)
{ {
<div class="carousel-item @(item == Model.Items.First() ? "active" : "")"> <div class="carousel-item @(item == images.First() ? "active" : "")">
<img src="@Url.Content(WebApp.Media.ResizeImage(((ImageBlock)item).Body.Media, 1100, 450))" class="d-block w-100"> <img src="@Url.Content(WebApp.Media.ResizeImage(((ImageBlock)item).Body.Media, 1100, 450))" class="d-block w-100">
</div> </div>
} }

Просмотреть файл

@ -1,26 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Piranha" Version="8.4.2" /> <PackageReference Include="Piranha" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.AspNetCore" Version="8.4.1" /> <PackageReference Include="Piranha.AspNetCore" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLite) != False" Include="Piranha.AspNetCore.Identity.SQLite" Version="8.4.0" /> <PackageReference Condition="$(UseSQLite) != False" Include="Piranha.AspNetCore.Identity.SQLite" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.AspNetCore.Identity.SQLServer" Version="8.4.0" /> <PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.AspNetCore.Identity.SQLServer" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseMySql) == True" Include="Piranha.AspNetCore.Identity.MySql" Version="8.4.0" /> <PackageReference Condition="$(UseMySql) == True" Include="Piranha.AspNetCore.Identity.MySql" Version="9.0.0-beta1" />
<PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.AspNetCore.Identity.PostgreSql" Version="8.4.0" /> <PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.AspNetCore.Identity.PostgreSql" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.AttributeBuilder" Version="8.4.0" /> <PackageReference Include="Piranha.AttributeBuilder" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseBlobStorage) == True" Include="Piranha.Azure.BlobStorage" Version="8.4.0" /> <PackageReference Condition="$(UseBlobStorage) == True" Include="Piranha.Azure.BlobStorage" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLite) != False" Include="Piranha.Data.EF.SQLite" Version="8.4.0" /> <PackageReference Condition="$(UseSQLite) != False" Include="Piranha.Data.EF.SQLite" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.Data.EF.SQLServer" Version="8.4.0" /> <PackageReference Condition="$(UseSQLServer) == True" Include="Piranha.Data.EF.SQLServer" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseMySql) == True" Include="Piranha.Data.EF.MySql" Version="8.4.0" /> <PackageReference Condition="$(UseMySql) == True" Include="Piranha.Data.EF.MySql" Version="9.0.0-beta1" />
<PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.Data.EF.PostgreSql" Version="8.4.0" /> <PackageReference Condition="$(UsePostgreSql) == True" Include="Piranha.Data.EF.PostgreSql" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.ImageSharp" Version="8.4.0" /> <PackageReference Include="Piranha.ImageSharp" Version="9.0.0-beta1" />
<PackageReference Condition="$(UseBlobStorage) != True" Include="Piranha.Local.FileStorage" Version="8.4.0" /> <PackageReference Condition="$(UseBlobStorage) != True" Include="Piranha.Local.FileStorage" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.Manager" Version="8.4.1" /> <PackageReference Include="Piranha.Manager" Version="9.0.0-beta1" />
<PackageReference Include="Piranha.Manager.TinyMCE" Version="8.4.0" /> <PackageReference Include="Piranha.Manager.TinyMCE" Version="9.0.0-beta1" />
</ItemGroup> </ItemGroup>
</Project> </Project>