public string Resolve(ResolvedContentItemData <Tweet> data)
        {
            var selectedTheme  = data.Item.Theme.FirstOrDefault()?.Name?.ToLower() ?? "light";
            var displayOptions = data.Item.DisplayOptions.ToList();
            var hideThread     = displayOptions.Any(o => o.Codename.Equals("hide_thread"));
            var hideMedia      = displayOptions.Any(o => o.Codename.Equals("hide_media"));
            var options        = $"&hide_thread={hideThread}&hide_media={hideMedia}";
            var tweetLink      = data.Item.TweetLink;

            var tweetResponse = Client.GetAsync(
                $"https://publish.twitter.com/oembed?url={tweetLink}&theme={selectedTheme}" + options).Result;
            dynamic jsonResponse = JObject.Parse(tweetResponse.Content.ReadAsStringAsync().Result);

            return("<div class=\"tweet__wrapper\">" + jsonResponse.html + "</div>");
        }
Пример #2
0
        public string Resolve(ResolvedContentItemData <HostedVideo> data)
        {
            var selected = data.Item.VideoHost.FirstOrDefault()?.Codename;

            switch (selected)
            {
            case "vimeo":
                return
                    ($"<iframe class=\"hosted-video__wrapper\" src=\"https://player.vimeo.com/video/{data.Item.VideoId}?title=0&byline=0&portrait=0\" width=\"640\" " +
                     $"height=\"360\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>");

            case "youtube":
                return($"<iframe class=\"hosted-video__wrapper\" width=\"560\" height=\"315\" " +
                       $"src=\"https://www.youtube.com/embed/{data.Item.VideoId}\" frameborder=\"0\" allowfullscreen></iframe>");
            }

            return(string.Empty);
        }
 /// <summary>
 /// Resolver for unretrieved inline content items, returning empty string
 /// </summary>
 /// <param name="data">Unretrieved content item</param>
 /// <returns>Empty output</returns>
 public string Resolve(ResolvedContentItemData <UnretrievedContentItem> data)
 {
     return(string.Empty);
 }
Пример #4
0
 /// <inheritdoc />
 public string Resolve(ResolvedContentItemData <object> item)
 {
     return($"Resolver for content type {item.GetType()} is not registered. Please do so in your app.");
 }
Пример #5
0
 /// <summary>
 /// Resolver for inline content items, returning empty string
 /// </summary>
 /// <param name="data">Content item to be resolved</param>
 /// <returns>Empty output</returns>
 public string Resolve(ResolvedContentItemData <object> data)
 {
     return(string.Empty);
 }
 public string Resolve(ResolvedContentItemData <ContentItemWithSingleRTE> data)
 {
     return(data.Item.RT);
 }
Пример #7
0
 /// <inheritdoc />
 public string Resolve(ResolvedContentItemData <UnretrievedContentItem> item)
 {
     return("This inline content item was not resolved because it was not retrieved from Delivery API.");
 }
 public string Resolve(ResolvedContentItemData <UnretrievedContentItem> item)
 {
     return(_message);
 }
 public string Resolve(ResolvedContentItemData <object> item)
 {
     return(_message);
 }
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> data)
 {
     return($"<![CDATA[ test ]]>");
 }
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> data)
 {
     return($"Text text brackets ( &lt; [ <span>{data.Item.Value}</span><div></div>&amp; Some more text");
 }
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> data)
 {
     return($"<span>{data.Item.Value}</span>");
 }
 public string Resolve(ResolvedContentItemData <DummyImageContentItem> data)
 {
     return($"<img src=\"{data.Item.Source}\" />");
 }
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> data)
 {
     return(data.Item?.Value ?? string.Empty);
 }
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> item)
 {
     callsForResolve++;
     return(string.Empty);
 }
Пример #16
0
 public string Resolve(ResolvedContentItemData <DummyProcessedContentItem> data)
 {
     return($"<span>Unclosed span tag");
 }