//// modified version of what's happening in the tag cloud // private Dictionary<string, Concept> CreateCategoryList() // { // // get all the tags and count the number of usages // Dictionary<string, Concept> dic = new Dictionary<string, Concept>(); // foreach (Post post in Post.Posts) // { // if (post.Visible) // { // foreach (Category cat in post.Categories) // { // if (dic.ContainsKey(cat.Title)) // { // Concept concept = dic[cat.Title]; // concept.Score++; // if (post.DateModified > concept.LastUpdated) // concept.LastUpdated = post.DateModified; // dic[cat.Title] = concept; // } // else // { // dic[cat.Title] = new Concept(post.DateModified, 1); // } // } // } // } // return FindMax(dic); // } /// <summary> /// Creates the link list. /// </summary> /// <returns>A dictionary of string, string.</returns> private static Dictionary<string, string> CreateLinkList() { var dic = new Dictionary<string, string>(); var blogroll = new Data.ViewModels.BlogRollVM(); foreach (var br in blogroll.BlogRolls) { var title = br.Title; var website = br.BlogUrl.ToString(); dic.Add(title, website); } return dic; }
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that /// implements the <see cref="T:System.Web.IHttpHandler"></see> interface. /// </summary> /// <param name="context"> /// An <see cref="T:System.Web.HttpContext"></see> /// object that provides references to the intrinsic server objects /// (for example, Request, Response, Session, and Server) used to service HTTP requests. /// </param> public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; var writerSettings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true }; using (var writer = XmlWriter.Create(context.Response.OutputStream, writerSettings)) { // open OPML writer.WriteStartElement("opml"); writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); writer.WriteAttributeString("version", "1.0"); // open BODY writer.WriteStartElement("body"); var blogroll = new Data.ViewModels.BlogRollVM(); foreach (var br in blogroll.BlogRolls) { // open OUTLINE writer.WriteStartElement("outline"); if (!string.IsNullOrEmpty(br.Xfn)) { writer.WriteAttributeString("xfn", br.Xfn); } writer.WriteAttributeString("title", br.Title); writer.WriteAttributeString("description", br.Description); writer.WriteAttributeString("xmlUrl", br.FeedUrl.ToString()); writer.WriteAttributeString("htmlUrl", br.BlogUrl.ToString()); // close OUTLINE writer.WriteEndElement(); } // close BODY writer.WriteEndElement(); // close OPML writer.WriteEndElement(); } }
/// <summary> /// Writes the FOAF. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="name"> /// The name of the FOAF. /// </param> private void WriteFoaf(HttpContext context, string name) { // begin FOAF var writer = GetWriter(context.Response.OutputStream); // write DOCUMENT writer.WriteStartElement("foaf", "PersonalProfileDocument", null); writer.WriteAttributeString("rdf", "about", null, string.Empty); writer.WriteStartElement("foaf", "maker", null); writer.WriteAttributeString("rdf", "resource", null, "#me"); writer.WriteEndElement(); // foaf:maker writer.WriteStartElement("foaf", "primaryTopic", null); writer.WriteAttributeString("rdf", "resource", null, "#me"); writer.WriteEndElement(); // foaf:primaryTopic writer.WriteEndElement(); // foaf:PersonalProfileDocument // get main person's data var ap = AuthorProfile.GetProfile(name); if (!ap.Private) { // main author object var me = new FoafPerson("#me", ap) { Friends = new List<FoafPerson>() }; // TODO: this really should be it's own data store // assume all other authors are friends foreach (var user in Membership.GetAllUsers().Cast<MembershipUser>().Where( user => !user.UserName.Equals(name, StringComparison.OrdinalIgnoreCase))) { var friend = AuthorProfile.GetProfile(user.UserName); if (friend == null) { continue; } me.Friends.Add(new FoafPerson("#" + user.UserName, friend)); } // assume blog roll = friends var blogroll = new Data.ViewModels.BlogRollVM(); foreach (var br in blogroll.BlogRolls) { var title = br.Title; var url = br.BlogUrl.ToString(); var foaf = new FoafPerson(title) { Name = title, Blog = url }; if (Blog.CurrentInstance.Cache[string.Format("foaf:{0}", title)] == null) { var docs = Utils.FindSemanticDocuments(new Uri(url), "foaf"); if (docs.Count > 0) { foreach (var key in docs.Keys) { Blog.CurrentInstance.Cache.Insert(string.Format("foaf:{0}", title), key.ToString()); break; } } else { Blog.CurrentInstance.Cache.Insert(string.Format("foaf:{0}", title), "0"); } } var seeAlso = (string)Blog.CurrentInstance.Cache[string.Format("foaf:{0}", title)]; if (seeAlso != null && seeAlso.Contains("://")) { foaf.Rdf = seeAlso; } me.Friends.Add(foaf); } // begin writing FOAF Persons this.WriteFoafPerson(writer, me); } CloseWriter(writer); }
/// <summary> /// Writes the FOAF. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="name"> /// The name of the FOAF. /// </param> private void WriteFoaf(HttpContext context, string name) { // begin FOAF var writer = GetWriter(context.Response.OutputStream); // write DOCUMENT writer.WriteStartElement("foaf", "PersonalProfileDocument", null); writer.WriteAttributeString("rdf", "about", null, string.Empty); writer.WriteStartElement("foaf", "maker", null); writer.WriteAttributeString("rdf", "resource", null, "#me"); writer.WriteEndElement(); // foaf:maker writer.WriteStartElement("foaf", "primaryTopic", null); writer.WriteAttributeString("rdf", "resource", null, "#me"); writer.WriteEndElement(); // foaf:primaryTopic writer.WriteEndElement(); // foaf:PersonalProfileDocument // get main person's data var ap = AuthorProfile.GetProfile(name); if (!ap.Private) { // main author object var me = new FoafPerson("#me", ap) { Friends = new List <FoafPerson>() }; // TODO: this really should be it's own data store // assume all other authors are friends foreach (var user in Membership.GetAllUsers().Cast <MembershipUser>().Where( user => !user.UserName.Equals(name, StringComparison.OrdinalIgnoreCase))) { var friend = AuthorProfile.GetProfile(user.UserName); if (friend == null) { continue; } me.Friends.Add(new FoafPerson("#" + user.UserName, friend)); } // assume blog roll = friends var blogroll = new Data.ViewModels.BlogRollVM(); foreach (var br in blogroll.BlogRolls) { var title = br.Title; var url = br.BlogUrl.ToString(); var foaf = new FoafPerson(title) { Name = title, Blog = url }; if (Blog.CurrentInstance.Cache[string.Format("foaf:{0}", title)] == null) { var docs = Utils.FindSemanticDocuments(new Uri(url), "foaf"); if (docs.Count > 0) { foreach (var key in docs.Keys) { Blog.CurrentInstance.Cache.Insert(string.Format("foaf:{0}", title), key.ToString()); break; } } else { Blog.CurrentInstance.Cache.Insert(string.Format("foaf:{0}", title), "0"); } } var seeAlso = (string)Blog.CurrentInstance.Cache[string.Format("foaf:{0}", title)]; if (seeAlso != null && seeAlso.Contains("://")) { foaf.Rdf = seeAlso; } me.Friends.Add(foaf); } // begin writing FOAF Persons this.WriteFoafPerson(writer, me); } CloseWriter(writer); }