Skip to content

Commit 6974d3c

Browse files
Merge branch 'support/13.x' into develop
2 parents 6e2153f + b39b180 commit 6974d3c

28 files changed

+259
-532
lines changed

Directory.Packages.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6-
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
6+
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.143" />
77
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
8-
<GlobalPackageReference Include="Umbraco.Code" Version="2.1.0" />
8+
<GlobalPackageReference Include="Umbraco.Code" Version="2.2.0" />
99
<GlobalPackageReference Include="Umbraco.GitVersioning.Extensions" Version="0.2.0" />
1010
</ItemGroup>
1111
<PropertyGroup>
1212
<UmbracoCmsPackageVersion>[14.0.0, 15)</UmbracoCmsPackageVersion>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<PackageVersion Include="Azure.Storage.Blobs" Version="12.20.0" />
16-
<PackageVersion Include="SixLabors.ImageSharp.Web.Providers.Azure" Version="3.1.2" />
15+
<PackageVersion Include="Azure.Storage.Blobs" Version="12.22.1" />
16+
<PackageVersion Include="SixLabors.ImageSharp.Web.Providers.Azure" Version="3.1.3" />
1717
<PackageVersion Include="Umbraco.Cms.Imaging.ImageSharp" Version="$(UmbracoCmsPackageVersion)" />
1818
<PackageVersion Include="Umbraco.Cms.Web.Common" Version="$(UmbracoCmsPackageVersion)" />
1919
</ItemGroup>
20-
</Project>
20+
</Project>

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This repository contains Umbraco storage providers that can replace the default
33

44
> **Note**
55
> Use the following documentation for previous Umbraco CMS versions:
6-
> * [Umbraco CMS 13 - v13](https://github.com/umbraco/Umbraco.StorageProviders/blob/support/13.0.x/README.md)
6+
> * [Umbraco CMS 13 - v13](https://github.com/umbraco/Umbraco.StorageProviders/blob/support/13.x/README.md)
77
> * [Umbraco CMS 12 - v12](https://github.com/umbraco/Umbraco.StorageProviders/blob/support/12.0.x/README.md)
88
> * [Umbraco CMS 11 - v11](https://github.com/umbraco/Umbraco.StorageProviders/blob/support/11.0.x/README.md)
99
> * [Umbraco CMS 10 - v10](https://github.com/umbraco/Umbraco.StorageProviders/blob/support/10.0.x/README.md)
@@ -108,6 +108,36 @@ UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=sample-container
108108
> **Note**
109109
> You still have to add the provider in the `Program.cs` file when not configuring the options in code.
110110
111+
### Custom blob container options
112+
To override the default blob container options, you can use the following extension methods on `AzureBlobFileSystemOptions`:
113+
```csharp
114+
// Add using default options (overly verbose, but shows how to revert back to the default)
115+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingDefault())
116+
// Add using options
117+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingOptions(_blobClientOptions))
118+
// If the connection string is parsed to a URI, use the delegate to create a BlobContainerClient
119+
.AddAzureBlobMediaFileSystem(options => options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, _blobClientOptions)))
120+
```
121+
122+
This can also be used together with the `Azure.Identity` package to authenticate with Azure AD (using managed identities):
123+
```csharp
124+
using Azure.Identity;
125+
using Azure.Storage.Blobs;
126+
using Umbraco.Cms.Core.Composing;
127+
using Umbraco.StorageProviders.AzureBlob.IO;
128+
129+
internal sealed class AzureBlobFileSystemComposer : IComposer
130+
{
131+
public void Compose(IUmbracoBuilder builder)
132+
=> builder.AddAzureBlobMediaFileSystem(options =>
133+
{
134+
options.ConnectionString = "https://[storage-account].blob.core.windows.net";
135+
options.ContainerName = "media";
136+
options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, new DefaultAzureCredential()));
137+
});
138+
}
139+
```
140+
111141
## Umbraco.StorageProviders.AzureBlob.ImageSharp
112142
Adds ImageSharp support for storing the image cache to a pre-configured Azure Blob Storage provider.
113143

examples/Umbraco.StorageProviders.AzureBlob.TestSite/AzureBlobFileSystemComposer.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Azure.Core;
2+
using Azure.Storage.Blobs;
13
using Microsoft.Extensions.Options;
24
using Umbraco.Cms.Core.Composing;
35
using Umbraco.Cms.Core.Events;
@@ -8,10 +10,25 @@ namespace Umbraco.StorageProviders.AzureBlob.TestSite;
810

911
internal sealed class AzureBlobFileSystemComposer : IComposer
1012
{
13+
private static readonly BlobClientOptions _blobClientOptions = new BlobClientOptions
14+
{
15+
Retry = {
16+
Mode = RetryMode.Exponential,
17+
MaxRetries = 3
18+
}
19+
};
20+
1121
public void Compose(IUmbracoBuilder builder)
1222
=> builder
13-
.AddAzureBlobMediaFileSystem()
23+
// Add using default options (overly verbose, but shows how to revert back to the default)
24+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingDefault())
25+
// Add using options
26+
.AddAzureBlobMediaFileSystem(options => options.CreateBlobContainerClientUsingOptions(_blobClientOptions))
27+
// If the connection string is parsed to a URI, use the delegate to create a BlobContainerClient
28+
.AddAzureBlobMediaFileSystem(options => options.TryCreateBlobContainerClientUsingUri(uri => new BlobContainerClient(uri, _blobClientOptions)))
29+
// Add the ImageSharp IImageCache implementation using the default media file system and "cache" container root path
1430
.AddAzureBlobImageSharpCache()
31+
// Add notification handler to create the media file system on install if it doesn't exist
1532
.AddNotificationHandler<UnattendedInstallNotification, AzureBlobMediaFileSystemCreateIfNotExistsHandler>();
1633

1734
private sealed class AzureBlobMediaFileSystemCreateIfNotExistsHandler : INotificationHandler<UnattendedInstallNotification>

examples/Umbraco.StorageProviders.AzureBlob.TestSite/Umbraco.StorageProviders.AzureBlob.TestSite.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Umbraco.Cms" Version="14.1.2" />
10-
<!--<PackageReference Include="Umbraco.TheStarterKit" Version="13.0.0" />-->
9+
<PackageReference Include="Umbraco.Cms" Version="14.3.1" />
10+
<PackageReference Include="Umbraco.TheStarterKit" Version="14.0.0" />
1111
</ItemGroup>
1212

1313
<Import Project="..\..\src\Umbraco.StorageProviders\buildTransitive\Umbraco.StorageProviders.props" />

examples/Umbraco.StorageProviders.AzureBlob.TestSite/Views/Blog.cshtml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
<section class="section">
1111

1212
<div class="container">
13-
@await Umbraco.RenderMacroAsync("latestBlogposts",
14-
new
15-
{
16-
numberOfPosts = Model.HowManyPostsShouldBeShown,
17-
startNodeId = Model.Id
18-
})
13+
@await Component.InvokeAsync("LatestBlogPosts",
14+
new { numberOfPosts = Model.HowManyPostsShouldBeShown, startNodeKey = Model.Key })
1915
</div>
2016

21-
</section>
17+
</section>

examples/Umbraco.StorageProviders.AzureBlob.TestSite/Views/MacroPartials/FeaturedProducts.cshtml

Lines changed: 0 additions & 27 deletions
This file was deleted.

examples/Umbraco.StorageProviders.AzureBlob.TestSite/Views/MacroPartials/LatestBlogposts.cshtml

Lines changed: 0 additions & 102 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@using Umbraco.Cms.Core.Models.PublishedContent
2+
@using Umbraco.Extensions
3+
@model Umbraco.SampleSite.Models.LatestBlogPostsViewModel;
4+
5+
<div class="blogposts">
6+
@foreach (IPublishedContent post in Model.BlogPosts)
7+
{
8+
<a href="@post.Url()" class="blogpost">
9+
<div class="blogpost-meta">
10+
<small class="blogpost-date">@post.CreateDate.ToShortDateString()</small>
11+
<small class="blogpost-cat">
12+
@await Html.PartialAsync("~/Views/Partials/CategoryLinks.cshtml", post.Value<IEnumerable<string>>("categories"))
13+
</small>
14+
</div>
15+
<h3 class="blogpost-title">@post.Value("pageTitle")</h3>
16+
<div class="blogpost-excerpt">@post.Value("excerpt")</div>
17+
</a>
18+
}
19+
20+
@if (Model.BlogPosts.Count() < Model.Total)
21+
{
22+
<div class="pagination">
23+
<nav class="nav-bar nav-bar--center">
24+
@if (Model.Page <= 1)
25+
{
26+
<span class="nav-link nav-link--black nav-link--disabled">Prev</span>
27+
}
28+
else
29+
{
30+
<a class="nav-link nav-link--black" href="@(Model.Url + "?page=" + (Model.Page - 1))">Prev</a>
31+
}
32+
33+
@for (int i = 1; i <= Model.PageCount; i++)
34+
{
35+
<a class="nav-link nav-link--black @(Model.Page == i ? " nav-link--active" : null)" href="@(Model.Url + "?page=" + i)">@i</a>
36+
}
37+
@if (Model.Page == Model.PageCount)
38+
{
39+
<span class="nav-link nav-link--black nav-link--disabled">Next</span>
40+
}
41+
else
42+
{
43+
<a class="nav-link nav-link--black" href="@(Model.Url + "?page=" + (Model.Page + 1))">Next</a>
44+
}
45+
46+
</nav>
47+
</div>
48+
}
49+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="blogposts">
2+
<h1>There are no posts at this time, try again later.</h1>
3+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem<ContentModels.LatestBlogposts>>;
2+
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
3+
4+
@await Component.InvokeAsync("LatestBlogPosts",
5+
new { numberOfPosts = Model.Content.NumberOfPosts, startNodeKey = Model.Content.StartNode?.Key ?? Guid.Empty })

0 commit comments

Comments
 (0)