public IBarelyView Index() { var c = BlogEntryData.All().Find(Query.EQ("Publish", true)).SetSortOrder(SortBy.Descending("Posted")); c = c.SetLimit(Config.PageSize); var entries = new List <BlogEntryData>(); foreach (var e in c) { string text = BetterCache.Get <string>(e.ID.ToString()); if (text == null) { e.Text = Config.GetMarkdown().Transform(e.Text); BetterCache.Add(e.ID.ToString(), e.Text); } else { e.Text = text; } entries.Add(e); } var v = new BlogIndexView(); v.ShowPaging = true; v.Page = 1; v.PageMax = ((int)c.Count()) / Config.PageSize + 1; v.Entries = entries; v.Layout.Active = "home"; v.Layout.Title = "Earlz.Net - Programming, Electronics, Hacking, Oh My!"; return(v); }
public IBarelyView Index() { var v = new TagIndexView(); v.Layout.Active = "tags"; v.Layout.Title = "Tag List - Earlz.Net"; var c = BlogEntryData.All(); var l = new List <string>(100); foreach (var i in c.FindAll()) { if (i.Tags == null) { continue; } foreach (var j in i.Tags) { if (!l.Contains(j)) { l.Add(j); } } } l.Sort(); v.Tags = l; return(v); }
public IBarelyView RecalculateCommentCounts() { foreach (var entry in BlogEntryData.All().FindAllAs <BlogEntryData>()) { BlogEntryData.RecalculateComments(entry.ID); } return(new WrapperView("Complete!")); }
public IBarelyView Index(int page) { var c = BlogEntryData.All().FindAs <BlogEntryData>(Query.EQ("Publish", true)).SetSortOrder(SortBy.Descending("Posted")); page -= 1; //so that routes start with /blog/1 than /blog/0 if (page == 0) { PermanentRedirect("/"); } c = c.SetSkip(page * Config.PageSize).SetLimit(Config.PageSize); int pagecount = ((int)c.Count()) / Config.PageSize + 1; //this takes a total count on the collection, not the query. var entries = new List <BlogEntryData>(); foreach (var e in c) { string text = BetterCache.Get <string>(e.ID.ToString()); if (text == null) { e.Text = Config.GetMarkdown().Transform(e.Text); BetterCache.Add(e.ID.ToString(), e.Text); } else { e.Text = text; } entries.Add(e); } if (entries.Count == 0) { throw new HttpException(404, "not found"); } var v = new BlogIndexView(); v.ShowPaging = true; page += 1; v.Page = page; v.PageMax = pagecount; v.Entries = entries; v.Layout.Active = "home"; v.Layout.Title = "Archive - Page " + (page) + " of " + (v.PageMax) + " - Earlz.Net"; return(v); }
public IBarelyView Tag(string tag, int page) { var v = new BlogIndexView(); v.ShowPaging = true; v.Tag = tag; v.Layout.Active = "tags"; MongoCursor <BlogEntryData> c; if (tag == "private-draft") { c = BlogEntryData.All().Find(Query.In("Tags", new BsonArray(new string[] { tag }))).SetSortOrder(SortBy.Descending(new string[] { "Posted" })); } else { //otherwise, filter out the private-draft results c = BlogEntryData.All().Find(Query.And(Query.NotIn("Tags", new BsonArray(new string[] { "private-draft" })), Query.In("Tags", new BsonArray(new string[] { tag })))).SetSortOrder(SortBy.Descending(new String[] { "Posted" })); } page -= 1; //so that routes start with /blog/1 than /blog/0 c = c.SetSkip(page * Config.PageSize).SetLimit(Config.PageSize); int pagecount = ((int)c.Count()) / Config.PageSize + 1; //this takes a total count on the collection, not the query. var entries = new List <BlogEntryData>(); foreach (var e in c) { e.Text = Config.GetMarkdown().Transform(e.Text); entries.Add(e); } if (entries.Count == 0) { throw new HttpException(404, "not found"); } page += 1; v.Page = page; v.PageMax = pagecount; v.Entries = entries; v.Layout.Active = "tags"; v.Layout.Title = "Posts Tagged '" + tag + "' - Page " + (page) + " of " + (v.PageMax) + " - Earlz.Net"; return(v); }
public IBarelyView Get() { var v = new BlogEntryView(); v.Layout.Title = "About Me - Earlz.Net"; v.Layout.Active = "aboutme"; v.Entry = BlogEntryData.All().FindOneAs <BlogEntryData>(Query.In("Tags", new BsonValue[] { "page-aboutme" })); string text = BetterCache.Get <string>(v.Entry.ID.ToString()); if (text == null) { v.Entry.Text = Config.GetMarkdown().Transform(v.Entry.Text); BetterCache.Add(v.Entry.ID.ToString(), v.Entry.Text); } else { v.Entry.Text = text; } v.ShowComments = true; v.Summary = false; return(v); }