Skip to content

Commit bc80892

Browse files
Merge branch 'v9/contrib' into v9/dev
# Conflicts: # src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Languages/languages.ts
2 parents a6903d8 + 5d2c950 commit bc80892

File tree

43 files changed

+742
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+742
-469
lines changed

.github/ISSUE_TEMPLATE/01_bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ body:
66
- type: input
77
id: "version"
88
attributes:
9-
label: "Which *exact* Umbraco version are you using? For example: 8.13.1 - don't just write v8"
9+
label: "Which *exact* Umbraco version are you using? For example: 9.0.1 - don't just write v9"
1010
description: "Use the help icon in the Umbraco backoffice to find the version you're using"
1111
validations:
1212
required: true
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
using Umbraco.Cms.Core.Composing;
2+
using Umbraco.Cms.Core.Dashboards;
3+
using Umbraco.Cms.Core.Media;
4+
using Umbraco.Cms.Core.Models.ContentEditing;
5+
using Umbraco.Cms.Core.Routing;
6+
using Umbraco.Cms.Core.Sections;
7+
8+
namespace Umbraco.Cms.Core.DependencyInjection
9+
{
10+
/// <summary>
11+
/// Contains extensions methods for <see cref="IUmbracoBuilder"/> used for registering content apps.
12+
/// </summary>
13+
public static partial class UmbracoBuilderExtensions
14+
{
15+
/// <summary>
16+
/// Register a component.
17+
/// </summary>
18+
/// <typeparam name="T">The type of the component.</typeparam>
19+
/// <param name="builder">The builder.</param>
20+
public static IUmbracoBuilder AddComponent<T>(this IUmbracoBuilder builder)
21+
where T : class, IComponent
22+
{
23+
builder.Components().Append<T>();
24+
return builder;
25+
}
26+
27+
/// <summary>
28+
/// Register a content app.
29+
/// </summary>
30+
/// <typeparam name="T">The type of the content app.</typeparam>
31+
/// <param name="builder">The builder.</param>
32+
public static IUmbracoBuilder AddContentApp<T>(this IUmbracoBuilder builder)
33+
where T : class, IContentAppFactory
34+
{
35+
builder.ContentApps().Append<T>();
36+
return builder;
37+
}
38+
39+
/// <summary>
40+
/// Register a content finder.
41+
/// </summary>
42+
/// <typeparam name="T">The type of the content finder.</typeparam>
43+
/// <param name="builder">The builder.</param>
44+
public static IUmbracoBuilder AddContentFinder<T>(this IUmbracoBuilder builder)
45+
where T : class, IContentFinder
46+
{
47+
builder.ContentFinders().Append<T>();
48+
return builder;
49+
}
50+
51+
/// <summary>
52+
/// Register a dashboard.
53+
/// </summary>
54+
/// <typeparam name="T">The type of the dashboard.</typeparam>
55+
/// <param name="builder">The builder.</param>
56+
public static IUmbracoBuilder AddDashboard<T>(this IUmbracoBuilder builder)
57+
where T : class, IDashboard
58+
{
59+
builder.Dashboards().Add<T>();
60+
return builder;
61+
}
62+
63+
/// <summary>
64+
/// Register a media url provider.
65+
/// </summary>
66+
/// <typeparam name="T">The type of the media url provider.</typeparam>
67+
/// <param name="builder">The builder.</param>
68+
public static IUmbracoBuilder AddMediaUrlProvider<T>(this IUmbracoBuilder builder)
69+
where T : class, IMediaUrlProvider
70+
{
71+
builder.MediaUrlProviders().Append<T>();
72+
return builder;
73+
}
74+
75+
/// <summary>
76+
/// Register a embed provider.
77+
/// </summary>
78+
/// <typeparam name="T">The type of the embed provider.</typeparam>
79+
/// <param name="builder">The builder.</param>
80+
public static IUmbracoBuilder AddEmbedProvider<T>(this IUmbracoBuilder builder)
81+
where T : class, IEmbedProvider
82+
{
83+
builder.EmbedProviders().Append<T>();
84+
return builder;
85+
}
86+
87+
/// <summary>
88+
/// Register a section.
89+
/// </summary>
90+
/// <typeparam name="T">The type of the section.</typeparam>
91+
/// <param name="builder">The builder.</param>
92+
public static IUmbracoBuilder AddSection<T>(this IUmbracoBuilder builder)
93+
where T : class, ISection
94+
{
95+
builder.Sections().Append<T>();
96+
return builder;
97+
}
98+
99+
/// <summary>
100+
/// Register a url provider.
101+
/// </summary>
102+
/// <typeparam name="T">The type of the url provider.</typeparam>
103+
/// <param name="builder">The Builder.</param>
104+
public static IUmbracoBuilder AddUrlProvider<T>(this IUmbracoBuilder builder)
105+
where T : class, IUrlProvider
106+
{
107+
builder.UrlProviders().Append<T>();
108+
return builder;
109+
}
110+
}
111+
}

src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Umbraco.Cms.Core.Actions;
23
using Umbraco.Cms.Core.Cache;
34
using Umbraco.Cms.Core.Composing;
@@ -102,7 +103,7 @@ internal static void AddAllCoreCollectionBuilders(this IUmbracoBuilder builder)
102103
builder.ManifestFilters();
103104
builder.MediaUrlGenerators();
104105
// register OEmbed providers - no type scanning - all explicit opt-in of adding types, IEmbedProvider is not IDiscoverable
105-
builder.OEmbedProviders()
106+
builder.EmbedProviders()
106107
.Append<YouTube>()
107108
.Append<Twitter>()
108109
.Append<Vimeo>()
@@ -265,7 +266,15 @@ public static MediaUrlGeneratorCollectionBuilder MediaUrlGenerators(this IUmbrac
265266
/// Gets the backoffice OEmbed Providers collection builder.
266267
/// </summary>
267268
/// <param name="builder">The builder.</param>
269+
[Obsolete("Use EmbedProviders() instead")]
268270
public static EmbedProvidersCollectionBuilder OEmbedProviders(this IUmbracoBuilder builder)
271+
=> EmbedProviders(builder);
272+
273+
/// <summary>
274+
/// Gets the backoffice Embed Providers collection builder.
275+
/// </summary>
276+
/// <param name="builder">The builder.</param>
277+
public static EmbedProvidersCollectionBuilder EmbedProviders(this IUmbracoBuilder builder)
269278
=> builder.WithCollectionBuilder<EmbedProvidersCollectionBuilder>();
270279

271280
/// <summary>

src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Umbraco.Cms.Core.Serialization;
33

44
namespace Umbraco.Cms.Core.Media.EmbedProviders
55
{
6+
// TODO (V10): change base class to OEmbedProviderBase
67
public class DailyMotion : EmbedProviderBase
78
{
89
public override string ApiEndpoint => "https://www.dailymotion.com/services/oembed";
Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Net;
4-
using System.Net.Http;
5-
using System.Text;
6-
using System.Xml;
1+
using System;
72
using Umbraco.Cms.Core.Serialization;
83

94
namespace Umbraco.Cms.Core.Media.EmbedProviders
105
{
11-
public abstract class EmbedProviderBase : IEmbedProvider
6+
[Obsolete("Use OEmbedProviderBase instead")]
7+
public abstract class EmbedProviderBase : OEmbedProviderBase
128
{
13-
private readonly IJsonSerializer _jsonSerializer;
14-
159
protected EmbedProviderBase(IJsonSerializer jsonSerializer)
10+
: base(jsonSerializer)
1611
{
17-
_jsonSerializer = jsonSerializer;
18-
}
19-
20-
private static HttpClient _httpClient;
21-
22-
public abstract string ApiEndpoint { get; }
23-
24-
public abstract string[] UrlSchemeRegex { get; }
25-
26-
public abstract Dictionary<string, string> RequestParams { get; }
27-
28-
public abstract string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0);
29-
30-
public virtual string GetEmbedProviderUrl(string url, int maxWidth, int maxHeight)
31-
{
32-
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute) == false)
33-
throw new ArgumentException("Not a valid URL.", nameof(url));
34-
35-
var fullUrl = new StringBuilder();
36-
37-
fullUrl.Append(ApiEndpoint);
38-
fullUrl.Append("?url=" + WebUtility.UrlEncode(url));
39-
40-
foreach (var param in RequestParams)
41-
fullUrl.Append($"&{param.Key}={param.Value}");
42-
43-
if (maxWidth > 0)
44-
fullUrl.Append("&maxwidth=" + maxWidth);
45-
46-
if (maxHeight > 0)
47-
fullUrl.Append("&maxheight=" + maxHeight);
48-
49-
return fullUrl.ToString();
50-
}
51-
52-
public virtual string DownloadResponse(string url)
53-
{
54-
if (_httpClient == null)
55-
_httpClient = new HttpClient();
56-
57-
using (var request = new HttpRequestMessage(HttpMethod.Get, url))
58-
{
59-
var response = _httpClient.SendAsync(request).Result;
60-
return response.Content.ReadAsStringAsync().Result;
61-
}
62-
}
63-
64-
public virtual T GetJsonResponse<T>(string url) where T : class
65-
{
66-
var response = DownloadResponse(url);
67-
return _jsonSerializer.Deserialize<T>(response);
68-
}
69-
70-
public virtual XmlDocument GetXmlResponse(string url)
71-
{
72-
var response = DownloadResponse(url);
73-
var doc = new XmlDocument();
74-
doc.LoadXml(response);
75-
76-
return doc;
77-
}
78-
79-
public virtual string GetXmlProperty(XmlDocument doc, string property)
80-
{
81-
var selectSingleNode = doc.SelectSingleNode(property);
82-
return selectSingleNode != null ? selectSingleNode.InnerText : string.Empty;
8312
}
8413
}
85-
};
14+
}

src/Umbraco.Core/Media/EmbedProviders/Flickr.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Net;
33
using Umbraco.Cms.Core.Serialization;
44

55
namespace Umbraco.Cms.Core.Media.EmbedProviders
66
{
7+
// TODO(V10) : change base class to OEmbedProviderBase
78
public class Flickr : EmbedProviderBase
89
{
910
public override string ApiEndpoint => "http://www.flickr.com/services/oembed/";

src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Umbraco.Cms.Core.Serialization;
33

44
namespace Umbraco.Cms.Core.Media.EmbedProviders
55
{
6+
// TODO(V10) : change base class to OEmbedProviderBase
67
public class GettyImages : EmbedProviderBase
78
{
89
public override string ApiEndpoint => "http://embed.gettyimages.com/oembed";

src/Umbraco.Core/Media/EmbedProviders/Giphy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Umbraco.Cms.Core.Serialization;
33

44
namespace Umbraco.Cms.Core.Media.EmbedProviders
55
{
66
/// <summary>
77
/// Embed Provider for Giphy.com the popular online GIFs and animated sticker provider.
88
/// </summary>
9+
/// TODO(V10) : change base class to OEmbedProviderBase
910
public class Giphy : EmbedProviderBase
1011
{
1112
public override string ApiEndpoint => "https://giphy.com/services/oembed?url=";

src/Umbraco.Core/Media/EmbedProviders/Hulu.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Umbraco.Cms.Core.Serialization;
33

44
namespace Umbraco.Cms.Core.Media.EmbedProviders
55
{
6+
// TODO(V10) : change base class to OEmbedProviderBase
67
public class Hulu : EmbedProviderBase
78
{
89
public override string ApiEndpoint => "http://www.hulu.com/api/oembed.json";

src/Umbraco.Core/Media/EmbedProviders/Issuu.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Umbraco.Cms.Core.Serialization;
33

44
namespace Umbraco.Cms.Core.Media.EmbedProviders
55
{
6+
// TODO(V10) : change base class to OEmbedProviderBase
67
public class Issuu : EmbedProviderBase
78
{
89
public override string ApiEndpoint => "https://issuu.com/oembed";

0 commit comments

Comments
 (0)