public ObjectDic(string name) { string folder = System.IO.Path.Combine(BlogServer.GetOutputFolderRootPath(), name); BlogServer.CreateFolderSafe(folder); this.Dictionary = new PersistentDictionary <string, T>(folder); }
private void handle_category(System.Net.HttpListenerContext context) { var tokens = context.Request.Url.AbsolutePath.Split(new char[] { '/' }); this.WriteLogMethodName(); var xdoc = this.CreateHtmlDom(); var el_body = xdoc.Element("html").Element("body"); var el_title = el_body.AddH1Element("Debug Page"); el_body.AddH1Element("Posts"); foreach (var post in this.PostList) { var cats = BlogServer.split_cat_strings(post.Categories); if (cats.Contains(tokens[tokens.Length - 1])) { el_body.AddParagraphElement(string.Format("Title=\"{0}\"", post.Title)); el_body.AddParagraphElement(string.Format("Link=\"{0}\"", post.Link)); } } string html = xdoc.ToString(); WriteResponseString(context, html, 200, ContentType_TextHtml); }
static void Main(string[] args) { // NOTE: If running within Visual Studio you'll need to run VS as an administrator var options = new BlogServerOptions(); options.CreateSampleContent = true; var blog_server = new BlogServer(options); blog_server.Start(); }
public PostInfoRecord(MP.PostInfo p) { this.Title = p.Title; this.Link = p.Link; this.DateCreated = p.DateCreated; this.PostId = p.PostId; this.UserId = p.UserId; this.CommentCount = p.CommentCount; this.PostStatus = p.PostStatus; this.Permalink = p.Permalink; this.Description = p.Description; this.Categories = BlogServer.join_cat_strings(p.Categories.Select(s => s.Trim())); }
public void Edit(string postid, DateTime?created, string title, string desc, IList <string> cats, bool publish) { var post = this.TryGetPostById(postid); if (post == null) { // Post was not found throw new System.ArgumentException("Post Not Found"); //respond_error_invalid_postid_parameter(context, 200); } var newpost = post.Value; if (title != null) { newpost.Title = title; } if (desc != null) { newpost.Description = desc; } if (cats != null) { // Reset the post categories newpost.Categories = BlogServer.join_cat_strings(cats); } if (publish) { newpost.PostStatus = "published"; } else { newpost.PostStatus = "draft"; } this.Dictionary[newpost.PostId] = newpost; }
internal string[] SplitCategories() { return(BlogServer.split_cat_strings(this.Categories)); }