public override string HandleNode(HtmlNode node) { var innerNode = new ForumContentParser(node.FirstChild).Body; node.InnerHtml = innerNode; return(node.OuterHtml); }
public static string Metrofy(PrivateMessageMetadata message) { if (message.Body == null) { message = message.Refresh(); } HtmlDocument html = new HtmlDocument(); html.LoadHtml(message.Body); HtmlNode postbody = html.DocumentNode.Descendants() .Where(node => node.GetAttributeValue("class", "").Equals("postbody")) .FirstOrDefault(); string result = new ForumContentParser(postbody.FirstChild).Body; return(result); }
public override string HandleLinks(HtmlNode node) { string url = node.Attributes["href"].Value; node.Attributes["href"].Value = String.Format("javascript:navigate('a{0}{1}')", CoreConstants.DEMARC, url); var textNode = node.FirstChild as HtmlTextNode; if (textNode != null) { //if (textNode.Text.Length > 25) //textNode.Text = String.Format("{0}­", node.InnerText); } else { ForumContentParser main = new ForumContentParser(node.FirstChild); node.InnerHtml = main.Body; } return(string.Format("{0}", node.OuterHtml)); }
public override string HandleQuotes(HtmlNode node) { if (node.GetAttributeValue("class", "").Equals("bbc-block")) { var quoteNode = node.Descendants("blockquote").First(); var authorNode = node.Descendants("h4").FirstOrDefault(); string author = null; if (authorNode != null) { author = authorNode.InnerText.Replace(" posted:", ""); } var parser = new QuoteWebParser(author, quoteNode.FirstChild); return(parser.Body); } else { var body = new ForumContentParser(node.FirstChild).Body; return(string.Format("<br/><blockquote>{0}</blockquote><br/>", body)); } //return string.Empty; }
public override string HandleQuotes(HtmlNode node) { if (node.GetAttributeValue("class", "").Equals("bbc-block")) { var quoteNode = node.Descendants("blockquote").First(); var authorNode = node.Descendants("h4").FirstOrDefault(); string author = null; if (authorNode != null) { author = authorNode.InnerText.Replace(" posted:", ""); } var parser = new QuoteWebParser(author, quoteNode.FirstChild); return parser.Body; } else { var body = new ForumContentParser(node.FirstChild).Body; return string.Format("<br/><blockquote>{0}</blockquote><br/>", body); } //return string.Empty; }
public override string HandleNode(HtmlNode node) { var innerNode = new ForumContentParser(node.FirstChild).Body; node.InnerHtml = innerNode; return node.OuterHtml; }
public override string HandleLinks(HtmlNode node) { string url = node.Attributes["href"].Value; node.Attributes["href"].Value = String.Format("javascript:navigate('a{0}{1}')", CoreConstants.DEMARC, url); var textNode = node.FirstChild as HtmlTextNode; if (textNode != null) { //if (textNode.Text.Length > 25) //textNode.Text = String.Format("{0}­", node.InnerText); } else { ForumContentParser main = new ForumContentParser(node.FirstChild); node.InnerHtml = main.Body; } return string.Format("{0}", node.OuterHtml); }
public static string Metrofy(PrivateMessageMetadata message) { if (message.Body == null) message = message.Refresh(); HtmlDocument html = new HtmlDocument(); html.LoadHtml(message.Body); HtmlNode postbody = html.DocumentNode.Descendants() .Where(node => node.GetAttributeValue("class", "").Equals("postbody")) .FirstOrDefault(); string result = new ForumContentParser(postbody.FirstChild).Body; return result; }
public static string Metrofy(ICollection<ThreadPostMetadata> posts) { StringBuilder html = new StringBuilder(); html.Append("<table>"); int postCount = posts.Count; foreach (var item in posts) { try { var post = item; html.Append("<tr><td>"); html.AppendFormat("<a href='#post_{0}' id='postlink{0}' style='display:none'>This should be hidden.</a>", post.PageIndex); html.AppendFormat("<div class='post_header' id='post_{0}' onclick=\"javascript:openPostMenu('{0}')\">", post.PageIndex); if (post.ShowIcon) { Uri iconUri = post.PostIconUri; html.AppendFormat("<img class='post_icon' alt='' src='{0}' />", iconUri.AbsoluteUri); html.AppendFormat("<div class='post_header_text' >", post.PageIndex); html.Append(AppendPostAuthor(post)); html.AppendFormat("<span class='text_subtlestyle'>#{0}/{1}, {2}</span>", post.PageIndex, postCount, post.PostDate); } else { html.Append("<div class='post_header_text_noicon'>"); html.Append(AppendPostAuthor(post)); html.AppendFormat("<span class='text_subtlestyle'>#{0}/{1}, {2}</span>", post.PageIndex, postCount, post.PostDate.ToString("MM/dd/yyyy, h:mm tt")); } var node = new HtmlNode(HtmlNodeType.Element, post.PostBody.OwnerDocument, -1) { InnerHtml = post.PostBody.InnerHtml, Name = post.PostBody.Name }; var content = new ForumContentParser(node.FirstChild).Body; html.AppendFormat("</div></div><div class='{0}'><pre>{1}</pre></div></pre></td></tr>", !post.IsNew ? "post_content_seen" : "post_content", content); } catch (Exception ex) { string error = string.Format("There was an error while merging posts. [{0}] {1}", ex.Message, ex.StackTrace); } } html.Append("</table>"); string result = html.ToString(); return result; }
public static string Metrofy(ICollection <ThreadPostMetadata> posts) { StringBuilder html = new StringBuilder(); html.Append("<table>"); int postCount = posts.Count; foreach (var item in posts) { try { var post = item; html.Append("<tr><td>"); html.AppendFormat("<a href='#post_{0}' id='postlink{0}' style='display:none'>This should be hidden.</a>", post.PageIndex); html.AppendFormat("<div class='post_header' id='post_{0}' onclick=\"javascript:openPostMenu('{0}')\">", post.PageIndex); if (post.ShowIcon) { Uri iconUri = post.PostIconUri; html.AppendFormat("<img class='post_icon' alt='' src='{0}' />", iconUri.AbsoluteUri); html.AppendFormat("<div class='post_header_text' >", post.PageIndex); html.Append(AppendPostAuthor(post)); html.AppendFormat("<span class='text_subtlestyle'>#{0}/{1}, {2}</span>", post.PageIndex, postCount, post.PostDate); } else { html.Append("<div class='post_header_text_noicon'>"); html.Append(AppendPostAuthor(post)); html.AppendFormat("<span class='text_subtlestyle'>#{0}/{1}, {2}</span>", post.PageIndex, postCount, post.PostDate.ToString("MM/dd/yyyy, h:mm tt")); } var node = new HtmlNode(HtmlNodeType.Element, post.PostBody.OwnerDocument, -1) { InnerHtml = post.PostBody.InnerHtml, Name = post.PostBody.Name }; var content = new ForumContentParser(node.FirstChild).Body; html.AppendFormat("</div></div><div class='{0}'><pre>{1}</pre></div></pre></td></tr>", !post.IsNew ? "post_content_seen" : "post_content", content); } catch (Exception ex) { string error = string.Format("There was an error while merging posts. [{0}] {1}", ex.Message, ex.StackTrace); } } html.Append("</table>"); string result = html.ToString(); return(result); }