Merge branch 'temp8-oembed-collection' into temp8
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
namespace Umbraco.Core.Media
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
public interface IEmbedProvider
|
||||
{
|
||||
bool SupportsDimensions { get; }
|
||||
/// <summary>
|
||||
/// The OEmbed API Endpoint
|
||||
/// </summary>
|
||||
string ApiEndpoint { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A string array of Regex patterns to match against the pasted OEmbed URL
|
||||
/// </summary>
|
||||
string[] UrlSchemeRegex { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of querystring request parameters to append to the API Url
|
||||
/// </summary>
|
||||
/// <example>?key=value&key2=value2</example>
|
||||
Dictionary<string, string> RequestParams { get; }
|
||||
|
||||
string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Xml;
|
||||
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
public interface IEmbedSettingProvider
|
||||
{
|
||||
object GetSetting(XmlNode settingNode);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
|
||||
// TODO: Could definitely have done with a better name
|
||||
public class Result
|
||||
public class OEmbedResult
|
||||
{
|
||||
public Status Status { get; set; }
|
||||
public OEmbedStatus OEmbedStatus { get; set; }
|
||||
public bool SupportsDimensions { get; set; }
|
||||
public string Markup { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
|
||||
//NOTE: Could definitely have done with a better name
|
||||
public enum Status
|
||||
public enum OEmbedStatus
|
||||
{
|
||||
NotSupported,
|
||||
Error,
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
public class ProviderSetting : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -650,10 +650,8 @@
|
||||
<Compile Include="Manifest\PackageManifest.cs" />
|
||||
<Compile Include="Manifest\DataEditorConverter.cs" />
|
||||
<Compile Include="Media\IEmbedProvider.cs" />
|
||||
<Compile Include="Media\IEmbedSettingProvider.cs" />
|
||||
<Compile Include="Media\ProviderSetting.cs" />
|
||||
<Compile Include="Media\Result.cs" />
|
||||
<Compile Include="Media\Status.cs" />
|
||||
<Compile Include="Media\OEmbedResult.cs" />
|
||||
<Compile Include="Media\OEmbedStatus.cs" />
|
||||
<Compile Include="Migrations\IPostMigration.cs" />
|
||||
<Compile Include="Migrations\MigrationBuilder.cs" />
|
||||
<Compile Include="Migrations\MigrationPlan.cs" />
|
||||
|
||||
@@ -54,21 +54,22 @@
|
||||
|
||||
$scope.model.embed.preview = "";
|
||||
|
||||
switch (response.data.Status) {
|
||||
|
||||
switch (response.data.OEmbedStatus) {
|
||||
case 0:
|
||||
//not supported
|
||||
$scope.model.embed.info = "Not supported";
|
||||
break;
|
||||
//not supported
|
||||
$scope.model.embed.info = "Not supported";
|
||||
break;
|
||||
case 1:
|
||||
//error
|
||||
$scope.model.embed.info = "Could not embed media - please ensure the URL is valid";
|
||||
break;
|
||||
//error
|
||||
$scope.model.embed.info = "Could not embed media - please ensure the URL is valid";
|
||||
break;
|
||||
case 2:
|
||||
$scope.model.embed.preview = response.data.Markup;
|
||||
vm.trustedPreview = $sce.trustAsHtml(response.data.Markup);
|
||||
$scope.model.embed.supportsDimensions = response.data.SupportsDimensions;
|
||||
$scope.model.embed.success = true;
|
||||
break;
|
||||
$scope.model.embed.preview = response.data.Markup;
|
||||
vm.trustedPreview = $sce.trustAsHtml(response.data.Markup);
|
||||
$scope.model.embed.supportsDimensions = response.data.SupportsDimensions;
|
||||
$scope.model.embed.success = true;
|
||||
break;
|
||||
}
|
||||
}, function() {
|
||||
$scope.model.embed.supportsDimensions = false;
|
||||
|
||||
@@ -178,9 +178,6 @@
|
||||
<Content Include="Config\imageprocessor\cache.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="Config\EmbeddedMedia.Release.config">
|
||||
<DependentUpon>EmbeddedMedia.config</DependentUpon>
|
||||
</None>
|
||||
<Content Include="Config\HealthChecks.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@@ -300,7 +297,6 @@
|
||||
<Content Include="Config\umbracoSettings.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Config\EmbeddedMedia.config" />
|
||||
<Content Include="Config\BackOfficeTours\getting-started.json" />
|
||||
</ItemGroup>
|
||||
<!-- determine VSToolsPath -->
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<embed>
|
||||
<!-- Flickr Settings-->
|
||||
<provider name="Flickr" type="Umbraco.Web.Media.EmbedProviders.OEmbedPhoto, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[flickr\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.flickr.com/services/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- SlideShare Settings -->
|
||||
<provider name="SlideShare" type="Umbraco.Web.Media.EmbedProviders.OEmbedRich, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[slideshare\.net/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.slideshare.net/api/oembed/2]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Kickstarter Settings-->
|
||||
<provider name="Kickstarter" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[kickstarter\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.kickstarter.com/services/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Getty Images Settings-->
|
||||
<provider name="GettyImages" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[gty\.im/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://embed.gettyimages.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Poll Everywhere Settings -->
|
||||
<provider name="PollEverywhere" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[polleverywhere\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.polleverywhere.com/services/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Poll Daddy Settings -->
|
||||
<provider name="PollDaddy" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[polldaddy\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://polldaddy.com/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- IFTTT Settings -->
|
||||
<provider name="IFTTT" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[ifttt\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.ifttt.com/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Instagram Settings -->
|
||||
<provider name="Instagram" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[instagram\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://api.instagram.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Issuu Settings-->
|
||||
<provider name="Issuu" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[issuu.com/(?:.*)/docs]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://issuu.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">json</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Rdio Settings -->
|
||||
<provider name="Rdio" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[rdio\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.rdio.com/api/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- SoundCloud Settings -->
|
||||
<provider name="SoundCloud" type="Umbraco.Web.Media.EmbedProviders.OEmbedRich, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[soundcloud\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://soundcloud.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Youtube Settings -->
|
||||
<provider name="Youtube" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://www.youtube.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="iframe">1</param>
|
||||
<param name="format">xml</param>
|
||||
<param name="scheme">https</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- StreamDotUmbracoDotCom -->
|
||||
<provider name="StreamDotUmbracoDotCom" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[stream\.umbraco\.org/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://stream.umbraco.org/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Daily Motion -->
|
||||
<provider name="DailyMotion" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[dailymotion\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.dailymotion.com/services/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Hulu -->
|
||||
<provider name="Hulu" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[hulu\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.hulu.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Vimeo -->
|
||||
<provider name="Vimeo" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[vimeo\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://vimeo.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Ted -->
|
||||
<provider name="Ted" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[ted\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.ted.com/talks/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Screenr Settings -->
|
||||
<provider name="Screenr" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web" supportsDimensions="False">
|
||||
<urlShemeRegex><![CDATA[screenr\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.screenr.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Twitgoo Settings , not an OEmbed one -->
|
||||
<provider name="Twitgoo" type="Umbraco.Web.Media.EmbedProviders.Twitgoo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[twitgoo\.com/]]></urlShemeRegex>
|
||||
</provider>
|
||||
<!-- Twitter Settings -->
|
||||
<provider name="Twitter" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[twitter\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://publish.twitter.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
</requestParams>
|
||||
</provider>
|
||||
</embed>
|
||||
@@ -1,134 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<embed>
|
||||
<!-- Flickr Settings-->
|
||||
<provider name="Flickr" type="Umbraco.Web.Media.EmbedProviders.OEmbedPhoto, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[flickr\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.flickr.com/services/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- SlideShare Settings -->
|
||||
<provider name="SlideShare" type="Umbraco.Web.Media.EmbedProviders.OEmbedRich, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[slideshare\.net/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.slideshare.net/api/oembed/2]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Kickstarter Settings-->
|
||||
<provider name="Kickstarter" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[kickstarter\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.kickstarter.com/services/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Getty Images Settings-->
|
||||
<provider name="GettyImages" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[gty\.im/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://embed.gettyimages.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Poll Everywhere Settings -->
|
||||
<provider name="PollEverywhere" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[polleverywhere\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.polleverywhere.com/services/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Poll Daddy Settings -->
|
||||
<provider name="PollDaddy" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[polldaddy\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://polldaddy.com/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- IFTTT Settings -->
|
||||
<provider name="IFTTT" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[ifttt\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.ifttt.com/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Instagram Settings -->
|
||||
<provider name="Instagram" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[instagram\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://api.instagram.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Issuu Settings -->
|
||||
<provider name="Issuu" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[issuu.com/(?:.*)/docs]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://issuu.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">json</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Rdio Settings -->
|
||||
<provider name="Rdio" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[rdio\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.rdio.com/api/oembed/]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- SoundCloud Settings -->
|
||||
<provider name="SoundCloud" type="Umbraco.Web.Media.EmbedProviders.OEmbedRich, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[soundcloud\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://soundcloud.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Youtube Settings -->
|
||||
<provider name="Youtube" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://www.youtube.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="iframe">1</param>
|
||||
<param name="format">xml</param>
|
||||
<param name="scheme">https</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- StreamDotUmbracoDotCom -->
|
||||
<provider name="StreamDotUmbracoDotCom" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[stream\.umbraco\.org/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://stream.umbraco.org/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Daily Motion -->
|
||||
<provider name="DailyMotion" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[dailymotion\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.dailymotion.com/services/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Hulu -->
|
||||
<provider name="Hulu" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[hulu\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.hulu.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
<param name="format">xml</param>
|
||||
</requestParams>
|
||||
</provider>
|
||||
<!-- Vimeo -->
|
||||
<provider name="Vimeo" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[vimeo\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://vimeo.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Ted -->
|
||||
<provider name="Ted" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[ted\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.ted.com/talks/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Screenr Settings -->
|
||||
<provider name="Screenr" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, Umbraco.Web" supportsDimensions="False">
|
||||
<urlShemeRegex><![CDATA[screenr\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[http://www.screenr.com/api/oembed.xml]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web"></requestParams>
|
||||
</provider>
|
||||
<!-- Twitgoo Settings , not an OEmbed one -->
|
||||
<provider name="Twitgoo" type="Umbraco.Web.Media.EmbedProviders.Twitgoo, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[twitgoo\.com/]]></urlShemeRegex>
|
||||
</provider>
|
||||
<!-- Twitter Settings -->
|
||||
<provider name="Twitter" type="Umbraco.Web.Media.EmbedProviders.OEmbedJson, Umbraco.Web">
|
||||
<urlShemeRegex><![CDATA[twitter\.com/]]></urlShemeRegex>
|
||||
<apiEndpoint><![CDATA[https://publish.twitter.com/oembed]]></apiEndpoint>
|
||||
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, Umbraco.Web">
|
||||
</requestParams>
|
||||
</provider>
|
||||
</embed>
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Web.ContentApps;
|
||||
using Umbraco.Web.Dashboards;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.HealthCheck;
|
||||
using Umbraco.Web.Media.EmbedProviders;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
@@ -101,6 +102,13 @@ namespace Umbraco.Web
|
||||
public static DashboardCollectionBuilder Dashboards(this Composition composition)
|
||||
=> composition.WithCollectionBuilder<DashboardCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the backoffice OEmbed Providers collection builder.
|
||||
/// </summary>
|
||||
/// <param name="composition">The composition.</param>
|
||||
public static EmbedProvidersCollectionBuilder OEmbedProviders(this Composition composition)
|
||||
=> composition.WithCollectionBuilder<EmbedProvidersCollectionBuilder>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uniques
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public abstract class AbstractProvider : IEmbedProvider
|
||||
{
|
||||
public virtual bool SupportsDimensions
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public abstract string GetMarkup(string url, int maxWidth, int maxHeight);
|
||||
}
|
||||
}
|
||||
28
src/Umbraco.Web/Media/EmbedProviders/DailyMotion.cs
Normal file
28
src/Umbraco.Web/Media/EmbedProviders/DailyMotion.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class DailyMotion : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "https://www.dailymotion.com/services/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"dailymotion.com/video/.*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>()
|
||||
{
|
||||
//ApiUrl/?format=xml
|
||||
{"format", "xml"}
|
||||
};
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,39 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
// TODO: Make all Http calls async
|
||||
|
||||
public abstract class AbstractOEmbedProvider : IEmbedProvider
|
||||
public abstract class EmbedProviderBase : IEmbedProvider
|
||||
{
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
public virtual bool SupportsDimensions
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
public abstract string ApiEndpoint { get; }
|
||||
|
||||
[ProviderSetting]
|
||||
public string APIEndpoint { get; set; }
|
||||
public abstract string[] UrlSchemeRegex { get; }
|
||||
|
||||
[ProviderSetting]
|
||||
public Dictionary<string, string> RequestParams { get; set; }
|
||||
public abstract Dictionary<string, string> RequestParams { get; }
|
||||
|
||||
public abstract string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0);
|
||||
|
||||
public abstract string GetMarkup(string url, int maxWidth, int maxHeight);
|
||||
|
||||
public virtual string BuildFullUrl(string url, int maxWidth, int maxHeight)
|
||||
public virtual string GetEmbedProviderUrl(string url, int maxWidth, int maxHeight)
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute) == false)
|
||||
throw new ArgumentException("Not a valid Url");
|
||||
|
||||
var fullUrl = new StringBuilder();
|
||||
|
||||
fullUrl.Append(APIEndpoint);
|
||||
fullUrl.Append(ApiEndpoint);
|
||||
fullUrl.Append("?url=" + HttpUtility.UrlEncode(url));
|
||||
|
||||
foreach (var p in RequestParams)
|
||||
fullUrl.Append(string.Format("&{0}={1}", p.Key, p.Value));
|
||||
foreach (var param in RequestParams)
|
||||
fullUrl.Append($"&{param.Key}={param.Value}");
|
||||
|
||||
if (maxWidth > 0)
|
||||
fullUrl.Append("&maxwidth=" + maxWidth);
|
||||
@@ -50,7 +43,7 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
|
||||
return fullUrl.ToString();
|
||||
}
|
||||
|
||||
|
||||
public virtual string DownloadResponse(string url)
|
||||
{
|
||||
if (_httpClient == null)
|
||||
@@ -83,6 +76,5 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
var selectSingleNode = doc.SelectSingleNode(property);
|
||||
return selectSingleNode != null ? selectSingleNode.InnerText : string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class EmbedProvidersCollection : BuilderCollectionBase<IEmbedProvider>
|
||||
{
|
||||
public EmbedProvidersCollection(IEnumerable<IEmbedProvider> items)
|
||||
: base(items)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class EmbedProvidersCollectionBuilder : OrderedCollectionBuilderBase<EmbedProvidersCollectionBuilder, EmbedProvidersCollection, IEmbedProvider>
|
||||
{
|
||||
protected override EmbedProvidersCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
31
src/Umbraco.Web/Media/EmbedProviders/Flickr.cs
Normal file
31
src/Umbraco.Web/Media/EmbedProviders/Flickr.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Flickr : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://www.flickr.com/services/oembed/";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"flickr.com\/photos\/*",
|
||||
@"flic.kr\/p\/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
var imageUrl = GetXmlProperty(xmlDocument, "/oembed/url");
|
||||
var imageWidth = GetXmlProperty(xmlDocument, "/oembed/width");
|
||||
var imageHeight = GetXmlProperty(xmlDocument, "/oembed/height");
|
||||
var imageTitle = GetXmlProperty(xmlDocument, "/oembed/title");
|
||||
|
||||
return string.Format("<img src=\"{0}\" width\"{1}\" height=\"{2}\" alt=\"{3}\" />", imageUrl, imageWidth, imageHeight, HttpUtility.HtmlEncode(imageTitle));
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/Umbraco.Web/Media/EmbedProviders/GettyImages.cs
Normal file
27
src/Umbraco.Web/Media/EmbedProviders/GettyImages.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class GettyImages : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://embed.gettyimages.com/oembed";
|
||||
|
||||
//http://gty.im/74917285
|
||||
//http://www.gettyimages.com/detail/74917285
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"gty\.im/*",
|
||||
@"gettyimages.com\/detail\/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Hulu.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Hulu.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Hulu : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://www.hulu.com/api/oembed.json";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"hulu.com/watch/.*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/Umbraco.Web/Media/EmbedProviders/Instagram.cs
Normal file
25
src/Umbraco.Web/Media/EmbedProviders/Instagram.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Instagram : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://api.instagram.com/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"instagram.com\/p\/*",
|
||||
@"instagr.am\/p\/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/Umbraco.Web/Media/EmbedProviders/Issuu.cs
Normal file
28
src/Umbraco.Web/Media/EmbedProviders/Issuu.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Issuu : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "https://issuu.com/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"issuu.com/.*/docs/.*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>()
|
||||
{
|
||||
//ApiUrl/?format=xml
|
||||
{"format", "xml"}
|
||||
};
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Kickstarter.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Kickstarter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Kickstarter : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://www.kickstarter.com/services/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"kickstarter\.com/projects/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class OEmbedJson : AbstractOEmbedProvider
|
||||
{
|
||||
public override string GetMarkup(string url, int maxWidth, int maxHeight)
|
||||
{
|
||||
string requestUrl = BuildFullUrl(url, maxWidth, maxHeight);
|
||||
|
||||
var jsonResponse = GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
return jsonResponse.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class OEmbedPhoto : AbstractOEmbedProvider
|
||||
{
|
||||
public override string GetMarkup(string url, int maxWidth, int maxHeight)
|
||||
{
|
||||
string requestUrl = BuildFullUrl(url, maxWidth, maxHeight);
|
||||
|
||||
XmlDocument doc = GetXmlResponse(requestUrl);
|
||||
string imageUrl = GetXmlProperty(doc, "/oembed/url");
|
||||
string imageWidth = GetXmlProperty(doc, "/oembed/width");
|
||||
string imageHeight = GetXmlProperty(doc, "/oembed/height");
|
||||
string imageTitle = GetXmlProperty(doc, "/oembed/title");
|
||||
|
||||
return string.Format("<img src=\"{0}\" width\"{1}\" height=\"{2}\" alt=\"{3}\" />",
|
||||
imageUrl, imageWidth, imageHeight, HttpUtility.HtmlEncode(imageTitle));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,18 +31,18 @@ namespace Umbraco.Web.Media.EmbedProviders
|
||||
public string ThumbnailUrl { get; set; }
|
||||
|
||||
[JsonProperty("thumbnail_height")]
|
||||
public int? ThumbnailHeight { get; set; }
|
||||
public double? ThumbnailHeight { get; set; }
|
||||
|
||||
[JsonProperty("thumbnail_width")]
|
||||
public int? ThumbnailWidth { get; set; }
|
||||
public double? ThumbnailWidth { get; set; }
|
||||
|
||||
public string Html { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public int? Height { get; set; }
|
||||
public double? Height { get; set; }
|
||||
|
||||
public int? Width { get; set; }
|
||||
public double? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTML.
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class OEmbedRich : OEmbedVideo
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Xml;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class OEmbedVideo : AbstractOEmbedProvider
|
||||
{
|
||||
public override string GetMarkup(string url, int maxWidth, int maxHeight)
|
||||
{
|
||||
string requestUrl = BuildFullUrl(url, maxWidth, maxHeight);
|
||||
|
||||
XmlDocument doc = GetXmlResponse(requestUrl);
|
||||
return GetXmlProperty(doc, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders.Settings
|
||||
{
|
||||
public class Dictionary : IEmbedSettingProvider
|
||||
{
|
||||
public object GetSetting(XmlNode settingNode)
|
||||
{
|
||||
return settingNode.ChildNodes.Cast<XmlNode>().ToDictionary(item => item.Attributes != null ? item.Attributes["name"].Value : null, item => item.InnerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders.Settings
|
||||
{
|
||||
public class String : IEmbedSettingProvider
|
||||
{
|
||||
public object GetSetting(XmlNode settingNode)
|
||||
{
|
||||
return settingNode.InnerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Slideshare.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Slideshare.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Slideshare : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://www.slideshare.net/api/oembed/2";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"slideshare\.net/"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/SoundCloud.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/SoundCloud.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Soundcloud : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "https://soundcloud.com/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"soundcloud.com\/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Ted.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Ted.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Ted : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://www.ted.com/talks/oembed.xml";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"ted.com\/talks\/*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using HtmlAgilityPack;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Twitgoo : AbstractProvider
|
||||
{
|
||||
public override bool SupportsDimensions
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth, int maxHeight)
|
||||
{
|
||||
var web = new HtmlWeb();
|
||||
var doc = web.Load(url);
|
||||
|
||||
var img = doc.DocumentNode.SelectSingleNode("//img [@id = 'fullsize']").Attributes["src"];
|
||||
|
||||
return string.Format("<img src=\"{0}\"/>",
|
||||
img.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Twitter.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Twitter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Twitter : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "http://publish.twitter.com/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"twitter.com/.*/status/.*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Umbraco.Web/Media/EmbedProviders/Vimeo.cs
Normal file
24
src/Umbraco.Web/Media/EmbedProviders/Vimeo.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class Vimeo : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "https://vimeo.com/api/oembed.xml";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"vimeo\.com/"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var xmlDocument = base.GetXmlResponse(requestUrl);
|
||||
|
||||
return GetXmlProperty(xmlDocument, "/oembed/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/Umbraco.Web/Media/EmbedProviders/Youtube.cs
Normal file
29
src/Umbraco.Web/Media/EmbedProviders/Youtube.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Media.EmbedProviders
|
||||
{
|
||||
public class YouTube : EmbedProviderBase
|
||||
{
|
||||
public override string ApiEndpoint => "https://www.youtube.com/oembed";
|
||||
|
||||
public override string[] UrlSchemeRegex => new string[]
|
||||
{
|
||||
@"youtu.be/.*",
|
||||
@"youtube.com/watch.*"
|
||||
};
|
||||
|
||||
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>()
|
||||
{
|
||||
//ApiUrl/?format=json
|
||||
{"format", "json"}
|
||||
};
|
||||
|
||||
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
|
||||
{
|
||||
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
|
||||
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
|
||||
|
||||
return oembed.GetHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Core.Media;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.Media.EmbedProviders;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
@@ -18,60 +14,56 @@ namespace Umbraco.Web.PropertyEditors
|
||||
[PluginController("UmbracoApi")]
|
||||
public class RteEmbedController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
public Result GetEmbed(string url, int width, int height)
|
||||
private EmbedProvidersCollection _embedCollection;
|
||||
|
||||
public RteEmbedController(EmbedProvidersCollection embedCollection)
|
||||
{
|
||||
var result = new Result();
|
||||
_embedCollection = embedCollection ?? throw new ArgumentNullException(nameof(embedCollection));
|
||||
}
|
||||
|
||||
// TODO: cache embed doc
|
||||
var xmlConfig = new XmlDocument();
|
||||
xmlConfig.Load(IOHelper.GetRootDirectorySafe() + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "EmbeddedMedia.config");
|
||||
public OEmbedResult GetEmbed(string url, int width, int height)
|
||||
{
|
||||
var result = new OEmbedResult();
|
||||
var foundMatch = false;
|
||||
IEmbedProvider matchedProvider = null;
|
||||
|
||||
foreach (XmlNode node in xmlConfig.SelectNodes("//provider"))
|
||||
foreach (var provider in _embedCollection)
|
||||
{
|
||||
var regexPattern = new Regex(node.SelectSingleNode("./urlShemeRegex").InnerText, RegexOptions.IgnoreCase);
|
||||
|
||||
if (regexPattern.IsMatch(url))
|
||||
//Url Scheme Regex is an array of possible regex patterns to match against the URL
|
||||
foreach(var urlPattern in provider.UrlSchemeRegex)
|
||||
{
|
||||
var prov = (IEmbedProvider)Activator.CreateInstance(Type.GetType(node.Attributes["type"].Value));
|
||||
|
||||
if (node.Attributes["supportsDimensions"] != null)
|
||||
result.SupportsDimensions = node.Attributes["supportsDimensions"].Value == "True";
|
||||
else
|
||||
result.SupportsDimensions = prov.SupportsDimensions;
|
||||
|
||||
var settings = node.ChildNodes.Cast<XmlNode>().ToDictionary(settingNode => settingNode.Name);
|
||||
|
||||
foreach (var prop in prov.GetType().GetProperties().Where(prop => prop.IsDefined(typeof(ProviderSetting), true)))
|
||||
var regexPattern = new Regex(urlPattern, RegexOptions.IgnoreCase);
|
||||
if (regexPattern.IsMatch(url))
|
||||
{
|
||||
|
||||
if (settings.Any(s => s.Key.ToLower() == prop.Name.ToLower()))
|
||||
{
|
||||
var setting = settings.FirstOrDefault(s => s.Key.ToLower() == prop.Name.ToLower()).Value;
|
||||
var settingType = typeof(Media.EmbedProviders.Settings.String);
|
||||
|
||||
if (setting.Attributes["type"] != null)
|
||||
settingType = Type.GetType(setting.Attributes["type"].Value);
|
||||
|
||||
var settingProv = (IEmbedSettingProvider)Activator.CreateInstance(settingType);
|
||||
prop.SetValue(prov, settingProv.GetSetting(settings.FirstOrDefault(s => s.Key.ToLower() == prop.Name.ToLower()).Value), null);
|
||||
}
|
||||
foundMatch = true;
|
||||
matchedProvider = provider;
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
result.Markup = prov.GetMarkup(url, width, height);
|
||||
result.Status = Status.Success;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logger.Error<RteEmbedController>(ex, "Error embedding url {Url} - width: {Width} height: {Height}", url, width, height);
|
||||
result.Status = Status.Error;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (foundMatch)
|
||||
break;
|
||||
}
|
||||
|
||||
if(foundMatch == false)
|
||||
{
|
||||
//No matches return/ exit
|
||||
result.OEmbedStatus = OEmbedStatus.NotSupported;
|
||||
return result;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
result.SupportsDimensions = true;
|
||||
result.Markup = matchedProvider.GetMarkup(url, width, height);
|
||||
result.OEmbedStatus = OEmbedStatus.Success;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logger.Error<RteEmbedController>(ex, "Error embedding url {Url} - width: {Width} height: {Height}", url, width, height);
|
||||
result.OEmbedStatus = OEmbedStatus.Error;
|
||||
}
|
||||
|
||||
result.Status = Status.NotSupported;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ using Umbraco.Web.Dictionary;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.Features;
|
||||
using Umbraco.Web.HealthCheck;
|
||||
using Umbraco.Web.Media.EmbedProviders;
|
||||
using Umbraco.Web.Models.PublishedContent;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
@@ -212,6 +213,24 @@ namespace Umbraco.Web.Runtime
|
||||
// and will filter out those that are not attributed with TreeAttribute
|
||||
composition.WithCollectionBuilder<TreeCollectionBuilder>()
|
||||
.AddTreeControllers(umbracoApiControllerTypes.Where(x => typeof(TreeControllerBase).IsAssignableFrom(x)));
|
||||
|
||||
// register OEmbed providers - no type scanning - all explicit opt-in of adding types
|
||||
// note: IEmbedProvider is not IDiscoverable - think about it if going for type scanning
|
||||
composition.WithCollectionBuilder<EmbedProvidersCollectionBuilder>()
|
||||
.Append<YouTube>()
|
||||
.Append<Instagram>()
|
||||
.Append<Twitter>()
|
||||
.Append<Vimeo>()
|
||||
.Append<DailyMotion>()
|
||||
.Append<Flickr>()
|
||||
.Append<Slideshare>()
|
||||
.Append<Kickstarter>()
|
||||
.Append<GettyImages>()
|
||||
.Append<Ted>()
|
||||
.Append<Soundcloud>()
|
||||
.Append<Issuu>()
|
||||
.Append<Hulu>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,23 @@
|
||||
<Compile Include="Logging\WebProfilerComponent.cs" />
|
||||
<Compile Include="Logging\WebProfilerComposer.cs" />
|
||||
<Compile Include="Logging\WebProfilerProvider.cs" />
|
||||
<Compile Include="Media\EmbedProviders\YouTube.cs" />
|
||||
<Compile Include="Media\EmbedProviders\EmbedProviderBase.cs" />
|
||||
<Compile Include="Media\EmbedProviders\EmbedProvidersCollection.cs" />
|
||||
<Compile Include="Media\EmbedProviders\EmbedProvidersCollectionBuilder.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Flickr.cs" />
|
||||
<Compile Include="Media\EmbedProviders\GettyImages.cs" />
|
||||
<Compile Include="Media\EmbedProviders\DailyMotion.cs" />
|
||||
<Compile Include="Media\EmbedProviders\SoundCloud.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Hulu.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Ted.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Issuu.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Vimeo.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Twitter.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Kickstarter.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedResponse.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Instagram.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Slideshare.cs" />
|
||||
<Compile Include="Media\Exif\BitConverterEx.cs" />
|
||||
<Compile Include="Media\Exif\ExifBitConverter.cs" />
|
||||
<Compile Include="Media\Exif\ExifEnums.cs" />
|
||||
@@ -657,9 +674,6 @@
|
||||
<Compile Include="Security\GetUserSecondsMiddleWare.cs" />
|
||||
<Compile Include="Models\ContentEditing\PropertyTypeDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\PropertyGroupDisplay.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedJson.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedResponse.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedPhoto.cs" />
|
||||
<Compile Include="Security\IUmbracoBackOfficeTwoFactorOptions.cs" />
|
||||
<Compile Include="Models\Mapping\PropertyTypeGroupResolver.cs" />
|
||||
<Compile Include="Services\TreeService.cs" />
|
||||
@@ -1071,13 +1085,6 @@
|
||||
</Compile>
|
||||
<Compile Include="HtmlHelperRenderExtensions.cs" />
|
||||
<Compile Include="Scheduling\SchedulerComponent.cs" />
|
||||
<Compile Include="Media\EmbedProviders\AbstractOEmbedProvider.cs" />
|
||||
<Compile Include="Media\EmbedProviders\AbstractProvider.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedRich.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedVideo.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Settings\Dictionary.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Settings\String.cs" />
|
||||
<Compile Include="Media\EmbedProviders\Twitgoo.cs" />
|
||||
<Compile Include="ModelStateExtensions.cs" />
|
||||
<Compile Include="Mvc\HtmlTagWrapper.cs" />
|
||||
<Compile Include="Mvc\HtmlTagWrapperTextNode.cs" />
|
||||
|
||||
Reference in New Issue
Block a user