public static Panel BuildCategoryPanel(BlogEntry entry) { Panel categoriesPanel = new Panel(); categoriesPanel.CssClass = "blogPostLabel"; categoriesPanel.Style.Add(HtmlTextWriterStyle.TextAlign, "right"); if (entry.Categories.Count > 0) { String category = entry.Categories[0]; HyperLink hyperLink = new HyperLink(); hyperLink.NavigateUrl = "blog.aspx?label=" + category; hyperLink.Text = category; categoriesPanel.Controls.Add(hyperLink); } for (int i = 1; i < entry.Categories.Count; i++) { String category = entry.Categories[i]; Literal labelSeparator = new Literal(); labelSeparator.Text = ", "; categoriesPanel.Controls.Add(labelSeparator); HyperLink hyperLink = new HyperLink(); hyperLink.NavigateUrl = "blog.aspx?label=" + category; hyperLink.Text = category; categoriesPanel.Controls.Add(hyperLink); } return categoriesPanel; }
private static WebControl BuildContentsControl(BlogEntry entry) { Panel contentsControl = new Panel(); WebControl textControl = new WebControl(HtmlTextWriterTag.P); textControl.Controls.Add(new LiteralControl(entry.Content)); contentsControl.Controls.Add(textControl); if (entry.Enclosure != null && entry.Enclosure.Uri != null) { HtmlGenericControl audio = new HtmlGenericControl("audio"); audio.Attributes.Add("controls", "controls"); audio.Attributes.Add("src", entry.Enclosure.Uri); audio.Attributes.Add("type", "audio/mp3"); WebControl musicPlayer = new WebControl(HtmlTextWriterTag.Embed); musicPlayer.ID = "musicPlayer_" + entry.id; musicPlayer.Style.Add(HtmlTextWriterStyle.Width, "400px"); musicPlayer.Style.Add(HtmlTextWriterStyle.Height, "27px"); musicPlayer.Style.Add("border", "1px solid rgb(170, 170, 170)"); musicPlayer.Attributes.Add("src", "http://www.google.com/reader/ui/3523697345-audio-player.swf"); musicPlayer.Attributes.Add("flashvars", "audioUrl=" + entry.Enclosure.Uri); musicPlayer.Attributes.Add("pluginspage", "http://www.macromedia.com/go/getflashplayer"); audio.Controls.Add(musicPlayer); contentsControl.Controls.Add(audio); } return contentsControl; }
/// <summary> /// Builds a web control for a blog post /// </summary> /// <param name="entry">Blog post to be built into a web control</param> /// <returns>A web control presentation of the given blog post</returns> public static Control buildBlogPostControl(BlogEntry entry) { Control blogPostControl = new Control(); if (entry == null) return blogPostControl; WebControl titleContentsSeparator = new WebControl(HtmlTextWriterTag.Br); titleContentsSeparator.Attributes.Add("clear", "all"); WebControl contentsFootSeparator = new WebControl(HtmlTextWriterTag.Br); contentsFootSeparator.Attributes.Add("clear", "all"); if (entry.Scheduled) blogPostControl.Controls.Add(BuildScheduledBlogPostTitle(entry)); else { blogPostControl.Controls.Add(BuildTitleControl(entry)); blogPostControl.Controls.Add(titleContentsSeparator); blogPostControl.Controls.Add(BuildContentsControl(entry)); blogPostControl.Controls.Add(contentsFootSeparator); blogPostControl.Controls.Add(PostFootControl(entry)); } //blogPostControl.Controls.Add(BuildCategoryPanel(entry)); return blogPostControl; }
public void WriteItunesXML(BlogEntry blogEntry, XmlTextWriter w) { if (blogEntry.Enclosure == null || blogEntry.Enclosure.Uri == null || blogEntry.Enclosure.Uri.Equals("")) return; w.WriteStartElement("item"); w.WriteElementString("title", blogEntry.Title); w.WriteElementString("itunes", "author", null, blogEntry.Author); //w.WriteElementString("itunes", "subtitle", null, blogEntry.sub); w.WriteElementString("itunes", "summary", null, blogEntry.Content); w.WriteElementString("pubDate", blogEntry.PubDate.ToString(FORMAT_PROVIDER)); w.WriteStartElement("enclosure"); w.WriteAttributeString("url", blogEntry.Enclosure.Uri); w.WriteAttributeString("type", blogEntry.Enclosure.Type); w.WriteEndElement(); w.WriteElementString("guid", blogEntry.Enclosure.Uri); w.WriteEndElement(); }
private static WebControl PostFootControl(BlogEntry entry) { Panel postFootControl = new Panel(); postFootControl.Style.Add(HtmlTextWriterStyle.TextAlign, "right"); postFootControl.Width = new Unit("100%"); postFootControl.Style.Add(HtmlTextWriterStyle.PaddingBottom, "2em"); Panel authorAndDate = new Panel(); authorAndDate.Style.Add("float", "left"); WebControl postedBy = new WebControl(HtmlTextWriterTag.I); //postedBy.Controls.Add(new LiteralControl("posted by ")); postedBy.Controls.Add(new LiteralControl("posted at ")); authorAndDate.Controls.Add(postedBy); StringBuilder authorAndDateString = new StringBuilder(); //authorAndDateString.Append(entry.Author); //authorAndDateString.Append(" @ "); authorAndDateString.Append(entry.PubDate.ToString("%h:mm tt")); authorAndDateString.Append("."); authorAndDate.Controls.Add(new LiteralControl(authorAndDateString.ToString())); HyperLink commentsControl = new HyperLink(); commentsControl.NavigateUrl = entry.CommentsLink.Uri; commentsControl.Text = entry.CommentsLink.Title; postFootControl.Controls.Add(authorAndDate); postFootControl.Controls.Add(commentsControl); return postFootControl; }
private static WebControl BuildTitleControl(BlogEntry entry) { Panel titleControl = new Panel(); titleControl.Style.Add(HtmlTextWriterStyle.TextAlign, "left"); titleControl.Style.Add("border-bottom", "solid 1px #666"); //WebControl dateHeader = new WebControl(HtmlTextWriterTag.H2); //dateHeader.CssClass = "date-header"; //dateHeader.Controls.Add(new LiteralControl(entry.PubDate.ToString("MMMM d, yyyy"))); HyperLink postTitleHeader = new HyperLink(); postTitleHeader.Font.Size = FontUnit.Parse("14px"); postTitleHeader.Font.Bold = true; postTitleHeader.ForeColor = Color.FromArgb(183,217,125); postTitleHeader.CssClass = "post-title"; postTitleHeader.Controls.Add(new LiteralControl(entry.PubDate.ToString("MMMM d, yyyy: "))); postTitleHeader.NavigateUrl = "sermon.aspx?sermonid=" + entry.id; postTitleHeader.Controls.Add(new LiteralControl(entry.Title)); //titleControl.Controls.Add(dateHeader); titleControl.Controls.Add(postTitleHeader); if (entry.Enclosure != null && entry.Enclosure.Uri != null) { HyperLink postTitle = new HyperLink(); postTitle.Text = "(download)"; postTitle.NavigateUrl = entry.Enclosure.Uri; //postTitle.Font.Size = FontUnit.Smaller; titleControl.Controls.Add(new LiteralControl(" ")); titleControl.Controls.Add(postTitle); } return titleControl; }
private static WebControl BuildScheduledBlogPostTitle(BlogEntry entry) { Panel titleControl = new Panel(); titleControl.Style.Add(HtmlTextWriterStyle.TextAlign, "left"); titleControl.Style.Add("border-bottom", "solid 1px #666"); WebControl dateHeader = new WebControl(HtmlTextWriterTag.H2); dateHeader.CssClass = "date-header"; dateHeader.Controls.Add(new LiteralControl(entry.PubDate.ToString("MMMM d, yyyy"))); WebControl postTitleHeader = new WebControl(HtmlTextWriterTag.H3); postTitleHeader.CssClass = "post-title"; postTitleHeader.Style.Add(HtmlTextWriterStyle.Color, "gray"); postTitleHeader.Controls.Add(new LiteralControl(entry.Title)); titleControl.Controls.Add(dateHeader); titleControl.Controls.Add(postTitleHeader); return titleControl; }
private BlogEntry MapEntry(AtomEntry entry) { DateTime pubDate = entry.Published.ToLocalTime(); if (pubDate.CompareTo(DateTime.Now) <= 0 && entry.IsDraft) return null; BlogEntry blogEntry = new BlogEntry(); blogEntry.Scheduled = pubDate.CompareTo(DateTime.Now) > 0; blogEntry.Content = entry.Content.Content; blogEntry.Title = entry.Title.Text; blogEntry.PubDate = pubDate; blogEntry.Author = entry.Authors[0].Name; blogEntry.Summary = entry.Summary.Text; //blogEntry.MediaUri = entry.MediaUri != null ? entry.MediaUri.Content : null; //blogEntry.Links = new List<Link>(); foreach (AtomLink link in entry.Links) { if ((link.Type != null && link.Type.Equals("audio/mpeg")) || (link.AbsoluteUri.EndsWith(".mp3"))) blogEntry.Enclosure = mapLink(link); else if (link.Rel.Equals("replies") && link.Type != null && link.Type.Equals("text/html")) blogEntry.CommentsLink = mapLink(link); //blogEntry.Links.Add(mapLink(link)); } blogEntry.Permalink = entry.SelfUri.Content; blogEntry.id = entry.Id.AbsoluteUri; blogEntry.Categories = new List<String>(); foreach (AtomCategory category in entry.Categories) { blogEntry.Categories.Add(category.Term); } return blogEntry; }