/// <summary> /// Constructor /// </summary> /// <param name="article">Full feed article instance.</param> public FeedDetailsViewModel(FeedArticle article) { Article = new HtmlWebViewSource { Html = article.Article }; }
public static string AuthorAndSiteName(this FeedArticle data) { var sb = new StringBuilder(); sb.Append(data.Author); if (!string.IsNullOrEmpty(data.Author) && !string.IsNullOrEmpty(data.SiteName)) { sb.Append(" - "); } sb.Append(data.SiteName?.Replace("www.", "", StringComparison.OrdinalIgnoreCase)); return(sb.ToString()); }
public static string YouTubeEmbeddedUrl(this FeedArticle data) { string param1 = ""; if (data.ArticleUrl.Contains("https://youtu.be/", StringComparison.OrdinalIgnoreCase)) { param1 = data.ArticleUrl.Replace("https://youtu.be/", "", StringComparison.OrdinalIgnoreCase); } else { Uri myUri = new Uri(data.ArticleUrl); param1 = HttpUtility.ParseQueryString(myUri.Query).Get("v"); } return($"https://www.youtube.com/embed/" + param1); }
/// <summary> /// Provides full feed article from network /// </summary> /// <param name="link">Article link</param> /// <param name="token">Cancelation token</param> /// <returns>Full feed article or null in case of fail or cancelation.</returns> public async Task <FeedArticle> GetFullFeedOnlineAsync(Uri link, CancellationToken token) { FeedArticle result = null; try { // Article missing in storage and should be downloaded var rowArticle = await _client.GetStringAsync(link); var resultArticle = new HtmlArticleParser().GetArticleFromPage(rowArticle); result = new FeedArticle(link.ToString(), resultArticle); await _storage.SaveFeedArticleAsync(result, token); } catch { // nothing to do here. } return(result); }
/// <summary> /// Opens details page for given article. /// </summary> /// <param name="article">Full feed article</param> private void OpenDetailPage(FeedArticle article) { var model = new FeedDetailsViewModel(article); MainPage.Navigation.PushAsync(new FeedDetailsPage(model)); }
public static string ButtonLabel(this FeedArticle data) { return(data.IsYouTube() ? "View" : "Read More"); }
public static bool IsYouTube(this FeedArticle data) { return(data.ArticleUrl.Contains("youtu", StringComparison.OrdinalIgnoreCase)); }
/// <summary> /// Save given list of feeds to storage. /// </summary> /// <param name="feeds">Feeds for saving</param> /// <param name="ctx">Saving operation cancelation token</param> /// <returns>Saved keys</returns> public Task SaveFeedArticleAsync(FeedArticle article, CancellationToken ctx) { return(SaveObjectAsync(article, ArticleId2Key, ctx)); }