public static ArticleModel FromTable(Tables.Articles_Extended article) { // add microdata to take advantage of Google's rich snippets for articles: // https://developers.google.com/structured-data/rich-snippets/articles if (article.Body_Html.Contains("<img ") && !article.Body_Html.Contains(" itemprop=\"image\" ")) { // only modify the first image int index = article.Body_Html.IndexOf("<img ") + "<img ".Length; article.Body_Html = article.Body_Html.Substring(0, index) + "itemprop=\"image\" " + article.Body_Html.Substring(index); // assume the body+ad contains the entire body index = article.BodyAndAd_Html.IndexOf("<img ") + "<img ".Length; article.BodyAndAd_Html = article.BodyAndAd_Html.Substring(0, index) + "itemprop=\"image\" " + article.BodyAndAd_Html.Substring(index); } return(new ArticleModel() { Id = article.Article_Id, Slug = article.Article_Slug, Author = AuthorModel.FromTable(article), BodyHtml = HtmlCleaner.UnmixContent(article.Body_Html), BodyAndAdHtml = HtmlCleaner.UnmixContent(article.BodyAndAd_Html), CachedCommentCount = (int)article.Cached_Comment_Count, DiscourseTopicId = article.Discourse_Topic_Id, DiscourseTopicOpened = article.Discourse_Topic_Opened == "Y", LastCommentDate = article.Last_Comment_Date, PublishedDate = article.Published_Date, Series = SeriesModel.FromTable(article), FooterAdHtml = HtmlCleaner.UnmixContent(article.Ad_Html), Status = article.PublishedStatus_Name, SummaryHtml = HtmlCleaner.UnmixContent(ArticleModel.ExtractSummary(article.Body_Html)), Title = article.Title_Text, PreviousArticleId = article.Previous_Article_Id, PreviousArticleSlug = article.Previous_Article_Slug, PreviousArticleTitle = article.Previous_Title_Text, NextArticleId = article.Next_Article_Id, NextArticleSlug = article.Next_Article_Slug, NextArticleTitle = article.Next_Title_Text }); }