Permalink
Browse files

archive

  • Loading branch information...
kijanawoodard committed Nov 4, 2013
1 parent 48ed632 commit ce65020fdb81e06dab3a70365c7588407e695f1e
@@ -0,0 +1,23 @@
+@model Blog.Web.Actions.PostGet.PostIndexViewModel
+
+@{
+ ViewBag.Title = "All Posts";
+ Layout = "~/Views/_Layout.cshtml";
+}
+
+<h2>Archive</h2>
+
+<section id="archive">
+ <h4>@Model.Active.Count posts @(Model.Future.Any() ? Model.Future.Count + " future" : "")</h4>
+ <ul>
+ @foreach (var post in Model.Active)
+ {
+ <li>
+ <small>@post.PublishedAtCst.ToString("yyyy.MMM.dd")</small>
+ <a href="@Url.Action("Execute", "PostGet", new {slug = post.Slug})" title="@post.Title">
+ <span>@post.Title</span>
+ </a>
+ </li>
+ }
+ </ul>
+</section>
@@ -23,6 +23,8 @@ public void Execute(IContainer container)
result = new MarkdownContentStorage(root).Handle(message, result);
return result;
});
+
+ mediator.Subscribe<PostIndexRequest, PostIndexViewModel>(message => new FilteredPostVault().Handle(message));
}
}
@@ -41,6 +43,12 @@ public ActionResult Execute(PostRequest request)
if (model.Post == null) return HttpNotFound();
return View(model);
}
+
+ public ActionResult Index()
+ {
+ var model = _mediator.Send<PostIndexRequest, PostIndexViewModel>(new PostIndexRequest());
+ return View(model);
+ }
}
public class PostRequest
@@ -60,4 +68,12 @@ public class PostGetViewModel
public bool HasPrevious { get { return Previous != null; } }
public bool HasNext { get { return Next != null; } }
}
+
+ public class PostIndexRequest { }
+
+ public class PostIndexViewModel
+ {
+ public IReadOnlyCollection<Post> Active { get; set; }
+ public IReadOnlyCollection<Post> Future { get; set; }
+ }
}
@@ -274,6 +274,9 @@
<ItemGroup>
<Content Include="Actions\DisplayErrors\Http404.cshtml" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Actions\PostGet\Index.cshtml" />
+ </ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@@ -82,4 +82,6 @@ footer p {
/* Large format tablet and desktop */
@media only screen and (min-width: 768px) {
-}
+}
+
+#archive ul { list-style-type: none;margin: 0;}
@@ -44,6 +44,15 @@ public PostGetViewModel Handle(PostRequest message, PostGetViewModel result)
return result;
}
+ public PostIndexViewModel Handle(PostIndexRequest message)
+ {
+ var result = new PostIndexViewModel();
+ result.Active = ActivePosts;
+ result.Future = FuturePosts;
+
+ return result;
+ }
+
public AtomGetViewModel Handle(AtomRequest message)
{
return new AtomGetViewModel {Posts = ActivePosts};
@@ -9,6 +9,11 @@ public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
+ routes.MapRoute(
+ null,
+ "posts",
+ new { controller = "PostGet", action = "Index" });
+
routes.MapRoute(
null,
"atom",

0 comments on commit ce65020

Please sign in to comment.